babylon.module.d.ts 6.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. }
  95. /**
  96. * Represent an Observer registered to a given Observable object.
  97. */
  98. export class Observer<T> {
  99. /**
  100. * Defines the callback to call when the observer is notified
  101. */
  102. callback: (eventData: T, eventState: EventState) => void;
  103. /**
  104. * Defines the mask of the observer (used to filter notifications)
  105. */
  106. mask: number;
  107. /**
  108. * Defines the current scope used to restore the JS context
  109. */
  110. scope: any;
  111. /** @hidden */
  112. _willBeUnregistered: boolean;
  113. /**
  114. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  115. */
  116. unregisterOnNextCall: boolean;
  117. /**
  118. * Creates a new observer
  119. * @param callback defines the callback to call when the observer is notified
  120. * @param mask defines the mask of the observer (used to filter notifications)
  121. * @param scope defines the current scope used to restore the JS context
  122. */
  123. constructor(
  124. /**
  125. * Defines the callback to call when the observer is notified
  126. */
  127. callback: (eventData: T, eventState: EventState) => void,
  128. /**
  129. * Defines the mask of the observer (used to filter notifications)
  130. */
  131. mask: number,
  132. /**
  133. * Defines the current scope used to restore the JS context
  134. */
  135. scope?: any);
  136. }
  137. /**
  138. * Represent a list of observers registered to multiple Observables object.
  139. */
  140. export class MultiObserver<T> {
  141. private _observers;
  142. private _observables;
  143. /**
  144. * Release associated resources
  145. */
  146. dispose(): void;
  147. /**
  148. * Raise a callback when one of the observable will notify
  149. * @param observables defines a list of observables to watch
  150. * @param callback defines the callback to call on notification
  151. * @param mask defines the mask used to filter notifications
  152. * @param scope defines the current scope used to restore the JS context
  153. * @returns the new MultiObserver
  154. */
  155. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  156. }
  157. /**
  158. * The Observable class is a simple implementation of the Observable pattern.
  159. *
  160. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  161. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  162. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  163. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  164. */
  165. export class Observable<T> {
  166. private _observers;
  167. private _eventState;
  168. private _onObserverAdded;
  169. /**
  170. * Gets the list of observers
  171. */
  172. get observers(): Array<Observer<T>>;
  173. /**
  174. * Creates a new observable
  175. * @param onObserverAdded defines a callback to call when a new observer is added
  176. */
  177. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  178. /**
  179. * Create a new Observer with the specified callback
  180. * @param callback the callback that will be executed for that Observer
  181. * @param mask the mask used to filter observers
  182. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  183. * @param scope optional scope for the callback to be called from
  184. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  185. * @returns the new observer created for the callback
  186. */
  187. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  188. /**
  189. * Create a new Observer with the specified callback and unregisters after the next notification
  190. * @param callback the callback that will be executed for that Observer
  191. * @returns the new observer created for the callback
  192. */
  193. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  194. /**
  195. * Remove an Observer from the Observable object
  196. * @param observer the instance of the Observer to remove
  197. * @returns false if it doesn't belong to this Observable
  198. */
  199. remove(observer: Nullable<Observer<T>>): boolean;
  200. /**
  201. * Remove a callback from the Observable object
  202. * @param callback the callback to remove
  203. * @param scope optional scope. If used only the callbacks with this scope will be removed
  204. * @returns false if it doesn't belong to this Observable
  205. */
  206. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  207. private _deferUnregister;
  208. private _remove;
  209. /**
  210. * Moves the observable to the top of the observer list making it get called first when notified
  211. * @param observer the observer to move
  212. */
  213. makeObserverTopPriority(observer: Observer<T>): void;
  214. /**
  215. * Moves the observable to the bottom of the observer list making it get called last when notified
  216. * @param observer the observer to move
  217. */
  218. makeObserverBottomPriority(observer: Observer<T>): void;
  219. /**
  220. * Notify all Observers by calling their respective callback with the given data
  221. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  222. * @param eventData defines the data to send to all observers
  223. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  224. * @param target defines the original target of the state
  225. * @param currentTarget defines the current target of the state
  226. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  227. */
  228. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  229. /**
  230. * Calling this will execute each callback, expecting it to be a promise or return a value.
  231. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  232. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  233. * and it is crucial that all callbacks will be executed.
  234. * The order of the callbacks is kept, callbacks are not executed parallel.
  235. *
  236. * @param eventData The data to be sent to each callback
  237. * @param mask is used to filter observers defaults to -1
  238. * @param target defines the callback target (see EventState)
  239. * @param currentTarget defines he current object in the bubbling phase
  240. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  241. */
  242. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  243. /**
  244. * Notify a specific observer
  245. * @param observer defines the observer to notify
  246. * @param eventData defines the data to be sent to each callback
  247. * @param mask is used to filter observers defaults to -1
  248. */
  249. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  250. /**
  251. * Gets a boolean indicating if the observable has at least one observer
  252. * @returns true is the Observable has at least one Observer registered
  253. */
  254. hasObservers(): boolean;
  255. /**
  256. * Clear the list of observers
  257. */
  258. clear(): void;
  259. /**
  260. * Clone the current observable
  261. * @returns a new observable
  262. */
  263. clone(): Observable<T>;
  264. /**
  265. * Does this observable handles observer registered with a given mask
  266. * @param mask defines the mask to be tested
  267. * @return whether or not one observer registered with the given mask is handeled
  268. **/
  269. hasSpecificMask(mask?: number): boolean;
  270. }
  271. }
  272. declare module "babylonjs/Misc/domManagement" {
  273. /**
  274. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  275. * Babylon.js
  276. */
  277. export class DomManagement {
  278. /**
  279. * Checks if the window object exists
  280. * @returns true if the window object exists
  281. */
  282. static IsWindowObjectExist(): boolean;
  283. /**
  284. * Checks if the navigator object exists
  285. * @returns true if the navigator object exists
  286. */
  287. static IsNavigatorAvailable(): boolean;
  288. /**
  289. * Extracts text content from a DOM element hierarchy
  290. * @param element defines the root element
  291. * @returns a string
  292. */
  293. static GetDOMTextContent(element: HTMLElement): string;
  294. }
  295. }
  296. declare module "babylonjs/Misc/logger" {
  297. /**
  298. * Logger used througouht the application to allow configuration of
  299. * the log level required for the messages.
  300. */
  301. export class Logger {
  302. /**
  303. * No log
  304. */
  305. static readonly NoneLogLevel: number;
  306. /**
  307. * Only message logs
  308. */
  309. static readonly MessageLogLevel: number;
  310. /**
  311. * Only warning logs
  312. */
  313. static readonly WarningLogLevel: number;
  314. /**
  315. * Only error logs
  316. */
  317. static readonly ErrorLogLevel: number;
  318. /**
  319. * All logs
  320. */
  321. static readonly AllLogLevel: number;
  322. private static _LogCache;
  323. /**
  324. * Gets a value indicating the number of loading errors
  325. * @ignorenaming
  326. */
  327. static errorsCount: number;
  328. /**
  329. * Callback called when a new log is added
  330. */
  331. static OnNewCacheEntry: (entry: string) => void;
  332. private static _AddLogEntry;
  333. private static _FormatMessage;
  334. private static _LogDisabled;
  335. private static _LogEnabled;
  336. private static _WarnDisabled;
  337. private static _WarnEnabled;
  338. private static _ErrorDisabled;
  339. private static _ErrorEnabled;
  340. /**
  341. * Log a message to the console
  342. */
  343. static Log: (message: string) => void;
  344. /**
  345. * Write a warning message to the console
  346. */
  347. static Warn: (message: string) => void;
  348. /**
  349. * Write an error message to the console
  350. */
  351. static Error: (message: string) => void;
  352. /**
  353. * Gets current log cache (list of logs)
  354. */
  355. static get LogCache(): string;
  356. /**
  357. * Clears the log cache
  358. */
  359. static ClearLogCache(): void;
  360. /**
  361. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  362. */
  363. static set LogLevels(level: number);
  364. }
  365. }
  366. declare module "babylonjs/Misc/typeStore" {
  367. /** @hidden */
  368. export class _TypeStore {
  369. /** @hidden */
  370. static RegisteredTypes: {
  371. [key: string]: Object;
  372. };
  373. /** @hidden */
  374. static GetClass(fqdn: string): any;
  375. }
  376. }
  377. declare module "babylonjs/Misc/stringTools" {
  378. /**
  379. * Helper to manipulate strings
  380. */
  381. export class StringTools {
  382. /**
  383. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  384. * @param str Source string
  385. * @param suffix Suffix to search for in the source string
  386. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  387. */
  388. static EndsWith(str: string, suffix: string): boolean;
  389. /**
  390. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  391. * @param str Source string
  392. * @param suffix Suffix to search for in the source string
  393. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  394. */
  395. static StartsWith(str: string, suffix: string): boolean;
  396. /**
  397. * Decodes a buffer into a string
  398. * @param buffer The buffer to decode
  399. * @returns The decoded string
  400. */
  401. static Decode(buffer: Uint8Array | Uint16Array): string;
  402. /**
  403. * Encode a buffer to a base64 string
  404. * @param buffer defines the buffer to encode
  405. * @returns the encoded string
  406. */
  407. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  408. }
  409. }
  410. declare module "babylonjs/Misc/deepCopier" {
  411. /**
  412. * Class containing a set of static utilities functions for deep copy.
  413. */
  414. export class DeepCopier {
  415. /**
  416. * Tries to copy an object by duplicating every property
  417. * @param source defines the source object
  418. * @param destination defines the target object
  419. * @param doNotCopyList defines a list of properties to avoid
  420. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  421. */
  422. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  423. }
  424. }
  425. declare module "babylonjs/Misc/precisionDate" {
  426. /**
  427. * Class containing a set of static utilities functions for precision date
  428. */
  429. export class PrecisionDate {
  430. /**
  431. * Gets either window.performance.now() if supported or Date.now() else
  432. */
  433. static get Now(): number;
  434. }
  435. }
  436. declare module "babylonjs/Misc/devTools" {
  437. /** @hidden */
  438. export class _DevTools {
  439. static WarnImport(name: string): string;
  440. }
  441. }
  442. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  443. /**
  444. * Interface used to define the mechanism to get data from the network
  445. */
  446. export interface IWebRequest {
  447. /**
  448. * Returns client's response url
  449. */
  450. responseURL: string;
  451. /**
  452. * Returns client's status
  453. */
  454. status: number;
  455. /**
  456. * Returns client's status as a text
  457. */
  458. statusText: string;
  459. }
  460. }
  461. declare module "babylonjs/Misc/webRequest" {
  462. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  463. import { Nullable } from "babylonjs/types";
  464. /**
  465. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  466. */
  467. export class WebRequest implements IWebRequest {
  468. private _xhr;
  469. /**
  470. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  471. * i.e. when loading files, where the server/service expects an Authorization header
  472. */
  473. static CustomRequestHeaders: {
  474. [key: string]: string;
  475. };
  476. /**
  477. * Add callback functions in this array to update all the requests before they get sent to the network
  478. */
  479. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  480. private _injectCustomRequestHeaders;
  481. /**
  482. * Gets or sets a function to be called when loading progress changes
  483. */
  484. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  485. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  486. /**
  487. * Returns client's state
  488. */
  489. get readyState(): number;
  490. /**
  491. * Returns client's status
  492. */
  493. get status(): number;
  494. /**
  495. * Returns client's status as a text
  496. */
  497. get statusText(): string;
  498. /**
  499. * Returns client's response
  500. */
  501. get response(): any;
  502. /**
  503. * Returns client's response url
  504. */
  505. get responseURL(): string;
  506. /**
  507. * Returns client's response as text
  508. */
  509. get responseText(): string;
  510. /**
  511. * Gets or sets the expected response type
  512. */
  513. get responseType(): XMLHttpRequestResponseType;
  514. set responseType(value: XMLHttpRequestResponseType);
  515. /** @hidden */
  516. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  517. /** @hidden */
  518. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  519. /**
  520. * Cancels any network activity
  521. */
  522. abort(): void;
  523. /**
  524. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  525. * @param body defines an optional request body
  526. */
  527. send(body?: Document | BodyInit | null): void;
  528. /**
  529. * Sets the request method, request URL
  530. * @param method defines the method to use (GET, POST, etc..)
  531. * @param url defines the url to connect with
  532. */
  533. open(method: string, url: string): void;
  534. /**
  535. * Sets the value of a request header.
  536. * @param name The name of the header whose value is to be set
  537. * @param value The value to set as the body of the header
  538. */
  539. setRequestHeader(name: string, value: string): void;
  540. /**
  541. * Get the string containing the text of a particular header's value.
  542. * @param name The name of the header
  543. * @returns The string containing the text of the given header name
  544. */
  545. getResponseHeader(name: string): Nullable<string>;
  546. }
  547. }
  548. declare module "babylonjs/Misc/fileRequest" {
  549. import { Observable } from "babylonjs/Misc/observable";
  550. /**
  551. * File request interface
  552. */
  553. export interface IFileRequest {
  554. /**
  555. * Raised when the request is complete (success or error).
  556. */
  557. onCompleteObservable: Observable<IFileRequest>;
  558. /**
  559. * Aborts the request for a file.
  560. */
  561. abort: () => void;
  562. }
  563. }
  564. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  565. /**
  566. * Define options used to create a render target texture
  567. */
  568. export class RenderTargetCreationOptions {
  569. /**
  570. * Specifies is mipmaps must be generated
  571. */
  572. generateMipMaps?: boolean;
  573. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  574. generateDepthBuffer?: boolean;
  575. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  576. generateStencilBuffer?: boolean;
  577. /** Defines texture type (int by default) */
  578. type?: number;
  579. /** Defines sampling mode (trilinear by default) */
  580. samplingMode?: number;
  581. /** Defines format (RGBA by default) */
  582. format?: number;
  583. }
  584. }
  585. declare module "babylonjs/Engines/constants" {
  586. /** Defines the cross module used constants to avoid circular dependncies */
  587. export class Constants {
  588. /** Defines that alpha blending is disabled */
  589. static readonly ALPHA_DISABLE: number;
  590. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  591. static readonly ALPHA_ADD: number;
  592. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  593. static readonly ALPHA_COMBINE: number;
  594. /** Defines that alpha blending is DEST - SRC * DEST */
  595. static readonly ALPHA_SUBTRACT: number;
  596. /** Defines that alpha blending is SRC * DEST */
  597. static readonly ALPHA_MULTIPLY: number;
  598. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  599. static readonly ALPHA_MAXIMIZED: number;
  600. /** Defines that alpha blending is SRC + DEST */
  601. static readonly ALPHA_ONEONE: number;
  602. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  603. static readonly ALPHA_PREMULTIPLIED: number;
  604. /**
  605. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  606. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  607. */
  608. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  609. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  610. static readonly ALPHA_INTERPOLATE: number;
  611. /**
  612. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  613. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  614. */
  615. static readonly ALPHA_SCREENMODE: number;
  616. /**
  617. * Defines that alpha blending is SRC + DST
  618. * Alpha will be set to SRC ALPHA + DST ALPHA
  619. */
  620. static readonly ALPHA_ONEONE_ONEONE: number;
  621. /**
  622. * Defines that alpha blending is SRC * DST ALPHA + DST
  623. * Alpha will be set to 0
  624. */
  625. static readonly ALPHA_ALPHATOCOLOR: number;
  626. /**
  627. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  628. */
  629. static readonly ALPHA_REVERSEONEMINUS: number;
  630. /**
  631. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  632. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  633. */
  634. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  635. /**
  636. * Defines that alpha blending is SRC + DST
  637. * Alpha will be set to SRC ALPHA
  638. */
  639. static readonly ALPHA_ONEONE_ONEZERO: number;
  640. /**
  641. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  642. * Alpha will be set to DST ALPHA
  643. */
  644. static readonly ALPHA_EXCLUSION: number;
  645. /** Defines that alpha blending equation a SUM */
  646. static readonly ALPHA_EQUATION_ADD: number;
  647. /** Defines that alpha blending equation a SUBSTRACTION */
  648. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  649. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  650. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  651. /** Defines that alpha blending equation a MAX operation */
  652. static readonly ALPHA_EQUATION_MAX: number;
  653. /** Defines that alpha blending equation a MIN operation */
  654. static readonly ALPHA_EQUATION_MIN: number;
  655. /**
  656. * Defines that alpha blending equation a DARKEN operation:
  657. * It takes the min of the src and sums the alpha channels.
  658. */
  659. static readonly ALPHA_EQUATION_DARKEN: number;
  660. /** Defines that the ressource is not delayed*/
  661. static readonly DELAYLOADSTATE_NONE: number;
  662. /** Defines that the ressource was successfully delay loaded */
  663. static readonly DELAYLOADSTATE_LOADED: number;
  664. /** Defines that the ressource is currently delay loading */
  665. static readonly DELAYLOADSTATE_LOADING: number;
  666. /** Defines that the ressource is delayed and has not started loading */
  667. static readonly DELAYLOADSTATE_NOTLOADED: number;
  668. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  669. static readonly NEVER: number;
  670. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  671. static readonly ALWAYS: number;
  672. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  673. static readonly LESS: number;
  674. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  675. static readonly EQUAL: number;
  676. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  677. static readonly LEQUAL: number;
  678. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  679. static readonly GREATER: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  681. static readonly GEQUAL: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  683. static readonly NOTEQUAL: number;
  684. /** Passed to stencilOperation to specify that stencil value must be kept */
  685. static readonly KEEP: number;
  686. /** Passed to stencilOperation to specify that stencil value must be replaced */
  687. static readonly REPLACE: number;
  688. /** Passed to stencilOperation to specify that stencil value must be incremented */
  689. static readonly INCR: number;
  690. /** Passed to stencilOperation to specify that stencil value must be decremented */
  691. static readonly DECR: number;
  692. /** Passed to stencilOperation to specify that stencil value must be inverted */
  693. static readonly INVERT: number;
  694. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  695. static readonly INCR_WRAP: number;
  696. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  697. static readonly DECR_WRAP: number;
  698. /** Texture is not repeating outside of 0..1 UVs */
  699. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  700. /** Texture is repeating outside of 0..1 UVs */
  701. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  702. /** Texture is repeating and mirrored */
  703. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  704. /** ALPHA */
  705. static readonly TEXTUREFORMAT_ALPHA: number;
  706. /** LUMINANCE */
  707. static readonly TEXTUREFORMAT_LUMINANCE: number;
  708. /** LUMINANCE_ALPHA */
  709. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  710. /** RGB */
  711. static readonly TEXTUREFORMAT_RGB: number;
  712. /** RGBA */
  713. static readonly TEXTUREFORMAT_RGBA: number;
  714. /** RED */
  715. static readonly TEXTUREFORMAT_RED: number;
  716. /** RED (2nd reference) */
  717. static readonly TEXTUREFORMAT_R: number;
  718. /** RG */
  719. static readonly TEXTUREFORMAT_RG: number;
  720. /** RED_INTEGER */
  721. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  722. /** RED_INTEGER (2nd reference) */
  723. static readonly TEXTUREFORMAT_R_INTEGER: number;
  724. /** RG_INTEGER */
  725. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  726. /** RGB_INTEGER */
  727. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  728. /** RGBA_INTEGER */
  729. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  730. /** UNSIGNED_BYTE */
  731. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  732. /** UNSIGNED_BYTE (2nd reference) */
  733. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  734. /** FLOAT */
  735. static readonly TEXTURETYPE_FLOAT: number;
  736. /** HALF_FLOAT */
  737. static readonly TEXTURETYPE_HALF_FLOAT: number;
  738. /** BYTE */
  739. static readonly TEXTURETYPE_BYTE: number;
  740. /** SHORT */
  741. static readonly TEXTURETYPE_SHORT: number;
  742. /** UNSIGNED_SHORT */
  743. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  744. /** INT */
  745. static readonly TEXTURETYPE_INT: number;
  746. /** UNSIGNED_INT */
  747. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  748. /** UNSIGNED_SHORT_4_4_4_4 */
  749. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  750. /** UNSIGNED_SHORT_5_5_5_1 */
  751. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  752. /** UNSIGNED_SHORT_5_6_5 */
  753. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  754. /** UNSIGNED_INT_2_10_10_10_REV */
  755. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  756. /** UNSIGNED_INT_24_8 */
  757. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  758. /** UNSIGNED_INT_10F_11F_11F_REV */
  759. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  760. /** UNSIGNED_INT_5_9_9_9_REV */
  761. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  762. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  763. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  764. /** nearest is mag = nearest and min = nearest and no mip */
  765. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  766. /** mag = nearest and min = nearest and mip = none */
  767. static readonly TEXTURE_NEAREST_NEAREST: number;
  768. /** Bilinear is mag = linear and min = linear and no mip */
  769. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  770. /** mag = linear and min = linear and mip = none */
  771. static readonly TEXTURE_LINEAR_LINEAR: number;
  772. /** Trilinear is mag = linear and min = linear and mip = linear */
  773. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  774. /** Trilinear is mag = linear and min = linear and mip = linear */
  775. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  776. /** mag = nearest and min = nearest and mip = nearest */
  777. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  778. /** mag = nearest and min = linear and mip = nearest */
  779. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  780. /** mag = nearest and min = linear and mip = linear */
  781. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  782. /** mag = nearest and min = linear and mip = none */
  783. static readonly TEXTURE_NEAREST_LINEAR: number;
  784. /** nearest is mag = nearest and min = nearest and mip = linear */
  785. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  786. /** mag = linear and min = nearest and mip = nearest */
  787. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  788. /** mag = linear and min = nearest and mip = linear */
  789. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  790. /** Bilinear is mag = linear and min = linear and mip = nearest */
  791. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  792. /** mag = linear and min = nearest and mip = none */
  793. static readonly TEXTURE_LINEAR_NEAREST: number;
  794. /** Explicit coordinates mode */
  795. static readonly TEXTURE_EXPLICIT_MODE: number;
  796. /** Spherical coordinates mode */
  797. static readonly TEXTURE_SPHERICAL_MODE: number;
  798. /** Planar coordinates mode */
  799. static readonly TEXTURE_PLANAR_MODE: number;
  800. /** Cubic coordinates mode */
  801. static readonly TEXTURE_CUBIC_MODE: number;
  802. /** Projection coordinates mode */
  803. static readonly TEXTURE_PROJECTION_MODE: number;
  804. /** Skybox coordinates mode */
  805. static readonly TEXTURE_SKYBOX_MODE: number;
  806. /** Inverse Cubic coordinates mode */
  807. static readonly TEXTURE_INVCUBIC_MODE: number;
  808. /** Equirectangular coordinates mode */
  809. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  810. /** Equirectangular Fixed coordinates mode */
  811. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  812. /** Equirectangular Fixed Mirrored coordinates mode */
  813. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  814. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  815. static readonly SCALEMODE_FLOOR: number;
  816. /** Defines that texture rescaling will look for the nearest power of 2 size */
  817. static readonly SCALEMODE_NEAREST: number;
  818. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  819. static readonly SCALEMODE_CEILING: number;
  820. /**
  821. * The dirty texture flag value
  822. */
  823. static readonly MATERIAL_TextureDirtyFlag: number;
  824. /**
  825. * The dirty light flag value
  826. */
  827. static readonly MATERIAL_LightDirtyFlag: number;
  828. /**
  829. * The dirty fresnel flag value
  830. */
  831. static readonly MATERIAL_FresnelDirtyFlag: number;
  832. /**
  833. * The dirty attribute flag value
  834. */
  835. static readonly MATERIAL_AttributesDirtyFlag: number;
  836. /**
  837. * The dirty misc flag value
  838. */
  839. static readonly MATERIAL_MiscDirtyFlag: number;
  840. /**
  841. * The all dirty flag value
  842. */
  843. static readonly MATERIAL_AllDirtyFlag: number;
  844. /**
  845. * Returns the triangle fill mode
  846. */
  847. static readonly MATERIAL_TriangleFillMode: number;
  848. /**
  849. * Returns the wireframe mode
  850. */
  851. static readonly MATERIAL_WireFrameFillMode: number;
  852. /**
  853. * Returns the point fill mode
  854. */
  855. static readonly MATERIAL_PointFillMode: number;
  856. /**
  857. * Returns the point list draw mode
  858. */
  859. static readonly MATERIAL_PointListDrawMode: number;
  860. /**
  861. * Returns the line list draw mode
  862. */
  863. static readonly MATERIAL_LineListDrawMode: number;
  864. /**
  865. * Returns the line loop draw mode
  866. */
  867. static readonly MATERIAL_LineLoopDrawMode: number;
  868. /**
  869. * Returns the line strip draw mode
  870. */
  871. static readonly MATERIAL_LineStripDrawMode: number;
  872. /**
  873. * Returns the triangle strip draw mode
  874. */
  875. static readonly MATERIAL_TriangleStripDrawMode: number;
  876. /**
  877. * Returns the triangle fan draw mode
  878. */
  879. static readonly MATERIAL_TriangleFanDrawMode: number;
  880. /**
  881. * Stores the clock-wise side orientation
  882. */
  883. static readonly MATERIAL_ClockWiseSideOrientation: number;
  884. /**
  885. * Stores the counter clock-wise side orientation
  886. */
  887. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  888. /**
  889. * Nothing
  890. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  891. */
  892. static readonly ACTION_NothingTrigger: number;
  893. /**
  894. * On pick
  895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  896. */
  897. static readonly ACTION_OnPickTrigger: number;
  898. /**
  899. * On left pick
  900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  901. */
  902. static readonly ACTION_OnLeftPickTrigger: number;
  903. /**
  904. * On right pick
  905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  906. */
  907. static readonly ACTION_OnRightPickTrigger: number;
  908. /**
  909. * On center pick
  910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  911. */
  912. static readonly ACTION_OnCenterPickTrigger: number;
  913. /**
  914. * On pick down
  915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  916. */
  917. static readonly ACTION_OnPickDownTrigger: number;
  918. /**
  919. * On double pick
  920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_OnDoublePickTrigger: number;
  923. /**
  924. * On pick up
  925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnPickUpTrigger: number;
  928. /**
  929. * On pick out.
  930. * This trigger will only be raised if you also declared a OnPickDown
  931. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  932. */
  933. static readonly ACTION_OnPickOutTrigger: number;
  934. /**
  935. * On long press
  936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnLongPressTrigger: number;
  939. /**
  940. * On pointer over
  941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnPointerOverTrigger: number;
  944. /**
  945. * On pointer out
  946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  947. */
  948. static readonly ACTION_OnPointerOutTrigger: number;
  949. /**
  950. * On every frame
  951. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnEveryFrameTrigger: number;
  954. /**
  955. * On intersection enter
  956. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  957. */
  958. static readonly ACTION_OnIntersectionEnterTrigger: number;
  959. /**
  960. * On intersection exit
  961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnIntersectionExitTrigger: number;
  964. /**
  965. * On key down
  966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnKeyDownTrigger: number;
  969. /**
  970. * On key up
  971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnKeyUpTrigger: number;
  974. /**
  975. * Billboard mode will only apply to Y axis
  976. */
  977. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  978. /**
  979. * Billboard mode will apply to all axes
  980. */
  981. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  982. /**
  983. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  984. */
  985. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  986. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  987. * Test order :
  988. * Is the bounding sphere outside the frustum ?
  989. * If not, are the bounding box vertices outside the frustum ?
  990. * It not, then the cullable object is in the frustum.
  991. */
  992. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  993. /** Culling strategy : Bounding Sphere Only.
  994. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  995. * It's also less accurate than the standard because some not visible objects can still be selected.
  996. * Test : is the bounding sphere outside the frustum ?
  997. * If not, then the cullable object is in the frustum.
  998. */
  999. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1000. /** Culling strategy : Optimistic Inclusion.
  1001. * This in an inclusion test first, then the standard exclusion test.
  1002. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1003. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1004. * Anyway, it's as accurate as the standard strategy.
  1005. * Test :
  1006. * Is the cullable object bounding sphere center in the frustum ?
  1007. * If not, apply the default culling strategy.
  1008. */
  1009. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1010. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1011. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1012. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1013. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1014. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1015. * Test :
  1016. * Is the cullable object bounding sphere center in the frustum ?
  1017. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1018. */
  1019. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1020. /**
  1021. * No logging while loading
  1022. */
  1023. static readonly SCENELOADER_NO_LOGGING: number;
  1024. /**
  1025. * Minimal logging while loading
  1026. */
  1027. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1028. /**
  1029. * Summary logging while loading
  1030. */
  1031. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1032. /**
  1033. * Detailled logging while loading
  1034. */
  1035. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1036. }
  1037. }
  1038. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1039. import { Nullable } from "babylonjs/types";
  1040. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1041. /**
  1042. * This represents the required contract to create a new type of texture loader.
  1043. */
  1044. export interface IInternalTextureLoader {
  1045. /**
  1046. * Defines wether the loader supports cascade loading the different faces.
  1047. */
  1048. supportCascades: boolean;
  1049. /**
  1050. * This returns if the loader support the current file information.
  1051. * @param extension defines the file extension of the file being loaded
  1052. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1053. * @param fallback defines the fallback internal texture if any
  1054. * @param isBase64 defines whether the texture is encoded as a base64
  1055. * @param isBuffer defines whether the texture data are stored as a buffer
  1056. * @returns true if the loader can load the specified file
  1057. */
  1058. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1059. /**
  1060. * Transform the url before loading if required.
  1061. * @param rootUrl the url of the texture
  1062. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1063. * @returns the transformed texture
  1064. */
  1065. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1066. /**
  1067. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1068. * @param rootUrl the url of the texture
  1069. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1070. * @returns the fallback texture
  1071. */
  1072. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1073. /**
  1074. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1075. * @param data contains the texture data
  1076. * @param texture defines the BabylonJS internal texture
  1077. * @param createPolynomials will be true if polynomials have been requested
  1078. * @param onLoad defines the callback to trigger once the texture is ready
  1079. * @param onError defines the callback to trigger in case of error
  1080. */
  1081. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1082. /**
  1083. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1084. * @param data contains the texture data
  1085. * @param texture defines the BabylonJS internal texture
  1086. * @param callback defines the method to call once ready to upload
  1087. */
  1088. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1089. }
  1090. }
  1091. declare module "babylonjs/Engines/IPipelineContext" {
  1092. /**
  1093. * Class used to store and describe the pipeline context associated with an effect
  1094. */
  1095. export interface IPipelineContext {
  1096. /**
  1097. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1098. */
  1099. isAsync: boolean;
  1100. /**
  1101. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1102. */
  1103. isReady: boolean;
  1104. /** @hidden */
  1105. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1106. }
  1107. }
  1108. declare module "babylonjs/Meshes/dataBuffer" {
  1109. /**
  1110. * Class used to store gfx data (like WebGLBuffer)
  1111. */
  1112. export class DataBuffer {
  1113. /**
  1114. * Gets or sets the number of objects referencing this buffer
  1115. */
  1116. references: number;
  1117. /** Gets or sets the size of the underlying buffer */
  1118. capacity: number;
  1119. /**
  1120. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1121. */
  1122. is32Bits: boolean;
  1123. /**
  1124. * Gets the underlying buffer
  1125. */
  1126. get underlyingResource(): any;
  1127. }
  1128. }
  1129. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1130. /** @hidden */
  1131. export interface IShaderProcessor {
  1132. attributeProcessor?: (attribute: string) => string;
  1133. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1134. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1135. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1136. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1137. lineProcessor?: (line: string, isFragment: boolean) => string;
  1138. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1139. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1140. }
  1141. }
  1142. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1143. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1144. /** @hidden */
  1145. export interface ProcessingOptions {
  1146. defines: string[];
  1147. indexParameters: any;
  1148. isFragment: boolean;
  1149. shouldUseHighPrecisionShader: boolean;
  1150. supportsUniformBuffers: boolean;
  1151. shadersRepository: string;
  1152. includesShadersStore: {
  1153. [key: string]: string;
  1154. };
  1155. processor?: IShaderProcessor;
  1156. version: string;
  1157. platformName: string;
  1158. lookForClosingBracketForUniformBuffer?: boolean;
  1159. }
  1160. }
  1161. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1162. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1163. /** @hidden */
  1164. export class ShaderCodeNode {
  1165. line: string;
  1166. children: ShaderCodeNode[];
  1167. additionalDefineKey?: string;
  1168. additionalDefineValue?: string;
  1169. isValid(preprocessors: {
  1170. [key: string]: string;
  1171. }): boolean;
  1172. process(preprocessors: {
  1173. [key: string]: string;
  1174. }, options: ProcessingOptions): string;
  1175. }
  1176. }
  1177. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1178. /** @hidden */
  1179. export class ShaderCodeCursor {
  1180. private _lines;
  1181. lineIndex: number;
  1182. get currentLine(): string;
  1183. get canRead(): boolean;
  1184. set lines(value: string[]);
  1185. }
  1186. }
  1187. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1188. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1189. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1190. /** @hidden */
  1191. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1192. process(preprocessors: {
  1193. [key: string]: string;
  1194. }, options: ProcessingOptions): string;
  1195. }
  1196. }
  1197. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1198. /** @hidden */
  1199. export class ShaderDefineExpression {
  1200. isTrue(preprocessors: {
  1201. [key: string]: string;
  1202. }): boolean;
  1203. }
  1204. }
  1205. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1206. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1207. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1208. /** @hidden */
  1209. export class ShaderCodeTestNode extends ShaderCodeNode {
  1210. testExpression: ShaderDefineExpression;
  1211. isValid(preprocessors: {
  1212. [key: string]: string;
  1213. }): boolean;
  1214. }
  1215. }
  1216. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1217. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1218. /** @hidden */
  1219. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1220. define: string;
  1221. not: boolean;
  1222. constructor(define: string, not?: boolean);
  1223. isTrue(preprocessors: {
  1224. [key: string]: string;
  1225. }): boolean;
  1226. }
  1227. }
  1228. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1229. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1230. /** @hidden */
  1231. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1232. leftOperand: ShaderDefineExpression;
  1233. rightOperand: ShaderDefineExpression;
  1234. isTrue(preprocessors: {
  1235. [key: string]: string;
  1236. }): boolean;
  1237. }
  1238. }
  1239. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1240. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1241. /** @hidden */
  1242. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1243. leftOperand: ShaderDefineExpression;
  1244. rightOperand: ShaderDefineExpression;
  1245. isTrue(preprocessors: {
  1246. [key: string]: string;
  1247. }): boolean;
  1248. }
  1249. }
  1250. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1251. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1252. /** @hidden */
  1253. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1254. define: string;
  1255. operand: string;
  1256. testValue: string;
  1257. constructor(define: string, operand: string, testValue: string);
  1258. isTrue(preprocessors: {
  1259. [key: string]: string;
  1260. }): boolean;
  1261. }
  1262. }
  1263. declare module "babylonjs/Offline/IOfflineProvider" {
  1264. /**
  1265. * Class used to enable access to offline support
  1266. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1267. */
  1268. export interface IOfflineProvider {
  1269. /**
  1270. * Gets a boolean indicating if scene must be saved in the database
  1271. */
  1272. enableSceneOffline: boolean;
  1273. /**
  1274. * Gets a boolean indicating if textures must be saved in the database
  1275. */
  1276. enableTexturesOffline: boolean;
  1277. /**
  1278. * Open the offline support and make it available
  1279. * @param successCallback defines the callback to call on success
  1280. * @param errorCallback defines the callback to call on error
  1281. */
  1282. open(successCallback: () => void, errorCallback: () => void): void;
  1283. /**
  1284. * Loads an image from the offline support
  1285. * @param url defines the url to load from
  1286. * @param image defines the target DOM image
  1287. */
  1288. loadImage(url: string, image: HTMLImageElement): void;
  1289. /**
  1290. * Loads a file from offline support
  1291. * @param url defines the URL to load from
  1292. * @param sceneLoaded defines a callback to call on success
  1293. * @param progressCallBack defines a callback to call when progress changed
  1294. * @param errorCallback defines a callback to call on error
  1295. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1296. */
  1297. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1298. }
  1299. }
  1300. declare module "babylonjs/Misc/filesInputStore" {
  1301. /**
  1302. * Class used to help managing file picking and drag'n'drop
  1303. * File Storage
  1304. */
  1305. export class FilesInputStore {
  1306. /**
  1307. * List of files ready to be loaded
  1308. */
  1309. static FilesToLoad: {
  1310. [key: string]: File;
  1311. };
  1312. }
  1313. }
  1314. declare module "babylonjs/Misc/retryStrategy" {
  1315. import { WebRequest } from "babylonjs/Misc/webRequest";
  1316. /**
  1317. * Class used to define a retry strategy when error happens while loading assets
  1318. */
  1319. export class RetryStrategy {
  1320. /**
  1321. * Function used to defines an exponential back off strategy
  1322. * @param maxRetries defines the maximum number of retries (3 by default)
  1323. * @param baseInterval defines the interval between retries
  1324. * @returns the strategy function to use
  1325. */
  1326. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1327. }
  1328. }
  1329. declare module "babylonjs/Misc/baseError" {
  1330. /**
  1331. * @ignore
  1332. * Application error to support additional information when loading a file
  1333. */
  1334. export abstract class BaseError extends Error {
  1335. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1336. }
  1337. }
  1338. declare module "babylonjs/Misc/fileTools" {
  1339. import { WebRequest } from "babylonjs/Misc/webRequest";
  1340. import { Nullable } from "babylonjs/types";
  1341. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1342. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1343. import { BaseError } from "babylonjs/Misc/baseError";
  1344. /** @ignore */
  1345. export class LoadFileError extends BaseError {
  1346. request?: WebRequest;
  1347. file?: File;
  1348. /**
  1349. * Creates a new LoadFileError
  1350. * @param message defines the message of the error
  1351. * @param request defines the optional web request
  1352. * @param file defines the optional file
  1353. */
  1354. constructor(message: string, object?: WebRequest | File);
  1355. }
  1356. /** @ignore */
  1357. export class RequestFileError extends BaseError {
  1358. request: WebRequest;
  1359. /**
  1360. * Creates a new LoadFileError
  1361. * @param message defines the message of the error
  1362. * @param request defines the optional web request
  1363. */
  1364. constructor(message: string, request: WebRequest);
  1365. }
  1366. /** @ignore */
  1367. export class ReadFileError extends BaseError {
  1368. file: File;
  1369. /**
  1370. * Creates a new ReadFileError
  1371. * @param message defines the message of the error
  1372. * @param file defines the optional file
  1373. */
  1374. constructor(message: string, file: File);
  1375. }
  1376. /**
  1377. * @hidden
  1378. */
  1379. export class FileTools {
  1380. /**
  1381. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1382. */
  1383. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1384. /**
  1385. * Gets or sets the base URL to use to load assets
  1386. */
  1387. static BaseUrl: string;
  1388. /**
  1389. * Default behaviour for cors in the application.
  1390. * It can be a string if the expected behavior is identical in the entire app.
  1391. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1392. */
  1393. static CorsBehavior: string | ((url: string | string[]) => string);
  1394. /**
  1395. * Gets or sets a function used to pre-process url before using them to load assets
  1396. */
  1397. static PreprocessUrl: (url: string) => string;
  1398. /**
  1399. * Removes unwanted characters from an url
  1400. * @param url defines the url to clean
  1401. * @returns the cleaned url
  1402. */
  1403. private static _CleanUrl;
  1404. /**
  1405. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1406. * @param url define the url we are trying
  1407. * @param element define the dom element where to configure the cors policy
  1408. */
  1409. static SetCorsBehavior(url: string | string[], element: {
  1410. crossOrigin: string | null;
  1411. }): void;
  1412. /**
  1413. * Loads an image as an HTMLImageElement.
  1414. * @param input url string, ArrayBuffer, or Blob to load
  1415. * @param onLoad callback called when the image successfully loads
  1416. * @param onError callback called when the image fails to load
  1417. * @param offlineProvider offline provider for caching
  1418. * @param mimeType optional mime type
  1419. * @returns the HTMLImageElement of the loaded image
  1420. */
  1421. 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>;
  1422. /**
  1423. * Reads a file from a File object
  1424. * @param file defines the file to load
  1425. * @param onSuccess defines the callback to call when data is loaded
  1426. * @param onProgress defines the callback to call during loading process
  1427. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1428. * @param onError defines the callback to call when an error occurs
  1429. * @returns a file request object
  1430. */
  1431. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1432. /**
  1433. * Loads a file from a url
  1434. * @param url url to load
  1435. * @param onSuccess callback called when the file successfully loads
  1436. * @param onProgress callback called while file is loading (if the server supports this mode)
  1437. * @param offlineProvider defines the offline provider for caching
  1438. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1439. * @param onError callback called when the file fails to load
  1440. * @returns a file request object
  1441. */
  1442. 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;
  1443. /**
  1444. * Loads a file
  1445. * @param url url to load
  1446. * @param onSuccess callback called when the file successfully loads
  1447. * @param onProgress callback called while file is loading (if the server supports this mode)
  1448. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1449. * @param onError callback called when the file fails to load
  1450. * @param onOpened callback called when the web request is opened
  1451. * @returns a file request object
  1452. */
  1453. 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;
  1454. /**
  1455. * Checks if the loaded document was accessed via `file:`-Protocol.
  1456. * @returns boolean
  1457. */
  1458. static IsFileURL(): boolean;
  1459. }
  1460. }
  1461. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1462. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1463. import { WebRequest } from "babylonjs/Misc/webRequest";
  1464. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1465. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1466. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1467. /** @hidden */
  1468. export class ShaderProcessor {
  1469. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1470. private static _ProcessPrecision;
  1471. private static _ExtractOperation;
  1472. private static _BuildSubExpression;
  1473. private static _BuildExpression;
  1474. private static _MoveCursorWithinIf;
  1475. private static _MoveCursor;
  1476. private static _EvaluatePreProcessors;
  1477. private static _PreparePreProcessors;
  1478. private static _ProcessShaderConversion;
  1479. private static _ProcessIncludes;
  1480. /**
  1481. * Loads a file from a url
  1482. * @param url url to load
  1483. * @param onSuccess callback called when the file successfully loads
  1484. * @param onProgress callback called while file is loading (if the server supports this mode)
  1485. * @param offlineProvider defines the offline provider for caching
  1486. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1487. * @param onError callback called when the file fails to load
  1488. * @returns a file request object
  1489. * @hidden
  1490. */
  1491. 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;
  1492. }
  1493. }
  1494. declare module "babylonjs/Maths/math.like" {
  1495. import { float, int, DeepImmutable } from "babylonjs/types";
  1496. /**
  1497. * @hidden
  1498. */
  1499. export interface IColor4Like {
  1500. r: float;
  1501. g: float;
  1502. b: float;
  1503. a: float;
  1504. }
  1505. /**
  1506. * @hidden
  1507. */
  1508. export interface IColor3Like {
  1509. r: float;
  1510. g: float;
  1511. b: float;
  1512. }
  1513. /**
  1514. * @hidden
  1515. */
  1516. export interface IVector4Like {
  1517. x: float;
  1518. y: float;
  1519. z: float;
  1520. w: float;
  1521. }
  1522. /**
  1523. * @hidden
  1524. */
  1525. export interface IVector3Like {
  1526. x: float;
  1527. y: float;
  1528. z: float;
  1529. }
  1530. /**
  1531. * @hidden
  1532. */
  1533. export interface IVector2Like {
  1534. x: float;
  1535. y: float;
  1536. }
  1537. /**
  1538. * @hidden
  1539. */
  1540. export interface IMatrixLike {
  1541. toArray(): DeepImmutable<Float32Array>;
  1542. updateFlag: int;
  1543. }
  1544. /**
  1545. * @hidden
  1546. */
  1547. export interface IViewportLike {
  1548. x: float;
  1549. y: float;
  1550. width: float;
  1551. height: float;
  1552. }
  1553. /**
  1554. * @hidden
  1555. */
  1556. export interface IPlaneLike {
  1557. normal: IVector3Like;
  1558. d: float;
  1559. normalize(): void;
  1560. }
  1561. }
  1562. declare module "babylonjs/Materials/iEffectFallbacks" {
  1563. import { Effect } from "babylonjs/Materials/effect";
  1564. /**
  1565. * Interface used to define common properties for effect fallbacks
  1566. */
  1567. export interface IEffectFallbacks {
  1568. /**
  1569. * Removes the defines that should be removed when falling back.
  1570. * @param currentDefines defines the current define statements for the shader.
  1571. * @param effect defines the current effect we try to compile
  1572. * @returns The resulting defines with defines of the current rank removed.
  1573. */
  1574. reduce(currentDefines: string, effect: Effect): string;
  1575. /**
  1576. * Removes the fallback from the bound mesh.
  1577. */
  1578. unBindMesh(): void;
  1579. /**
  1580. * Checks to see if more fallbacks are still availible.
  1581. */
  1582. hasMoreFallbacks: boolean;
  1583. }
  1584. }
  1585. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1586. /**
  1587. * Class used to evalaute queries containing `and` and `or` operators
  1588. */
  1589. export class AndOrNotEvaluator {
  1590. /**
  1591. * Evaluate a query
  1592. * @param query defines the query to evaluate
  1593. * @param evaluateCallback defines the callback used to filter result
  1594. * @returns true if the query matches
  1595. */
  1596. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1597. private static _HandleParenthesisContent;
  1598. private static _SimplifyNegation;
  1599. }
  1600. }
  1601. declare module "babylonjs/Misc/tags" {
  1602. /**
  1603. * Class used to store custom tags
  1604. */
  1605. export class Tags {
  1606. /**
  1607. * Adds support for tags on the given object
  1608. * @param obj defines the object to use
  1609. */
  1610. static EnableFor(obj: any): void;
  1611. /**
  1612. * Removes tags support
  1613. * @param obj defines the object to use
  1614. */
  1615. static DisableFor(obj: any): void;
  1616. /**
  1617. * Gets a boolean indicating if the given object has tags
  1618. * @param obj defines the object to use
  1619. * @returns a boolean
  1620. */
  1621. static HasTags(obj: any): boolean;
  1622. /**
  1623. * Gets the tags available on a given object
  1624. * @param obj defines the object to use
  1625. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1626. * @returns the tags
  1627. */
  1628. static GetTags(obj: any, asString?: boolean): any;
  1629. /**
  1630. * Adds tags to an object
  1631. * @param obj defines the object to use
  1632. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1633. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1634. */
  1635. static AddTagsTo(obj: any, tagsString: string): void;
  1636. /**
  1637. * @hidden
  1638. */
  1639. static _AddTagTo(obj: any, tag: string): void;
  1640. /**
  1641. * Removes specific tags from a specific object
  1642. * @param obj defines the object to use
  1643. * @param tagsString defines the tags to remove
  1644. */
  1645. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1646. /**
  1647. * @hidden
  1648. */
  1649. static _RemoveTagFrom(obj: any, tag: string): void;
  1650. /**
  1651. * Defines if tags hosted on an object match a given query
  1652. * @param obj defines the object to use
  1653. * @param tagsQuery defines the tag query
  1654. * @returns a boolean
  1655. */
  1656. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1657. }
  1658. }
  1659. declare module "babylonjs/Maths/math.scalar" {
  1660. /**
  1661. * Scalar computation library
  1662. */
  1663. export class Scalar {
  1664. /**
  1665. * Two pi constants convenient for computation.
  1666. */
  1667. static TwoPi: number;
  1668. /**
  1669. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1670. * @param a number
  1671. * @param b number
  1672. * @param epsilon (default = 1.401298E-45)
  1673. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1674. */
  1675. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1676. /**
  1677. * Returns a string : the upper case translation of the number i to hexadecimal.
  1678. * @param i number
  1679. * @returns the upper case translation of the number i to hexadecimal.
  1680. */
  1681. static ToHex(i: number): string;
  1682. /**
  1683. * Returns -1 if value is negative and +1 is value is positive.
  1684. * @param value the value
  1685. * @returns the value itself if it's equal to zero.
  1686. */
  1687. static Sign(value: number): number;
  1688. /**
  1689. * Returns the value itself if it's between min and max.
  1690. * Returns min if the value is lower than min.
  1691. * Returns max if the value is greater than max.
  1692. * @param value the value to clmap
  1693. * @param min the min value to clamp to (default: 0)
  1694. * @param max the max value to clamp to (default: 1)
  1695. * @returns the clamped value
  1696. */
  1697. static Clamp(value: number, min?: number, max?: number): number;
  1698. /**
  1699. * the log2 of value.
  1700. * @param value the value to compute log2 of
  1701. * @returns the log2 of value.
  1702. */
  1703. static Log2(value: number): number;
  1704. /**
  1705. * Loops the value, so that it is never larger than length and never smaller than 0.
  1706. *
  1707. * This is similar to the modulo operator but it works with floating point numbers.
  1708. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1709. * With t = 5 and length = 2.5, the result would be 0.0.
  1710. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1711. * @param value the value
  1712. * @param length the length
  1713. * @returns the looped value
  1714. */
  1715. static Repeat(value: number, length: number): number;
  1716. /**
  1717. * Normalize the value between 0.0 and 1.0 using min and max values
  1718. * @param value value to normalize
  1719. * @param min max to normalize between
  1720. * @param max min to normalize between
  1721. * @returns the normalized value
  1722. */
  1723. static Normalize(value: number, min: number, max: number): number;
  1724. /**
  1725. * Denormalize the value from 0.0 and 1.0 using min and max values
  1726. * @param normalized value to denormalize
  1727. * @param min max to denormalize between
  1728. * @param max min to denormalize between
  1729. * @returns the denormalized value
  1730. */
  1731. static Denormalize(normalized: number, min: number, max: number): number;
  1732. /**
  1733. * Calculates the shortest difference between two given angles given in degrees.
  1734. * @param current current angle in degrees
  1735. * @param target target angle in degrees
  1736. * @returns the delta
  1737. */
  1738. static DeltaAngle(current: number, target: number): number;
  1739. /**
  1740. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1741. * @param tx value
  1742. * @param length length
  1743. * @returns The returned value will move back and forth between 0 and length
  1744. */
  1745. static PingPong(tx: number, length: number): number;
  1746. /**
  1747. * Interpolates between min and max with smoothing at the limits.
  1748. *
  1749. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1750. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1751. * @param from from
  1752. * @param to to
  1753. * @param tx value
  1754. * @returns the smooth stepped value
  1755. */
  1756. static SmoothStep(from: number, to: number, tx: number): number;
  1757. /**
  1758. * Moves a value current towards target.
  1759. *
  1760. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1761. * Negative values of maxDelta pushes the value away from target.
  1762. * @param current current value
  1763. * @param target target value
  1764. * @param maxDelta max distance to move
  1765. * @returns resulting value
  1766. */
  1767. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1768. /**
  1769. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1770. *
  1771. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1772. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1773. * @param current current value
  1774. * @param target target value
  1775. * @param maxDelta max distance to move
  1776. * @returns resulting angle
  1777. */
  1778. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1779. /**
  1780. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1781. * @param start start value
  1782. * @param end target value
  1783. * @param amount amount to lerp between
  1784. * @returns the lerped value
  1785. */
  1786. static Lerp(start: number, end: number, amount: number): number;
  1787. /**
  1788. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1789. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1790. * @param start start value
  1791. * @param end target value
  1792. * @param amount amount to lerp between
  1793. * @returns the lerped value
  1794. */
  1795. static LerpAngle(start: number, end: number, amount: number): number;
  1796. /**
  1797. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1798. * @param a start value
  1799. * @param b target value
  1800. * @param value value between a and b
  1801. * @returns the inverseLerp value
  1802. */
  1803. static InverseLerp(a: number, b: number, value: number): number;
  1804. /**
  1805. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1806. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1807. * @param value1 spline value
  1808. * @param tangent1 spline value
  1809. * @param value2 spline value
  1810. * @param tangent2 spline value
  1811. * @param amount input value
  1812. * @returns hermite result
  1813. */
  1814. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1815. /**
  1816. * Returns a random float number between and min and max values
  1817. * @param min min value of random
  1818. * @param max max value of random
  1819. * @returns random value
  1820. */
  1821. static RandomRange(min: number, max: number): number;
  1822. /**
  1823. * This function returns percentage of a number in a given range.
  1824. *
  1825. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1826. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1827. * @param number to convert to percentage
  1828. * @param min min range
  1829. * @param max max range
  1830. * @returns the percentage
  1831. */
  1832. static RangeToPercent(number: number, min: number, max: number): number;
  1833. /**
  1834. * This function returns number that corresponds to the percentage in a given range.
  1835. *
  1836. * PercentToRange(0.34,0,100) will return 34.
  1837. * @param percent to convert to number
  1838. * @param min min range
  1839. * @param max max range
  1840. * @returns the number
  1841. */
  1842. static PercentToRange(percent: number, min: number, max: number): number;
  1843. /**
  1844. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1845. * @param angle The angle to normalize in radian.
  1846. * @return The converted angle.
  1847. */
  1848. static NormalizeRadians(angle: number): number;
  1849. }
  1850. }
  1851. declare module "babylonjs/Maths/math.constants" {
  1852. /**
  1853. * Constant used to convert a value to gamma space
  1854. * @ignorenaming
  1855. */
  1856. export const ToGammaSpace: number;
  1857. /**
  1858. * Constant used to convert a value to linear space
  1859. * @ignorenaming
  1860. */
  1861. export const ToLinearSpace = 2.2;
  1862. /**
  1863. * Constant used to define the minimal number value in Babylon.js
  1864. * @ignorenaming
  1865. */
  1866. let Epsilon: number;
  1867. export { Epsilon };
  1868. }
  1869. declare module "babylonjs/Maths/math.viewport" {
  1870. /**
  1871. * Class used to represent a viewport on screen
  1872. */
  1873. export class Viewport {
  1874. /** viewport left coordinate */
  1875. x: number;
  1876. /** viewport top coordinate */
  1877. y: number;
  1878. /**viewport width */
  1879. width: number;
  1880. /** viewport height */
  1881. height: number;
  1882. /**
  1883. * Creates a Viewport object located at (x, y) and sized (width, height)
  1884. * @param x defines viewport left coordinate
  1885. * @param y defines viewport top coordinate
  1886. * @param width defines the viewport width
  1887. * @param height defines the viewport height
  1888. */
  1889. constructor(
  1890. /** viewport left coordinate */
  1891. x: number,
  1892. /** viewport top coordinate */
  1893. y: number,
  1894. /**viewport width */
  1895. width: number,
  1896. /** viewport height */
  1897. height: number);
  1898. /**
  1899. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1900. * @param renderWidth defines the rendering width
  1901. * @param renderHeight defines the rendering height
  1902. * @returns a new Viewport
  1903. */
  1904. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1905. /**
  1906. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1907. * @param renderWidth defines the rendering width
  1908. * @param renderHeight defines the rendering height
  1909. * @param ref defines the target viewport
  1910. * @returns the current viewport
  1911. */
  1912. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1913. /**
  1914. * Returns a new Viewport copied from the current one
  1915. * @returns a new Viewport
  1916. */
  1917. clone(): Viewport;
  1918. }
  1919. }
  1920. declare module "babylonjs/Misc/arrayTools" {
  1921. /**
  1922. * Class containing a set of static utilities functions for arrays.
  1923. */
  1924. export class ArrayTools {
  1925. /**
  1926. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1927. * @param size the number of element to construct and put in the array
  1928. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1929. * @returns a new array filled with new objects
  1930. */
  1931. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1932. }
  1933. }
  1934. declare module "babylonjs/Maths/math.vector" {
  1935. import { Viewport } from "babylonjs/Maths/math.viewport";
  1936. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1937. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1938. /**
  1939. * Class representing a vector containing 2 coordinates
  1940. */
  1941. export class Vector2 {
  1942. /** defines the first coordinate */
  1943. x: number;
  1944. /** defines the second coordinate */
  1945. y: number;
  1946. /**
  1947. * Creates a new Vector2 from the given x and y coordinates
  1948. * @param x defines the first coordinate
  1949. * @param y defines the second coordinate
  1950. */
  1951. constructor(
  1952. /** defines the first coordinate */
  1953. x?: number,
  1954. /** defines the second coordinate */
  1955. y?: number);
  1956. /**
  1957. * Gets a string with the Vector2 coordinates
  1958. * @returns a string with the Vector2 coordinates
  1959. */
  1960. toString(): string;
  1961. /**
  1962. * Gets class name
  1963. * @returns the string "Vector2"
  1964. */
  1965. getClassName(): string;
  1966. /**
  1967. * Gets current vector hash code
  1968. * @returns the Vector2 hash code as a number
  1969. */
  1970. getHashCode(): number;
  1971. /**
  1972. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1973. * @param array defines the source array
  1974. * @param index defines the offset in source array
  1975. * @returns the current Vector2
  1976. */
  1977. toArray(array: FloatArray, index?: number): Vector2;
  1978. /**
  1979. * Copy the current vector to an array
  1980. * @returns a new array with 2 elements: the Vector2 coordinates.
  1981. */
  1982. asArray(): number[];
  1983. /**
  1984. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1985. * @param source defines the source Vector2
  1986. * @returns the current updated Vector2
  1987. */
  1988. copyFrom(source: DeepImmutable<Vector2>): 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. copyFromFloats(x: number, y: number): Vector2;
  1996. /**
  1997. * Sets the Vector2 coordinates with the given floats
  1998. * @param x defines the first coordinate
  1999. * @param y defines the second coordinate
  2000. * @returns the current updated Vector2
  2001. */
  2002. set(x: number, y: number): Vector2;
  2003. /**
  2004. * Add another vector with the current one
  2005. * @param otherVector defines the other vector
  2006. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2007. */
  2008. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2009. /**
  2010. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2011. * @param otherVector defines the other vector
  2012. * @param result defines the target vector
  2013. * @returns the unmodified current Vector2
  2014. */
  2015. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2016. /**
  2017. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2018. * @param otherVector defines the other vector
  2019. * @returns the current updated Vector2
  2020. */
  2021. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2022. /**
  2023. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2024. * @param otherVector defines the other vector
  2025. * @returns a new Vector2
  2026. */
  2027. addVector3(otherVector: Vector3): Vector2;
  2028. /**
  2029. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2030. * @param otherVector defines the other vector
  2031. * @returns a new Vector2
  2032. */
  2033. subtract(otherVector: Vector2): Vector2;
  2034. /**
  2035. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2036. * @param otherVector defines the other vector
  2037. * @param result defines the target vector
  2038. * @returns the unmodified current Vector2
  2039. */
  2040. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2041. /**
  2042. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2043. * @param otherVector defines the other vector
  2044. * @returns the current updated Vector2
  2045. */
  2046. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2047. /**
  2048. * Multiplies in place the current Vector2 coordinates by the given ones
  2049. * @param otherVector defines the other vector
  2050. * @returns the current updated Vector2
  2051. */
  2052. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2053. /**
  2054. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2055. * @param otherVector defines the other vector
  2056. * @returns a new Vector2
  2057. */
  2058. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2059. /**
  2060. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2061. * @param otherVector defines the other vector
  2062. * @param result defines the target vector
  2063. * @returns the unmodified current Vector2
  2064. */
  2065. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2066. /**
  2067. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2068. * @param x defines the first coordinate
  2069. * @param y defines the second coordinate
  2070. * @returns a new Vector2
  2071. */
  2072. multiplyByFloats(x: number, y: number): Vector2;
  2073. /**
  2074. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2075. * @param otherVector defines the other vector
  2076. * @returns a new Vector2
  2077. */
  2078. divide(otherVector: Vector2): Vector2;
  2079. /**
  2080. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2081. * @param otherVector defines the other vector
  2082. * @param result defines the target vector
  2083. * @returns the unmodified current Vector2
  2084. */
  2085. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2086. /**
  2087. * Divides the current Vector2 coordinates by the given ones
  2088. * @param otherVector defines the other vector
  2089. * @returns the current updated Vector2
  2090. */
  2091. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2092. /**
  2093. * Gets a new Vector2 with current Vector2 negated coordinates
  2094. * @returns a new Vector2
  2095. */
  2096. negate(): Vector2;
  2097. /**
  2098. * Negate this vector in place
  2099. * @returns this
  2100. */
  2101. negateInPlace(): Vector2;
  2102. /**
  2103. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2104. * @param result defines the Vector3 object where to store the result
  2105. * @returns the current Vector2
  2106. */
  2107. negateToRef(result: Vector2): Vector2;
  2108. /**
  2109. * Multiply the Vector2 coordinates by scale
  2110. * @param scale defines the scaling factor
  2111. * @returns the current updated Vector2
  2112. */
  2113. scaleInPlace(scale: number): Vector2;
  2114. /**
  2115. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2116. * @param scale defines the scaling factor
  2117. * @returns a new Vector2
  2118. */
  2119. scale(scale: number): Vector2;
  2120. /**
  2121. * Scale the current Vector2 values by a factor 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. scaleToRef(scale: number, result: Vector2): Vector2;
  2127. /**
  2128. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2129. * @param scale defines the scale factor
  2130. * @param result defines the Vector2 object where to store the result
  2131. * @returns the unmodified current Vector2
  2132. */
  2133. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2134. /**
  2135. * Gets a boolean if two vectors are equals
  2136. * @param otherVector defines the other vector
  2137. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2138. */
  2139. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2140. /**
  2141. * Gets a boolean if two vectors are equals (using an epsilon value)
  2142. * @param otherVector defines the other vector
  2143. * @param epsilon defines the minimal distance to consider equality
  2144. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2145. */
  2146. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2147. /**
  2148. * Gets a new Vector2 from current Vector2 floored values
  2149. * @returns a new Vector2
  2150. */
  2151. floor(): Vector2;
  2152. /**
  2153. * Gets a new Vector2 from current Vector2 floored values
  2154. * @returns a new Vector2
  2155. */
  2156. fract(): Vector2;
  2157. /**
  2158. * Gets the length of the vector
  2159. * @returns the vector length (float)
  2160. */
  2161. length(): number;
  2162. /**
  2163. * Gets the vector squared length
  2164. * @returns the vector squared length (float)
  2165. */
  2166. lengthSquared(): number;
  2167. /**
  2168. * Normalize the vector
  2169. * @returns the current updated Vector2
  2170. */
  2171. normalize(): Vector2;
  2172. /**
  2173. * Gets a new Vector2 copied from the Vector2
  2174. * @returns a new Vector2
  2175. */
  2176. clone(): Vector2;
  2177. /**
  2178. * Gets a new Vector2(0, 0)
  2179. * @returns a new Vector2
  2180. */
  2181. static Zero(): Vector2;
  2182. /**
  2183. * Gets a new Vector2(1, 1)
  2184. * @returns a new Vector2
  2185. */
  2186. static One(): Vector2;
  2187. /**
  2188. * Gets a new Vector2 set 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. * @returns a new Vector2
  2192. */
  2193. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2194. /**
  2195. * Sets "result" from the given index element of the given array
  2196. * @param array defines the data source
  2197. * @param offset defines the offset in the data source
  2198. * @param result defines the target vector
  2199. */
  2200. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2201. /**
  2202. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2203. * @param value1 defines 1st point of control
  2204. * @param value2 defines 2nd point of control
  2205. * @param value3 defines 3rd point of control
  2206. * @param value4 defines 4th point of control
  2207. * @param amount defines the interpolation factor
  2208. * @returns a new Vector2
  2209. */
  2210. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2211. /**
  2212. * 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".
  2213. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2214. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2215. * @param value defines the value to clamp
  2216. * @param min defines the lower limit
  2217. * @param max defines the upper limit
  2218. * @returns a new Vector2
  2219. */
  2220. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2221. /**
  2222. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2223. * @param value1 defines the 1st control point
  2224. * @param tangent1 defines the outgoing tangent
  2225. * @param value2 defines the 2nd control point
  2226. * @param tangent2 defines the incoming tangent
  2227. * @param amount defines the interpolation factor
  2228. * @returns a new Vector2
  2229. */
  2230. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2231. /**
  2232. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2233. * @param start defines the start vector
  2234. * @param end defines the end vector
  2235. * @param amount defines the interpolation factor
  2236. * @returns a new Vector2
  2237. */
  2238. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2239. /**
  2240. * Gets the dot product of the vector "left" and the vector "right"
  2241. * @param left defines first vector
  2242. * @param right defines second vector
  2243. * @returns the dot product (float)
  2244. */
  2245. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2246. /**
  2247. * Returns a new Vector2 equal to the normalized given vector
  2248. * @param vector defines the vector to normalize
  2249. * @returns a new Vector2
  2250. */
  2251. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2252. /**
  2253. * Gets a new Vector2 set with the minimal 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 Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2259. /**
  2260. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2261. * @param left defines 1st vector
  2262. * @param right defines 2nd vector
  2263. * @returns a new Vector2
  2264. */
  2265. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2266. /**
  2267. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2268. * @param vector defines the vector to transform
  2269. * @param transformation defines the matrix to apply
  2270. * @returns a new Vector2
  2271. */
  2272. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2273. /**
  2274. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2275. * @param vector defines the vector to transform
  2276. * @param transformation defines the matrix to apply
  2277. * @param result defines the target vector
  2278. */
  2279. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2280. /**
  2281. * Determines if a given vector is included in a triangle
  2282. * @param p defines the vector to test
  2283. * @param p0 defines 1st triangle point
  2284. * @param p1 defines 2nd triangle point
  2285. * @param p2 defines 3rd triangle point
  2286. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2287. */
  2288. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2289. /**
  2290. * Gets the distance between the vectors "value1" and "value2"
  2291. * @param value1 defines first vector
  2292. * @param value2 defines second vector
  2293. * @returns the distance between vectors
  2294. */
  2295. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2296. /**
  2297. * Returns the squared distance between the vectors "value1" and "value2"
  2298. * @param value1 defines first vector
  2299. * @param value2 defines second vector
  2300. * @returns the squared distance between vectors
  2301. */
  2302. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2303. /**
  2304. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2305. * @param value1 defines first vector
  2306. * @param value2 defines second vector
  2307. * @returns a new Vector2
  2308. */
  2309. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2310. /**
  2311. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2312. * @param p defines the middle point
  2313. * @param segA defines one point of the segment
  2314. * @param segB defines the other point of the segment
  2315. * @returns the shortest distance
  2316. */
  2317. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2318. }
  2319. /**
  2320. * Class used to store (x,y,z) vector representation
  2321. * A Vector3 is the main object used in 3D geometry
  2322. * It can represent etiher the coordinates of a point the space, either a direction
  2323. * Reminder: js uses a left handed forward facing system
  2324. */
  2325. export class Vector3 {
  2326. /**
  2327. * Defines the first coordinates (on X axis)
  2328. */
  2329. x: number;
  2330. /**
  2331. * Defines the second coordinates (on Y axis)
  2332. */
  2333. y: number;
  2334. /**
  2335. * Defines the third coordinates (on Z axis)
  2336. */
  2337. z: number;
  2338. private static _UpReadOnly;
  2339. private static _ZeroReadOnly;
  2340. /**
  2341. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2342. * @param x defines the first coordinates (on X axis)
  2343. * @param y defines the second coordinates (on Y axis)
  2344. * @param z defines the third coordinates (on Z axis)
  2345. */
  2346. constructor(
  2347. /**
  2348. * Defines the first coordinates (on X axis)
  2349. */
  2350. x?: number,
  2351. /**
  2352. * Defines the second coordinates (on Y axis)
  2353. */
  2354. y?: number,
  2355. /**
  2356. * Defines the third coordinates (on Z axis)
  2357. */
  2358. z?: number);
  2359. /**
  2360. * Creates a string representation of the Vector3
  2361. * @returns a string with the Vector3 coordinates.
  2362. */
  2363. toString(): string;
  2364. /**
  2365. * Gets the class name
  2366. * @returns the string "Vector3"
  2367. */
  2368. getClassName(): string;
  2369. /**
  2370. * Creates the Vector3 hash code
  2371. * @returns a number which tends to be unique between Vector3 instances
  2372. */
  2373. getHashCode(): number;
  2374. /**
  2375. * Creates an array containing three elements : the coordinates of the Vector3
  2376. * @returns a new array of numbers
  2377. */
  2378. asArray(): number[];
  2379. /**
  2380. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2381. * @param array defines the destination array
  2382. * @param index defines the offset in the destination array
  2383. * @returns the current Vector3
  2384. */
  2385. toArray(array: FloatArray, index?: number): Vector3;
  2386. /**
  2387. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2388. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2389. */
  2390. toQuaternion(): Quaternion;
  2391. /**
  2392. * Adds the given vector to the current Vector3
  2393. * @param otherVector defines the second operand
  2394. * @returns the current updated Vector3
  2395. */
  2396. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2397. /**
  2398. * Adds the given coordinates to the current Vector3
  2399. * @param x defines the x coordinate of the operand
  2400. * @param y defines the y coordinate of the operand
  2401. * @param z defines the z coordinate of the operand
  2402. * @returns the current updated Vector3
  2403. */
  2404. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2405. /**
  2406. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2407. * @param otherVector defines the second operand
  2408. * @returns the resulting Vector3
  2409. */
  2410. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2411. /**
  2412. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2413. * @param otherVector defines the second operand
  2414. * @param result defines the Vector3 object where to store the result
  2415. * @returns the current Vector3
  2416. */
  2417. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2418. /**
  2419. * Subtract the given vector from the current Vector3
  2420. * @param otherVector defines the second operand
  2421. * @returns the current updated Vector3
  2422. */
  2423. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2424. /**
  2425. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2426. * @param otherVector defines the second operand
  2427. * @returns the resulting Vector3
  2428. */
  2429. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2430. /**
  2431. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2432. * @param otherVector defines the second operand
  2433. * @param result defines the Vector3 object where to store the result
  2434. * @returns the current Vector3
  2435. */
  2436. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2437. /**
  2438. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2439. * @param x defines the x coordinate of the operand
  2440. * @param y defines the y coordinate of the operand
  2441. * @param z defines the z coordinate of the operand
  2442. * @returns the resulting Vector3
  2443. */
  2444. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2445. /**
  2446. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2447. * @param x defines the x coordinate of the operand
  2448. * @param y defines the y coordinate of the operand
  2449. * @param z defines the z coordinate of the operand
  2450. * @param result defines the Vector3 object where to store the result
  2451. * @returns the current Vector3
  2452. */
  2453. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2454. /**
  2455. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2456. * @returns a new Vector3
  2457. */
  2458. negate(): Vector3;
  2459. /**
  2460. * Negate this vector in place
  2461. * @returns this
  2462. */
  2463. negateInPlace(): Vector3;
  2464. /**
  2465. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2466. * @param result defines the Vector3 object where to store the result
  2467. * @returns the current Vector3
  2468. */
  2469. negateToRef(result: Vector3): Vector3;
  2470. /**
  2471. * Multiplies the Vector3 coordinates by the float "scale"
  2472. * @param scale defines the multiplier factor
  2473. * @returns the current updated Vector3
  2474. */
  2475. scaleInPlace(scale: number): Vector3;
  2476. /**
  2477. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2478. * @param scale defines the multiplier factor
  2479. * @returns a new Vector3
  2480. */
  2481. scale(scale: number): Vector3;
  2482. /**
  2483. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2484. * @param scale defines the multiplier factor
  2485. * @param result defines the Vector3 object where to store the result
  2486. * @returns the current Vector3
  2487. */
  2488. scaleToRef(scale: number, result: Vector3): Vector3;
  2489. /**
  2490. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2491. * @param scale defines the scale factor
  2492. * @param result defines the Vector3 object where to store the result
  2493. * @returns the unmodified current Vector3
  2494. */
  2495. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2496. /**
  2497. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2498. * @param otherVector defines the second operand
  2499. * @returns true if both vectors are equals
  2500. */
  2501. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2502. /**
  2503. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2504. * @param otherVector defines the second operand
  2505. * @param epsilon defines the minimal distance to define values as equals
  2506. * @returns true if both vectors are distant less than epsilon
  2507. */
  2508. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2509. /**
  2510. * Returns true if the current Vector3 coordinates equals the given floats
  2511. * @param x defines the x coordinate of the operand
  2512. * @param y defines the y coordinate of the operand
  2513. * @param z defines the z coordinate of the operand
  2514. * @returns true if both vectors are equals
  2515. */
  2516. equalsToFloats(x: number, y: number, z: number): boolean;
  2517. /**
  2518. * Multiplies the current Vector3 coordinates by the given ones
  2519. * @param otherVector defines the second operand
  2520. * @returns the current updated Vector3
  2521. */
  2522. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2523. /**
  2524. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2525. * @param otherVector defines the second operand
  2526. * @returns the new Vector3
  2527. */
  2528. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2529. /**
  2530. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2531. * @param otherVector defines the second operand
  2532. * @param result defines the Vector3 object where to store the result
  2533. * @returns the current Vector3
  2534. */
  2535. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2536. /**
  2537. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2538. * @param x defines the x coordinate of the operand
  2539. * @param y defines the y coordinate of the operand
  2540. * @param z defines the z coordinate of the operand
  2541. * @returns the new Vector3
  2542. */
  2543. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2544. /**
  2545. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2546. * @param otherVector defines the second operand
  2547. * @returns the new Vector3
  2548. */
  2549. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2550. /**
  2551. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2552. * @param otherVector defines the second operand
  2553. * @param result defines the Vector3 object where to store the result
  2554. * @returns the current Vector3
  2555. */
  2556. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2557. /**
  2558. * Divides the current Vector3 coordinates by the given ones.
  2559. * @param otherVector defines the second operand
  2560. * @returns the current updated Vector3
  2561. */
  2562. divideInPlace(otherVector: Vector3): Vector3;
  2563. /**
  2564. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2565. * @param other defines the second operand
  2566. * @returns the current updated Vector3
  2567. */
  2568. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2569. /**
  2570. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2571. * @param other defines the second operand
  2572. * @returns the current updated Vector3
  2573. */
  2574. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2575. /**
  2576. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2577. * @param x defines the x coordinate of the operand
  2578. * @param y defines the y coordinate of the operand
  2579. * @param z defines the z coordinate of the operand
  2580. * @returns the current updated Vector3
  2581. */
  2582. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2583. /**
  2584. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2585. * @param x defines the x coordinate of the operand
  2586. * @param y defines the y coordinate of the operand
  2587. * @param z defines the z coordinate of the operand
  2588. * @returns the current updated Vector3
  2589. */
  2590. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2591. /**
  2592. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2593. * Check if is non uniform within a certain amount of decimal places to account for this
  2594. * @param epsilon the amount the values can differ
  2595. * @returns if the the vector is non uniform to a certain number of decimal places
  2596. */
  2597. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2598. /**
  2599. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2600. */
  2601. get isNonUniform(): boolean;
  2602. /**
  2603. * Gets a new Vector3 from current Vector3 floored values
  2604. * @returns a new Vector3
  2605. */
  2606. floor(): Vector3;
  2607. /**
  2608. * Gets a new Vector3 from current Vector3 floored values
  2609. * @returns a new Vector3
  2610. */
  2611. fract(): Vector3;
  2612. /**
  2613. * Gets the length of the Vector3
  2614. * @returns the length of the Vector3
  2615. */
  2616. length(): number;
  2617. /**
  2618. * Gets the squared length of the Vector3
  2619. * @returns squared length of the Vector3
  2620. */
  2621. lengthSquared(): number;
  2622. /**
  2623. * Normalize the current Vector3.
  2624. * Please note that this is an in place operation.
  2625. * @returns the current updated Vector3
  2626. */
  2627. normalize(): Vector3;
  2628. /**
  2629. * Reorders the x y z properties of the vector in place
  2630. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2631. * @returns the current updated vector
  2632. */
  2633. reorderInPlace(order: string): this;
  2634. /**
  2635. * Rotates the vector around 0,0,0 by a quaternion
  2636. * @param quaternion the rotation quaternion
  2637. * @param result vector to store the result
  2638. * @returns the resulting vector
  2639. */
  2640. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2641. /**
  2642. * Rotates a vector around a given point
  2643. * @param quaternion the rotation quaternion
  2644. * @param point the point to rotate around
  2645. * @param result vector to store the result
  2646. * @returns the resulting vector
  2647. */
  2648. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2649. /**
  2650. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2651. * The cross product is then orthogonal to both current and "other"
  2652. * @param other defines the right operand
  2653. * @returns the cross product
  2654. */
  2655. cross(other: Vector3): Vector3;
  2656. /**
  2657. * Normalize the current Vector3 with the given input length.
  2658. * Please note that this is an in place operation.
  2659. * @param len the length of the vector
  2660. * @returns the current updated Vector3
  2661. */
  2662. normalizeFromLength(len: number): Vector3;
  2663. /**
  2664. * Normalize the current Vector3 to a new vector
  2665. * @returns the new Vector3
  2666. */
  2667. normalizeToNew(): Vector3;
  2668. /**
  2669. * Normalize the current Vector3 to the reference
  2670. * @param reference define the Vector3 to update
  2671. * @returns the updated Vector3
  2672. */
  2673. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2674. /**
  2675. * Creates a new Vector3 copied from the current Vector3
  2676. * @returns the new Vector3
  2677. */
  2678. clone(): Vector3;
  2679. /**
  2680. * Copies the given vector coordinates to the current Vector3 ones
  2681. * @param source defines the source Vector3
  2682. * @returns the current updated Vector3
  2683. */
  2684. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2685. /**
  2686. * Copies the given floats to the current Vector3 coordinates
  2687. * @param x defines the x coordinate of the operand
  2688. * @param y defines the y coordinate of the operand
  2689. * @param z defines the z coordinate of the operand
  2690. * @returns the current updated Vector3
  2691. */
  2692. copyFromFloats(x: number, y: number, z: number): Vector3;
  2693. /**
  2694. * Copies the given floats to the current Vector3 coordinates
  2695. * @param x defines the x coordinate of the operand
  2696. * @param y defines the y coordinate of the operand
  2697. * @param z defines the z coordinate of the operand
  2698. * @returns the current updated Vector3
  2699. */
  2700. set(x: number, y: number, z: number): Vector3;
  2701. /**
  2702. * Copies the given float to the current Vector3 coordinates
  2703. * @param v defines the x, y and z coordinates of the operand
  2704. * @returns the current updated Vector3
  2705. */
  2706. setAll(v: number): Vector3;
  2707. /**
  2708. * Get the clip factor between two vectors
  2709. * @param vector0 defines the first operand
  2710. * @param vector1 defines the second operand
  2711. * @param axis defines the axis to use
  2712. * @param size defines the size along the axis
  2713. * @returns the clip factor
  2714. */
  2715. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2716. /**
  2717. * Get angle between two vectors
  2718. * @param vector0 angle between vector0 and vector1
  2719. * @param vector1 angle between vector0 and vector1
  2720. * @param normal direction of the normal
  2721. * @return the angle between vector0 and vector1
  2722. */
  2723. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2724. /**
  2725. * Returns a new Vector3 set from the index "offset" of the given array
  2726. * @param array defines the source array
  2727. * @param offset defines the offset in the source array
  2728. * @returns the new Vector3
  2729. */
  2730. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2731. /**
  2732. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2733. * @param array defines the source array
  2734. * @param offset defines the offset in the source array
  2735. * @returns the new Vector3
  2736. * @deprecated Please use FromArray instead.
  2737. */
  2738. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2739. /**
  2740. * Sets the given vector "result" with the element values from the index "offset" of the given array
  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. */
  2745. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2746. /**
  2747. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2748. * @param array defines the source array
  2749. * @param offset defines the offset in the source array
  2750. * @param result defines the Vector3 where to store the result
  2751. * @deprecated Please use FromArrayToRef instead.
  2752. */
  2753. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2754. /**
  2755. * Sets the given vector "result" with the given floats.
  2756. * @param x defines the x coordinate of the source
  2757. * @param y defines the y coordinate of the source
  2758. * @param z defines the z coordinate of the source
  2759. * @param result defines the Vector3 where to store the result
  2760. */
  2761. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2762. /**
  2763. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2764. * @returns a new empty Vector3
  2765. */
  2766. static Zero(): Vector3;
  2767. /**
  2768. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2769. * @returns a new unit Vector3
  2770. */
  2771. static One(): Vector3;
  2772. /**
  2773. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2774. * @returns a new up Vector3
  2775. */
  2776. static Up(): Vector3;
  2777. /**
  2778. * Gets a up Vector3 that must not be updated
  2779. */
  2780. static get UpReadOnly(): DeepImmutable<Vector3>;
  2781. /**
  2782. * Gets a zero Vector3 that must not be updated
  2783. */
  2784. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2785. /**
  2786. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2787. * @returns a new down Vector3
  2788. */
  2789. static Down(): Vector3;
  2790. /**
  2791. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2792. * @returns a new forward Vector3
  2793. */
  2794. static Forward(): Vector3;
  2795. /**
  2796. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2797. * @returns a new forward Vector3
  2798. */
  2799. static Backward(): Vector3;
  2800. /**
  2801. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2802. * @returns a new right Vector3
  2803. */
  2804. static Right(): Vector3;
  2805. /**
  2806. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2807. * @returns a new left Vector3
  2808. */
  2809. static Left(): Vector3;
  2810. /**
  2811. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2812. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2813. * @param vector defines the Vector3 to transform
  2814. * @param transformation defines the transformation matrix
  2815. * @returns the transformed Vector3
  2816. */
  2817. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2818. /**
  2819. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2820. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2821. * @param vector defines the Vector3 to transform
  2822. * @param transformation defines the transformation matrix
  2823. * @param result defines the Vector3 where to store the result
  2824. */
  2825. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2826. /**
  2827. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2828. * This method computes tranformed coordinates only, not transformed direction vectors
  2829. * @param x define the x coordinate of the source vector
  2830. * @param y define the y coordinate of the source vector
  2831. * @param z define the z coordinate of the source vector
  2832. * @param transformation defines the transformation matrix
  2833. * @param result defines the Vector3 where to store the result
  2834. */
  2835. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2836. /**
  2837. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2838. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2839. * @param vector defines the Vector3 to transform
  2840. * @param transformation defines the transformation matrix
  2841. * @returns the new Vector3
  2842. */
  2843. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2844. /**
  2845. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2846. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2847. * @param vector defines the Vector3 to transform
  2848. * @param transformation defines the transformation matrix
  2849. * @param result defines the Vector3 where to store the result
  2850. */
  2851. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2852. /**
  2853. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2854. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2855. * @param x define the x coordinate of the source vector
  2856. * @param y define the y coordinate of the source vector
  2857. * @param z define the z coordinate of the source vector
  2858. * @param transformation defines the transformation matrix
  2859. * @param result defines the Vector3 where to store the result
  2860. */
  2861. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2862. /**
  2863. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2864. * @param value1 defines the first control point
  2865. * @param value2 defines the second control point
  2866. * @param value3 defines the third control point
  2867. * @param value4 defines the fourth control point
  2868. * @param amount defines the amount on the spline to use
  2869. * @returns the new Vector3
  2870. */
  2871. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2872. /**
  2873. * 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"
  2874. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2875. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2876. * @param value defines the current value
  2877. * @param min defines the lower range value
  2878. * @param max defines the upper range value
  2879. * @returns the new Vector3
  2880. */
  2881. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2882. /**
  2883. * 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"
  2884. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2885. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2886. * @param value defines the current value
  2887. * @param min defines the lower range value
  2888. * @param max defines the upper range value
  2889. * @param result defines the Vector3 where to store the result
  2890. */
  2891. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2892. /**
  2893. * Checks if a given vector is inside a specific range
  2894. * @param v defines the vector to test
  2895. * @param min defines the minimum range
  2896. * @param max defines the maximum range
  2897. */
  2898. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2899. /**
  2900. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2901. * @param value1 defines the first control point
  2902. * @param tangent1 defines the first tangent vector
  2903. * @param value2 defines the second control point
  2904. * @param tangent2 defines the second tangent vector
  2905. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2906. * @returns the new Vector3
  2907. */
  2908. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2909. /**
  2910. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2911. * @param start defines the start value
  2912. * @param end defines the end value
  2913. * @param amount max defines amount between both (between 0 and 1)
  2914. * @returns the new Vector3
  2915. */
  2916. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2917. /**
  2918. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2919. * @param start defines the start value
  2920. * @param end defines the end value
  2921. * @param amount max defines amount between both (between 0 and 1)
  2922. * @param result defines the Vector3 where to store the result
  2923. */
  2924. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2925. /**
  2926. * Returns the dot product (float) between the vectors "left" and "right"
  2927. * @param left defines the left operand
  2928. * @param right defines the right operand
  2929. * @returns the dot product
  2930. */
  2931. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2932. /**
  2933. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2934. * The cross product is then orthogonal to both "left" and "right"
  2935. * @param left defines the left operand
  2936. * @param right defines the right operand
  2937. * @returns the cross product
  2938. */
  2939. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2940. /**
  2941. * Sets the given vector "result" with the cross product of "left" and "right"
  2942. * The cross product is then orthogonal to both "left" and "right"
  2943. * @param left defines the left operand
  2944. * @param right defines the right operand
  2945. * @param result defines the Vector3 where to store the result
  2946. */
  2947. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2948. /**
  2949. * Returns a new Vector3 as the normalization of the given vector
  2950. * @param vector defines the Vector3 to normalize
  2951. * @returns the new Vector3
  2952. */
  2953. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2954. /**
  2955. * Sets the given vector "result" with the normalization of the given first vector
  2956. * @param vector defines the Vector3 to normalize
  2957. * @param result defines the Vector3 where to store the result
  2958. */
  2959. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2960. /**
  2961. * Project a Vector3 onto screen space
  2962. * @param vector defines the Vector3 to project
  2963. * @param world defines the world matrix to use
  2964. * @param transform defines the transform (view x projection) matrix to use
  2965. * @param viewport defines the screen viewport to use
  2966. * @returns the new Vector3
  2967. */
  2968. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2969. /** @hidden */
  2970. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2971. /**
  2972. * Unproject from screen space to object space
  2973. * @param source defines the screen space Vector3 to use
  2974. * @param viewportWidth defines the current width of the viewport
  2975. * @param viewportHeight defines the current height of the viewport
  2976. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2977. * @param transform defines the transform (view x projection) matrix to use
  2978. * @returns the new Vector3
  2979. */
  2980. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2981. /**
  2982. * Unproject from screen space to object space
  2983. * @param source defines the screen space Vector3 to use
  2984. * @param viewportWidth defines the current width of the viewport
  2985. * @param viewportHeight defines the current height of the viewport
  2986. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2987. * @param view defines the view matrix to use
  2988. * @param projection defines the projection matrix to use
  2989. * @returns the new Vector3
  2990. */
  2991. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2992. /**
  2993. * Unproject from screen space to object space
  2994. * @param source defines the screen space Vector3 to use
  2995. * @param viewportWidth defines the current width of the viewport
  2996. * @param viewportHeight defines the current height of the viewport
  2997. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2998. * @param view defines the view matrix to use
  2999. * @param projection defines the projection matrix to use
  3000. * @param result defines the Vector3 where to store the result
  3001. */
  3002. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3003. /**
  3004. * Unproject from screen space to object space
  3005. * @param sourceX defines the screen space x coordinate to use
  3006. * @param sourceY defines the screen space y coordinate to use
  3007. * @param sourceZ defines the screen space z coordinate to use
  3008. * @param viewportWidth defines the current width of the viewport
  3009. * @param viewportHeight defines the current height of the viewport
  3010. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3011. * @param view defines the view matrix to use
  3012. * @param projection defines the projection matrix to use
  3013. * @param result defines the Vector3 where to store the result
  3014. */
  3015. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3016. /**
  3017. * Gets the minimal 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 Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3023. /**
  3024. * Gets the maximal coordinate values between two Vector3
  3025. * @param left defines the first operand
  3026. * @param right defines the second operand
  3027. * @returns the new Vector3
  3028. */
  3029. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3030. /**
  3031. * Returns the distance between the vectors "value1" and "value2"
  3032. * @param value1 defines the first operand
  3033. * @param value2 defines the second operand
  3034. * @returns the distance
  3035. */
  3036. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3037. /**
  3038. * Returns the squared distance between the vectors "value1" and "value2"
  3039. * @param value1 defines the first operand
  3040. * @param value2 defines the second operand
  3041. * @returns the squared distance
  3042. */
  3043. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3044. /**
  3045. * Returns a new Vector3 located at the center between "value1" and "value2"
  3046. * @param value1 defines the first operand
  3047. * @param value2 defines the second operand
  3048. * @returns the new Vector3
  3049. */
  3050. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3051. /**
  3052. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3053. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3054. * to something in order to rotate it from its local system to the given target system
  3055. * Note: axis1, axis2 and axis3 are normalized during this operation
  3056. * @param axis1 defines the first axis
  3057. * @param axis2 defines the second axis
  3058. * @param axis3 defines the third axis
  3059. * @returns a new Vector3
  3060. */
  3061. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3062. /**
  3063. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3064. * @param axis1 defines the first axis
  3065. * @param axis2 defines the second axis
  3066. * @param axis3 defines the third axis
  3067. * @param ref defines the Vector3 where to store the result
  3068. */
  3069. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3070. }
  3071. /**
  3072. * Vector4 class created for EulerAngle class conversion to Quaternion
  3073. */
  3074. export class Vector4 {
  3075. /** x value of the vector */
  3076. x: number;
  3077. /** y value of the vector */
  3078. y: number;
  3079. /** z value of the vector */
  3080. z: number;
  3081. /** w value of the vector */
  3082. w: number;
  3083. /**
  3084. * Creates a Vector4 object from the given floats.
  3085. * @param x x value of the vector
  3086. * @param y y value of the vector
  3087. * @param z z value of the vector
  3088. * @param w w value of the vector
  3089. */
  3090. constructor(
  3091. /** x value of the vector */
  3092. x: number,
  3093. /** y value of the vector */
  3094. y: number,
  3095. /** z value of the vector */
  3096. z: number,
  3097. /** w value of the vector */
  3098. w: number);
  3099. /**
  3100. * Returns the string with the Vector4 coordinates.
  3101. * @returns a string containing all the vector values
  3102. */
  3103. toString(): string;
  3104. /**
  3105. * Returns the string "Vector4".
  3106. * @returns "Vector4"
  3107. */
  3108. getClassName(): string;
  3109. /**
  3110. * Returns the Vector4 hash code.
  3111. * @returns a unique hash code
  3112. */
  3113. getHashCode(): number;
  3114. /**
  3115. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3116. * @returns the resulting array
  3117. */
  3118. asArray(): number[];
  3119. /**
  3120. * Populates the given array from the given index with the Vector4 coordinates.
  3121. * @param array array to populate
  3122. * @param index index of the array to start at (default: 0)
  3123. * @returns the Vector4.
  3124. */
  3125. toArray(array: FloatArray, index?: number): Vector4;
  3126. /**
  3127. * Adds the given vector to the current Vector4.
  3128. * @param otherVector the vector to add
  3129. * @returns the updated Vector4.
  3130. */
  3131. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3132. /**
  3133. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3134. * @param otherVector the vector to add
  3135. * @returns the resulting vector
  3136. */
  3137. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3138. /**
  3139. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3140. * @param otherVector the vector to add
  3141. * @param result the vector to store the result
  3142. * @returns the current Vector4.
  3143. */
  3144. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3145. /**
  3146. * Subtract in place the given vector from the current Vector4.
  3147. * @param otherVector the vector to subtract
  3148. * @returns the updated Vector4.
  3149. */
  3150. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3151. /**
  3152. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3153. * @param otherVector the vector to add
  3154. * @returns the new vector with the result
  3155. */
  3156. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3157. /**
  3158. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3159. * @param otherVector the vector to subtract
  3160. * @param result the vector to store the result
  3161. * @returns the current Vector4.
  3162. */
  3163. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3164. /**
  3165. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3166. */
  3167. /**
  3168. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3169. * @param x value to subtract
  3170. * @param y value to subtract
  3171. * @param z value to subtract
  3172. * @param w value to subtract
  3173. * @returns new vector containing the result
  3174. */
  3175. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3176. /**
  3177. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3178. * @param x value to subtract
  3179. * @param y value to subtract
  3180. * @param z value to subtract
  3181. * @param w value to subtract
  3182. * @param result the vector to store the result in
  3183. * @returns the current Vector4.
  3184. */
  3185. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3186. /**
  3187. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3188. * @returns a new vector with the negated values
  3189. */
  3190. negate(): Vector4;
  3191. /**
  3192. * Negate this vector in place
  3193. * @returns this
  3194. */
  3195. negateInPlace(): Vector4;
  3196. /**
  3197. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3198. * @param result defines the Vector3 object where to store the result
  3199. * @returns the current Vector4
  3200. */
  3201. negateToRef(result: Vector4): Vector4;
  3202. /**
  3203. * Multiplies the current Vector4 coordinates by scale (float).
  3204. * @param scale the number to scale with
  3205. * @returns the updated Vector4.
  3206. */
  3207. scaleInPlace(scale: number): Vector4;
  3208. /**
  3209. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3210. * @param scale the number to scale with
  3211. * @returns a new vector with the result
  3212. */
  3213. scale(scale: number): Vector4;
  3214. /**
  3215. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3216. * @param scale the number to scale with
  3217. * @param result a vector to store the result in
  3218. * @returns the current Vector4.
  3219. */
  3220. scaleToRef(scale: number, result: Vector4): Vector4;
  3221. /**
  3222. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3223. * @param scale defines the scale factor
  3224. * @param result defines the Vector4 object where to store the result
  3225. * @returns the unmodified current Vector4
  3226. */
  3227. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3228. /**
  3229. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3230. * @param otherVector the vector to compare against
  3231. * @returns true if they are equal
  3232. */
  3233. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3234. /**
  3235. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3236. * @param otherVector vector to compare against
  3237. * @param epsilon (Default: very small number)
  3238. * @returns true if they are equal
  3239. */
  3240. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3241. /**
  3242. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3243. * @param x x value to compare against
  3244. * @param y y value to compare against
  3245. * @param z z value to compare against
  3246. * @param w w value to compare against
  3247. * @returns true if equal
  3248. */
  3249. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3250. /**
  3251. * Multiplies in place the current Vector4 by the given one.
  3252. * @param otherVector vector to multiple with
  3253. * @returns the updated Vector4.
  3254. */
  3255. multiplyInPlace(otherVector: Vector4): Vector4;
  3256. /**
  3257. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3258. * @param otherVector vector to multiple with
  3259. * @returns resulting new vector
  3260. */
  3261. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3262. /**
  3263. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3264. * @param otherVector vector to multiple with
  3265. * @param result vector to store the result
  3266. * @returns the current Vector4.
  3267. */
  3268. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3269. /**
  3270. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3271. * @param x x value multiply with
  3272. * @param y y value multiply with
  3273. * @param z z value multiply with
  3274. * @param w w value multiply with
  3275. * @returns resulting new vector
  3276. */
  3277. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3278. /**
  3279. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3280. * @param otherVector vector to devide with
  3281. * @returns resulting new vector
  3282. */
  3283. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3284. /**
  3285. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3286. * @param otherVector vector to devide with
  3287. * @param result vector to store the result
  3288. * @returns the current Vector4.
  3289. */
  3290. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3291. /**
  3292. * Divides the current Vector3 coordinates by the given ones.
  3293. * @param otherVector vector to devide with
  3294. * @returns the updated Vector3.
  3295. */
  3296. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3297. /**
  3298. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3299. * @param other defines the second operand
  3300. * @returns the current updated Vector4
  3301. */
  3302. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3303. /**
  3304. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3305. * @param other defines the second operand
  3306. * @returns the current updated Vector4
  3307. */
  3308. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3309. /**
  3310. * Gets a new Vector4 from current Vector4 floored values
  3311. * @returns a new Vector4
  3312. */
  3313. floor(): Vector4;
  3314. /**
  3315. * Gets a new Vector4 from current Vector3 floored values
  3316. * @returns a new Vector4
  3317. */
  3318. fract(): Vector4;
  3319. /**
  3320. * Returns the Vector4 length (float).
  3321. * @returns the length
  3322. */
  3323. length(): number;
  3324. /**
  3325. * Returns the Vector4 squared length (float).
  3326. * @returns the length squared
  3327. */
  3328. lengthSquared(): number;
  3329. /**
  3330. * Normalizes in place the Vector4.
  3331. * @returns the updated Vector4.
  3332. */
  3333. normalize(): Vector4;
  3334. /**
  3335. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3336. * @returns this converted to a new vector3
  3337. */
  3338. toVector3(): Vector3;
  3339. /**
  3340. * Returns a new Vector4 copied from the current one.
  3341. * @returns the new cloned vector
  3342. */
  3343. clone(): Vector4;
  3344. /**
  3345. * Updates the current Vector4 with the given one coordinates.
  3346. * @param source the source vector to copy from
  3347. * @returns the updated Vector4.
  3348. */
  3349. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3350. /**
  3351. * Updates the current Vector4 coordinates with the given floats.
  3352. * @param x float to copy from
  3353. * @param y float to copy from
  3354. * @param z float to copy from
  3355. * @param w float to copy from
  3356. * @returns the updated Vector4.
  3357. */
  3358. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3359. /**
  3360. * Updates the current Vector4 coordinates with the given floats.
  3361. * @param x float to set from
  3362. * @param y float to set from
  3363. * @param z float to set from
  3364. * @param w float to set from
  3365. * @returns the updated Vector4.
  3366. */
  3367. set(x: number, y: number, z: number, w: number): Vector4;
  3368. /**
  3369. * Copies the given float to the current Vector3 coordinates
  3370. * @param v defines the x, y, z and w coordinates of the operand
  3371. * @returns the current updated Vector3
  3372. */
  3373. setAll(v: number): Vector4;
  3374. /**
  3375. * Returns a new Vector4 set 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. * @returns the new vector
  3379. */
  3380. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3381. /**
  3382. * Updates the given vector "result" from the starting index of the given array.
  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 FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3388. /**
  3389. * Updates the given vector "result" from the starting index of the given Float32Array.
  3390. * @param array the array to pull values from
  3391. * @param offset the offset into the array to start at
  3392. * @param result the vector to store the result in
  3393. */
  3394. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3395. /**
  3396. * Updates the given vector "result" coordinates from the given floats.
  3397. * @param x float to set from
  3398. * @param y float to set from
  3399. * @param z float to set from
  3400. * @param w float to set from
  3401. * @param result the vector to the floats in
  3402. */
  3403. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3404. /**
  3405. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3406. * @returns the new vector
  3407. */
  3408. static Zero(): Vector4;
  3409. /**
  3410. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3411. * @returns the new vector
  3412. */
  3413. static One(): Vector4;
  3414. /**
  3415. * Returns a new normalized Vector4 from the given one.
  3416. * @param vector the vector to normalize
  3417. * @returns the vector
  3418. */
  3419. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3420. /**
  3421. * Updates the given vector "result" from the normalization of the given one.
  3422. * @param vector the vector to normalize
  3423. * @param result the vector to store the result in
  3424. */
  3425. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3426. /**
  3427. * Returns a vector with the minimum values from the left and right vectors
  3428. * @param left left vector to minimize
  3429. * @param right right vector to minimize
  3430. * @returns a new vector with the minimum of the left and right vector values
  3431. */
  3432. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3433. /**
  3434. * Returns a vector with the maximum values from the left and right vectors
  3435. * @param left left vector to maximize
  3436. * @param right right vector to maximize
  3437. * @returns a new vector with the maximum of the left and right vector values
  3438. */
  3439. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3440. /**
  3441. * Returns the 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
  3445. */
  3446. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3447. /**
  3448. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3449. * @param value1 value to calulate the distance between
  3450. * @param value2 value to calulate the distance between
  3451. * @return the distance between the two vectors squared
  3452. */
  3453. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3454. /**
  3455. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3456. * @param value1 value to calulate the center between
  3457. * @param value2 value to calulate the center between
  3458. * @return the center between the two vectors
  3459. */
  3460. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3461. /**
  3462. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3463. * This methods computes transformed normalized direction vectors only.
  3464. * @param vector the vector to transform
  3465. * @param transformation the transformation matrix to apply
  3466. * @returns the new vector
  3467. */
  3468. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3469. /**
  3470. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3471. * This methods computes transformed normalized direction vectors only.
  3472. * @param vector the vector to transform
  3473. * @param transformation the transformation matrix to apply
  3474. * @param result the vector to store the result in
  3475. */
  3476. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3477. /**
  3478. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3479. * This methods computes transformed normalized direction vectors only.
  3480. * @param x value to transform
  3481. * @param y value to transform
  3482. * @param z value to transform
  3483. * @param w value to transform
  3484. * @param transformation the transformation matrix to apply
  3485. * @param result the vector to store the results in
  3486. */
  3487. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3488. /**
  3489. * Creates a new Vector4 from a Vector3
  3490. * @param source defines the source data
  3491. * @param w defines the 4th component (default is 0)
  3492. * @returns a new Vector4
  3493. */
  3494. static FromVector3(source: Vector3, w?: number): Vector4;
  3495. }
  3496. /**
  3497. * Class used to store quaternion data
  3498. * @see https://en.wikipedia.org/wiki/Quaternion
  3499. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3500. */
  3501. export class Quaternion {
  3502. /** defines the first component (0 by default) */
  3503. x: number;
  3504. /** defines the second component (0 by default) */
  3505. y: number;
  3506. /** defines the third component (0 by default) */
  3507. z: number;
  3508. /** defines the fourth component (1.0 by default) */
  3509. w: number;
  3510. /**
  3511. * Creates a new Quaternion from the given floats
  3512. * @param x defines the first component (0 by default)
  3513. * @param y defines the second component (0 by default)
  3514. * @param z defines the third component (0 by default)
  3515. * @param w defines the fourth component (1.0 by default)
  3516. */
  3517. constructor(
  3518. /** defines the first component (0 by default) */
  3519. x?: number,
  3520. /** defines the second component (0 by default) */
  3521. y?: number,
  3522. /** defines the third component (0 by default) */
  3523. z?: number,
  3524. /** defines the fourth component (1.0 by default) */
  3525. w?: number);
  3526. /**
  3527. * Gets a string representation for the current quaternion
  3528. * @returns a string with the Quaternion coordinates
  3529. */
  3530. toString(): string;
  3531. /**
  3532. * Gets the class name of the quaternion
  3533. * @returns the string "Quaternion"
  3534. */
  3535. getClassName(): string;
  3536. /**
  3537. * Gets a hash code for this quaternion
  3538. * @returns the quaternion hash code
  3539. */
  3540. getHashCode(): number;
  3541. /**
  3542. * Copy the quaternion to an array
  3543. * @returns a new array populated with 4 elements from the quaternion coordinates
  3544. */
  3545. asArray(): number[];
  3546. /**
  3547. * Check if two quaternions are equals
  3548. * @param otherQuaternion defines the second operand
  3549. * @return true if the current quaternion and the given one coordinates are strictly equals
  3550. */
  3551. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3552. /**
  3553. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3554. * @param otherQuaternion defines the other quaternion
  3555. * @param epsilon defines the minimal distance to consider equality
  3556. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3557. */
  3558. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3559. /**
  3560. * Clone the current quaternion
  3561. * @returns a new quaternion copied from the current one
  3562. */
  3563. clone(): Quaternion;
  3564. /**
  3565. * Copy a quaternion to the current one
  3566. * @param other defines the other quaternion
  3567. * @returns the updated current quaternion
  3568. */
  3569. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3570. /**
  3571. * Updates the current quaternion with the given float coordinates
  3572. * @param x defines the x coordinate
  3573. * @param y defines the y coordinate
  3574. * @param z defines the z coordinate
  3575. * @param w defines the w coordinate
  3576. * @returns the updated current quaternion
  3577. */
  3578. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3579. /**
  3580. * Updates the current quaternion from the given float coordinates
  3581. * @param x defines the x coordinate
  3582. * @param y defines the y coordinate
  3583. * @param z defines the z coordinate
  3584. * @param w defines the w coordinate
  3585. * @returns the updated current quaternion
  3586. */
  3587. set(x: number, y: number, z: number, w: number): Quaternion;
  3588. /**
  3589. * Adds two quaternions
  3590. * @param other defines the second operand
  3591. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3592. */
  3593. add(other: DeepImmutable<Quaternion>): Quaternion;
  3594. /**
  3595. * Add a quaternion to the current one
  3596. * @param other defines the quaternion to add
  3597. * @returns the current quaternion
  3598. */
  3599. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3600. /**
  3601. * Subtract two quaternions
  3602. * @param other defines the second operand
  3603. * @returns a new quaternion as the subtraction result of the given one from the current one
  3604. */
  3605. subtract(other: Quaternion): Quaternion;
  3606. /**
  3607. * Multiplies the current quaternion by a scale factor
  3608. * @param value defines the scale factor
  3609. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3610. */
  3611. scale(value: number): Quaternion;
  3612. /**
  3613. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3614. * @param scale defines the scale factor
  3615. * @param result defines the Quaternion object where to store the result
  3616. * @returns the unmodified current quaternion
  3617. */
  3618. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3619. /**
  3620. * Multiplies in place the current quaternion by a scale factor
  3621. * @param value defines the scale factor
  3622. * @returns the current modified quaternion
  3623. */
  3624. scaleInPlace(value: number): Quaternion;
  3625. /**
  3626. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3627. * @param scale defines the scale factor
  3628. * @param result defines the Quaternion object where to store the result
  3629. * @returns the unmodified current quaternion
  3630. */
  3631. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3632. /**
  3633. * Multiplies two quaternions
  3634. * @param q1 defines the second operand
  3635. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3636. */
  3637. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3638. /**
  3639. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3640. * @param q1 defines the second operand
  3641. * @param result defines the target quaternion
  3642. * @returns the current quaternion
  3643. */
  3644. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3645. /**
  3646. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3647. * @param q1 defines the second operand
  3648. * @returns the currentupdated quaternion
  3649. */
  3650. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3651. /**
  3652. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3653. * @param ref defines the target quaternion
  3654. * @returns the current quaternion
  3655. */
  3656. conjugateToRef(ref: Quaternion): Quaternion;
  3657. /**
  3658. * Conjugates in place (1-q) the current quaternion
  3659. * @returns the current updated quaternion
  3660. */
  3661. conjugateInPlace(): Quaternion;
  3662. /**
  3663. * Conjugates in place (1-q) the current quaternion
  3664. * @returns a new quaternion
  3665. */
  3666. conjugate(): Quaternion;
  3667. /**
  3668. * Gets length of current quaternion
  3669. * @returns the quaternion length (float)
  3670. */
  3671. length(): number;
  3672. /**
  3673. * Normalize in place the current quaternion
  3674. * @returns the current updated quaternion
  3675. */
  3676. normalize(): Quaternion;
  3677. /**
  3678. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3679. * @param order is a reserved parameter and is ignore for now
  3680. * @returns a new Vector3 containing the Euler angles
  3681. */
  3682. toEulerAngles(order?: string): Vector3;
  3683. /**
  3684. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3685. * @param result defines the vector which will be filled with the Euler angles
  3686. * @param order is a reserved parameter and is ignore for now
  3687. * @returns the current unchanged quaternion
  3688. */
  3689. toEulerAnglesToRef(result: Vector3): Quaternion;
  3690. /**
  3691. * Updates the given rotation matrix with the current quaternion values
  3692. * @param result defines the target matrix
  3693. * @returns the current unchanged quaternion
  3694. */
  3695. toRotationMatrix(result: Matrix): Quaternion;
  3696. /**
  3697. * Updates the current quaternion from the given rotation matrix values
  3698. * @param matrix defines the source matrix
  3699. * @returns the current updated quaternion
  3700. */
  3701. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3702. /**
  3703. * Creates a new quaternion from a rotation matrix
  3704. * @param matrix defines the source matrix
  3705. * @returns a new quaternion created from the given rotation matrix values
  3706. */
  3707. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3708. /**
  3709. * Updates the given quaternion with the given rotation matrix values
  3710. * @param matrix defines the source matrix
  3711. * @param result defines the target quaternion
  3712. */
  3713. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3714. /**
  3715. * Returns the dot product (float) between the quaternions "left" and "right"
  3716. * @param left defines the left operand
  3717. * @param right defines the right operand
  3718. * @returns the dot product
  3719. */
  3720. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3721. /**
  3722. * Checks if the two quaternions are close to each other
  3723. * @param quat0 defines the first quaternion to check
  3724. * @param quat1 defines the second quaternion to check
  3725. * @returns true if the two quaternions are close to each other
  3726. */
  3727. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3728. /**
  3729. * Creates an empty quaternion
  3730. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3731. */
  3732. static Zero(): Quaternion;
  3733. /**
  3734. * Inverse a given quaternion
  3735. * @param q defines the source quaternion
  3736. * @returns a new quaternion as the inverted current quaternion
  3737. */
  3738. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3739. /**
  3740. * Inverse a given quaternion
  3741. * @param q defines the source quaternion
  3742. * @param result the quaternion the result will be stored in
  3743. * @returns the result quaternion
  3744. */
  3745. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3746. /**
  3747. * Creates an identity quaternion
  3748. * @returns the identity quaternion
  3749. */
  3750. static Identity(): Quaternion;
  3751. /**
  3752. * Gets a boolean indicating if the given quaternion is identity
  3753. * @param quaternion defines the quaternion to check
  3754. * @returns true if the quaternion is identity
  3755. */
  3756. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3757. /**
  3758. * Creates a quaternion from a rotation around an axis
  3759. * @param axis defines the axis to use
  3760. * @param angle defines the angle to use
  3761. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3762. */
  3763. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3764. /**
  3765. * Creates a rotation around an axis and stores it into the given quaternion
  3766. * @param axis defines the axis to use
  3767. * @param angle defines the angle to use
  3768. * @param result defines the target quaternion
  3769. * @returns the target quaternion
  3770. */
  3771. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3772. /**
  3773. * Creates a new quaternion from data stored into an array
  3774. * @param array defines the data source
  3775. * @param offset defines the offset in the source array where the data starts
  3776. * @returns a new quaternion
  3777. */
  3778. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  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. * @returns a string containing the hexadecimal representation of the Color4 object
  5816. */
  5817. toHexString(): string;
  5818. /**
  5819. * Computes a new Color4 converted from the current one to linear space
  5820. * @returns a new Color4 object
  5821. */
  5822. toLinearSpace(): Color4;
  5823. /**
  5824. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5825. * @param convertedColor defines the Color4 object where to store the linear space version
  5826. * @returns the unmodified Color4
  5827. */
  5828. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5829. /**
  5830. * Computes a new Color4 converted from the current one to gamma space
  5831. * @returns a new Color4 object
  5832. */
  5833. toGammaSpace(): Color4;
  5834. /**
  5835. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5836. * @param convertedColor defines the Color4 object where to store the gamma space version
  5837. * @returns the unmodified Color4
  5838. */
  5839. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5840. /**
  5841. * Creates a new Color4 from the string containing valid hexadecimal values
  5842. * @param hex defines a string containing valid hexadecimal values
  5843. * @returns a new Color4 object
  5844. */
  5845. static FromHexString(hex: string): Color4;
  5846. /**
  5847. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5848. * @param left defines the start value
  5849. * @param right defines the end value
  5850. * @param amount defines the gradient factor
  5851. * @returns a new Color4 object
  5852. */
  5853. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5854. /**
  5855. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5856. * @param left defines the start value
  5857. * @param right defines the end value
  5858. * @param amount defines the gradient factor
  5859. * @param result defines the Color4 object where to store data
  5860. */
  5861. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5862. /**
  5863. * Creates a new Color4 from a Color3 and an alpha value
  5864. * @param color3 defines the source Color3 to read from
  5865. * @param alpha defines the alpha component (1.0 by default)
  5866. * @returns a new Color4 object
  5867. */
  5868. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5869. /**
  5870. * Creates a new Color4 from the starting index element of the given array
  5871. * @param array defines the source array to read from
  5872. * @param offset defines the offset in the source array
  5873. * @returns a new Color4 object
  5874. */
  5875. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5876. /**
  5877. * Creates a new Color3 from integer values (< 256)
  5878. * @param r defines the red component to read from (value between 0 and 255)
  5879. * @param g defines the green component to read from (value between 0 and 255)
  5880. * @param b defines the blue component to read from (value between 0 and 255)
  5881. * @param a defines the alpha component to read from (value between 0 and 255)
  5882. * @returns a new Color3 object
  5883. */
  5884. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5885. /**
  5886. * Check the content of a given array and convert it to an array containing RGBA data
  5887. * If the original array was already containing count * 4 values then it is returned directly
  5888. * @param colors defines the array to check
  5889. * @param count defines the number of RGBA data to expect
  5890. * @returns an array containing count * 4 values (RGBA)
  5891. */
  5892. static CheckColors4(colors: number[], count: number): number[];
  5893. }
  5894. /**
  5895. * @hidden
  5896. */
  5897. export class TmpColors {
  5898. static Color3: Color3[];
  5899. static Color4: Color4[];
  5900. }
  5901. }
  5902. declare module "babylonjs/Animations/animationKey" {
  5903. /**
  5904. * Defines an interface which represents an animation key frame
  5905. */
  5906. export interface IAnimationKey {
  5907. /**
  5908. * Frame of the key frame
  5909. */
  5910. frame: number;
  5911. /**
  5912. * Value at the specifies key frame
  5913. */
  5914. value: any;
  5915. /**
  5916. * The input tangent for the cubic hermite spline
  5917. */
  5918. inTangent?: any;
  5919. /**
  5920. * The output tangent for the cubic hermite spline
  5921. */
  5922. outTangent?: any;
  5923. /**
  5924. * The animation interpolation type
  5925. */
  5926. interpolation?: AnimationKeyInterpolation;
  5927. }
  5928. /**
  5929. * Enum for the animation key frame interpolation type
  5930. */
  5931. export enum AnimationKeyInterpolation {
  5932. /**
  5933. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5934. */
  5935. STEP = 1
  5936. }
  5937. }
  5938. declare module "babylonjs/Animations/animationRange" {
  5939. /**
  5940. * Represents the range of an animation
  5941. */
  5942. export class AnimationRange {
  5943. /**The name of the animation range**/
  5944. name: string;
  5945. /**The starting frame of the animation */
  5946. from: number;
  5947. /**The ending frame of the animation*/
  5948. to: number;
  5949. /**
  5950. * Initializes the range of an animation
  5951. * @param name The name of the animation range
  5952. * @param from The starting frame of the animation
  5953. * @param to The ending frame of the animation
  5954. */
  5955. constructor(
  5956. /**The name of the animation range**/
  5957. name: string,
  5958. /**The starting frame of the animation */
  5959. from: number,
  5960. /**The ending frame of the animation*/
  5961. to: number);
  5962. /**
  5963. * Makes a copy of the animation range
  5964. * @returns A copy of the animation range
  5965. */
  5966. clone(): AnimationRange;
  5967. }
  5968. }
  5969. declare module "babylonjs/Animations/animationEvent" {
  5970. /**
  5971. * Composed of a frame, and an action function
  5972. */
  5973. export class AnimationEvent {
  5974. /** The frame for which the event is triggered **/
  5975. frame: number;
  5976. /** The event to perform when triggered **/
  5977. action: (currentFrame: number) => void;
  5978. /** Specifies if the event should be triggered only once**/
  5979. onlyOnce?: boolean | undefined;
  5980. /**
  5981. * Specifies if the animation event is done
  5982. */
  5983. isDone: boolean;
  5984. /**
  5985. * Initializes the animation event
  5986. * @param frame The frame for which the event is triggered
  5987. * @param action The event to perform when triggered
  5988. * @param onlyOnce Specifies if the event should be triggered only once
  5989. */
  5990. constructor(
  5991. /** The frame for which the event is triggered **/
  5992. frame: number,
  5993. /** The event to perform when triggered **/
  5994. action: (currentFrame: number) => void,
  5995. /** Specifies if the event should be triggered only once**/
  5996. onlyOnce?: boolean | undefined);
  5997. /** @hidden */
  5998. _clone(): AnimationEvent;
  5999. }
  6000. }
  6001. declare module "babylonjs/Behaviors/behavior" {
  6002. import { Nullable } from "babylonjs/types";
  6003. /**
  6004. * Interface used to define a behavior
  6005. */
  6006. export interface Behavior<T> {
  6007. /** gets or sets behavior's name */
  6008. name: string;
  6009. /**
  6010. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6011. */
  6012. init(): void;
  6013. /**
  6014. * Called when the behavior is attached to a target
  6015. * @param target defines the target where the behavior is attached to
  6016. */
  6017. attach(target: T): void;
  6018. /**
  6019. * Called when the behavior is detached from its target
  6020. */
  6021. detach(): void;
  6022. }
  6023. /**
  6024. * Interface implemented by classes supporting behaviors
  6025. */
  6026. export interface IBehaviorAware<T> {
  6027. /**
  6028. * Attach a behavior
  6029. * @param behavior defines the behavior to attach
  6030. * @returns the current host
  6031. */
  6032. addBehavior(behavior: Behavior<T>): T;
  6033. /**
  6034. * Remove a behavior from the current object
  6035. * @param behavior defines the behavior to detach
  6036. * @returns the current host
  6037. */
  6038. removeBehavior(behavior: Behavior<T>): T;
  6039. /**
  6040. * Gets a behavior using its name to search
  6041. * @param name defines the name to search
  6042. * @returns the behavior or null if not found
  6043. */
  6044. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6045. }
  6046. }
  6047. declare module "babylonjs/Misc/smartArray" {
  6048. /**
  6049. * Defines an array and its length.
  6050. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6051. */
  6052. export interface ISmartArrayLike<T> {
  6053. /**
  6054. * The data of the array.
  6055. */
  6056. data: Array<T>;
  6057. /**
  6058. * The active length of the array.
  6059. */
  6060. length: number;
  6061. }
  6062. /**
  6063. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6064. */
  6065. export class SmartArray<T> implements ISmartArrayLike<T> {
  6066. /**
  6067. * The full set of data from the array.
  6068. */
  6069. data: Array<T>;
  6070. /**
  6071. * The active length of the array.
  6072. */
  6073. length: number;
  6074. protected _id: number;
  6075. /**
  6076. * Instantiates a Smart Array.
  6077. * @param capacity defines the default capacity of the array.
  6078. */
  6079. constructor(capacity: number);
  6080. /**
  6081. * Pushes a value at the end of the active data.
  6082. * @param value defines the object to push in the array.
  6083. */
  6084. push(value: T): void;
  6085. /**
  6086. * Iterates over the active data and apply the lambda to them.
  6087. * @param func defines the action to apply on each value.
  6088. */
  6089. forEach(func: (content: T) => void): void;
  6090. /**
  6091. * Sorts the full sets of data.
  6092. * @param compareFn defines the comparison function to apply.
  6093. */
  6094. sort(compareFn: (a: T, b: T) => number): void;
  6095. /**
  6096. * Resets the active data to an empty array.
  6097. */
  6098. reset(): void;
  6099. /**
  6100. * Releases all the data from the array as well as the array.
  6101. */
  6102. dispose(): void;
  6103. /**
  6104. * Concats the active data with a given array.
  6105. * @param array defines the data to concatenate with.
  6106. */
  6107. concat(array: any): void;
  6108. /**
  6109. * Returns the position of a value in the active data.
  6110. * @param value defines the value to find the index for
  6111. * @returns the index if found in the active data otherwise -1
  6112. */
  6113. indexOf(value: T): number;
  6114. /**
  6115. * Returns whether an element is part of the active data.
  6116. * @param value defines the value to look for
  6117. * @returns true if found in the active data otherwise false
  6118. */
  6119. contains(value: T): boolean;
  6120. private static _GlobalId;
  6121. }
  6122. /**
  6123. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6124. * The data in this array can only be present once
  6125. */
  6126. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6127. private _duplicateId;
  6128. /**
  6129. * Pushes a value at the end of the active data.
  6130. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6131. * @param value defines the object to push in the array.
  6132. */
  6133. push(value: T): void;
  6134. /**
  6135. * Pushes a value at the end of the active data.
  6136. * If the data is already present, it won t be added again
  6137. * @param value defines the object to push in the array.
  6138. * @returns true if added false if it was already present
  6139. */
  6140. pushNoDuplicate(value: T): boolean;
  6141. /**
  6142. * Resets the active data to an empty array.
  6143. */
  6144. reset(): void;
  6145. /**
  6146. * Concats the active data with a given array.
  6147. * This ensures no dupplicate will be present in the result.
  6148. * @param array defines the data to concatenate with.
  6149. */
  6150. concatWithNoDuplicate(array: any): void;
  6151. }
  6152. }
  6153. declare module "babylonjs/Cameras/cameraInputsManager" {
  6154. import { Nullable } from "babylonjs/types";
  6155. import { Camera } from "babylonjs/Cameras/camera";
  6156. /**
  6157. * @ignore
  6158. * This is a list of all the different input types that are available in the application.
  6159. * Fo instance: ArcRotateCameraGamepadInput...
  6160. */
  6161. export var CameraInputTypes: {};
  6162. /**
  6163. * This is the contract to implement in order to create a new input class.
  6164. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6165. */
  6166. export interface ICameraInput<TCamera extends Camera> {
  6167. /**
  6168. * Defines the camera the input is attached to.
  6169. */
  6170. camera: Nullable<TCamera>;
  6171. /**
  6172. * Gets the class name of the current intput.
  6173. * @returns the class name
  6174. */
  6175. getClassName(): string;
  6176. /**
  6177. * Get the friendly name associated with the input class.
  6178. * @returns the input friendly name
  6179. */
  6180. getSimpleName(): string;
  6181. /**
  6182. * Attach the input controls to a specific dom element to get the input from.
  6183. * @param element Defines the element the controls should be listened from
  6184. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6185. */
  6186. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6187. /**
  6188. * Detach the current controls from the specified dom element.
  6189. * @param element Defines the element to stop listening the inputs from
  6190. */
  6191. detachControl(element: Nullable<HTMLElement>): void;
  6192. /**
  6193. * Update the current camera state depending on the inputs that have been used this frame.
  6194. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6195. */
  6196. checkInputs?: () => void;
  6197. }
  6198. /**
  6199. * Represents a map of input types to input instance or input index to input instance.
  6200. */
  6201. export interface CameraInputsMap<TCamera extends Camera> {
  6202. /**
  6203. * Accessor to the input by input type.
  6204. */
  6205. [name: string]: ICameraInput<TCamera>;
  6206. /**
  6207. * Accessor to the input by input index.
  6208. */
  6209. [idx: number]: ICameraInput<TCamera>;
  6210. }
  6211. /**
  6212. * This represents the input manager used within a camera.
  6213. * It helps dealing with all the different kind of input attached to a camera.
  6214. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6215. */
  6216. export class CameraInputsManager<TCamera extends Camera> {
  6217. /**
  6218. * Defines the list of inputs attahed to the camera.
  6219. */
  6220. attached: CameraInputsMap<TCamera>;
  6221. /**
  6222. * Defines the dom element the camera is collecting inputs from.
  6223. * This is null if the controls have not been attached.
  6224. */
  6225. attachedElement: Nullable<HTMLElement>;
  6226. /**
  6227. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6228. */
  6229. noPreventDefault: boolean;
  6230. /**
  6231. * Defined the camera the input manager belongs to.
  6232. */
  6233. camera: TCamera;
  6234. /**
  6235. * Update the current camera state depending on the inputs that have been used this frame.
  6236. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6237. */
  6238. checkInputs: () => void;
  6239. /**
  6240. * Instantiate a new Camera Input Manager.
  6241. * @param camera Defines the camera the input manager blongs to
  6242. */
  6243. constructor(camera: TCamera);
  6244. /**
  6245. * Add an input method to a camera
  6246. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6247. * @param input camera input method
  6248. */
  6249. add(input: ICameraInput<TCamera>): void;
  6250. /**
  6251. * Remove a specific input method from a camera
  6252. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6253. * @param inputToRemove camera input method
  6254. */
  6255. remove(inputToRemove: ICameraInput<TCamera>): void;
  6256. /**
  6257. * Remove a specific input type from a camera
  6258. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6259. * @param inputType the type of the input to remove
  6260. */
  6261. removeByType(inputType: string): void;
  6262. private _addCheckInputs;
  6263. /**
  6264. * Attach the input controls to the currently attached dom element to listen the events from.
  6265. * @param input Defines the input to attach
  6266. */
  6267. attachInput(input: ICameraInput<TCamera>): void;
  6268. /**
  6269. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6270. * @param element Defines the dom element to collect the events from
  6271. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6272. */
  6273. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6274. /**
  6275. * Detach the current manager inputs controls from a specific dom element.
  6276. * @param element Defines the dom element to collect the events from
  6277. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6278. */
  6279. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6280. /**
  6281. * Rebuild the dynamic inputCheck function from the current list of
  6282. * defined inputs in the manager.
  6283. */
  6284. rebuildInputCheck(): void;
  6285. /**
  6286. * Remove all attached input methods from a camera
  6287. */
  6288. clear(): void;
  6289. /**
  6290. * Serialize the current input manager attached to a camera.
  6291. * This ensures than once parsed,
  6292. * the input associated to the camera will be identical to the current ones
  6293. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6294. */
  6295. serialize(serializedCamera: any): void;
  6296. /**
  6297. * Parses an input manager serialized JSON to restore the previous list of inputs
  6298. * and states associated to a camera.
  6299. * @param parsedCamera Defines the JSON to parse
  6300. */
  6301. parse(parsedCamera: any): void;
  6302. }
  6303. }
  6304. declare module "babylonjs/Meshes/buffer" {
  6305. import { Nullable, DataArray } from "babylonjs/types";
  6306. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6307. /**
  6308. * Class used to store data that will be store in GPU memory
  6309. */
  6310. export class Buffer {
  6311. private _engine;
  6312. private _buffer;
  6313. /** @hidden */
  6314. _data: Nullable<DataArray>;
  6315. private _updatable;
  6316. private _instanced;
  6317. private _divisor;
  6318. /**
  6319. * Gets the byte stride.
  6320. */
  6321. readonly byteStride: number;
  6322. /**
  6323. * Constructor
  6324. * @param engine the engine
  6325. * @param data the data to use for this buffer
  6326. * @param updatable whether the data is updatable
  6327. * @param stride the stride (optional)
  6328. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6329. * @param instanced whether the buffer is instanced (optional)
  6330. * @param useBytes set to true if the stride in in bytes (optional)
  6331. * @param divisor sets an optional divisor for instances (1 by default)
  6332. */
  6333. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6334. /**
  6335. * Create a new VertexBuffer based on the current buffer
  6336. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6337. * @param offset defines offset in the buffer (0 by default)
  6338. * @param size defines the size in floats of attributes (position is 3 for instance)
  6339. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6340. * @param instanced defines if the vertex buffer contains indexed data
  6341. * @param useBytes defines if the offset and stride are in bytes *
  6342. * @param divisor sets an optional divisor for instances (1 by default)
  6343. * @returns the new vertex buffer
  6344. */
  6345. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6346. /**
  6347. * Gets a boolean indicating if the Buffer is updatable?
  6348. * @returns true if the buffer is updatable
  6349. */
  6350. isUpdatable(): boolean;
  6351. /**
  6352. * Gets current buffer's data
  6353. * @returns a DataArray or null
  6354. */
  6355. getData(): Nullable<DataArray>;
  6356. /**
  6357. * Gets underlying native buffer
  6358. * @returns underlying native buffer
  6359. */
  6360. getBuffer(): Nullable<DataBuffer>;
  6361. /**
  6362. * Gets the stride in float32 units (i.e. byte stride / 4).
  6363. * May not be an integer if the byte stride is not divisible by 4.
  6364. * @returns the stride in float32 units
  6365. * @deprecated Please use byteStride instead.
  6366. */
  6367. getStrideSize(): number;
  6368. /**
  6369. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6370. * @param data defines the data to store
  6371. */
  6372. create(data?: Nullable<DataArray>): void;
  6373. /** @hidden */
  6374. _rebuild(): void;
  6375. /**
  6376. * Update current buffer data
  6377. * @param data defines the data to store
  6378. */
  6379. update(data: DataArray): void;
  6380. /**
  6381. * Updates the data directly.
  6382. * @param data the new data
  6383. * @param offset the new offset
  6384. * @param vertexCount the vertex count (optional)
  6385. * @param useBytes set to true if the offset is in bytes
  6386. */
  6387. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6388. /**
  6389. * Release all resources
  6390. */
  6391. dispose(): void;
  6392. }
  6393. /**
  6394. * Specialized buffer used to store vertex data
  6395. */
  6396. export class VertexBuffer {
  6397. /** @hidden */
  6398. _buffer: Buffer;
  6399. private _kind;
  6400. private _size;
  6401. private _ownsBuffer;
  6402. private _instanced;
  6403. private _instanceDivisor;
  6404. /**
  6405. * The byte type.
  6406. */
  6407. static readonly BYTE: number;
  6408. /**
  6409. * The unsigned byte type.
  6410. */
  6411. static readonly UNSIGNED_BYTE: number;
  6412. /**
  6413. * The short type.
  6414. */
  6415. static readonly SHORT: number;
  6416. /**
  6417. * The unsigned short type.
  6418. */
  6419. static readonly UNSIGNED_SHORT: number;
  6420. /**
  6421. * The integer type.
  6422. */
  6423. static readonly INT: number;
  6424. /**
  6425. * The unsigned integer type.
  6426. */
  6427. static readonly UNSIGNED_INT: number;
  6428. /**
  6429. * The float type.
  6430. */
  6431. static readonly FLOAT: number;
  6432. /**
  6433. * Gets or sets the instance divisor when in instanced mode
  6434. */
  6435. get instanceDivisor(): number;
  6436. set instanceDivisor(value: number);
  6437. /**
  6438. * Gets the byte stride.
  6439. */
  6440. readonly byteStride: number;
  6441. /**
  6442. * Gets the byte offset.
  6443. */
  6444. readonly byteOffset: number;
  6445. /**
  6446. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6447. */
  6448. readonly normalized: boolean;
  6449. /**
  6450. * Gets the data type of each component in the array.
  6451. */
  6452. readonly type: number;
  6453. /**
  6454. * Constructor
  6455. * @param engine the engine
  6456. * @param data the data to use for this vertex buffer
  6457. * @param kind the vertex buffer kind
  6458. * @param updatable whether the data is updatable
  6459. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6460. * @param stride the stride (optional)
  6461. * @param instanced whether the buffer is instanced (optional)
  6462. * @param offset the offset of the data (optional)
  6463. * @param size the number of components (optional)
  6464. * @param type the type of the component (optional)
  6465. * @param normalized whether the data contains normalized data (optional)
  6466. * @param useBytes set to true if stride and offset are in bytes (optional)
  6467. * @param divisor defines the instance divisor to use (1 by default)
  6468. */
  6469. 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);
  6470. /** @hidden */
  6471. _rebuild(): void;
  6472. /**
  6473. * Returns the kind of the VertexBuffer (string)
  6474. * @returns a string
  6475. */
  6476. getKind(): string;
  6477. /**
  6478. * Gets a boolean indicating if the VertexBuffer is updatable?
  6479. * @returns true if the buffer is updatable
  6480. */
  6481. isUpdatable(): boolean;
  6482. /**
  6483. * Gets current buffer's data
  6484. * @returns a DataArray or null
  6485. */
  6486. getData(): Nullable<DataArray>;
  6487. /**
  6488. * Gets underlying native buffer
  6489. * @returns underlying native buffer
  6490. */
  6491. getBuffer(): Nullable<DataBuffer>;
  6492. /**
  6493. * Gets the stride in float32 units (i.e. byte stride / 4).
  6494. * May not be an integer if the byte stride is not divisible by 4.
  6495. * @returns the stride in float32 units
  6496. * @deprecated Please use byteStride instead.
  6497. */
  6498. getStrideSize(): number;
  6499. /**
  6500. * Returns the offset as a multiple of the type byte length.
  6501. * @returns the offset in bytes
  6502. * @deprecated Please use byteOffset instead.
  6503. */
  6504. getOffset(): number;
  6505. /**
  6506. * Returns the number of components per vertex attribute (integer)
  6507. * @returns the size in float
  6508. */
  6509. getSize(): number;
  6510. /**
  6511. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6512. * @returns true if this buffer is instanced
  6513. */
  6514. getIsInstanced(): boolean;
  6515. /**
  6516. * Returns the instancing divisor, zero for non-instanced (integer).
  6517. * @returns a number
  6518. */
  6519. getInstanceDivisor(): number;
  6520. /**
  6521. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6522. * @param data defines the data to store
  6523. */
  6524. create(data?: DataArray): void;
  6525. /**
  6526. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6527. * This function will create a new buffer if the current one is not updatable
  6528. * @param data defines the data to store
  6529. */
  6530. update(data: DataArray): void;
  6531. /**
  6532. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6533. * Returns the directly updated WebGLBuffer.
  6534. * @param data the new data
  6535. * @param offset the new offset
  6536. * @param useBytes set to true if the offset is in bytes
  6537. */
  6538. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6539. /**
  6540. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6541. */
  6542. dispose(): void;
  6543. /**
  6544. * Enumerates each value of this vertex buffer as numbers.
  6545. * @param count the number of values to enumerate
  6546. * @param callback the callback function called for each value
  6547. */
  6548. forEach(count: number, callback: (value: number, index: number) => void): void;
  6549. /**
  6550. * Positions
  6551. */
  6552. static readonly PositionKind: string;
  6553. /**
  6554. * Normals
  6555. */
  6556. static readonly NormalKind: string;
  6557. /**
  6558. * Tangents
  6559. */
  6560. static readonly TangentKind: string;
  6561. /**
  6562. * Texture coordinates
  6563. */
  6564. static readonly UVKind: string;
  6565. /**
  6566. * Texture coordinates 2
  6567. */
  6568. static readonly UV2Kind: string;
  6569. /**
  6570. * Texture coordinates 3
  6571. */
  6572. static readonly UV3Kind: string;
  6573. /**
  6574. * Texture coordinates 4
  6575. */
  6576. static readonly UV4Kind: string;
  6577. /**
  6578. * Texture coordinates 5
  6579. */
  6580. static readonly UV5Kind: string;
  6581. /**
  6582. * Texture coordinates 6
  6583. */
  6584. static readonly UV6Kind: string;
  6585. /**
  6586. * Colors
  6587. */
  6588. static readonly ColorKind: string;
  6589. /**
  6590. * Matrix indices (for bones)
  6591. */
  6592. static readonly MatricesIndicesKind: string;
  6593. /**
  6594. * Matrix weights (for bones)
  6595. */
  6596. static readonly MatricesWeightsKind: string;
  6597. /**
  6598. * Additional matrix indices (for bones)
  6599. */
  6600. static readonly MatricesIndicesExtraKind: string;
  6601. /**
  6602. * Additional matrix weights (for bones)
  6603. */
  6604. static readonly MatricesWeightsExtraKind: string;
  6605. /**
  6606. * Deduces the stride given a kind.
  6607. * @param kind The kind string to deduce
  6608. * @returns The deduced stride
  6609. */
  6610. static DeduceStride(kind: string): number;
  6611. /**
  6612. * Gets the byte length of the given type.
  6613. * @param type the type
  6614. * @returns the number of bytes
  6615. */
  6616. static GetTypeByteLength(type: number): number;
  6617. /**
  6618. * Enumerates each value of the given parameters as numbers.
  6619. * @param data the data to enumerate
  6620. * @param byteOffset the byte offset of the data
  6621. * @param byteStride the byte stride of the data
  6622. * @param componentCount the number of components per element
  6623. * @param componentType the type of the component
  6624. * @param count the number of values to enumerate
  6625. * @param normalized whether the data is normalized
  6626. * @param callback the callback function called for each value
  6627. */
  6628. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6629. private static _GetFloatValue;
  6630. }
  6631. }
  6632. declare module "babylonjs/Collisions/intersectionInfo" {
  6633. import { Nullable } from "babylonjs/types";
  6634. /**
  6635. * @hidden
  6636. */
  6637. export class IntersectionInfo {
  6638. bu: Nullable<number>;
  6639. bv: Nullable<number>;
  6640. distance: number;
  6641. faceId: number;
  6642. subMeshId: number;
  6643. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6644. }
  6645. }
  6646. declare module "babylonjs/Maths/math.plane" {
  6647. import { DeepImmutable } from "babylonjs/types";
  6648. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6649. /**
  6650. * Represens a plane by the equation ax + by + cz + d = 0
  6651. */
  6652. export class Plane {
  6653. private static _TmpMatrix;
  6654. /**
  6655. * Normal of the plane (a,b,c)
  6656. */
  6657. normal: Vector3;
  6658. /**
  6659. * d component of the plane
  6660. */
  6661. d: number;
  6662. /**
  6663. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6664. * @param a a component of the plane
  6665. * @param b b component of the plane
  6666. * @param c c component of the plane
  6667. * @param d d component of the plane
  6668. */
  6669. constructor(a: number, b: number, c: number, d: number);
  6670. /**
  6671. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6672. */
  6673. asArray(): number[];
  6674. /**
  6675. * @returns a new plane copied from the current Plane.
  6676. */
  6677. clone(): Plane;
  6678. /**
  6679. * @returns the string "Plane".
  6680. */
  6681. getClassName(): string;
  6682. /**
  6683. * @returns the Plane hash code.
  6684. */
  6685. getHashCode(): number;
  6686. /**
  6687. * Normalize the current Plane in place.
  6688. * @returns the updated Plane.
  6689. */
  6690. normalize(): Plane;
  6691. /**
  6692. * Applies a transformation the plane and returns the result
  6693. * @param transformation the transformation matrix to be applied to the plane
  6694. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6695. */
  6696. transform(transformation: DeepImmutable<Matrix>): Plane;
  6697. /**
  6698. * Calcualtte the dot product between the point and the plane normal
  6699. * @param point point to calculate the dot product with
  6700. * @returns the dot product (float) of the point coordinates and the plane normal.
  6701. */
  6702. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6703. /**
  6704. * Updates the current Plane from the plane defined by the three given points.
  6705. * @param point1 one of the points used to contruct the plane
  6706. * @param point2 one of the points used to contruct the plane
  6707. * @param point3 one of the points used to contruct the plane
  6708. * @returns the updated Plane.
  6709. */
  6710. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6711. /**
  6712. * Checks if the plane is facing a given direction
  6713. * @param direction the direction to check if the plane is facing
  6714. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6715. * @returns True is the vector "direction" is the same side than the plane normal.
  6716. */
  6717. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6718. /**
  6719. * Calculates the distance to a point
  6720. * @param point point to calculate distance to
  6721. * @returns the signed distance (float) from the given point to the Plane.
  6722. */
  6723. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6724. /**
  6725. * Creates a plane from an array
  6726. * @param array the array to create a plane from
  6727. * @returns a new Plane from the given array.
  6728. */
  6729. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6730. /**
  6731. * Creates a plane from three points
  6732. * @param point1 point used to create the plane
  6733. * @param point2 point used to create the plane
  6734. * @param point3 point used to create the plane
  6735. * @returns a new Plane defined by the three given points.
  6736. */
  6737. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6738. /**
  6739. * Creates a plane from an origin point and a normal
  6740. * @param origin origin of the plane to be constructed
  6741. * @param normal normal of the plane to be constructed
  6742. * @returns a new Plane the normal vector to this plane at the given origin point.
  6743. * Note : the vector "normal" is updated because normalized.
  6744. */
  6745. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6746. /**
  6747. * Calculates the distance from a plane and a point
  6748. * @param origin origin of the plane to be constructed
  6749. * @param normal normal of the plane to be constructed
  6750. * @param point point to calculate distance to
  6751. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6752. */
  6753. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6754. }
  6755. }
  6756. declare module "babylonjs/Culling/boundingSphere" {
  6757. import { DeepImmutable } from "babylonjs/types";
  6758. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6759. import { Plane } from "babylonjs/Maths/math.plane";
  6760. /**
  6761. * Class used to store bounding sphere information
  6762. */
  6763. export class BoundingSphere {
  6764. /**
  6765. * Gets the center of the bounding sphere in local space
  6766. */
  6767. readonly center: Vector3;
  6768. /**
  6769. * Radius of the bounding sphere in local space
  6770. */
  6771. radius: number;
  6772. /**
  6773. * Gets the center of the bounding sphere in world space
  6774. */
  6775. readonly centerWorld: Vector3;
  6776. /**
  6777. * Radius of the bounding sphere in world space
  6778. */
  6779. radiusWorld: number;
  6780. /**
  6781. * Gets the minimum vector in local space
  6782. */
  6783. readonly minimum: Vector3;
  6784. /**
  6785. * Gets the maximum vector in local space
  6786. */
  6787. readonly maximum: Vector3;
  6788. private _worldMatrix;
  6789. private static readonly TmpVector3;
  6790. /**
  6791. * Creates a new bounding sphere
  6792. * @param min defines the minimum vector (in local space)
  6793. * @param max defines the maximum vector (in local space)
  6794. * @param worldMatrix defines the new world matrix
  6795. */
  6796. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6797. /**
  6798. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6799. * @param min defines the new minimum vector (in local space)
  6800. * @param max defines the new maximum vector (in local space)
  6801. * @param worldMatrix defines the new world matrix
  6802. */
  6803. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6804. /**
  6805. * Scale the current bounding sphere by applying a scale factor
  6806. * @param factor defines the scale factor to apply
  6807. * @returns the current bounding box
  6808. */
  6809. scale(factor: number): BoundingSphere;
  6810. /**
  6811. * Gets the world matrix of the bounding box
  6812. * @returns a matrix
  6813. */
  6814. getWorldMatrix(): DeepImmutable<Matrix>;
  6815. /** @hidden */
  6816. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6817. /**
  6818. * Tests if the bounding sphere is intersecting the frustum planes
  6819. * @param frustumPlanes defines the frustum planes to test
  6820. * @returns true if there is an intersection
  6821. */
  6822. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6823. /**
  6824. * Tests if the bounding sphere center is in between the frustum planes.
  6825. * Used for optimistic fast inclusion.
  6826. * @param frustumPlanes defines the frustum planes to test
  6827. * @returns true if the sphere center is in between the frustum planes
  6828. */
  6829. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6830. /**
  6831. * Tests if a point is inside the bounding sphere
  6832. * @param point defines the point to test
  6833. * @returns true if the point is inside the bounding sphere
  6834. */
  6835. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6836. /**
  6837. * Checks if two sphere intersct
  6838. * @param sphere0 sphere 0
  6839. * @param sphere1 sphere 1
  6840. * @returns true if the speres intersect
  6841. */
  6842. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6843. }
  6844. }
  6845. declare module "babylonjs/Culling/boundingBox" {
  6846. import { DeepImmutable } from "babylonjs/types";
  6847. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6848. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6849. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6850. import { Plane } from "babylonjs/Maths/math.plane";
  6851. /**
  6852. * Class used to store bounding box information
  6853. */
  6854. export class BoundingBox implements ICullable {
  6855. /**
  6856. * Gets the 8 vectors representing the bounding box in local space
  6857. */
  6858. readonly vectors: Vector3[];
  6859. /**
  6860. * Gets the center of the bounding box in local space
  6861. */
  6862. readonly center: Vector3;
  6863. /**
  6864. * Gets the center of the bounding box in world space
  6865. */
  6866. readonly centerWorld: Vector3;
  6867. /**
  6868. * Gets the extend size in local space
  6869. */
  6870. readonly extendSize: Vector3;
  6871. /**
  6872. * Gets the extend size in world space
  6873. */
  6874. readonly extendSizeWorld: Vector3;
  6875. /**
  6876. * Gets the OBB (object bounding box) directions
  6877. */
  6878. readonly directions: Vector3[];
  6879. /**
  6880. * Gets the 8 vectors representing the bounding box in world space
  6881. */
  6882. readonly vectorsWorld: Vector3[];
  6883. /**
  6884. * Gets the minimum vector in world space
  6885. */
  6886. readonly minimumWorld: Vector3;
  6887. /**
  6888. * Gets the maximum vector in world space
  6889. */
  6890. readonly maximumWorld: Vector3;
  6891. /**
  6892. * Gets the minimum vector in local space
  6893. */
  6894. readonly minimum: Vector3;
  6895. /**
  6896. * Gets the maximum vector in local space
  6897. */
  6898. readonly maximum: Vector3;
  6899. private _worldMatrix;
  6900. private static readonly TmpVector3;
  6901. /**
  6902. * @hidden
  6903. */
  6904. _tag: number;
  6905. /**
  6906. * Creates a new bounding box
  6907. * @param min defines the minimum vector (in local space)
  6908. * @param max defines the maximum vector (in local space)
  6909. * @param worldMatrix defines the new world matrix
  6910. */
  6911. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6912. /**
  6913. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6914. * @param min defines the new minimum vector (in local space)
  6915. * @param max defines the new maximum vector (in local space)
  6916. * @param worldMatrix defines the new world matrix
  6917. */
  6918. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6919. /**
  6920. * Scale the current bounding box by applying a scale factor
  6921. * @param factor defines the scale factor to apply
  6922. * @returns the current bounding box
  6923. */
  6924. scale(factor: number): BoundingBox;
  6925. /**
  6926. * Gets the world matrix of the bounding box
  6927. * @returns a matrix
  6928. */
  6929. getWorldMatrix(): DeepImmutable<Matrix>;
  6930. /** @hidden */
  6931. _update(world: DeepImmutable<Matrix>): void;
  6932. /**
  6933. * Tests if the bounding box is intersecting the frustum planes
  6934. * @param frustumPlanes defines the frustum planes to test
  6935. * @returns true if there is an intersection
  6936. */
  6937. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6938. /**
  6939. * Tests if the bounding box is entirely inside the frustum planes
  6940. * @param frustumPlanes defines the frustum planes to test
  6941. * @returns true if there is an inclusion
  6942. */
  6943. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6944. /**
  6945. * Tests if a point is inside the bounding box
  6946. * @param point defines the point to test
  6947. * @returns true if the point is inside the bounding box
  6948. */
  6949. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6950. /**
  6951. * Tests if the bounding box intersects with a bounding sphere
  6952. * @param sphere defines the sphere to test
  6953. * @returns true if there is an intersection
  6954. */
  6955. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6956. /**
  6957. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6958. * @param min defines the min vector to use
  6959. * @param max defines the max vector to use
  6960. * @returns true if there is an intersection
  6961. */
  6962. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6963. /**
  6964. * Tests if two bounding boxes are intersections
  6965. * @param box0 defines the first box to test
  6966. * @param box1 defines the second box to test
  6967. * @returns true if there is an intersection
  6968. */
  6969. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6970. /**
  6971. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6972. * @param minPoint defines the minimum vector of the bounding box
  6973. * @param maxPoint defines the maximum vector of the bounding box
  6974. * @param sphereCenter defines the sphere center
  6975. * @param sphereRadius defines the sphere radius
  6976. * @returns true if there is an intersection
  6977. */
  6978. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6979. /**
  6980. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6981. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6982. * @param frustumPlanes defines the frustum planes to test
  6983. * @return true if there is an inclusion
  6984. */
  6985. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6986. /**
  6987. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6988. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6989. * @param frustumPlanes defines the frustum planes to test
  6990. * @return true if there is an intersection
  6991. */
  6992. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6993. }
  6994. }
  6995. declare module "babylonjs/Collisions/collider" {
  6996. import { Nullable, IndicesArray } from "babylonjs/types";
  6997. import { Vector3 } from "babylonjs/Maths/math.vector";
  6998. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  6999. import { Plane } from "babylonjs/Maths/math.plane";
  7000. /** @hidden */
  7001. export class Collider {
  7002. /** Define if a collision was found */
  7003. collisionFound: boolean;
  7004. /**
  7005. * Define last intersection point in local space
  7006. */
  7007. intersectionPoint: Vector3;
  7008. /**
  7009. * Define last collided mesh
  7010. */
  7011. collidedMesh: Nullable<AbstractMesh>;
  7012. private _collisionPoint;
  7013. private _planeIntersectionPoint;
  7014. private _tempVector;
  7015. private _tempVector2;
  7016. private _tempVector3;
  7017. private _tempVector4;
  7018. private _edge;
  7019. private _baseToVertex;
  7020. private _destinationPoint;
  7021. private _slidePlaneNormal;
  7022. private _displacementVector;
  7023. /** @hidden */
  7024. _radius: Vector3;
  7025. /** @hidden */
  7026. _retry: number;
  7027. private _velocity;
  7028. private _basePoint;
  7029. private _epsilon;
  7030. /** @hidden */
  7031. _velocityWorldLength: number;
  7032. /** @hidden */
  7033. _basePointWorld: Vector3;
  7034. private _velocityWorld;
  7035. private _normalizedVelocity;
  7036. /** @hidden */
  7037. _initialVelocity: Vector3;
  7038. /** @hidden */
  7039. _initialPosition: Vector3;
  7040. private _nearestDistance;
  7041. private _collisionMask;
  7042. get collisionMask(): number;
  7043. set collisionMask(mask: number);
  7044. /**
  7045. * Gets the plane normal used to compute the sliding response (in local space)
  7046. */
  7047. get slidePlaneNormal(): Vector3;
  7048. /** @hidden */
  7049. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7050. /** @hidden */
  7051. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7052. /** @hidden */
  7053. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7054. /** @hidden */
  7055. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7056. /** @hidden */
  7057. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7058. /** @hidden */
  7059. _getResponse(pos: Vector3, vel: Vector3): void;
  7060. }
  7061. }
  7062. declare module "babylonjs/Culling/boundingInfo" {
  7063. import { DeepImmutable } from "babylonjs/types";
  7064. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7065. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7066. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7067. import { Plane } from "babylonjs/Maths/math.plane";
  7068. import { Collider } from "babylonjs/Collisions/collider";
  7069. /**
  7070. * Interface for cullable objects
  7071. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7072. */
  7073. export interface ICullable {
  7074. /**
  7075. * Checks if the object or part of the object is in the frustum
  7076. * @param frustumPlanes Camera near/planes
  7077. * @returns true if the object is in frustum otherwise false
  7078. */
  7079. isInFrustum(frustumPlanes: Plane[]): boolean;
  7080. /**
  7081. * Checks if a cullable object (mesh...) is in the camera frustum
  7082. * Unlike isInFrustum this cheks the full bounding box
  7083. * @param frustumPlanes Camera near/planes
  7084. * @returns true if the object is in frustum otherwise false
  7085. */
  7086. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7087. }
  7088. /**
  7089. * Info for a bounding data of a mesh
  7090. */
  7091. export class BoundingInfo implements ICullable {
  7092. /**
  7093. * Bounding box for the mesh
  7094. */
  7095. readonly boundingBox: BoundingBox;
  7096. /**
  7097. * Bounding sphere for the mesh
  7098. */
  7099. readonly boundingSphere: BoundingSphere;
  7100. private _isLocked;
  7101. private static readonly TmpVector3;
  7102. /**
  7103. * Constructs bounding info
  7104. * @param minimum min vector of the bounding box/sphere
  7105. * @param maximum max vector of the bounding box/sphere
  7106. * @param worldMatrix defines the new world matrix
  7107. */
  7108. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7109. /**
  7110. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7111. * @param min defines the new minimum vector (in local space)
  7112. * @param max defines the new maximum vector (in local space)
  7113. * @param worldMatrix defines the new world matrix
  7114. */
  7115. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7116. /**
  7117. * min vector of the bounding box/sphere
  7118. */
  7119. get minimum(): Vector3;
  7120. /**
  7121. * max vector of the bounding box/sphere
  7122. */
  7123. get maximum(): Vector3;
  7124. /**
  7125. * If the info is locked and won't be updated to avoid perf overhead
  7126. */
  7127. get isLocked(): boolean;
  7128. set isLocked(value: boolean);
  7129. /**
  7130. * Updates the bounding sphere and box
  7131. * @param world world matrix to be used to update
  7132. */
  7133. update(world: DeepImmutable<Matrix>): void;
  7134. /**
  7135. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7136. * @param center New center of the bounding info
  7137. * @param extend New extend of the bounding info
  7138. * @returns the current bounding info
  7139. */
  7140. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7141. /**
  7142. * Scale the current bounding info by applying a scale factor
  7143. * @param factor defines the scale factor to apply
  7144. * @returns the current bounding info
  7145. */
  7146. scale(factor: number): BoundingInfo;
  7147. /**
  7148. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7149. * @param frustumPlanes defines the frustum to test
  7150. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7151. * @returns true if the bounding info is in the frustum planes
  7152. */
  7153. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7154. /**
  7155. * Gets the world distance between the min and max points of the bounding box
  7156. */
  7157. get diagonalLength(): number;
  7158. /**
  7159. * Checks if a cullable object (mesh...) is in the camera frustum
  7160. * Unlike isInFrustum this cheks the full bounding box
  7161. * @param frustumPlanes Camera near/planes
  7162. * @returns true if the object is in frustum otherwise false
  7163. */
  7164. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7165. /** @hidden */
  7166. _checkCollision(collider: Collider): boolean;
  7167. /**
  7168. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7169. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7170. * @param point the point to check intersection with
  7171. * @returns if the point intersects
  7172. */
  7173. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7174. /**
  7175. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7176. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7177. * @param boundingInfo the bounding info to check intersection with
  7178. * @param precise if the intersection should be done using OBB
  7179. * @returns if the bounding info intersects
  7180. */
  7181. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7182. }
  7183. }
  7184. declare module "babylonjs/Maths/math.functions" {
  7185. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7186. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7187. /**
  7188. * Extracts minimum and maximum values from a list of indexed positions
  7189. * @param positions defines the positions to use
  7190. * @param indices defines the indices to the positions
  7191. * @param indexStart defines the start index
  7192. * @param indexCount defines the end index
  7193. * @param bias defines bias value to add to the result
  7194. * @return minimum and maximum values
  7195. */
  7196. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7197. minimum: Vector3;
  7198. maximum: Vector3;
  7199. };
  7200. /**
  7201. * Extracts minimum and maximum values from a list of positions
  7202. * @param positions defines the positions to use
  7203. * @param start defines the start index in the positions array
  7204. * @param count defines the number of positions to handle
  7205. * @param bias defines bias value to add to the result
  7206. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7207. * @return minimum and maximum values
  7208. */
  7209. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7210. minimum: Vector3;
  7211. maximum: Vector3;
  7212. };
  7213. }
  7214. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7215. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7216. /** @hidden */
  7217. export class WebGLDataBuffer extends DataBuffer {
  7218. private _buffer;
  7219. constructor(resource: WebGLBuffer);
  7220. get underlyingResource(): any;
  7221. }
  7222. }
  7223. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7224. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7225. import { Nullable } from "babylonjs/types";
  7226. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7227. /** @hidden */
  7228. export class WebGLPipelineContext implements IPipelineContext {
  7229. engine: ThinEngine;
  7230. program: Nullable<WebGLProgram>;
  7231. context?: WebGLRenderingContext;
  7232. vertexShader?: WebGLShader;
  7233. fragmentShader?: WebGLShader;
  7234. isParallelCompiled: boolean;
  7235. onCompiled?: () => void;
  7236. transformFeedback?: WebGLTransformFeedback | null;
  7237. vertexCompilationError: Nullable<string>;
  7238. fragmentCompilationError: Nullable<string>;
  7239. programLinkError: Nullable<string>;
  7240. programValidationError: Nullable<string>;
  7241. get isAsync(): boolean;
  7242. get isReady(): boolean;
  7243. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7244. }
  7245. }
  7246. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7247. import { FloatArray, Nullable } from "babylonjs/types";
  7248. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7249. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7250. module "babylonjs/Engines/thinEngine" {
  7251. interface ThinEngine {
  7252. /**
  7253. * Create an uniform buffer
  7254. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7255. * @param elements defines the content of the uniform buffer
  7256. * @returns the webGL uniform buffer
  7257. */
  7258. createUniformBuffer(elements: FloatArray): DataBuffer;
  7259. /**
  7260. * Create a dynamic uniform buffer
  7261. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7262. * @param elements defines the content of the uniform buffer
  7263. * @returns the webGL uniform buffer
  7264. */
  7265. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7266. /**
  7267. * Update an existing uniform buffer
  7268. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7269. * @param uniformBuffer defines the target uniform buffer
  7270. * @param elements defines the content to update
  7271. * @param offset defines the offset in the uniform buffer where update should start
  7272. * @param count defines the size of the data to update
  7273. */
  7274. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7275. /**
  7276. * Bind an uniform buffer to the current webGL context
  7277. * @param buffer defines the buffer to bind
  7278. */
  7279. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7280. /**
  7281. * Bind a buffer to the current webGL context at a given location
  7282. * @param buffer defines the buffer to bind
  7283. * @param location defines the index where to bind the buffer
  7284. */
  7285. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7286. /**
  7287. * Bind a specific block at a given index in a specific shader program
  7288. * @param pipelineContext defines the pipeline context to use
  7289. * @param blockName defines the block name
  7290. * @param index defines the index where to bind the block
  7291. */
  7292. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7293. }
  7294. }
  7295. }
  7296. declare module "babylonjs/Materials/uniformBuffer" {
  7297. import { Nullable, FloatArray } from "babylonjs/types";
  7298. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7299. import { Engine } from "babylonjs/Engines/engine";
  7300. import { Effect } from "babylonjs/Materials/effect";
  7301. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7302. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7303. import { Color3 } from "babylonjs/Maths/math.color";
  7304. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7305. /**
  7306. * Uniform buffer objects.
  7307. *
  7308. * Handles blocks of uniform on the GPU.
  7309. *
  7310. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7311. *
  7312. * For more information, please refer to :
  7313. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7314. */
  7315. export class UniformBuffer {
  7316. private _engine;
  7317. private _buffer;
  7318. private _data;
  7319. private _bufferData;
  7320. private _dynamic?;
  7321. private _uniformLocations;
  7322. private _uniformSizes;
  7323. private _uniformLocationPointer;
  7324. private _needSync;
  7325. private _noUBO;
  7326. private _currentEffect;
  7327. /** @hidden */
  7328. _alreadyBound: boolean;
  7329. private static _MAX_UNIFORM_SIZE;
  7330. private static _tempBuffer;
  7331. /**
  7332. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7333. * This is dynamic to allow compat with webgl 1 and 2.
  7334. * You will need to pass the name of the uniform as well as the value.
  7335. */
  7336. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7337. /**
  7338. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7339. * This is dynamic to allow compat with webgl 1 and 2.
  7340. * You will need to pass the name of the uniform as well as the value.
  7341. */
  7342. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7343. /**
  7344. * Lambda to Update a single float in a uniform buffer.
  7345. * This is dynamic to allow compat with webgl 1 and 2.
  7346. * You will need to pass the name of the uniform as well as the value.
  7347. */
  7348. updateFloat: (name: string, x: number) => void;
  7349. /**
  7350. * Lambda to Update a vec2 of float in a uniform buffer.
  7351. * This is dynamic to allow compat with webgl 1 and 2.
  7352. * You will need to pass the name of the uniform as well as the value.
  7353. */
  7354. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7355. /**
  7356. * Lambda to Update a vec3 of float in a uniform buffer.
  7357. * This is dynamic to allow compat with webgl 1 and 2.
  7358. * You will need to pass the name of the uniform as well as the value.
  7359. */
  7360. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7361. /**
  7362. * Lambda to Update a vec4 of float in a uniform buffer.
  7363. * This is dynamic to allow compat with webgl 1 and 2.
  7364. * You will need to pass the name of the uniform as well as the value.
  7365. */
  7366. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7367. /**
  7368. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7369. * This is dynamic to allow compat with webgl 1 and 2.
  7370. * You will need to pass the name of the uniform as well as the value.
  7371. */
  7372. updateMatrix: (name: string, mat: Matrix) => void;
  7373. /**
  7374. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7375. * This is dynamic to allow compat with webgl 1 and 2.
  7376. * You will need to pass the name of the uniform as well as the value.
  7377. */
  7378. updateVector3: (name: string, vector: Vector3) => void;
  7379. /**
  7380. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7381. * This is dynamic to allow compat with webgl 1 and 2.
  7382. * You will need to pass the name of the uniform as well as the value.
  7383. */
  7384. updateVector4: (name: string, vector: Vector4) => void;
  7385. /**
  7386. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7387. * This is dynamic to allow compat with webgl 1 and 2.
  7388. * You will need to pass the name of the uniform as well as the value.
  7389. */
  7390. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7391. /**
  7392. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7393. * This is dynamic to allow compat with webgl 1 and 2.
  7394. * You will need to pass the name of the uniform as well as the value.
  7395. */
  7396. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7397. /**
  7398. * Instantiates a new Uniform buffer objects.
  7399. *
  7400. * Handles blocks of uniform on the GPU.
  7401. *
  7402. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7403. *
  7404. * For more information, please refer to :
  7405. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7406. * @param engine Define the engine the buffer is associated with
  7407. * @param data Define the data contained in the buffer
  7408. * @param dynamic Define if the buffer is updatable
  7409. */
  7410. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7411. /**
  7412. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7413. * or just falling back on setUniformXXX calls.
  7414. */
  7415. get useUbo(): boolean;
  7416. /**
  7417. * Indicates if the WebGL underlying uniform buffer is in sync
  7418. * with the javascript cache data.
  7419. */
  7420. get isSync(): boolean;
  7421. /**
  7422. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7423. * Also, a dynamic UniformBuffer will disable cache verification and always
  7424. * update the underlying WebGL uniform buffer to the GPU.
  7425. * @returns if Dynamic, otherwise false
  7426. */
  7427. isDynamic(): boolean;
  7428. /**
  7429. * The data cache on JS side.
  7430. * @returns the underlying data as a float array
  7431. */
  7432. getData(): Float32Array;
  7433. /**
  7434. * The underlying WebGL Uniform buffer.
  7435. * @returns the webgl buffer
  7436. */
  7437. getBuffer(): Nullable<DataBuffer>;
  7438. /**
  7439. * std140 layout specifies how to align data within an UBO structure.
  7440. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7441. * for specs.
  7442. */
  7443. private _fillAlignment;
  7444. /**
  7445. * Adds an uniform in the buffer.
  7446. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7447. * for the layout to be correct !
  7448. * @param name Name of the uniform, as used in the uniform block in the shader.
  7449. * @param size Data size, or data directly.
  7450. */
  7451. addUniform(name: string, size: number | number[]): void;
  7452. /**
  7453. * Adds a Matrix 4x4 to the uniform buffer.
  7454. * @param name Name of the uniform, as used in the uniform block in the shader.
  7455. * @param mat A 4x4 matrix.
  7456. */
  7457. addMatrix(name: string, mat: Matrix): void;
  7458. /**
  7459. * Adds a vec2 to the uniform buffer.
  7460. * @param name Name of the uniform, as used in the uniform block in the shader.
  7461. * @param x Define the x component value of the vec2
  7462. * @param y Define the y component value of the vec2
  7463. */
  7464. addFloat2(name: string, x: number, y: number): void;
  7465. /**
  7466. * Adds a vec3 to the uniform buffer.
  7467. * @param name Name of the uniform, as used in the uniform block in the shader.
  7468. * @param x Define the x component value of the vec3
  7469. * @param y Define the y component value of the vec3
  7470. * @param z Define the z component value of the vec3
  7471. */
  7472. addFloat3(name: string, x: number, y: number, z: number): void;
  7473. /**
  7474. * Adds a vec3 to the uniform buffer.
  7475. * @param name Name of the uniform, as used in the uniform block in the shader.
  7476. * @param color Define the vec3 from a Color
  7477. */
  7478. addColor3(name: string, color: Color3): void;
  7479. /**
  7480. * Adds a vec4 to the uniform buffer.
  7481. * @param name Name of the uniform, as used in the uniform block in the shader.
  7482. * @param color Define the rgb components from a Color
  7483. * @param alpha Define the a component of the vec4
  7484. */
  7485. addColor4(name: string, color: Color3, alpha: number): void;
  7486. /**
  7487. * Adds a vec3 to the uniform buffer.
  7488. * @param name Name of the uniform, as used in the uniform block in the shader.
  7489. * @param vector Define the vec3 components from a Vector
  7490. */
  7491. addVector3(name: string, vector: Vector3): void;
  7492. /**
  7493. * Adds a Matrix 3x3 to the uniform buffer.
  7494. * @param name Name of the uniform, as used in the uniform block in the shader.
  7495. */
  7496. addMatrix3x3(name: string): void;
  7497. /**
  7498. * Adds a Matrix 2x2 to the uniform buffer.
  7499. * @param name Name of the uniform, as used in the uniform block in the shader.
  7500. */
  7501. addMatrix2x2(name: string): void;
  7502. /**
  7503. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7504. */
  7505. create(): void;
  7506. /** @hidden */
  7507. _rebuild(): void;
  7508. /**
  7509. * Updates the WebGL Uniform Buffer on the GPU.
  7510. * If the `dynamic` flag is set to true, no cache comparison is done.
  7511. * Otherwise, the buffer will be updated only if the cache differs.
  7512. */
  7513. update(): void;
  7514. /**
  7515. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7516. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7517. * @param data Define the flattened data
  7518. * @param size Define the size of the data.
  7519. */
  7520. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7521. private _valueCache;
  7522. private _cacheMatrix;
  7523. private _updateMatrix3x3ForUniform;
  7524. private _updateMatrix3x3ForEffect;
  7525. private _updateMatrix2x2ForEffect;
  7526. private _updateMatrix2x2ForUniform;
  7527. private _updateFloatForEffect;
  7528. private _updateFloatForUniform;
  7529. private _updateFloat2ForEffect;
  7530. private _updateFloat2ForUniform;
  7531. private _updateFloat3ForEffect;
  7532. private _updateFloat3ForUniform;
  7533. private _updateFloat4ForEffect;
  7534. private _updateFloat4ForUniform;
  7535. private _updateMatrixForEffect;
  7536. private _updateMatrixForUniform;
  7537. private _updateVector3ForEffect;
  7538. private _updateVector3ForUniform;
  7539. private _updateVector4ForEffect;
  7540. private _updateVector4ForUniform;
  7541. private _updateColor3ForEffect;
  7542. private _updateColor3ForUniform;
  7543. private _updateColor4ForEffect;
  7544. private _updateColor4ForUniform;
  7545. /**
  7546. * Sets a sampler uniform on the effect.
  7547. * @param name Define the name of the sampler.
  7548. * @param texture Define the texture to set in the sampler
  7549. */
  7550. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7551. /**
  7552. * Directly updates the value of the uniform in the cache AND on the GPU.
  7553. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7554. * @param data Define the flattened data
  7555. */
  7556. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7557. /**
  7558. * Binds this uniform buffer to an effect.
  7559. * @param effect Define the effect to bind the buffer to
  7560. * @param name Name of the uniform block in the shader.
  7561. */
  7562. bindToEffect(effect: Effect, name: string): void;
  7563. /**
  7564. * Disposes the uniform buffer.
  7565. */
  7566. dispose(): void;
  7567. }
  7568. }
  7569. declare module "babylonjs/Misc/iInspectable" {
  7570. /**
  7571. * Enum that determines the text-wrapping mode to use.
  7572. */
  7573. export enum InspectableType {
  7574. /**
  7575. * Checkbox for booleans
  7576. */
  7577. Checkbox = 0,
  7578. /**
  7579. * Sliders for numbers
  7580. */
  7581. Slider = 1,
  7582. /**
  7583. * Vector3
  7584. */
  7585. Vector3 = 2,
  7586. /**
  7587. * Quaternions
  7588. */
  7589. Quaternion = 3,
  7590. /**
  7591. * Color3
  7592. */
  7593. Color3 = 4,
  7594. /**
  7595. * String
  7596. */
  7597. String = 5
  7598. }
  7599. /**
  7600. * Interface used to define custom inspectable properties.
  7601. * This interface is used by the inspector to display custom property grids
  7602. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7603. */
  7604. export interface IInspectable {
  7605. /**
  7606. * Gets the label to display
  7607. */
  7608. label: string;
  7609. /**
  7610. * Gets the name of the property to edit
  7611. */
  7612. propertyName: string;
  7613. /**
  7614. * Gets the type of the editor to use
  7615. */
  7616. type: InspectableType;
  7617. /**
  7618. * Gets the minimum value of the property when using in "slider" mode
  7619. */
  7620. min?: number;
  7621. /**
  7622. * Gets the maximum value of the property when using in "slider" mode
  7623. */
  7624. max?: number;
  7625. /**
  7626. * Gets the setp to use when using in "slider" mode
  7627. */
  7628. step?: number;
  7629. }
  7630. }
  7631. declare module "babylonjs/Misc/timingTools" {
  7632. /**
  7633. * Class used to provide helper for timing
  7634. */
  7635. export class TimingTools {
  7636. /**
  7637. * Polyfill for setImmediate
  7638. * @param action defines the action to execute after the current execution block
  7639. */
  7640. static SetImmediate(action: () => void): void;
  7641. }
  7642. }
  7643. declare module "babylonjs/Misc/instantiationTools" {
  7644. /**
  7645. * Class used to enable instatition of objects by class name
  7646. */
  7647. export class InstantiationTools {
  7648. /**
  7649. * Use this object to register external classes like custom textures or material
  7650. * to allow the laoders to instantiate them
  7651. */
  7652. static RegisteredExternalClasses: {
  7653. [key: string]: Object;
  7654. };
  7655. /**
  7656. * Tries to instantiate a new object from a given class name
  7657. * @param className defines the class name to instantiate
  7658. * @returns the new object or null if the system was not able to do the instantiation
  7659. */
  7660. static Instantiate(className: string): any;
  7661. }
  7662. }
  7663. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7664. /**
  7665. * Define options used to create a depth texture
  7666. */
  7667. export class DepthTextureCreationOptions {
  7668. /** Specifies whether or not a stencil should be allocated in the texture */
  7669. generateStencil?: boolean;
  7670. /** Specifies whether or not bilinear filtering is enable on the texture */
  7671. bilinearFiltering?: boolean;
  7672. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7673. comparisonFunction?: number;
  7674. /** Specifies if the created texture is a cube texture */
  7675. isCube?: boolean;
  7676. }
  7677. }
  7678. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7679. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7680. import { Nullable } from "babylonjs/types";
  7681. import { Scene } from "babylonjs/scene";
  7682. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7683. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7684. module "babylonjs/Engines/thinEngine" {
  7685. interface ThinEngine {
  7686. /**
  7687. * Creates a depth stencil cube texture.
  7688. * This is only available in WebGL 2.
  7689. * @param size The size of face edge in the cube texture.
  7690. * @param options The options defining the cube texture.
  7691. * @returns The cube texture
  7692. */
  7693. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7694. /**
  7695. * Creates a cube texture
  7696. * @param rootUrl defines the url where the files to load is located
  7697. * @param scene defines the current scene
  7698. * @param files defines the list of files to load (1 per face)
  7699. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7700. * @param onLoad defines an optional callback raised when the texture is loaded
  7701. * @param onError defines an optional callback raised if there is an issue to load the texture
  7702. * @param format defines the format of the data
  7703. * @param forcedExtension defines the extension to use to pick the right loader
  7704. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7705. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7706. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7707. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7708. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7709. * @returns the cube texture as an InternalTexture
  7710. */
  7711. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  7712. /**
  7713. * Creates a cube texture
  7714. * @param rootUrl defines the url where the files to load is located
  7715. * @param scene defines the current scene
  7716. * @param files defines the list of files to load (1 per face)
  7717. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7718. * @param onLoad defines an optional callback raised when the texture is loaded
  7719. * @param onError defines an optional callback raised if there is an issue to load the texture
  7720. * @param format defines the format of the data
  7721. * @param forcedExtension defines the extension to use to pick the right loader
  7722. * @returns the cube texture as an InternalTexture
  7723. */
  7724. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7725. /**
  7726. * Creates a cube texture
  7727. * @param rootUrl defines the url where the files to load is located
  7728. * @param scene defines the current scene
  7729. * @param files defines the list of files to load (1 per face)
  7730. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7731. * @param onLoad defines an optional callback raised when the texture is loaded
  7732. * @param onError defines an optional callback raised if there is an issue to load the texture
  7733. * @param format defines the format of the data
  7734. * @param forcedExtension defines the extension to use to pick the right loader
  7735. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7736. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7737. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7738. * @returns the cube texture as an InternalTexture
  7739. */
  7740. 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;
  7741. /** @hidden */
  7742. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7743. /** @hidden */
  7744. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7745. /** @hidden */
  7746. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7747. /** @hidden */
  7748. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7749. /**
  7750. * @hidden
  7751. */
  7752. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7753. }
  7754. }
  7755. }
  7756. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7757. import { Nullable } from "babylonjs/types";
  7758. import { Scene } from "babylonjs/scene";
  7759. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7760. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7761. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7762. import { Observable } from "babylonjs/Misc/observable";
  7763. /**
  7764. * Class for creating a cube texture
  7765. */
  7766. export class CubeTexture extends BaseTexture {
  7767. private _delayedOnLoad;
  7768. /**
  7769. * Observable triggered once the texture has been loaded.
  7770. */
  7771. onLoadObservable: Observable<CubeTexture>;
  7772. /**
  7773. * The url of the texture
  7774. */
  7775. url: string;
  7776. /**
  7777. * Gets or sets the center of the bounding box associated with the cube texture.
  7778. * It must define where the camera used to render the texture was set
  7779. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7780. */
  7781. boundingBoxPosition: Vector3;
  7782. private _boundingBoxSize;
  7783. /**
  7784. * Gets or sets the size of the bounding box associated with the cube texture
  7785. * When defined, the cubemap will switch to local mode
  7786. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7787. * @example https://www.babylonjs-playground.com/#RNASML
  7788. */
  7789. set boundingBoxSize(value: Vector3);
  7790. /**
  7791. * Returns the bounding box size
  7792. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7793. */
  7794. get boundingBoxSize(): Vector3;
  7795. protected _rotationY: number;
  7796. /**
  7797. * Sets texture matrix rotation angle around Y axis in radians.
  7798. */
  7799. set rotationY(value: number);
  7800. /**
  7801. * Gets texture matrix rotation angle around Y axis radians.
  7802. */
  7803. get rotationY(): number;
  7804. /**
  7805. * Are mip maps generated for this texture or not.
  7806. */
  7807. get noMipmap(): boolean;
  7808. private _noMipmap;
  7809. private _files;
  7810. protected _forcedExtension: Nullable<string>;
  7811. private _extensions;
  7812. private _textureMatrix;
  7813. private _format;
  7814. private _createPolynomials;
  7815. /** @hidden */
  7816. _prefiltered: boolean;
  7817. /**
  7818. * Creates a cube texture from an array of image urls
  7819. * @param files defines an array of image urls
  7820. * @param scene defines the hosting scene
  7821. * @param noMipmap specifies if mip maps are not used
  7822. * @returns a cube texture
  7823. */
  7824. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7825. /**
  7826. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7827. * @param url defines the url of the prefiltered texture
  7828. * @param scene defines the scene the texture is attached to
  7829. * @param forcedExtension defines the extension of the file if different from the url
  7830. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7831. * @return the prefiltered texture
  7832. */
  7833. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7834. /**
  7835. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7836. * as prefiltered data.
  7837. * @param rootUrl defines the url of the texture or the root name of the six images
  7838. * @param scene defines the scene the texture is attached to
  7839. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7840. * @param noMipmap defines if mipmaps should be created or not
  7841. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7842. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7843. * @param onError defines a callback triggered in case of error during load
  7844. * @param format defines the internal format to use for the texture once loaded
  7845. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7846. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7847. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7848. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7849. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7850. * @return the cube texture
  7851. */
  7852. 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);
  7853. /**
  7854. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7855. */
  7856. get isPrefiltered(): boolean;
  7857. /**
  7858. * Get the current class name of the texture useful for serialization or dynamic coding.
  7859. * @returns "CubeTexture"
  7860. */
  7861. getClassName(): string;
  7862. /**
  7863. * Update the url (and optional buffer) of this texture if url was null during construction.
  7864. * @param url the url of the texture
  7865. * @param forcedExtension defines the extension to use
  7866. * @param onLoad callback called when the texture is loaded (defaults to null)
  7867. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7868. */
  7869. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7870. /**
  7871. * Delays loading of the cube texture
  7872. * @param forcedExtension defines the extension to use
  7873. */
  7874. delayLoad(forcedExtension?: string): void;
  7875. /**
  7876. * Returns the reflection texture matrix
  7877. * @returns the reflection texture matrix
  7878. */
  7879. getReflectionTextureMatrix(): Matrix;
  7880. /**
  7881. * Sets the reflection texture matrix
  7882. * @param value Reflection texture matrix
  7883. */
  7884. setReflectionTextureMatrix(value: Matrix): void;
  7885. /**
  7886. * Parses text to create a cube texture
  7887. * @param parsedTexture define the serialized text to read from
  7888. * @param scene defines the hosting scene
  7889. * @param rootUrl defines the root url of the cube texture
  7890. * @returns a cube texture
  7891. */
  7892. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7893. /**
  7894. * Makes a clone, or deep copy, of the cube texture
  7895. * @returns a new cube texture
  7896. */
  7897. clone(): CubeTexture;
  7898. }
  7899. }
  7900. declare module "babylonjs/Materials/materialDefines" {
  7901. /**
  7902. * Manages the defines for the Material
  7903. */
  7904. export class MaterialDefines {
  7905. /** @hidden */
  7906. protected _keys: string[];
  7907. private _isDirty;
  7908. /** @hidden */
  7909. _renderId: number;
  7910. /** @hidden */
  7911. _areLightsDirty: boolean;
  7912. /** @hidden */
  7913. _areLightsDisposed: boolean;
  7914. /** @hidden */
  7915. _areAttributesDirty: boolean;
  7916. /** @hidden */
  7917. _areTexturesDirty: boolean;
  7918. /** @hidden */
  7919. _areFresnelDirty: boolean;
  7920. /** @hidden */
  7921. _areMiscDirty: boolean;
  7922. /** @hidden */
  7923. _areImageProcessingDirty: boolean;
  7924. /** @hidden */
  7925. _normals: boolean;
  7926. /** @hidden */
  7927. _uvs: boolean;
  7928. /** @hidden */
  7929. _needNormals: boolean;
  7930. /** @hidden */
  7931. _needUVs: boolean;
  7932. [id: string]: any;
  7933. /**
  7934. * Specifies if the material needs to be re-calculated
  7935. */
  7936. get isDirty(): boolean;
  7937. /**
  7938. * Marks the material to indicate that it has been re-calculated
  7939. */
  7940. markAsProcessed(): void;
  7941. /**
  7942. * Marks the material to indicate that it needs to be re-calculated
  7943. */
  7944. markAsUnprocessed(): void;
  7945. /**
  7946. * Marks the material to indicate all of its defines need to be re-calculated
  7947. */
  7948. markAllAsDirty(): void;
  7949. /**
  7950. * Marks the material to indicate that image processing needs to be re-calculated
  7951. */
  7952. markAsImageProcessingDirty(): void;
  7953. /**
  7954. * Marks the material to indicate the lights need to be re-calculated
  7955. * @param disposed Defines whether the light is dirty due to dispose or not
  7956. */
  7957. markAsLightDirty(disposed?: boolean): void;
  7958. /**
  7959. * Marks the attribute state as changed
  7960. */
  7961. markAsAttributesDirty(): void;
  7962. /**
  7963. * Marks the texture state as changed
  7964. */
  7965. markAsTexturesDirty(): void;
  7966. /**
  7967. * Marks the fresnel state as changed
  7968. */
  7969. markAsFresnelDirty(): void;
  7970. /**
  7971. * Marks the misc state as changed
  7972. */
  7973. markAsMiscDirty(): void;
  7974. /**
  7975. * Rebuilds the material defines
  7976. */
  7977. rebuild(): void;
  7978. /**
  7979. * Specifies if two material defines are equal
  7980. * @param other - A material define instance to compare to
  7981. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7982. */
  7983. isEqual(other: MaterialDefines): boolean;
  7984. /**
  7985. * Clones this instance's defines to another instance
  7986. * @param other - material defines to clone values to
  7987. */
  7988. cloneTo(other: MaterialDefines): void;
  7989. /**
  7990. * Resets the material define values
  7991. */
  7992. reset(): void;
  7993. /**
  7994. * Converts the material define values to a string
  7995. * @returns - String of material define information
  7996. */
  7997. toString(): string;
  7998. }
  7999. }
  8000. declare module "babylonjs/Materials/colorCurves" {
  8001. import { Effect } from "babylonjs/Materials/effect";
  8002. /**
  8003. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8004. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8005. * 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;
  8006. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8007. */
  8008. export class ColorCurves {
  8009. private _dirty;
  8010. private _tempColor;
  8011. private _globalCurve;
  8012. private _highlightsCurve;
  8013. private _midtonesCurve;
  8014. private _shadowsCurve;
  8015. private _positiveCurve;
  8016. private _negativeCurve;
  8017. private _globalHue;
  8018. private _globalDensity;
  8019. private _globalSaturation;
  8020. private _globalExposure;
  8021. /**
  8022. * Gets the global Hue value.
  8023. * 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).
  8024. */
  8025. get globalHue(): number;
  8026. /**
  8027. * Sets the global Hue value.
  8028. * 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).
  8029. */
  8030. set globalHue(value: number);
  8031. /**
  8032. * Gets the global Density value.
  8033. * 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.
  8034. * Values less than zero provide a filter of opposite hue.
  8035. */
  8036. get globalDensity(): number;
  8037. /**
  8038. * Sets the global Density value.
  8039. * 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.
  8040. * Values less than zero provide a filter of opposite hue.
  8041. */
  8042. set globalDensity(value: number);
  8043. /**
  8044. * Gets the global Saturation value.
  8045. * 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.
  8046. */
  8047. get globalSaturation(): number;
  8048. /**
  8049. * Sets the global Saturation value.
  8050. * 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.
  8051. */
  8052. set globalSaturation(value: number);
  8053. /**
  8054. * Gets the global Exposure value.
  8055. * 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.
  8056. */
  8057. get globalExposure(): number;
  8058. /**
  8059. * Sets the global Exposure value.
  8060. * 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.
  8061. */
  8062. set globalExposure(value: number);
  8063. private _highlightsHue;
  8064. private _highlightsDensity;
  8065. private _highlightsSaturation;
  8066. private _highlightsExposure;
  8067. /**
  8068. * Gets the highlights Hue value.
  8069. * 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).
  8070. */
  8071. get highlightsHue(): number;
  8072. /**
  8073. * Sets the highlights Hue value.
  8074. * 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).
  8075. */
  8076. set highlightsHue(value: number);
  8077. /**
  8078. * Gets the highlights Density value.
  8079. * 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.
  8080. * Values less than zero provide a filter of opposite hue.
  8081. */
  8082. get highlightsDensity(): number;
  8083. /**
  8084. * Sets the highlights Density value.
  8085. * 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.
  8086. * Values less than zero provide a filter of opposite hue.
  8087. */
  8088. set highlightsDensity(value: number);
  8089. /**
  8090. * Gets the highlights Saturation value.
  8091. * 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.
  8092. */
  8093. get highlightsSaturation(): number;
  8094. /**
  8095. * Sets the highlights Saturation value.
  8096. * 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.
  8097. */
  8098. set highlightsSaturation(value: number);
  8099. /**
  8100. * Gets the highlights Exposure value.
  8101. * 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.
  8102. */
  8103. get highlightsExposure(): number;
  8104. /**
  8105. * Sets the highlights Exposure value.
  8106. * 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.
  8107. */
  8108. set highlightsExposure(value: number);
  8109. private _midtonesHue;
  8110. private _midtonesDensity;
  8111. private _midtonesSaturation;
  8112. private _midtonesExposure;
  8113. /**
  8114. * Gets the midtones Hue value.
  8115. * 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).
  8116. */
  8117. get midtonesHue(): number;
  8118. /**
  8119. * Sets the midtones Hue value.
  8120. * 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).
  8121. */
  8122. set midtonesHue(value: number);
  8123. /**
  8124. * Gets the midtones Density value.
  8125. * 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.
  8126. * Values less than zero provide a filter of opposite hue.
  8127. */
  8128. get midtonesDensity(): number;
  8129. /**
  8130. * Sets the midtones Density value.
  8131. * 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.
  8132. * Values less than zero provide a filter of opposite hue.
  8133. */
  8134. set midtonesDensity(value: number);
  8135. /**
  8136. * Gets the midtones Saturation value.
  8137. * 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.
  8138. */
  8139. get midtonesSaturation(): number;
  8140. /**
  8141. * Sets the midtones Saturation value.
  8142. * 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.
  8143. */
  8144. set midtonesSaturation(value: number);
  8145. /**
  8146. * Gets the midtones Exposure value.
  8147. * 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.
  8148. */
  8149. get midtonesExposure(): number;
  8150. /**
  8151. * Sets the midtones Exposure value.
  8152. * 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.
  8153. */
  8154. set midtonesExposure(value: number);
  8155. private _shadowsHue;
  8156. private _shadowsDensity;
  8157. private _shadowsSaturation;
  8158. private _shadowsExposure;
  8159. /**
  8160. * Gets the shadows Hue value.
  8161. * 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).
  8162. */
  8163. get shadowsHue(): number;
  8164. /**
  8165. * Sets the shadows Hue value.
  8166. * 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).
  8167. */
  8168. set shadowsHue(value: number);
  8169. /**
  8170. * Gets the shadows Density value.
  8171. * 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.
  8172. * Values less than zero provide a filter of opposite hue.
  8173. */
  8174. get shadowsDensity(): number;
  8175. /**
  8176. * Sets the shadows Density value.
  8177. * 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.
  8178. * Values less than zero provide a filter of opposite hue.
  8179. */
  8180. set shadowsDensity(value: number);
  8181. /**
  8182. * Gets the shadows Saturation value.
  8183. * 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.
  8184. */
  8185. get shadowsSaturation(): number;
  8186. /**
  8187. * Sets the shadows Saturation value.
  8188. * 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.
  8189. */
  8190. set shadowsSaturation(value: number);
  8191. /**
  8192. * Gets the shadows Exposure value.
  8193. * 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.
  8194. */
  8195. get shadowsExposure(): number;
  8196. /**
  8197. * Sets the shadows Exposure value.
  8198. * 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.
  8199. */
  8200. set shadowsExposure(value: number);
  8201. /**
  8202. * Returns the class name
  8203. * @returns The class name
  8204. */
  8205. getClassName(): string;
  8206. /**
  8207. * Binds the color curves to the shader.
  8208. * @param colorCurves The color curve to bind
  8209. * @param effect The effect to bind to
  8210. * @param positiveUniform The positive uniform shader parameter
  8211. * @param neutralUniform The neutral uniform shader parameter
  8212. * @param negativeUniform The negative uniform shader parameter
  8213. */
  8214. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8215. /**
  8216. * Prepare the list of uniforms associated with the ColorCurves effects.
  8217. * @param uniformsList The list of uniforms used in the effect
  8218. */
  8219. static PrepareUniforms(uniformsList: string[]): void;
  8220. /**
  8221. * Returns color grading data based on a hue, density, saturation and exposure value.
  8222. * @param filterHue The hue of the color filter.
  8223. * @param filterDensity The density of the color filter.
  8224. * @param saturation The saturation.
  8225. * @param exposure The exposure.
  8226. * @param result The result data container.
  8227. */
  8228. private getColorGradingDataToRef;
  8229. /**
  8230. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8231. * @param value The input slider value in range [-100,100].
  8232. * @returns Adjusted value.
  8233. */
  8234. private static applyColorGradingSliderNonlinear;
  8235. /**
  8236. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8237. * @param hue The hue (H) input.
  8238. * @param saturation The saturation (S) input.
  8239. * @param brightness The brightness (B) input.
  8240. * @result An RGBA color represented as Vector4.
  8241. */
  8242. private static fromHSBToRef;
  8243. /**
  8244. * Returns a value clamped between min and max
  8245. * @param value The value to clamp
  8246. * @param min The minimum of value
  8247. * @param max The maximum of value
  8248. * @returns The clamped value.
  8249. */
  8250. private static clamp;
  8251. /**
  8252. * Clones the current color curve instance.
  8253. * @return The cloned curves
  8254. */
  8255. clone(): ColorCurves;
  8256. /**
  8257. * Serializes the current color curve instance to a json representation.
  8258. * @return a JSON representation
  8259. */
  8260. serialize(): any;
  8261. /**
  8262. * Parses the color curve from a json representation.
  8263. * @param source the JSON source to parse
  8264. * @return The parsed curves
  8265. */
  8266. static Parse(source: any): ColorCurves;
  8267. }
  8268. }
  8269. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8270. import { Observable } from "babylonjs/Misc/observable";
  8271. import { Nullable } from "babylonjs/types";
  8272. import { Color4 } from "babylonjs/Maths/math.color";
  8273. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8274. import { Effect } from "babylonjs/Materials/effect";
  8275. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8276. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8277. /**
  8278. * Interface to follow in your material defines to integrate easily the
  8279. * Image proccessing functions.
  8280. * @hidden
  8281. */
  8282. export interface IImageProcessingConfigurationDefines {
  8283. IMAGEPROCESSING: boolean;
  8284. VIGNETTE: boolean;
  8285. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8286. VIGNETTEBLENDMODEOPAQUE: boolean;
  8287. TONEMAPPING: boolean;
  8288. TONEMAPPING_ACES: boolean;
  8289. CONTRAST: boolean;
  8290. EXPOSURE: boolean;
  8291. COLORCURVES: boolean;
  8292. COLORGRADING: boolean;
  8293. COLORGRADING3D: boolean;
  8294. SAMPLER3DGREENDEPTH: boolean;
  8295. SAMPLER3DBGRMAP: boolean;
  8296. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8297. }
  8298. /**
  8299. * @hidden
  8300. */
  8301. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8302. IMAGEPROCESSING: boolean;
  8303. VIGNETTE: boolean;
  8304. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8305. VIGNETTEBLENDMODEOPAQUE: boolean;
  8306. TONEMAPPING: boolean;
  8307. TONEMAPPING_ACES: boolean;
  8308. CONTRAST: boolean;
  8309. COLORCURVES: boolean;
  8310. COLORGRADING: boolean;
  8311. COLORGRADING3D: boolean;
  8312. SAMPLER3DGREENDEPTH: boolean;
  8313. SAMPLER3DBGRMAP: boolean;
  8314. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8315. EXPOSURE: boolean;
  8316. constructor();
  8317. }
  8318. /**
  8319. * This groups together the common properties used for image processing either in direct forward pass
  8320. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8321. * or not.
  8322. */
  8323. export class ImageProcessingConfiguration {
  8324. /**
  8325. * Default tone mapping applied in BabylonJS.
  8326. */
  8327. static readonly TONEMAPPING_STANDARD: number;
  8328. /**
  8329. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8330. * to other engines rendering to increase portability.
  8331. */
  8332. static readonly TONEMAPPING_ACES: number;
  8333. /**
  8334. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8335. */
  8336. colorCurves: Nullable<ColorCurves>;
  8337. private _colorCurvesEnabled;
  8338. /**
  8339. * Gets wether the color curves effect is enabled.
  8340. */
  8341. get colorCurvesEnabled(): boolean;
  8342. /**
  8343. * Sets wether the color curves effect is enabled.
  8344. */
  8345. set colorCurvesEnabled(value: boolean);
  8346. private _colorGradingTexture;
  8347. /**
  8348. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8349. */
  8350. get colorGradingTexture(): Nullable<BaseTexture>;
  8351. /**
  8352. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8353. */
  8354. set colorGradingTexture(value: Nullable<BaseTexture>);
  8355. private _colorGradingEnabled;
  8356. /**
  8357. * Gets wether the color grading effect is enabled.
  8358. */
  8359. get colorGradingEnabled(): boolean;
  8360. /**
  8361. * Sets wether the color grading effect is enabled.
  8362. */
  8363. set colorGradingEnabled(value: boolean);
  8364. private _colorGradingWithGreenDepth;
  8365. /**
  8366. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8367. */
  8368. get colorGradingWithGreenDepth(): boolean;
  8369. /**
  8370. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8371. */
  8372. set colorGradingWithGreenDepth(value: boolean);
  8373. private _colorGradingBGR;
  8374. /**
  8375. * Gets wether the color grading texture contains BGR values.
  8376. */
  8377. get colorGradingBGR(): boolean;
  8378. /**
  8379. * Sets wether the color grading texture contains BGR values.
  8380. */
  8381. set colorGradingBGR(value: boolean);
  8382. /** @hidden */
  8383. _exposure: number;
  8384. /**
  8385. * Gets the Exposure used in the effect.
  8386. */
  8387. get exposure(): number;
  8388. /**
  8389. * Sets the Exposure used in the effect.
  8390. */
  8391. set exposure(value: number);
  8392. private _toneMappingEnabled;
  8393. /**
  8394. * Gets wether the tone mapping effect is enabled.
  8395. */
  8396. get toneMappingEnabled(): boolean;
  8397. /**
  8398. * Sets wether the tone mapping effect is enabled.
  8399. */
  8400. set toneMappingEnabled(value: boolean);
  8401. private _toneMappingType;
  8402. /**
  8403. * Gets the type of tone mapping effect.
  8404. */
  8405. get toneMappingType(): number;
  8406. /**
  8407. * Sets the type of tone mapping effect used in BabylonJS.
  8408. */
  8409. set toneMappingType(value: number);
  8410. protected _contrast: number;
  8411. /**
  8412. * Gets the contrast used in the effect.
  8413. */
  8414. get contrast(): number;
  8415. /**
  8416. * Sets the contrast used in the effect.
  8417. */
  8418. set contrast(value: number);
  8419. /**
  8420. * Vignette stretch size.
  8421. */
  8422. vignetteStretch: number;
  8423. /**
  8424. * Vignette centre X Offset.
  8425. */
  8426. vignetteCentreX: number;
  8427. /**
  8428. * Vignette centre Y Offset.
  8429. */
  8430. vignetteCentreY: number;
  8431. /**
  8432. * Vignette weight or intensity of the vignette effect.
  8433. */
  8434. vignetteWeight: number;
  8435. /**
  8436. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8437. * if vignetteEnabled is set to true.
  8438. */
  8439. vignetteColor: Color4;
  8440. /**
  8441. * Camera field of view used by the Vignette effect.
  8442. */
  8443. vignetteCameraFov: number;
  8444. private _vignetteBlendMode;
  8445. /**
  8446. * Gets the vignette blend mode allowing different kind of effect.
  8447. */
  8448. get vignetteBlendMode(): number;
  8449. /**
  8450. * Sets the vignette blend mode allowing different kind of effect.
  8451. */
  8452. set vignetteBlendMode(value: number);
  8453. private _vignetteEnabled;
  8454. /**
  8455. * Gets wether the vignette effect is enabled.
  8456. */
  8457. get vignetteEnabled(): boolean;
  8458. /**
  8459. * Sets wether the vignette effect is enabled.
  8460. */
  8461. set vignetteEnabled(value: boolean);
  8462. private _applyByPostProcess;
  8463. /**
  8464. * Gets wether the image processing is applied through a post process or not.
  8465. */
  8466. get applyByPostProcess(): boolean;
  8467. /**
  8468. * Sets wether the image processing is applied through a post process or not.
  8469. */
  8470. set applyByPostProcess(value: boolean);
  8471. private _isEnabled;
  8472. /**
  8473. * Gets wether the image processing is enabled or not.
  8474. */
  8475. get isEnabled(): boolean;
  8476. /**
  8477. * Sets wether the image processing is enabled or not.
  8478. */
  8479. set isEnabled(value: boolean);
  8480. /**
  8481. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8482. */
  8483. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8484. /**
  8485. * Method called each time the image processing information changes requires to recompile the effect.
  8486. */
  8487. protected _updateParameters(): void;
  8488. /**
  8489. * Gets the current class name.
  8490. * @return "ImageProcessingConfiguration"
  8491. */
  8492. getClassName(): string;
  8493. /**
  8494. * Prepare the list of uniforms associated with the Image Processing effects.
  8495. * @param uniforms The list of uniforms used in the effect
  8496. * @param defines the list of defines currently in use
  8497. */
  8498. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8499. /**
  8500. * Prepare the list of samplers associated with the Image Processing effects.
  8501. * @param samplersList The list of uniforms used in the effect
  8502. * @param defines the list of defines currently in use
  8503. */
  8504. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8505. /**
  8506. * Prepare the list of defines associated to the shader.
  8507. * @param defines the list of defines to complete
  8508. * @param forPostProcess Define if we are currently in post process mode or not
  8509. */
  8510. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8511. /**
  8512. * Returns true if all the image processing information are ready.
  8513. * @returns True if ready, otherwise, false
  8514. */
  8515. isReady(): boolean;
  8516. /**
  8517. * Binds the image processing to the shader.
  8518. * @param effect The effect to bind to
  8519. * @param overrideAspectRatio Override the aspect ratio of the effect
  8520. */
  8521. bind(effect: Effect, overrideAspectRatio?: number): void;
  8522. /**
  8523. * Clones the current image processing instance.
  8524. * @return The cloned image processing
  8525. */
  8526. clone(): ImageProcessingConfiguration;
  8527. /**
  8528. * Serializes the current image processing instance to a json representation.
  8529. * @return a JSON representation
  8530. */
  8531. serialize(): any;
  8532. /**
  8533. * Parses the image processing from a json representation.
  8534. * @param source the JSON source to parse
  8535. * @return The parsed image processing
  8536. */
  8537. static Parse(source: any): ImageProcessingConfiguration;
  8538. private static _VIGNETTEMODE_MULTIPLY;
  8539. private static _VIGNETTEMODE_OPAQUE;
  8540. /**
  8541. * Used to apply the vignette as a mix with the pixel color.
  8542. */
  8543. static get VIGNETTEMODE_MULTIPLY(): number;
  8544. /**
  8545. * Used to apply the vignette as a replacement of the pixel color.
  8546. */
  8547. static get VIGNETTEMODE_OPAQUE(): number;
  8548. }
  8549. }
  8550. declare module "babylonjs/Shaders/postprocess.vertex" {
  8551. /** @hidden */
  8552. export var postprocessVertexShader: {
  8553. name: string;
  8554. shader: string;
  8555. };
  8556. }
  8557. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8558. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8559. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8560. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8561. module "babylonjs/Engines/thinEngine" {
  8562. interface ThinEngine {
  8563. /**
  8564. * Creates a new render target texture
  8565. * @param size defines the size of the texture
  8566. * @param options defines the options used to create the texture
  8567. * @returns a new render target texture stored in an InternalTexture
  8568. */
  8569. createRenderTargetTexture(size: number | {
  8570. width: number;
  8571. height: number;
  8572. layers?: number;
  8573. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8574. /**
  8575. * Creates a depth stencil texture.
  8576. * This is only available in WebGL 2 or with the depth texture extension available.
  8577. * @param size The size of face edge in the texture.
  8578. * @param options The options defining the texture.
  8579. * @returns The texture
  8580. */
  8581. createDepthStencilTexture(size: number | {
  8582. width: number;
  8583. height: number;
  8584. layers?: number;
  8585. }, options: DepthTextureCreationOptions): InternalTexture;
  8586. /** @hidden */
  8587. _createDepthStencilTexture(size: number | {
  8588. width: number;
  8589. height: number;
  8590. layers?: number;
  8591. }, options: DepthTextureCreationOptions): InternalTexture;
  8592. }
  8593. }
  8594. }
  8595. declare module "babylonjs/Maths/math.axis" {
  8596. import { Vector3 } from "babylonjs/Maths/math.vector";
  8597. /** Defines supported spaces */
  8598. export enum Space {
  8599. /** Local (object) space */
  8600. LOCAL = 0,
  8601. /** World space */
  8602. WORLD = 1,
  8603. /** Bone space */
  8604. BONE = 2
  8605. }
  8606. /** Defines the 3 main axes */
  8607. export class Axis {
  8608. /** X axis */
  8609. static X: Vector3;
  8610. /** Y axis */
  8611. static Y: Vector3;
  8612. /** Z axis */
  8613. static Z: Vector3;
  8614. }
  8615. }
  8616. declare module "babylonjs/Cameras/targetCamera" {
  8617. import { Nullable } from "babylonjs/types";
  8618. import { Camera } from "babylonjs/Cameras/camera";
  8619. import { Scene } from "babylonjs/scene";
  8620. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8621. /**
  8622. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8623. * This is the base of the follow, arc rotate cameras and Free camera
  8624. * @see http://doc.babylonjs.com/features/cameras
  8625. */
  8626. export class TargetCamera extends Camera {
  8627. private static _RigCamTransformMatrix;
  8628. private static _TargetTransformMatrix;
  8629. private static _TargetFocalPoint;
  8630. /**
  8631. * Define the current direction the camera is moving to
  8632. */
  8633. cameraDirection: Vector3;
  8634. /**
  8635. * Define the current rotation the camera is rotating to
  8636. */
  8637. cameraRotation: Vector2;
  8638. /**
  8639. * When set, the up vector of the camera will be updated by the rotation of the camera
  8640. */
  8641. updateUpVectorFromRotation: boolean;
  8642. private _tmpQuaternion;
  8643. /**
  8644. * Define the current rotation of the camera
  8645. */
  8646. rotation: Vector3;
  8647. /**
  8648. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8649. */
  8650. rotationQuaternion: Quaternion;
  8651. /**
  8652. * Define the current speed of the camera
  8653. */
  8654. speed: number;
  8655. /**
  8656. * Add constraint to the camera to prevent it to move freely in all directions and
  8657. * around all axis.
  8658. */
  8659. noRotationConstraint: boolean;
  8660. /**
  8661. * Define the current target of the camera as an object or a position.
  8662. */
  8663. lockedTarget: any;
  8664. /** @hidden */
  8665. _currentTarget: Vector3;
  8666. /** @hidden */
  8667. _initialFocalDistance: number;
  8668. /** @hidden */
  8669. _viewMatrix: Matrix;
  8670. /** @hidden */
  8671. _camMatrix: Matrix;
  8672. /** @hidden */
  8673. _cameraTransformMatrix: Matrix;
  8674. /** @hidden */
  8675. _cameraRotationMatrix: Matrix;
  8676. /** @hidden */
  8677. _referencePoint: Vector3;
  8678. /** @hidden */
  8679. _transformedReferencePoint: Vector3;
  8680. protected _globalCurrentTarget: Vector3;
  8681. protected _globalCurrentUpVector: Vector3;
  8682. /** @hidden */
  8683. _reset: () => void;
  8684. private _defaultUp;
  8685. /**
  8686. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8687. * This is the base of the follow, arc rotate cameras and Free camera
  8688. * @see http://doc.babylonjs.com/features/cameras
  8689. * @param name Defines the name of the camera in the scene
  8690. * @param position Defines the start position of the camera in the scene
  8691. * @param scene Defines the scene the camera belongs to
  8692. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8693. */
  8694. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8695. /**
  8696. * Gets the position in front of the camera at a given distance.
  8697. * @param distance The distance from the camera we want the position to be
  8698. * @returns the position
  8699. */
  8700. getFrontPosition(distance: number): Vector3;
  8701. /** @hidden */
  8702. _getLockedTargetPosition(): Nullable<Vector3>;
  8703. private _storedPosition;
  8704. private _storedRotation;
  8705. private _storedRotationQuaternion;
  8706. /**
  8707. * Store current camera state of the camera (fov, position, rotation, etc..)
  8708. * @returns the camera
  8709. */
  8710. storeState(): Camera;
  8711. /**
  8712. * Restored camera state. You must call storeState() first
  8713. * @returns whether it was successful or not
  8714. * @hidden
  8715. */
  8716. _restoreStateValues(): boolean;
  8717. /** @hidden */
  8718. _initCache(): void;
  8719. /** @hidden */
  8720. _updateCache(ignoreParentClass?: boolean): void;
  8721. /** @hidden */
  8722. _isSynchronizedViewMatrix(): boolean;
  8723. /** @hidden */
  8724. _computeLocalCameraSpeed(): number;
  8725. /**
  8726. * Defines the target the camera should look at.
  8727. * @param target Defines the new target as a Vector or a mesh
  8728. */
  8729. setTarget(target: Vector3): void;
  8730. /**
  8731. * Return the current target position of the camera. This value is expressed in local space.
  8732. * @returns the target position
  8733. */
  8734. getTarget(): Vector3;
  8735. /** @hidden */
  8736. _decideIfNeedsToMove(): boolean;
  8737. /** @hidden */
  8738. _updatePosition(): void;
  8739. /** @hidden */
  8740. _checkInputs(): void;
  8741. protected _updateCameraRotationMatrix(): void;
  8742. /**
  8743. * 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)
  8744. * @returns the current camera
  8745. */
  8746. private _rotateUpVectorWithCameraRotationMatrix;
  8747. private _cachedRotationZ;
  8748. private _cachedQuaternionRotationZ;
  8749. /** @hidden */
  8750. _getViewMatrix(): Matrix;
  8751. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8752. /**
  8753. * @hidden
  8754. */
  8755. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8756. /**
  8757. * @hidden
  8758. */
  8759. _updateRigCameras(): void;
  8760. private _getRigCamPositionAndTarget;
  8761. /**
  8762. * Gets the current object class name.
  8763. * @return the class name
  8764. */
  8765. getClassName(): string;
  8766. }
  8767. }
  8768. declare module "babylonjs/Events/keyboardEvents" {
  8769. /**
  8770. * Gather the list of keyboard event types as constants.
  8771. */
  8772. export class KeyboardEventTypes {
  8773. /**
  8774. * The keydown event is fired when a key becomes active (pressed).
  8775. */
  8776. static readonly KEYDOWN: number;
  8777. /**
  8778. * The keyup event is fired when a key has been released.
  8779. */
  8780. static readonly KEYUP: number;
  8781. }
  8782. /**
  8783. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8784. */
  8785. export class KeyboardInfo {
  8786. /**
  8787. * Defines the type of event (KeyboardEventTypes)
  8788. */
  8789. type: number;
  8790. /**
  8791. * Defines the related dom event
  8792. */
  8793. event: KeyboardEvent;
  8794. /**
  8795. * Instantiates a new keyboard info.
  8796. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8797. * @param type Defines the type of event (KeyboardEventTypes)
  8798. * @param event Defines the related dom event
  8799. */
  8800. constructor(
  8801. /**
  8802. * Defines the type of event (KeyboardEventTypes)
  8803. */
  8804. type: number,
  8805. /**
  8806. * Defines the related dom event
  8807. */
  8808. event: KeyboardEvent);
  8809. }
  8810. /**
  8811. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8812. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8813. */
  8814. export class KeyboardInfoPre extends KeyboardInfo {
  8815. /**
  8816. * Defines the type of event (KeyboardEventTypes)
  8817. */
  8818. type: number;
  8819. /**
  8820. * Defines the related dom event
  8821. */
  8822. event: KeyboardEvent;
  8823. /**
  8824. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8825. */
  8826. skipOnPointerObservable: boolean;
  8827. /**
  8828. * Instantiates a new keyboard pre info.
  8829. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8830. * @param type Defines the type of event (KeyboardEventTypes)
  8831. * @param event Defines the related dom event
  8832. */
  8833. constructor(
  8834. /**
  8835. * Defines the type of event (KeyboardEventTypes)
  8836. */
  8837. type: number,
  8838. /**
  8839. * Defines the related dom event
  8840. */
  8841. event: KeyboardEvent);
  8842. }
  8843. }
  8844. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8845. import { Nullable } from "babylonjs/types";
  8846. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8847. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8848. /**
  8849. * Manage the keyboard inputs to control the movement of a free camera.
  8850. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8851. */
  8852. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8853. /**
  8854. * Defines the camera the input is attached to.
  8855. */
  8856. camera: FreeCamera;
  8857. /**
  8858. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8859. */
  8860. keysUp: number[];
  8861. /**
  8862. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8863. */
  8864. keysDown: number[];
  8865. /**
  8866. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8867. */
  8868. keysLeft: number[];
  8869. /**
  8870. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8871. */
  8872. keysRight: number[];
  8873. private _keys;
  8874. private _onCanvasBlurObserver;
  8875. private _onKeyboardObserver;
  8876. private _engine;
  8877. private _scene;
  8878. /**
  8879. * Attach the input controls to a specific dom element to get the input from.
  8880. * @param element Defines the element the controls should be listened from
  8881. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8882. */
  8883. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8884. /**
  8885. * Detach the current controls from the specified dom element.
  8886. * @param element Defines the element to stop listening the inputs from
  8887. */
  8888. detachControl(element: Nullable<HTMLElement>): void;
  8889. /**
  8890. * Update the current camera state depending on the inputs that have been used this frame.
  8891. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8892. */
  8893. checkInputs(): void;
  8894. /**
  8895. * Gets the class name of the current intput.
  8896. * @returns the class name
  8897. */
  8898. getClassName(): string;
  8899. /** @hidden */
  8900. _onLostFocus(): void;
  8901. /**
  8902. * Get the friendly name associated with the input class.
  8903. * @returns the input friendly name
  8904. */
  8905. getSimpleName(): string;
  8906. }
  8907. }
  8908. declare module "babylonjs/Lights/shadowLight" {
  8909. import { Camera } from "babylonjs/Cameras/camera";
  8910. import { Scene } from "babylonjs/scene";
  8911. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8912. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8913. import { Light } from "babylonjs/Lights/light";
  8914. /**
  8915. * Interface describing all the common properties and methods a shadow light needs to implement.
  8916. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8917. * as well as binding the different shadow properties to the effects.
  8918. */
  8919. export interface IShadowLight extends Light {
  8920. /**
  8921. * The light id in the scene (used in scene.findLighById for instance)
  8922. */
  8923. id: string;
  8924. /**
  8925. * The position the shdow will be casted from.
  8926. */
  8927. position: Vector3;
  8928. /**
  8929. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8930. */
  8931. direction: Vector3;
  8932. /**
  8933. * The transformed position. Position of the light in world space taking parenting in account.
  8934. */
  8935. transformedPosition: Vector3;
  8936. /**
  8937. * The transformed direction. Direction of the light in world space taking parenting in account.
  8938. */
  8939. transformedDirection: Vector3;
  8940. /**
  8941. * The friendly name of the light in the scene.
  8942. */
  8943. name: string;
  8944. /**
  8945. * Defines the shadow projection clipping minimum z value.
  8946. */
  8947. shadowMinZ: number;
  8948. /**
  8949. * Defines the shadow projection clipping maximum z value.
  8950. */
  8951. shadowMaxZ: number;
  8952. /**
  8953. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8954. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8955. */
  8956. computeTransformedInformation(): boolean;
  8957. /**
  8958. * Gets the scene the light belongs to.
  8959. * @returns The scene
  8960. */
  8961. getScene(): Scene;
  8962. /**
  8963. * Callback defining a custom Projection Matrix Builder.
  8964. * This can be used to override the default projection matrix computation.
  8965. */
  8966. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8967. /**
  8968. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8969. * @param matrix The materix to updated with the projection information
  8970. * @param viewMatrix The transform matrix of the light
  8971. * @param renderList The list of mesh to render in the map
  8972. * @returns The current light
  8973. */
  8974. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8975. /**
  8976. * Gets the current depth scale used in ESM.
  8977. * @returns The scale
  8978. */
  8979. getDepthScale(): number;
  8980. /**
  8981. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8982. * @returns true if a cube texture needs to be use
  8983. */
  8984. needCube(): boolean;
  8985. /**
  8986. * Detects if the projection matrix requires to be recomputed this frame.
  8987. * @returns true if it requires to be recomputed otherwise, false.
  8988. */
  8989. needProjectionMatrixCompute(): boolean;
  8990. /**
  8991. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8992. */
  8993. forceProjectionMatrixCompute(): void;
  8994. /**
  8995. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8996. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8997. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8998. */
  8999. getShadowDirection(faceIndex?: number): Vector3;
  9000. /**
  9001. * Gets the minZ used for shadow according to both the scene and the light.
  9002. * @param activeCamera The camera we are returning the min for
  9003. * @returns the depth min z
  9004. */
  9005. getDepthMinZ(activeCamera: Camera): number;
  9006. /**
  9007. * Gets the maxZ used for shadow according to both the scene and the light.
  9008. * @param activeCamera The camera we are returning the max for
  9009. * @returns the depth max z
  9010. */
  9011. getDepthMaxZ(activeCamera: Camera): number;
  9012. }
  9013. /**
  9014. * Base implementation IShadowLight
  9015. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9016. */
  9017. export abstract class ShadowLight extends Light implements IShadowLight {
  9018. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9019. protected _position: Vector3;
  9020. protected _setPosition(value: Vector3): void;
  9021. /**
  9022. * Sets the position the shadow will be casted from. Also use as the light position for both
  9023. * point and spot lights.
  9024. */
  9025. get position(): Vector3;
  9026. /**
  9027. * Sets the position the shadow will be casted from. Also use as the light position for both
  9028. * point and spot lights.
  9029. */
  9030. set position(value: Vector3);
  9031. protected _direction: Vector3;
  9032. protected _setDirection(value: Vector3): void;
  9033. /**
  9034. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9035. * Also use as the light direction on spot and directional lights.
  9036. */
  9037. get direction(): Vector3;
  9038. /**
  9039. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9040. * Also use as the light direction on spot and directional lights.
  9041. */
  9042. set direction(value: Vector3);
  9043. protected _shadowMinZ: number;
  9044. /**
  9045. * Gets the shadow projection clipping minimum z value.
  9046. */
  9047. get shadowMinZ(): number;
  9048. /**
  9049. * Sets the shadow projection clipping minimum z value.
  9050. */
  9051. set shadowMinZ(value: number);
  9052. protected _shadowMaxZ: number;
  9053. /**
  9054. * Sets the shadow projection clipping maximum z value.
  9055. */
  9056. get shadowMaxZ(): number;
  9057. /**
  9058. * Gets the shadow projection clipping maximum z value.
  9059. */
  9060. set shadowMaxZ(value: number);
  9061. /**
  9062. * Callback defining a custom Projection Matrix Builder.
  9063. * This can be used to override the default projection matrix computation.
  9064. */
  9065. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9066. /**
  9067. * The transformed position. Position of the light in world space taking parenting in account.
  9068. */
  9069. transformedPosition: Vector3;
  9070. /**
  9071. * The transformed direction. Direction of the light in world space taking parenting in account.
  9072. */
  9073. transformedDirection: Vector3;
  9074. private _needProjectionMatrixCompute;
  9075. /**
  9076. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9077. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9078. */
  9079. computeTransformedInformation(): boolean;
  9080. /**
  9081. * Return the depth scale used for the shadow map.
  9082. * @returns the depth scale.
  9083. */
  9084. getDepthScale(): number;
  9085. /**
  9086. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9087. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9088. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9089. */
  9090. getShadowDirection(faceIndex?: number): Vector3;
  9091. /**
  9092. * Returns the ShadowLight absolute position in the World.
  9093. * @returns the position vector in world space
  9094. */
  9095. getAbsolutePosition(): Vector3;
  9096. /**
  9097. * Sets the ShadowLight direction toward the passed target.
  9098. * @param target The point to target in local space
  9099. * @returns the updated ShadowLight direction
  9100. */
  9101. setDirectionToTarget(target: Vector3): Vector3;
  9102. /**
  9103. * Returns the light rotation in euler definition.
  9104. * @returns the x y z rotation in local space.
  9105. */
  9106. getRotation(): Vector3;
  9107. /**
  9108. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9109. * @returns true if a cube texture needs to be use
  9110. */
  9111. needCube(): boolean;
  9112. /**
  9113. * Detects if the projection matrix requires to be recomputed this frame.
  9114. * @returns true if it requires to be recomputed otherwise, false.
  9115. */
  9116. needProjectionMatrixCompute(): boolean;
  9117. /**
  9118. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9119. */
  9120. forceProjectionMatrixCompute(): void;
  9121. /** @hidden */
  9122. _initCache(): void;
  9123. /** @hidden */
  9124. _isSynchronized(): boolean;
  9125. /**
  9126. * Computes the world matrix of the node
  9127. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9128. * @returns the world matrix
  9129. */
  9130. computeWorldMatrix(force?: boolean): Matrix;
  9131. /**
  9132. * Gets the minZ used for shadow according to both the scene and the light.
  9133. * @param activeCamera The camera we are returning the min for
  9134. * @returns the depth min z
  9135. */
  9136. getDepthMinZ(activeCamera: Camera): number;
  9137. /**
  9138. * Gets the maxZ used for shadow according to both the scene and the light.
  9139. * @param activeCamera The camera we are returning the max for
  9140. * @returns the depth max z
  9141. */
  9142. getDepthMaxZ(activeCamera: Camera): number;
  9143. /**
  9144. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9145. * @param matrix The materix to updated with the projection information
  9146. * @param viewMatrix The transform matrix of the light
  9147. * @param renderList The list of mesh to render in the map
  9148. * @returns The current light
  9149. */
  9150. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9151. }
  9152. }
  9153. declare module "babylonjs/Materials/effectFallbacks" {
  9154. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9155. import { Effect } from "babylonjs/Materials/effect";
  9156. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9157. /**
  9158. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9159. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9160. */
  9161. export class EffectFallbacks implements IEffectFallbacks {
  9162. private _defines;
  9163. private _currentRank;
  9164. private _maxRank;
  9165. private _mesh;
  9166. /**
  9167. * Removes the fallback from the bound mesh.
  9168. */
  9169. unBindMesh(): void;
  9170. /**
  9171. * Adds a fallback on the specified property.
  9172. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9173. * @param define The name of the define in the shader
  9174. */
  9175. addFallback(rank: number, define: string): void;
  9176. /**
  9177. * Sets the mesh to use CPU skinning when needing to fallback.
  9178. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9179. * @param mesh The mesh to use the fallbacks.
  9180. */
  9181. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9182. /**
  9183. * Checks to see if more fallbacks are still availible.
  9184. */
  9185. get hasMoreFallbacks(): boolean;
  9186. /**
  9187. * Removes the defines that should be removed when falling back.
  9188. * @param currentDefines defines the current define statements for the shader.
  9189. * @param effect defines the current effect we try to compile
  9190. * @returns The resulting defines with defines of the current rank removed.
  9191. */
  9192. reduce(currentDefines: string, effect: Effect): string;
  9193. }
  9194. }
  9195. declare module "babylonjs/Materials/materialHelper" {
  9196. import { Nullable } from "babylonjs/types";
  9197. import { Scene } from "babylonjs/scene";
  9198. import { Engine } from "babylonjs/Engines/engine";
  9199. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9200. import { Light } from "babylonjs/Lights/light";
  9201. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9202. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  9203. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9204. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9205. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  9206. /**
  9207. * "Static Class" containing the most commonly used helper while dealing with material for
  9208. * rendering purpose.
  9209. *
  9210. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9211. *
  9212. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9213. */
  9214. export class MaterialHelper {
  9215. /**
  9216. * Bind the current view position to an effect.
  9217. * @param effect The effect to be bound
  9218. * @param scene The scene the eyes position is used from
  9219. */
  9220. static BindEyePosition(effect: Effect, scene: Scene): void;
  9221. /**
  9222. * Helps preparing the defines values about the UVs in used in the effect.
  9223. * UVs are shared as much as we can accross channels in the shaders.
  9224. * @param texture The texture we are preparing the UVs for
  9225. * @param defines The defines to update
  9226. * @param key The channel key "diffuse", "specular"... used in the shader
  9227. */
  9228. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9229. /**
  9230. * Binds a texture matrix value to its corrsponding uniform
  9231. * @param texture The texture to bind the matrix for
  9232. * @param uniformBuffer The uniform buffer receivin the data
  9233. * @param key The channel key "diffuse", "specular"... used in the shader
  9234. */
  9235. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9236. /**
  9237. * Gets the current status of the fog (should it be enabled?)
  9238. * @param mesh defines the mesh to evaluate for fog support
  9239. * @param scene defines the hosting scene
  9240. * @returns true if fog must be enabled
  9241. */
  9242. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9243. /**
  9244. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9245. * @param mesh defines the current mesh
  9246. * @param scene defines the current scene
  9247. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9248. * @param pointsCloud defines if point cloud rendering has to be turned on
  9249. * @param fogEnabled defines if fog has to be turned on
  9250. * @param alphaTest defines if alpha testing has to be turned on
  9251. * @param defines defines the current list of defines
  9252. */
  9253. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9254. /**
  9255. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9256. * @param scene defines the current scene
  9257. * @param engine defines the current engine
  9258. * @param defines specifies the list of active defines
  9259. * @param useInstances defines if instances have to be turned on
  9260. * @param useClipPlane defines if clip plane have to be turned on
  9261. */
  9262. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9263. /**
  9264. * Prepares the defines for bones
  9265. * @param mesh The mesh containing the geometry data we will draw
  9266. * @param defines The defines to update
  9267. */
  9268. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9269. /**
  9270. * Prepares the defines for morph targets
  9271. * @param mesh The mesh containing the geometry data we will draw
  9272. * @param defines The defines to update
  9273. */
  9274. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9275. /**
  9276. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9277. * @param mesh The mesh containing the geometry data we will draw
  9278. * @param defines The defines to update
  9279. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9280. * @param useBones Precise whether bones should be used or not (override mesh info)
  9281. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9282. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9283. * @returns false if defines are considered not dirty and have not been checked
  9284. */
  9285. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9286. /**
  9287. * Prepares the defines related to multiview
  9288. * @param scene The scene we are intending to draw
  9289. * @param defines The defines to update
  9290. */
  9291. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9292. /**
  9293. * Prepares the defines related to the light information passed in parameter
  9294. * @param scene The scene we are intending to draw
  9295. * @param mesh The mesh the effect is compiling for
  9296. * @param light The light the effect is compiling for
  9297. * @param lightIndex The index of the light
  9298. * @param defines The defines to update
  9299. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9300. * @param state Defines the current state regarding what is needed (normals, etc...)
  9301. */
  9302. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9303. needNormals: boolean;
  9304. needRebuild: boolean;
  9305. shadowEnabled: boolean;
  9306. specularEnabled: boolean;
  9307. lightmapMode: boolean;
  9308. }): void;
  9309. /**
  9310. * Prepares the defines related to the light information passed in parameter
  9311. * @param scene The scene we are intending to draw
  9312. * @param mesh The mesh the effect is compiling for
  9313. * @param defines The defines to update
  9314. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9315. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9316. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9317. * @returns true if normals will be required for the rest of the effect
  9318. */
  9319. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9320. /**
  9321. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9322. * @param lightIndex defines the light index
  9323. * @param uniformsList The uniform list
  9324. * @param samplersList The sampler list
  9325. * @param projectedLightTexture defines if projected texture must be used
  9326. * @param uniformBuffersList defines an optional list of uniform buffers
  9327. */
  9328. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9329. /**
  9330. * Prepares the uniforms and samplers list to be used in the effect
  9331. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9332. * @param samplersList The sampler list
  9333. * @param defines The defines helping in the list generation
  9334. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9335. */
  9336. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9337. /**
  9338. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9339. * @param defines The defines to update while falling back
  9340. * @param fallbacks The authorized effect fallbacks
  9341. * @param maxSimultaneousLights The maximum number of lights allowed
  9342. * @param rank the current rank of the Effect
  9343. * @returns The newly affected rank
  9344. */
  9345. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9346. private static _TmpMorphInfluencers;
  9347. /**
  9348. * Prepares the list of attributes required for morph targets according to the effect defines.
  9349. * @param attribs The current list of supported attribs
  9350. * @param mesh The mesh to prepare the morph targets attributes for
  9351. * @param influencers The number of influencers
  9352. */
  9353. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9354. /**
  9355. * Prepares the list of attributes required for morph targets according to the effect defines.
  9356. * @param attribs The current list of supported attribs
  9357. * @param mesh The mesh to prepare the morph targets attributes for
  9358. * @param defines The current Defines of the effect
  9359. */
  9360. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9361. /**
  9362. * Prepares the list of attributes required for bones according to the effect defines.
  9363. * @param attribs The current list of supported attribs
  9364. * @param mesh The mesh to prepare the bones attributes for
  9365. * @param defines The current Defines of the effect
  9366. * @param fallbacks The current efffect fallback strategy
  9367. */
  9368. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9369. /**
  9370. * Check and prepare the list of attributes required for instances according to the effect defines.
  9371. * @param attribs The current list of supported attribs
  9372. * @param defines The current MaterialDefines of the effect
  9373. */
  9374. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9375. /**
  9376. * Add the list of attributes required for instances to the attribs array.
  9377. * @param attribs The current list of supported attribs
  9378. */
  9379. static PushAttributesForInstances(attribs: string[]): void;
  9380. /**
  9381. * Binds the light information to the effect.
  9382. * @param light The light containing the generator
  9383. * @param effect The effect we are binding the data to
  9384. * @param lightIndex The light index in the effect used to render
  9385. */
  9386. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9387. /**
  9388. * Binds the lights information from the scene to the effect for the given mesh.
  9389. * @param light Light to bind
  9390. * @param lightIndex Light index
  9391. * @param scene The scene where the light belongs to
  9392. * @param effect The effect we are binding the data to
  9393. * @param useSpecular Defines if specular is supported
  9394. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9395. */
  9396. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9397. /**
  9398. * Binds the lights information from the scene to the effect for the given mesh.
  9399. * @param scene The scene the lights belongs to
  9400. * @param mesh The mesh we are binding the information to render
  9401. * @param effect The effect we are binding the data to
  9402. * @param defines The generated defines for the effect
  9403. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9404. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9405. */
  9406. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9407. private static _tempFogColor;
  9408. /**
  9409. * Binds the fog information from the scene to the effect for the given mesh.
  9410. * @param scene The scene the lights belongs to
  9411. * @param mesh The mesh we are binding the information to render
  9412. * @param effect The effect we are binding the data to
  9413. * @param linearSpace Defines if the fog effect is applied in linear space
  9414. */
  9415. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9416. /**
  9417. * Binds the bones information from the mesh to the effect.
  9418. * @param mesh The mesh we are binding the information to render
  9419. * @param effect The effect we are binding the data to
  9420. */
  9421. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9422. /**
  9423. * Binds the morph targets information from the mesh to the effect.
  9424. * @param abstractMesh The mesh we are binding the information to render
  9425. * @param effect The effect we are binding the data to
  9426. */
  9427. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9428. /**
  9429. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9430. * @param defines The generated defines used in the effect
  9431. * @param effect The effect we are binding the data to
  9432. * @param scene The scene we are willing to render with logarithmic scale for
  9433. */
  9434. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9435. /**
  9436. * Binds the clip plane information from the scene to the effect.
  9437. * @param scene The scene the clip plane information are extracted from
  9438. * @param effect The effect we are binding the data to
  9439. */
  9440. static BindClipPlane(effect: Effect, scene: Scene): void;
  9441. }
  9442. }
  9443. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9444. /** @hidden */
  9445. export var packingFunctions: {
  9446. name: string;
  9447. shader: string;
  9448. };
  9449. }
  9450. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9451. /** @hidden */
  9452. export var clipPlaneFragmentDeclaration: {
  9453. name: string;
  9454. shader: string;
  9455. };
  9456. }
  9457. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9458. /** @hidden */
  9459. export var clipPlaneFragment: {
  9460. name: string;
  9461. shader: string;
  9462. };
  9463. }
  9464. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9465. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9466. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9467. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9468. /** @hidden */
  9469. export var shadowMapPixelShader: {
  9470. name: string;
  9471. shader: string;
  9472. };
  9473. }
  9474. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9475. /** @hidden */
  9476. export var bonesDeclaration: {
  9477. name: string;
  9478. shader: string;
  9479. };
  9480. }
  9481. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9482. /** @hidden */
  9483. export var morphTargetsVertexGlobalDeclaration: {
  9484. name: string;
  9485. shader: string;
  9486. };
  9487. }
  9488. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9489. /** @hidden */
  9490. export var morphTargetsVertexDeclaration: {
  9491. name: string;
  9492. shader: string;
  9493. };
  9494. }
  9495. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9496. /** @hidden */
  9497. export var instancesDeclaration: {
  9498. name: string;
  9499. shader: string;
  9500. };
  9501. }
  9502. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9503. /** @hidden */
  9504. export var helperFunctions: {
  9505. name: string;
  9506. shader: string;
  9507. };
  9508. }
  9509. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9510. /** @hidden */
  9511. export var clipPlaneVertexDeclaration: {
  9512. name: string;
  9513. shader: string;
  9514. };
  9515. }
  9516. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9517. /** @hidden */
  9518. export var morphTargetsVertex: {
  9519. name: string;
  9520. shader: string;
  9521. };
  9522. }
  9523. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9524. /** @hidden */
  9525. export var instancesVertex: {
  9526. name: string;
  9527. shader: string;
  9528. };
  9529. }
  9530. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9531. /** @hidden */
  9532. export var bonesVertex: {
  9533. name: string;
  9534. shader: string;
  9535. };
  9536. }
  9537. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9538. /** @hidden */
  9539. export var clipPlaneVertex: {
  9540. name: string;
  9541. shader: string;
  9542. };
  9543. }
  9544. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9545. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9546. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9547. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9548. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9549. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9550. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9551. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9552. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9553. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9554. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9555. /** @hidden */
  9556. export var shadowMapVertexShader: {
  9557. name: string;
  9558. shader: string;
  9559. };
  9560. }
  9561. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9562. /** @hidden */
  9563. export var depthBoxBlurPixelShader: {
  9564. name: string;
  9565. shader: string;
  9566. };
  9567. }
  9568. declare module "babylonjs/Culling/ray" {
  9569. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  9570. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9571. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9572. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9573. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  9574. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  9575. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  9576. import { Plane } from "babylonjs/Maths/math.plane";
  9577. /**
  9578. * Class representing a ray with position and direction
  9579. */
  9580. export class Ray {
  9581. /** origin point */
  9582. origin: Vector3;
  9583. /** direction */
  9584. direction: Vector3;
  9585. /** length of the ray */
  9586. length: number;
  9587. private static readonly TmpVector3;
  9588. private _tmpRay;
  9589. /**
  9590. * Creates a new ray
  9591. * @param origin origin point
  9592. * @param direction direction
  9593. * @param length length of the ray
  9594. */
  9595. constructor(
  9596. /** origin point */
  9597. origin: Vector3,
  9598. /** direction */
  9599. direction: Vector3,
  9600. /** length of the ray */
  9601. length?: number);
  9602. /**
  9603. * Checks if the ray intersects a box
  9604. * @param minimum bound of the box
  9605. * @param maximum bound of the box
  9606. * @param intersectionTreshold extra extend to be added to the box in all direction
  9607. * @returns if the box was hit
  9608. */
  9609. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9610. /**
  9611. * Checks if the ray intersects a box
  9612. * @param box the bounding box to check
  9613. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9614. * @returns if the box was hit
  9615. */
  9616. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9617. /**
  9618. * If the ray hits a sphere
  9619. * @param sphere the bounding sphere to check
  9620. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9621. * @returns true if it hits the sphere
  9622. */
  9623. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9624. /**
  9625. * If the ray hits a triange
  9626. * @param vertex0 triangle vertex
  9627. * @param vertex1 triangle vertex
  9628. * @param vertex2 triangle vertex
  9629. * @returns intersection information if hit
  9630. */
  9631. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9632. /**
  9633. * Checks if ray intersects a plane
  9634. * @param plane the plane to check
  9635. * @returns the distance away it was hit
  9636. */
  9637. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9638. /**
  9639. * Calculate the intercept of a ray on a given axis
  9640. * @param axis to check 'x' | 'y' | 'z'
  9641. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  9642. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  9643. */
  9644. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  9645. /**
  9646. * Checks if ray intersects a mesh
  9647. * @param mesh the mesh to check
  9648. * @param fastCheck if only the bounding box should checked
  9649. * @returns picking info of the intersecton
  9650. */
  9651. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9652. /**
  9653. * Checks if ray intersects a mesh
  9654. * @param meshes the meshes to check
  9655. * @param fastCheck if only the bounding box should checked
  9656. * @param results array to store result in
  9657. * @returns Array of picking infos
  9658. */
  9659. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9660. private _comparePickingInfo;
  9661. private static smallnum;
  9662. private static rayl;
  9663. /**
  9664. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9665. * @param sega the first point of the segment to test the intersection against
  9666. * @param segb the second point of the segment to test the intersection against
  9667. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9668. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9669. */
  9670. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9671. /**
  9672. * Update the ray from viewport position
  9673. * @param x position
  9674. * @param y y position
  9675. * @param viewportWidth viewport width
  9676. * @param viewportHeight viewport height
  9677. * @param world world matrix
  9678. * @param view view matrix
  9679. * @param projection projection matrix
  9680. * @returns this ray updated
  9681. */
  9682. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9683. /**
  9684. * Creates a ray with origin and direction of 0,0,0
  9685. * @returns the new ray
  9686. */
  9687. static Zero(): Ray;
  9688. /**
  9689. * Creates a new ray from screen space and viewport
  9690. * @param x position
  9691. * @param y y position
  9692. * @param viewportWidth viewport width
  9693. * @param viewportHeight viewport height
  9694. * @param world world matrix
  9695. * @param view view matrix
  9696. * @param projection projection matrix
  9697. * @returns new ray
  9698. */
  9699. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9700. /**
  9701. * 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
  9702. * transformed to the given world matrix.
  9703. * @param origin The origin point
  9704. * @param end The end point
  9705. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9706. * @returns the new ray
  9707. */
  9708. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9709. /**
  9710. * Transforms a ray by a matrix
  9711. * @param ray ray to transform
  9712. * @param matrix matrix to apply
  9713. * @returns the resulting new ray
  9714. */
  9715. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9716. /**
  9717. * Transforms a ray by a matrix
  9718. * @param ray ray to transform
  9719. * @param matrix matrix to apply
  9720. * @param result ray to store result in
  9721. */
  9722. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9723. /**
  9724. * Unproject a ray from screen space to object space
  9725. * @param sourceX defines the screen space x coordinate to use
  9726. * @param sourceY defines the screen space y coordinate to use
  9727. * @param viewportWidth defines the current width of the viewport
  9728. * @param viewportHeight defines the current height of the viewport
  9729. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9730. * @param view defines the view matrix to use
  9731. * @param projection defines the projection matrix to use
  9732. */
  9733. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  9734. }
  9735. /**
  9736. * Type used to define predicate used to select faces when a mesh intersection is detected
  9737. */
  9738. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  9739. module "babylonjs/scene" {
  9740. interface Scene {
  9741. /** @hidden */
  9742. _tempPickingRay: Nullable<Ray>;
  9743. /** @hidden */
  9744. _cachedRayForTransform: Ray;
  9745. /** @hidden */
  9746. _pickWithRayInverseMatrix: Matrix;
  9747. /** @hidden */
  9748. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  9749. /** @hidden */
  9750. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  9751. }
  9752. }
  9753. }
  9754. declare module "babylonjs/sceneComponent" {
  9755. import { Scene } from "babylonjs/scene";
  9756. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9757. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9758. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  9759. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  9760. import { Nullable } from "babylonjs/types";
  9761. import { Camera } from "babylonjs/Cameras/camera";
  9762. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9763. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9764. import { AbstractScene } from "babylonjs/abstractScene";
  9765. import { Mesh } from "babylonjs/Meshes/mesh";
  9766. /**
  9767. * Groups all the scene component constants in one place to ease maintenance.
  9768. * @hidden
  9769. */
  9770. export class SceneComponentConstants {
  9771. static readonly NAME_EFFECTLAYER: string;
  9772. static readonly NAME_LAYER: string;
  9773. static readonly NAME_LENSFLARESYSTEM: string;
  9774. static readonly NAME_BOUNDINGBOXRENDERER: string;
  9775. static readonly NAME_PARTICLESYSTEM: string;
  9776. static readonly NAME_GAMEPAD: string;
  9777. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  9778. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  9779. static readonly NAME_DEPTHRENDERER: string;
  9780. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  9781. static readonly NAME_SPRITE: string;
  9782. static readonly NAME_OUTLINERENDERER: string;
  9783. static readonly NAME_PROCEDURALTEXTURE: string;
  9784. static readonly NAME_SHADOWGENERATOR: string;
  9785. static readonly NAME_OCTREE: string;
  9786. static readonly NAME_PHYSICSENGINE: string;
  9787. static readonly NAME_AUDIO: string;
  9788. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  9789. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9790. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  9791. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9792. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  9793. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  9794. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  9795. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  9796. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  9797. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  9798. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  9799. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  9800. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  9801. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  9802. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  9803. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  9804. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  9805. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  9806. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  9807. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  9808. static readonly STEP_AFTERRENDER_AUDIO: number;
  9809. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  9810. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  9811. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  9812. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  9813. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  9814. static readonly STEP_POINTERMOVE_SPRITE: number;
  9815. static readonly STEP_POINTERDOWN_SPRITE: number;
  9816. static readonly STEP_POINTERUP_SPRITE: number;
  9817. }
  9818. /**
  9819. * This represents a scene component.
  9820. *
  9821. * This is used to decouple the dependency the scene is having on the different workloads like
  9822. * layers, post processes...
  9823. */
  9824. export interface ISceneComponent {
  9825. /**
  9826. * The name of the component. Each component must have a unique name.
  9827. */
  9828. name: string;
  9829. /**
  9830. * The scene the component belongs to.
  9831. */
  9832. scene: Scene;
  9833. /**
  9834. * Register the component to one instance of a scene.
  9835. */
  9836. register(): void;
  9837. /**
  9838. * Rebuilds the elements related to this component in case of
  9839. * context lost for instance.
  9840. */
  9841. rebuild(): void;
  9842. /**
  9843. * Disposes the component and the associated ressources.
  9844. */
  9845. dispose(): void;
  9846. }
  9847. /**
  9848. * This represents a SERIALIZABLE scene component.
  9849. *
  9850. * This extends Scene Component to add Serialization methods on top.
  9851. */
  9852. export interface ISceneSerializableComponent extends ISceneComponent {
  9853. /**
  9854. * Adds all the elements from the container to the scene
  9855. * @param container the container holding the elements
  9856. */
  9857. addFromContainer(container: AbstractScene): void;
  9858. /**
  9859. * Removes all the elements in the container from the scene
  9860. * @param container contains the elements to remove
  9861. * @param dispose if the removed element should be disposed (default: false)
  9862. */
  9863. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  9864. /**
  9865. * Serializes the component data to the specified json object
  9866. * @param serializationObject The object to serialize to
  9867. */
  9868. serialize(serializationObject: any): void;
  9869. }
  9870. /**
  9871. * Strong typing of a Mesh related stage step action
  9872. */
  9873. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  9874. /**
  9875. * Strong typing of a Evaluate Sub Mesh related stage step action
  9876. */
  9877. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  9878. /**
  9879. * Strong typing of a Active Mesh related stage step action
  9880. */
  9881. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  9882. /**
  9883. * Strong typing of a Camera related stage step action
  9884. */
  9885. export type CameraStageAction = (camera: Camera) => void;
  9886. /**
  9887. * Strong typing of a Camera Frame buffer related stage step action
  9888. */
  9889. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  9890. /**
  9891. * Strong typing of a Render Target related stage step action
  9892. */
  9893. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  9894. /**
  9895. * Strong typing of a RenderingGroup related stage step action
  9896. */
  9897. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  9898. /**
  9899. * Strong typing of a Mesh Render related stage step action
  9900. */
  9901. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  9902. /**
  9903. * Strong typing of a simple stage step action
  9904. */
  9905. export type SimpleStageAction = () => void;
  9906. /**
  9907. * Strong typing of a render target action.
  9908. */
  9909. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  9910. /**
  9911. * Strong typing of a pointer move action.
  9912. */
  9913. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  9914. /**
  9915. * Strong typing of a pointer up/down action.
  9916. */
  9917. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  9918. /**
  9919. * Representation of a stage in the scene (Basically a list of ordered steps)
  9920. * @hidden
  9921. */
  9922. export class Stage<T extends Function> extends Array<{
  9923. index: number;
  9924. component: ISceneComponent;
  9925. action: T;
  9926. }> {
  9927. /**
  9928. * Hide ctor from the rest of the world.
  9929. * @param items The items to add.
  9930. */
  9931. private constructor();
  9932. /**
  9933. * Creates a new Stage.
  9934. * @returns A new instance of a Stage
  9935. */
  9936. static Create<T extends Function>(): Stage<T>;
  9937. /**
  9938. * Registers a step in an ordered way in the targeted stage.
  9939. * @param index Defines the position to register the step in
  9940. * @param component Defines the component attached to the step
  9941. * @param action Defines the action to launch during the step
  9942. */
  9943. registerStep(index: number, component: ISceneComponent, action: T): void;
  9944. /**
  9945. * Clears all the steps from the stage.
  9946. */
  9947. clear(): void;
  9948. }
  9949. }
  9950. declare module "babylonjs/Sprites/spriteSceneComponent" {
  9951. import { Nullable } from "babylonjs/types";
  9952. import { Observable } from "babylonjs/Misc/observable";
  9953. import { Scene } from "babylonjs/scene";
  9954. import { Sprite } from "babylonjs/Sprites/sprite";
  9955. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  9956. import { Ray } from "babylonjs/Culling/ray";
  9957. import { Camera } from "babylonjs/Cameras/camera";
  9958. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9959. import { ISceneComponent } from "babylonjs/sceneComponent";
  9960. module "babylonjs/scene" {
  9961. interface Scene {
  9962. /** @hidden */
  9963. _pointerOverSprite: Nullable<Sprite>;
  9964. /** @hidden */
  9965. _pickedDownSprite: Nullable<Sprite>;
  9966. /** @hidden */
  9967. _tempSpritePickingRay: Nullable<Ray>;
  9968. /**
  9969. * All of the sprite managers added to this scene
  9970. * @see http://doc.babylonjs.com/babylon101/sprites
  9971. */
  9972. spriteManagers: Array<ISpriteManager>;
  9973. /**
  9974. * An event triggered when sprites rendering is about to start
  9975. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9976. */
  9977. onBeforeSpritesRenderingObservable: Observable<Scene>;
  9978. /**
  9979. * An event triggered when sprites rendering is done
  9980. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9981. */
  9982. onAfterSpritesRenderingObservable: Observable<Scene>;
  9983. /** @hidden */
  9984. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9985. /** Launch a ray to try to pick a sprite in the scene
  9986. * @param x position on screen
  9987. * @param y position on screen
  9988. * @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
  9989. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9990. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9991. * @returns a PickingInfo
  9992. */
  9993. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9994. /** Use the given ray to pick a sprite in the scene
  9995. * @param ray The ray (in world space) to use to pick meshes
  9996. * @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
  9997. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9998. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9999. * @returns a PickingInfo
  10000. */
  10001. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10002. /** @hidden */
  10003. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10004. /** Launch a ray to try to pick sprites in the scene
  10005. * @param x position on screen
  10006. * @param y position on screen
  10007. * @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
  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 array
  10010. */
  10011. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10012. /** Use the given ray to pick sprites 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 camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10016. * @returns a PickingInfo array
  10017. */
  10018. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10019. /**
  10020. * Force the sprite under the pointer
  10021. * @param sprite defines the sprite to use
  10022. */
  10023. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10024. /**
  10025. * Gets the sprite under the pointer
  10026. * @returns a Sprite or null if no sprite is under the pointer
  10027. */
  10028. getPointerOverSprite(): Nullable<Sprite>;
  10029. }
  10030. }
  10031. /**
  10032. * Defines the sprite scene component responsible to manage sprites
  10033. * in a given scene.
  10034. */
  10035. export class SpriteSceneComponent implements ISceneComponent {
  10036. /**
  10037. * The component name helpfull to identify the component in the list of scene components.
  10038. */
  10039. readonly name: string;
  10040. /**
  10041. * The scene the component belongs to.
  10042. */
  10043. scene: Scene;
  10044. /** @hidden */
  10045. private _spritePredicate;
  10046. /**
  10047. * Creates a new instance of the component for the given scene
  10048. * @param scene Defines the scene to register the component in
  10049. */
  10050. constructor(scene: Scene);
  10051. /**
  10052. * Registers the component in a given scene
  10053. */
  10054. register(): void;
  10055. /**
  10056. * Rebuilds the elements related to this component in case of
  10057. * context lost for instance.
  10058. */
  10059. rebuild(): void;
  10060. /**
  10061. * Disposes the component and the associated ressources.
  10062. */
  10063. dispose(): void;
  10064. private _pickSpriteButKeepRay;
  10065. private _pointerMove;
  10066. private _pointerDown;
  10067. private _pointerUp;
  10068. }
  10069. }
  10070. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  10071. /** @hidden */
  10072. export var fogFragmentDeclaration: {
  10073. name: string;
  10074. shader: string;
  10075. };
  10076. }
  10077. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  10078. /** @hidden */
  10079. export var fogFragment: {
  10080. name: string;
  10081. shader: string;
  10082. };
  10083. }
  10084. declare module "babylonjs/Shaders/sprites.fragment" {
  10085. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  10086. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  10087. /** @hidden */
  10088. export var spritesPixelShader: {
  10089. name: string;
  10090. shader: string;
  10091. };
  10092. }
  10093. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  10094. /** @hidden */
  10095. export var fogVertexDeclaration: {
  10096. name: string;
  10097. shader: string;
  10098. };
  10099. }
  10100. declare module "babylonjs/Shaders/sprites.vertex" {
  10101. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  10102. /** @hidden */
  10103. export var spritesVertexShader: {
  10104. name: string;
  10105. shader: string;
  10106. };
  10107. }
  10108. declare module "babylonjs/Sprites/spriteManager" {
  10109. import { IDisposable, Scene } from "babylonjs/scene";
  10110. import { Nullable } from "babylonjs/types";
  10111. import { Observable } from "babylonjs/Misc/observable";
  10112. import { Sprite } from "babylonjs/Sprites/sprite";
  10113. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10114. import { Camera } from "babylonjs/Cameras/camera";
  10115. import { Texture } from "babylonjs/Materials/Textures/texture";
  10116. import "babylonjs/Shaders/sprites.fragment";
  10117. import "babylonjs/Shaders/sprites.vertex";
  10118. import { Ray } from "babylonjs/Culling/ray";
  10119. /**
  10120. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10121. */
  10122. export interface ISpriteManager extends IDisposable {
  10123. /**
  10124. * Restricts the camera to viewing objects with the same layerMask.
  10125. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10126. */
  10127. layerMask: number;
  10128. /**
  10129. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10130. */
  10131. isPickable: boolean;
  10132. /**
  10133. * Specifies the rendering group id for this mesh (0 by default)
  10134. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10135. */
  10136. renderingGroupId: number;
  10137. /**
  10138. * Defines the list of sprites managed by the manager.
  10139. */
  10140. sprites: Array<Sprite>;
  10141. /**
  10142. * Tests the intersection of a sprite with a specific ray.
  10143. * @param ray The ray we are sending to test the collision
  10144. * @param camera The camera space we are sending rays in
  10145. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10146. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  10147. * @returns picking info or null.
  10148. */
  10149. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10150. /**
  10151. * Intersects the sprites with a ray
  10152. * @param ray defines the ray to intersect with
  10153. * @param camera defines the current active camera
  10154. * @param predicate defines a predicate used to select candidate sprites
  10155. * @returns null if no hit or a PickingInfo array
  10156. */
  10157. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10158. /**
  10159. * Renders the list of sprites on screen.
  10160. */
  10161. render(): void;
  10162. }
  10163. /**
  10164. * Class used to manage multiple sprites on the same spritesheet
  10165. * @see http://doc.babylonjs.com/babylon101/sprites
  10166. */
  10167. export class SpriteManager implements ISpriteManager {
  10168. /** defines the manager's name */
  10169. name: string;
  10170. /** Gets the list of sprites */
  10171. sprites: Sprite[];
  10172. /** Gets or sets the rendering group id (0 by default) */
  10173. renderingGroupId: number;
  10174. /** Gets or sets camera layer mask */
  10175. layerMask: number;
  10176. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10177. fogEnabled: boolean;
  10178. /** Gets or sets a boolean indicating if the sprites are pickable */
  10179. isPickable: boolean;
  10180. /** Defines the default width of a cell in the spritesheet */
  10181. cellWidth: number;
  10182. /** Defines the default height of a cell in the spritesheet */
  10183. cellHeight: number;
  10184. /** Associative array from JSON sprite data file */
  10185. private _cellData;
  10186. /** Array of sprite names from JSON sprite data file */
  10187. private _spriteMap;
  10188. /** True when packed cell data from JSON file is ready*/
  10189. private _packedAndReady;
  10190. /**
  10191. * An event triggered when the manager is disposed.
  10192. */
  10193. onDisposeObservable: Observable<SpriteManager>;
  10194. private _onDisposeObserver;
  10195. /**
  10196. * Callback called when the manager is disposed
  10197. */
  10198. set onDispose(callback: () => void);
  10199. private _capacity;
  10200. private _fromPacked;
  10201. private _spriteTexture;
  10202. private _epsilon;
  10203. private _scene;
  10204. private _vertexData;
  10205. private _buffer;
  10206. private _vertexBuffers;
  10207. private _indexBuffer;
  10208. private _effectBase;
  10209. private _effectFog;
  10210. /**
  10211. * Gets or sets the spritesheet texture
  10212. */
  10213. get texture(): Texture;
  10214. set texture(value: Texture);
  10215. /**
  10216. * Creates a new sprite manager
  10217. * @param name defines the manager's name
  10218. * @param imgUrl defines the sprite sheet url
  10219. * @param capacity defines the maximum allowed number of sprites
  10220. * @param cellSize defines the size of a sprite cell
  10221. * @param scene defines the hosting scene
  10222. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10223. * @param samplingMode defines the smapling mode to use with spritesheet
  10224. * @param fromPacked set to false; do not alter
  10225. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10226. */
  10227. constructor(
  10228. /** defines the manager's name */
  10229. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10230. private _makePacked;
  10231. private _appendSpriteVertex;
  10232. /**
  10233. * Intersects the sprites with a ray
  10234. * @param ray defines the ray to intersect with
  10235. * @param camera defines the current active camera
  10236. * @param predicate defines a predicate used to select candidate sprites
  10237. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  10238. * @returns null if no hit or a PickingInfo
  10239. */
  10240. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10241. /**
  10242. * Intersects the sprites with a ray
  10243. * @param ray defines the ray to intersect with
  10244. * @param camera defines the current active camera
  10245. * @param predicate defines a predicate used to select candidate sprites
  10246. * @returns null if no hit or a PickingInfo array
  10247. */
  10248. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10249. /**
  10250. * Render all child sprites
  10251. */
  10252. render(): void;
  10253. /**
  10254. * Release associated resources
  10255. */
  10256. dispose(): void;
  10257. }
  10258. }
  10259. declare module "babylonjs/Misc/gradients" {
  10260. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  10261. /** Interface used by value gradients (color, factor, ...) */
  10262. export interface IValueGradient {
  10263. /**
  10264. * Gets or sets the gradient value (between 0 and 1)
  10265. */
  10266. gradient: number;
  10267. }
  10268. /** Class used to store color4 gradient */
  10269. export class ColorGradient implements IValueGradient {
  10270. /**
  10271. * Gets or sets the gradient value (between 0 and 1)
  10272. */
  10273. gradient: number;
  10274. /**
  10275. * Gets or sets first associated color
  10276. */
  10277. color1: Color4;
  10278. /**
  10279. * Gets or sets second associated color
  10280. */
  10281. color2?: Color4;
  10282. /**
  10283. * Will get a color picked randomly between color1 and color2.
  10284. * If color2 is undefined then color1 will be used
  10285. * @param result defines the target Color4 to store the result in
  10286. */
  10287. getColorToRef(result: Color4): void;
  10288. }
  10289. /** Class used to store color 3 gradient */
  10290. export class Color3Gradient implements IValueGradient {
  10291. /**
  10292. * Gets or sets the gradient value (between 0 and 1)
  10293. */
  10294. gradient: number;
  10295. /**
  10296. * Gets or sets the associated color
  10297. */
  10298. color: Color3;
  10299. }
  10300. /** Class used to store factor gradient */
  10301. export class FactorGradient implements IValueGradient {
  10302. /**
  10303. * Gets or sets the gradient value (between 0 and 1)
  10304. */
  10305. gradient: number;
  10306. /**
  10307. * Gets or sets first associated factor
  10308. */
  10309. factor1: number;
  10310. /**
  10311. * Gets or sets second associated factor
  10312. */
  10313. factor2?: number;
  10314. /**
  10315. * Will get a number picked randomly between factor1 and factor2.
  10316. * If factor2 is undefined then factor1 will be used
  10317. * @returns the picked number
  10318. */
  10319. getFactor(): number;
  10320. }
  10321. /**
  10322. * Helper used to simplify some generic gradient tasks
  10323. */
  10324. export class GradientHelper {
  10325. /**
  10326. * Gets the current gradient from an array of IValueGradient
  10327. * @param ratio defines the current ratio to get
  10328. * @param gradients defines the array of IValueGradient
  10329. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  10330. */
  10331. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  10332. }
  10333. }
  10334. declare module "babylonjs/Maths/math.size" {
  10335. /**
  10336. * Interface for the size containing width and height
  10337. */
  10338. export interface ISize {
  10339. /**
  10340. * Width
  10341. */
  10342. width: number;
  10343. /**
  10344. * Heighht
  10345. */
  10346. height: number;
  10347. }
  10348. /**
  10349. * Size containing widht and height
  10350. */
  10351. export class Size implements ISize {
  10352. /**
  10353. * Width
  10354. */
  10355. width: number;
  10356. /**
  10357. * Height
  10358. */
  10359. height: number;
  10360. /**
  10361. * Creates a Size object from the given width and height (floats).
  10362. * @param width width of the new size
  10363. * @param height height of the new size
  10364. */
  10365. constructor(width: number, height: number);
  10366. /**
  10367. * Returns a string with the Size width and height
  10368. * @returns a string with the Size width and height
  10369. */
  10370. toString(): string;
  10371. /**
  10372. * "Size"
  10373. * @returns the string "Size"
  10374. */
  10375. getClassName(): string;
  10376. /**
  10377. * Returns the Size hash code.
  10378. * @returns a hash code for a unique width and height
  10379. */
  10380. getHashCode(): number;
  10381. /**
  10382. * Updates the current size from the given one.
  10383. * @param src the given size
  10384. */
  10385. copyFrom(src: Size): void;
  10386. /**
  10387. * Updates in place the current Size from the given floats.
  10388. * @param width width of the new size
  10389. * @param height height of the new size
  10390. * @returns the updated Size.
  10391. */
  10392. copyFromFloats(width: number, height: number): Size;
  10393. /**
  10394. * Updates in place the current Size from the given floats.
  10395. * @param width width to set
  10396. * @param height height to set
  10397. * @returns the updated Size.
  10398. */
  10399. set(width: number, height: number): Size;
  10400. /**
  10401. * Multiplies the width and height by numbers
  10402. * @param w factor to multiple the width by
  10403. * @param h factor to multiple the height by
  10404. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  10405. */
  10406. multiplyByFloats(w: number, h: number): Size;
  10407. /**
  10408. * Clones the size
  10409. * @returns a new Size copied from the given one.
  10410. */
  10411. clone(): Size;
  10412. /**
  10413. * True if the current Size and the given one width and height are strictly equal.
  10414. * @param other the other size to compare against
  10415. * @returns True if the current Size and the given one width and height are strictly equal.
  10416. */
  10417. equals(other: Size): boolean;
  10418. /**
  10419. * The surface of the Size : width * height (float).
  10420. */
  10421. get surface(): number;
  10422. /**
  10423. * Create a new size of zero
  10424. * @returns a new Size set to (0.0, 0.0)
  10425. */
  10426. static Zero(): Size;
  10427. /**
  10428. * Sums the width and height of two sizes
  10429. * @param otherSize size to add to this size
  10430. * @returns a new Size set as the addition result of the current Size and the given one.
  10431. */
  10432. add(otherSize: Size): Size;
  10433. /**
  10434. * Subtracts the width and height of two
  10435. * @param otherSize size to subtract to this size
  10436. * @returns a new Size set as the subtraction result of the given one from the current Size.
  10437. */
  10438. subtract(otherSize: Size): Size;
  10439. /**
  10440. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  10441. * @param start starting size to lerp between
  10442. * @param end end size to lerp between
  10443. * @param amount amount to lerp between the start and end values
  10444. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  10445. */
  10446. static Lerp(start: Size, end: Size, amount: number): Size;
  10447. }
  10448. }
  10449. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  10450. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10451. import { Nullable } from "babylonjs/types";
  10452. module "babylonjs/Engines/thinEngine" {
  10453. interface ThinEngine {
  10454. /**
  10455. * Creates a dynamic texture
  10456. * @param width defines the width of the texture
  10457. * @param height defines the height of the texture
  10458. * @param generateMipMaps defines if the engine should generate the mip levels
  10459. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10460. * @returns the dynamic texture inside an InternalTexture
  10461. */
  10462. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10463. /**
  10464. * Update the content of a dynamic texture
  10465. * @param texture defines the texture to update
  10466. * @param canvas defines the canvas containing the source
  10467. * @param invertY defines if data must be stored with Y axis inverted
  10468. * @param premulAlpha defines if alpha is stored as premultiplied
  10469. * @param format defines the format of the data
  10470. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  10471. */
  10472. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  10473. }
  10474. }
  10475. }
  10476. declare module "babylonjs/Misc/canvasGenerator" {
  10477. /**
  10478. * Helper class used to generate a canvas to manipulate images
  10479. */
  10480. export class CanvasGenerator {
  10481. /**
  10482. * Create a new canvas (or offscreen canvas depending on the context)
  10483. * @param width defines the expected width
  10484. * @param height defines the expected height
  10485. * @return a new canvas or offscreen canvas
  10486. */
  10487. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  10488. }
  10489. }
  10490. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  10491. import { Scene } from "babylonjs/scene";
  10492. import { Texture } from "babylonjs/Materials/Textures/texture";
  10493. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  10494. /**
  10495. * A class extending Texture allowing drawing on a texture
  10496. * @see http://doc.babylonjs.com/how_to/dynamictexture
  10497. */
  10498. export class DynamicTexture extends Texture {
  10499. private _generateMipMaps;
  10500. private _canvas;
  10501. private _context;
  10502. private _engine;
  10503. /**
  10504. * Creates a DynamicTexture
  10505. * @param name defines the name of the texture
  10506. * @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
  10507. * @param scene defines the scene where you want the texture
  10508. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  10509. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  10510. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  10511. */
  10512. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  10513. /**
  10514. * Get the current class name of the texture useful for serialization or dynamic coding.
  10515. * @returns "DynamicTexture"
  10516. */
  10517. getClassName(): string;
  10518. /**
  10519. * Gets the current state of canRescale
  10520. */
  10521. get canRescale(): boolean;
  10522. private _recreate;
  10523. /**
  10524. * Scales the texture
  10525. * @param ratio the scale factor to apply to both width and height
  10526. */
  10527. scale(ratio: number): void;
  10528. /**
  10529. * Resizes the texture
  10530. * @param width the new width
  10531. * @param height the new height
  10532. */
  10533. scaleTo(width: number, height: number): void;
  10534. /**
  10535. * Gets the context of the canvas used by the texture
  10536. * @returns the canvas context of the dynamic texture
  10537. */
  10538. getContext(): CanvasRenderingContext2D;
  10539. /**
  10540. * Clears the texture
  10541. */
  10542. clear(): void;
  10543. /**
  10544. * Updates the texture
  10545. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10546. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  10547. */
  10548. update(invertY?: boolean, premulAlpha?: boolean): void;
  10549. /**
  10550. * Draws text onto the texture
  10551. * @param text defines the text to be drawn
  10552. * @param x defines the placement of the text from the left
  10553. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  10554. * @param font defines the font to be used with font-style, font-size, font-name
  10555. * @param color defines the color used for the text
  10556. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  10557. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10558. * @param update defines whether texture is immediately update (default is true)
  10559. */
  10560. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  10561. /**
  10562. * Clones the texture
  10563. * @returns the clone of the texture.
  10564. */
  10565. clone(): DynamicTexture;
  10566. /**
  10567. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  10568. * @returns a serialized dynamic texture object
  10569. */
  10570. serialize(): any;
  10571. /** @hidden */
  10572. _rebuild(): void;
  10573. }
  10574. }
  10575. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  10576. import { Nullable } from "babylonjs/types";
  10577. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10578. import { Scene } from "babylonjs/scene";
  10579. module "babylonjs/Engines/engine" {
  10580. interface Engine {
  10581. /**
  10582. * Creates a raw texture
  10583. * @param data defines the data to store in the texture
  10584. * @param width defines the width of the texture
  10585. * @param height defines the height of the texture
  10586. * @param format defines the format of the data
  10587. * @param generateMipMaps defines if the engine should generate the mip levels
  10588. * @param invertY defines if data must be stored with Y axis inverted
  10589. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10590. * @param compression defines the compression used (null by default)
  10591. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10592. * @returns the raw texture inside an InternalTexture
  10593. */
  10594. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  10595. /**
  10596. * Update a raw texture
  10597. * @param texture defines the texture to update
  10598. * @param data defines the data to store in the texture
  10599. * @param format defines the format of the data
  10600. * @param invertY defines if data must be stored with Y axis inverted
  10601. */
  10602. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10603. /**
  10604. * Update a raw texture
  10605. * @param texture defines the texture to update
  10606. * @param data defines the data to store in the texture
  10607. * @param format defines the format of the data
  10608. * @param invertY defines if data must be stored with Y axis inverted
  10609. * @param compression defines the compression used (null by default)
  10610. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10611. */
  10612. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  10613. /**
  10614. * Creates a new raw cube texture
  10615. * @param data defines the array of data to use to create each face
  10616. * @param size defines the size of the textures
  10617. * @param format defines the format of the data
  10618. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10619. * @param generateMipMaps defines if the engine should generate the mip levels
  10620. * @param invertY defines if data must be stored with Y axis inverted
  10621. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10622. * @param compression defines the compression used (null by default)
  10623. * @returns the cube texture as an InternalTexture
  10624. */
  10625. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  10626. /**
  10627. * Update a raw cube texture
  10628. * @param texture defines the texture to udpdate
  10629. * @param data defines the data to store
  10630. * @param format defines the data format
  10631. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10632. * @param invertY defines if data must be stored with Y axis inverted
  10633. */
  10634. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  10635. /**
  10636. * Update a raw cube texture
  10637. * @param texture defines the texture to udpdate
  10638. * @param data defines the data to store
  10639. * @param format defines the data format
  10640. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10641. * @param invertY defines if data must be stored with Y axis inverted
  10642. * @param compression defines the compression used (null by default)
  10643. */
  10644. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  10645. /**
  10646. * Update a raw cube texture
  10647. * @param texture defines the texture to udpdate
  10648. * @param data defines the data to store
  10649. * @param format defines the data format
  10650. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10651. * @param invertY defines if data must be stored with Y axis inverted
  10652. * @param compression defines the compression used (null by default)
  10653. * @param level defines which level of the texture to update
  10654. */
  10655. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  10656. /**
  10657. * Creates a new raw cube texture from a specified url
  10658. * @param url defines the url where the data is located
  10659. * @param scene defines the current scene
  10660. * @param size defines the size of the textures
  10661. * @param format defines the format of the data
  10662. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10663. * @param noMipmap defines if the engine should avoid generating the mip levels
  10664. * @param callback defines a callback used to extract texture data from loaded data
  10665. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10666. * @param onLoad defines a callback called when texture is loaded
  10667. * @param onError defines a callback called if there is an error
  10668. * @returns the cube texture as an InternalTexture
  10669. */
  10670. 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;
  10671. /**
  10672. * Creates a new raw cube texture from a specified url
  10673. * @param url defines the url where the data is located
  10674. * @param scene defines the current scene
  10675. * @param size defines the size of the textures
  10676. * @param format defines the format of the data
  10677. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10678. * @param noMipmap defines if the engine should avoid generating the mip levels
  10679. * @param callback defines a callback used to extract texture data from loaded data
  10680. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10681. * @param onLoad defines a callback called when texture is loaded
  10682. * @param onError defines a callback called if there is an error
  10683. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10684. * @param invertY defines if data must be stored with Y axis inverted
  10685. * @returns the cube texture as an InternalTexture
  10686. */
  10687. 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;
  10688. /**
  10689. * Creates a new raw 3D texture
  10690. * @param data defines the data used to create the texture
  10691. * @param width defines the width of the texture
  10692. * @param height defines the height of the texture
  10693. * @param depth defines the depth of the texture
  10694. * @param format defines the format of the texture
  10695. * @param generateMipMaps defines if the engine must generate mip levels
  10696. * @param invertY defines if data must be stored with Y axis inverted
  10697. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10698. * @param compression defines the compressed used (can be null)
  10699. * @param textureType defines the compressed used (can be null)
  10700. * @returns a new raw 3D texture (stored in an InternalTexture)
  10701. */
  10702. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10703. /**
  10704. * Update a raw 3D texture
  10705. * @param texture defines the texture to update
  10706. * @param data defines the data to store
  10707. * @param format defines the data format
  10708. * @param invertY defines if data must be stored with Y axis inverted
  10709. */
  10710. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10711. /**
  10712. * Update a raw 3D texture
  10713. * @param texture defines the texture to update
  10714. * @param data defines the data to store
  10715. * @param format defines the data format
  10716. * @param invertY defines if data must be stored with Y axis inverted
  10717. * @param compression defines the used compression (can be null)
  10718. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10719. */
  10720. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10721. /**
  10722. * Creates a new raw 2D array texture
  10723. * @param data defines the data used to create the texture
  10724. * @param width defines the width of the texture
  10725. * @param height defines the height of the texture
  10726. * @param depth defines the number of layers of the texture
  10727. * @param format defines the format of the texture
  10728. * @param generateMipMaps defines if the engine must generate mip levels
  10729. * @param invertY defines if data must be stored with Y axis inverted
  10730. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10731. * @param compression defines the compressed used (can be null)
  10732. * @param textureType defines the compressed used (can be null)
  10733. * @returns a new raw 2D array texture (stored in an InternalTexture)
  10734. */
  10735. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10736. /**
  10737. * Update a raw 2D array texture
  10738. * @param texture defines the texture to update
  10739. * @param data defines the data to store
  10740. * @param format defines the data format
  10741. * @param invertY defines if data must be stored with Y axis inverted
  10742. */
  10743. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10744. /**
  10745. * Update a raw 2D array texture
  10746. * @param texture defines the texture to update
  10747. * @param data defines the data to store
  10748. * @param format defines the data format
  10749. * @param invertY defines if data must be stored with Y axis inverted
  10750. * @param compression defines the used compression (can be null)
  10751. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10752. */
  10753. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10754. }
  10755. }
  10756. }
  10757. declare module "babylonjs/Materials/Textures/rawTexture" {
  10758. import { Scene } from "babylonjs/scene";
  10759. import { Texture } from "babylonjs/Materials/Textures/texture";
  10760. import "babylonjs/Engines/Extensions/engine.rawTexture";
  10761. /**
  10762. * Raw texture can help creating a texture directly from an array of data.
  10763. * This can be super useful if you either get the data from an uncompressed source or
  10764. * if you wish to create your texture pixel by pixel.
  10765. */
  10766. export class RawTexture extends Texture {
  10767. /**
  10768. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10769. */
  10770. format: number;
  10771. private _engine;
  10772. /**
  10773. * Instantiates a new RawTexture.
  10774. * Raw texture can help creating a texture directly from an array of data.
  10775. * This can be super useful if you either get the data from an uncompressed source or
  10776. * if you wish to create your texture pixel by pixel.
  10777. * @param data define the array of data to use to create the texture
  10778. * @param width define the width of the texture
  10779. * @param height define the height of the texture
  10780. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10781. * @param scene define the scene the texture belongs to
  10782. * @param generateMipMaps define whether mip maps should be generated or not
  10783. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10784. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10785. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10786. */
  10787. constructor(data: ArrayBufferView, width: number, height: number,
  10788. /**
  10789. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10790. */
  10791. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  10792. /**
  10793. * Updates the texture underlying data.
  10794. * @param data Define the new data of the texture
  10795. */
  10796. update(data: ArrayBufferView): void;
  10797. /**
  10798. * Creates a luminance texture from some data.
  10799. * @param data Define the texture data
  10800. * @param width Define the width of the texture
  10801. * @param height Define the height of the texture
  10802. * @param scene Define the scene the texture belongs to
  10803. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10804. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10805. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10806. * @returns the luminance texture
  10807. */
  10808. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10809. /**
  10810. * Creates a luminance alpha texture from some data.
  10811. * @param data Define the texture data
  10812. * @param width Define the width of the texture
  10813. * @param height Define the height of the texture
  10814. * @param scene Define the scene the texture belongs to
  10815. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10816. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10817. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10818. * @returns the luminance alpha texture
  10819. */
  10820. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10821. /**
  10822. * Creates an alpha texture from some data.
  10823. * @param data Define the texture data
  10824. * @param width Define the width of the texture
  10825. * @param height Define the height of the texture
  10826. * @param scene Define the scene the texture belongs to
  10827. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10828. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10829. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10830. * @returns the alpha texture
  10831. */
  10832. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10833. /**
  10834. * Creates a RGB texture from some data.
  10835. * @param data Define the texture data
  10836. * @param width Define the width of the texture
  10837. * @param height Define the height of the texture
  10838. * @param scene Define the scene the texture belongs to
  10839. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10840. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10841. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10842. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10843. * @returns the RGB alpha texture
  10844. */
  10845. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10846. /**
  10847. * Creates a RGBA texture from some data.
  10848. * @param data Define the texture data
  10849. * @param width Define the width of the texture
  10850. * @param height Define the height of the texture
  10851. * @param scene Define the scene the texture belongs to
  10852. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10853. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10854. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10855. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10856. * @returns the RGBA texture
  10857. */
  10858. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10859. /**
  10860. * Creates a R texture from some data.
  10861. * @param data Define the texture data
  10862. * @param width Define the width of the texture
  10863. * @param height Define the height of the texture
  10864. * @param scene Define the scene the texture belongs to
  10865. * @param generateMipMaps Define whether or not to create mip maps for the texture
  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. * @returns the R texture
  10870. */
  10871. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10872. }
  10873. }
  10874. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  10875. import { Scene } from "babylonjs/scene";
  10876. import { ISceneComponent } from "babylonjs/sceneComponent";
  10877. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  10878. module "babylonjs/abstractScene" {
  10879. interface AbstractScene {
  10880. /**
  10881. * The list of procedural textures added to the scene
  10882. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10883. */
  10884. proceduralTextures: Array<ProceduralTexture>;
  10885. }
  10886. }
  10887. /**
  10888. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  10889. * in a given scene.
  10890. */
  10891. export class ProceduralTextureSceneComponent implements ISceneComponent {
  10892. /**
  10893. * The component name helpfull to identify the component in the list of scene components.
  10894. */
  10895. readonly name: string;
  10896. /**
  10897. * The scene the component belongs to.
  10898. */
  10899. scene: Scene;
  10900. /**
  10901. * Creates a new instance of the component for the given scene
  10902. * @param scene Defines the scene to register the component in
  10903. */
  10904. constructor(scene: Scene);
  10905. /**
  10906. * Registers the component in a given scene
  10907. */
  10908. register(): void;
  10909. /**
  10910. * Rebuilds the elements related to this component in case of
  10911. * context lost for instance.
  10912. */
  10913. rebuild(): void;
  10914. /**
  10915. * Disposes the component and the associated ressources.
  10916. */
  10917. dispose(): void;
  10918. private _beforeClear;
  10919. }
  10920. }
  10921. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  10922. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10923. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  10924. module "babylonjs/Engines/thinEngine" {
  10925. interface ThinEngine {
  10926. /**
  10927. * Creates a new render target cube texture
  10928. * @param size defines the size of the texture
  10929. * @param options defines the options used to create the texture
  10930. * @returns a new render target cube texture stored in an InternalTexture
  10931. */
  10932. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  10933. }
  10934. }
  10935. }
  10936. declare module "babylonjs/Shaders/procedural.vertex" {
  10937. /** @hidden */
  10938. export var proceduralVertexShader: {
  10939. name: string;
  10940. shader: string;
  10941. };
  10942. }
  10943. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  10944. import { Observable } from "babylonjs/Misc/observable";
  10945. import { Nullable } from "babylonjs/types";
  10946. import { Scene } from "babylonjs/scene";
  10947. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10948. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  10949. import { Effect } from "babylonjs/Materials/effect";
  10950. import { Texture } from "babylonjs/Materials/Textures/texture";
  10951. import "babylonjs/Engines/Extensions/engine.renderTarget";
  10952. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  10953. import "babylonjs/Shaders/procedural.vertex";
  10954. /**
  10955. * 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.
  10956. * This is the base class of any Procedural texture and contains most of the shareable code.
  10957. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10958. */
  10959. export class ProceduralTexture extends Texture {
  10960. isCube: boolean;
  10961. /**
  10962. * Define if the texture is enabled or not (disabled texture will not render)
  10963. */
  10964. isEnabled: boolean;
  10965. /**
  10966. * Define if the texture must be cleared before rendering (default is true)
  10967. */
  10968. autoClear: boolean;
  10969. /**
  10970. * Callback called when the texture is generated
  10971. */
  10972. onGenerated: () => void;
  10973. /**
  10974. * Event raised when the texture is generated
  10975. */
  10976. onGeneratedObservable: Observable<ProceduralTexture>;
  10977. /** @hidden */
  10978. _generateMipMaps: boolean;
  10979. /** @hidden **/
  10980. _effect: Effect;
  10981. /** @hidden */
  10982. _textures: {
  10983. [key: string]: Texture;
  10984. };
  10985. private _size;
  10986. private _currentRefreshId;
  10987. private _frameId;
  10988. private _refreshRate;
  10989. private _vertexBuffers;
  10990. private _indexBuffer;
  10991. private _uniforms;
  10992. private _samplers;
  10993. private _fragment;
  10994. private _floats;
  10995. private _ints;
  10996. private _floatsArrays;
  10997. private _colors3;
  10998. private _colors4;
  10999. private _vectors2;
  11000. private _vectors3;
  11001. private _matrices;
  11002. private _fallbackTexture;
  11003. private _fallbackTextureUsed;
  11004. private _engine;
  11005. private _cachedDefines;
  11006. private _contentUpdateId;
  11007. private _contentData;
  11008. /**
  11009. * Instantiates a new procedural texture.
  11010. * 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.
  11011. * This is the base class of any Procedural texture and contains most of the shareable code.
  11012. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11013. * @param name Define the name of the texture
  11014. * @param size Define the size of the texture to create
  11015. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11016. * @param scene Define the scene the texture belongs to
  11017. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11018. * @param generateMipMaps Define if the texture should creates mip maps or not
  11019. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11020. */
  11021. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11022. /**
  11023. * The effect that is created when initializing the post process.
  11024. * @returns The created effect corresponding the the postprocess.
  11025. */
  11026. getEffect(): Effect;
  11027. /**
  11028. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11029. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11030. */
  11031. getContent(): Nullable<ArrayBufferView>;
  11032. private _createIndexBuffer;
  11033. /** @hidden */
  11034. _rebuild(): void;
  11035. /**
  11036. * Resets the texture in order to recreate its associated resources.
  11037. * This can be called in case of context loss
  11038. */
  11039. reset(): void;
  11040. protected _getDefines(): string;
  11041. /**
  11042. * Is the texture ready to be used ? (rendered at least once)
  11043. * @returns true if ready, otherwise, false.
  11044. */
  11045. isReady(): boolean;
  11046. /**
  11047. * Resets the refresh counter of the texture and start bak from scratch.
  11048. * Could be useful to regenerate the texture if it is setup to render only once.
  11049. */
  11050. resetRefreshCounter(): void;
  11051. /**
  11052. * Set the fragment shader to use in order to render the texture.
  11053. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11054. */
  11055. setFragment(fragment: any): void;
  11056. /**
  11057. * Define the refresh rate of the texture or the rendering frequency.
  11058. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11059. */
  11060. get refreshRate(): number;
  11061. set refreshRate(value: number);
  11062. /** @hidden */
  11063. _shouldRender(): boolean;
  11064. /**
  11065. * Get the size the texture is rendering at.
  11066. * @returns the size (texture is always squared)
  11067. */
  11068. getRenderSize(): number;
  11069. /**
  11070. * Resize the texture to new value.
  11071. * @param size Define the new size the texture should have
  11072. * @param generateMipMaps Define whether the new texture should create mip maps
  11073. */
  11074. resize(size: number, generateMipMaps: boolean): void;
  11075. private _checkUniform;
  11076. /**
  11077. * Set a texture in the shader program used to render.
  11078. * @param name Define the name of the uniform samplers as defined in the shader
  11079. * @param texture Define the texture to bind to this sampler
  11080. * @return the texture itself allowing "fluent" like uniform updates
  11081. */
  11082. setTexture(name: string, texture: Texture): ProceduralTexture;
  11083. /**
  11084. * Set a float in the shader.
  11085. * @param name Define the name of the uniform as defined in the shader
  11086. * @param value Define the value to give to the uniform
  11087. * @return the texture itself allowing "fluent" like uniform updates
  11088. */
  11089. setFloat(name: string, value: number): ProceduralTexture;
  11090. /**
  11091. * Set a int in the shader.
  11092. * @param name Define the name of the uniform as defined in the shader
  11093. * @param value Define the value to give to the uniform
  11094. * @return the texture itself allowing "fluent" like uniform updates
  11095. */
  11096. setInt(name: string, value: number): ProceduralTexture;
  11097. /**
  11098. * Set an array of floats in the shader.
  11099. * @param name Define the name of the uniform as defined in the shader
  11100. * @param value Define the value to give to the uniform
  11101. * @return the texture itself allowing "fluent" like uniform updates
  11102. */
  11103. setFloats(name: string, value: number[]): ProceduralTexture;
  11104. /**
  11105. * Set a vec3 in the shader from a Color3.
  11106. * @param name Define the name of the uniform as defined in the shader
  11107. * @param value Define the value to give to the uniform
  11108. * @return the texture itself allowing "fluent" like uniform updates
  11109. */
  11110. setColor3(name: string, value: Color3): ProceduralTexture;
  11111. /**
  11112. * Set a vec4 in the shader from a Color4.
  11113. * @param name Define the name of the uniform as defined in the shader
  11114. * @param value Define the value to give to the uniform
  11115. * @return the texture itself allowing "fluent" like uniform updates
  11116. */
  11117. setColor4(name: string, value: Color4): ProceduralTexture;
  11118. /**
  11119. * Set a vec2 in the shader from a Vector2.
  11120. * @param name Define the name of the uniform as defined in the shader
  11121. * @param value Define the value to give to the uniform
  11122. * @return the texture itself allowing "fluent" like uniform updates
  11123. */
  11124. setVector2(name: string, value: Vector2): ProceduralTexture;
  11125. /**
  11126. * Set a vec3 in the shader from a Vector3.
  11127. * @param name Define the name of the uniform as defined in the shader
  11128. * @param value Define the value to give to the uniform
  11129. * @return the texture itself allowing "fluent" like uniform updates
  11130. */
  11131. setVector3(name: string, value: Vector3): ProceduralTexture;
  11132. /**
  11133. * Set a mat4 in the shader from a MAtrix.
  11134. * @param name Define the name of the uniform as defined in the shader
  11135. * @param value Define the value to give to the uniform
  11136. * @return the texture itself allowing "fluent" like uniform updates
  11137. */
  11138. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11139. /**
  11140. * Render the texture to its associated render target.
  11141. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11142. */
  11143. render(useCameraPostProcess?: boolean): void;
  11144. /**
  11145. * Clone the texture.
  11146. * @returns the cloned texture
  11147. */
  11148. clone(): ProceduralTexture;
  11149. /**
  11150. * Dispose the texture and release its asoociated resources.
  11151. */
  11152. dispose(): void;
  11153. }
  11154. }
  11155. declare module "babylonjs/Particles/baseParticleSystem" {
  11156. import { Nullable } from "babylonjs/types";
  11157. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  11158. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11159. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  11160. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11161. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  11162. import { Scene } from "babylonjs/scene";
  11163. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  11164. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  11165. import { Texture } from "babylonjs/Materials/Textures/texture";
  11166. import { Color4 } from "babylonjs/Maths/math.color";
  11167. import { Animation } from "babylonjs/Animations/animation";
  11168. /**
  11169. * This represents the base class for particle system in Babylon.
  11170. * 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.
  11171. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11172. * @example https://doc.babylonjs.com/babylon101/particles
  11173. */
  11174. export class BaseParticleSystem {
  11175. /**
  11176. * Source color is added to the destination color without alpha affecting the result
  11177. */
  11178. static BLENDMODE_ONEONE: number;
  11179. /**
  11180. * Blend current color and particle color using particle’s alpha
  11181. */
  11182. static BLENDMODE_STANDARD: number;
  11183. /**
  11184. * Add current color and particle color multiplied by particle’s alpha
  11185. */
  11186. static BLENDMODE_ADD: number;
  11187. /**
  11188. * Multiply current color with particle color
  11189. */
  11190. static BLENDMODE_MULTIPLY: number;
  11191. /**
  11192. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11193. */
  11194. static BLENDMODE_MULTIPLYADD: number;
  11195. /**
  11196. * List of animations used by the particle system.
  11197. */
  11198. animations: Animation[];
  11199. /**
  11200. * The id of the Particle system.
  11201. */
  11202. id: string;
  11203. /**
  11204. * The friendly name of the Particle system.
  11205. */
  11206. name: string;
  11207. /**
  11208. * The rendering group used by the Particle system to chose when to render.
  11209. */
  11210. renderingGroupId: number;
  11211. /**
  11212. * The emitter represents the Mesh or position we are attaching the particle system to.
  11213. */
  11214. emitter: Nullable<AbstractMesh | Vector3>;
  11215. /**
  11216. * The maximum number of particles to emit per frame
  11217. */
  11218. emitRate: number;
  11219. /**
  11220. * If you want to launch only a few particles at once, that can be done, as well.
  11221. */
  11222. manualEmitCount: number;
  11223. /**
  11224. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11225. */
  11226. updateSpeed: number;
  11227. /**
  11228. * The amount of time the particle system is running (depends of the overall update speed).
  11229. */
  11230. targetStopDuration: number;
  11231. /**
  11232. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11233. */
  11234. disposeOnStop: boolean;
  11235. /**
  11236. * Minimum power of emitting particles.
  11237. */
  11238. minEmitPower: number;
  11239. /**
  11240. * Maximum power of emitting particles.
  11241. */
  11242. maxEmitPower: number;
  11243. /**
  11244. * Minimum life time of emitting particles.
  11245. */
  11246. minLifeTime: number;
  11247. /**
  11248. * Maximum life time of emitting particles.
  11249. */
  11250. maxLifeTime: number;
  11251. /**
  11252. * Minimum Size of emitting particles.
  11253. */
  11254. minSize: number;
  11255. /**
  11256. * Maximum Size of emitting particles.
  11257. */
  11258. maxSize: number;
  11259. /**
  11260. * Minimum scale of emitting particles on X axis.
  11261. */
  11262. minScaleX: number;
  11263. /**
  11264. * Maximum scale of emitting particles on X axis.
  11265. */
  11266. maxScaleX: number;
  11267. /**
  11268. * Minimum scale of emitting particles on Y axis.
  11269. */
  11270. minScaleY: number;
  11271. /**
  11272. * Maximum scale of emitting particles on Y axis.
  11273. */
  11274. maxScaleY: number;
  11275. /**
  11276. * Gets or sets the minimal initial rotation in radians.
  11277. */
  11278. minInitialRotation: number;
  11279. /**
  11280. * Gets or sets the maximal initial rotation in radians.
  11281. */
  11282. maxInitialRotation: number;
  11283. /**
  11284. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11285. */
  11286. minAngularSpeed: number;
  11287. /**
  11288. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11289. */
  11290. maxAngularSpeed: number;
  11291. /**
  11292. * The texture used to render each particle. (this can be a spritesheet)
  11293. */
  11294. particleTexture: Nullable<Texture>;
  11295. /**
  11296. * The layer mask we are rendering the particles through.
  11297. */
  11298. layerMask: number;
  11299. /**
  11300. * This can help using your own shader to render the particle system.
  11301. * The according effect will be created
  11302. */
  11303. customShader: any;
  11304. /**
  11305. * By default particle system starts as soon as they are created. This prevents the
  11306. * automatic start to happen and let you decide when to start emitting particles.
  11307. */
  11308. preventAutoStart: boolean;
  11309. private _noiseTexture;
  11310. /**
  11311. * Gets or sets a texture used to add random noise to particle positions
  11312. */
  11313. get noiseTexture(): Nullable<ProceduralTexture>;
  11314. set noiseTexture(value: Nullable<ProceduralTexture>);
  11315. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11316. noiseStrength: Vector3;
  11317. /**
  11318. * Callback triggered when the particle animation is ending.
  11319. */
  11320. onAnimationEnd: Nullable<() => void>;
  11321. /**
  11322. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11323. */
  11324. blendMode: number;
  11325. /**
  11326. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11327. * to override the particles.
  11328. */
  11329. forceDepthWrite: boolean;
  11330. /** 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 */
  11331. preWarmCycles: number;
  11332. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11333. preWarmStepOffset: number;
  11334. /**
  11335. * 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)
  11336. */
  11337. spriteCellChangeSpeed: number;
  11338. /**
  11339. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11340. */
  11341. startSpriteCellID: number;
  11342. /**
  11343. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11344. */
  11345. endSpriteCellID: number;
  11346. /**
  11347. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11348. */
  11349. spriteCellWidth: number;
  11350. /**
  11351. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11352. */
  11353. spriteCellHeight: number;
  11354. /**
  11355. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11356. */
  11357. spriteRandomStartCell: boolean;
  11358. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11359. translationPivot: Vector2;
  11360. /** @hidden */
  11361. protected _isAnimationSheetEnabled: boolean;
  11362. /**
  11363. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11364. */
  11365. beginAnimationOnStart: boolean;
  11366. /**
  11367. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11368. */
  11369. beginAnimationFrom: number;
  11370. /**
  11371. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11372. */
  11373. beginAnimationTo: number;
  11374. /**
  11375. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11376. */
  11377. beginAnimationLoop: boolean;
  11378. /**
  11379. * Gets or sets a world offset applied to all particles
  11380. */
  11381. worldOffset: Vector3;
  11382. /**
  11383. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11384. */
  11385. get isAnimationSheetEnabled(): boolean;
  11386. set isAnimationSheetEnabled(value: boolean);
  11387. /**
  11388. * Get hosting scene
  11389. * @returns the scene
  11390. */
  11391. getScene(): Scene;
  11392. /**
  11393. * You can use gravity if you want to give an orientation to your particles.
  11394. */
  11395. gravity: Vector3;
  11396. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11397. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11398. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11399. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11400. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11401. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11402. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11403. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11404. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11405. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11406. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11407. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11408. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11409. /**
  11410. * Defines the delay in milliseconds before starting the system (0 by default)
  11411. */
  11412. startDelay: number;
  11413. /**
  11414. * Gets the current list of drag gradients.
  11415. * You must use addDragGradient and removeDragGradient to udpate this list
  11416. * @returns the list of drag gradients
  11417. */
  11418. getDragGradients(): Nullable<Array<FactorGradient>>;
  11419. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  11420. limitVelocityDamping: number;
  11421. /**
  11422. * Gets the current list of limit velocity gradients.
  11423. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  11424. * @returns the list of limit velocity gradients
  11425. */
  11426. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  11427. /**
  11428. * Gets the current list of color gradients.
  11429. * You must use addColorGradient and removeColorGradient to udpate this list
  11430. * @returns the list of color gradients
  11431. */
  11432. getColorGradients(): Nullable<Array<ColorGradient>>;
  11433. /**
  11434. * Gets the current list of size gradients.
  11435. * You must use addSizeGradient and removeSizeGradient to udpate this list
  11436. * @returns the list of size gradients
  11437. */
  11438. getSizeGradients(): Nullable<Array<FactorGradient>>;
  11439. /**
  11440. * Gets the current list of color remap gradients.
  11441. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  11442. * @returns the list of color remap gradients
  11443. */
  11444. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  11445. /**
  11446. * Gets the current list of alpha remap gradients.
  11447. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  11448. * @returns the list of alpha remap gradients
  11449. */
  11450. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  11451. /**
  11452. * Gets the current list of life time gradients.
  11453. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  11454. * @returns the list of life time gradients
  11455. */
  11456. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  11457. /**
  11458. * Gets the current list of angular speed gradients.
  11459. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  11460. * @returns the list of angular speed gradients
  11461. */
  11462. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  11463. /**
  11464. * Gets the current list of velocity gradients.
  11465. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  11466. * @returns the list of velocity gradients
  11467. */
  11468. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  11469. /**
  11470. * Gets the current list of start size gradients.
  11471. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  11472. * @returns the list of start size gradients
  11473. */
  11474. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  11475. /**
  11476. * Gets the current list of emit rate gradients.
  11477. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  11478. * @returns the list of emit rate gradients
  11479. */
  11480. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  11481. /**
  11482. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11483. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11484. */
  11485. get direction1(): Vector3;
  11486. set direction1(value: Vector3);
  11487. /**
  11488. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11489. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11490. */
  11491. get direction2(): Vector3;
  11492. set direction2(value: Vector3);
  11493. /**
  11494. * 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.
  11495. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11496. */
  11497. get minEmitBox(): Vector3;
  11498. set minEmitBox(value: Vector3);
  11499. /**
  11500. * 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.
  11501. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11502. */
  11503. get maxEmitBox(): Vector3;
  11504. set maxEmitBox(value: Vector3);
  11505. /**
  11506. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11507. */
  11508. color1: Color4;
  11509. /**
  11510. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11511. */
  11512. color2: Color4;
  11513. /**
  11514. * Color the particle will have at the end of its lifetime
  11515. */
  11516. colorDead: Color4;
  11517. /**
  11518. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  11519. */
  11520. textureMask: Color4;
  11521. /**
  11522. * The particle emitter type defines the emitter used by the particle system.
  11523. * It can be for example box, sphere, or cone...
  11524. */
  11525. particleEmitterType: IParticleEmitterType;
  11526. /** @hidden */
  11527. _isSubEmitter: boolean;
  11528. /**
  11529. * Gets or sets the billboard mode to use when isBillboardBased = true.
  11530. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  11531. */
  11532. billboardMode: number;
  11533. protected _isBillboardBased: boolean;
  11534. /**
  11535. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  11536. */
  11537. get isBillboardBased(): boolean;
  11538. set isBillboardBased(value: boolean);
  11539. /**
  11540. * The scene the particle system belongs to.
  11541. */
  11542. protected _scene: Scene;
  11543. /**
  11544. * Local cache of defines for image processing.
  11545. */
  11546. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  11547. /**
  11548. * Default configuration related to image processing available in the standard Material.
  11549. */
  11550. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  11551. /**
  11552. * Gets the image processing configuration used either in this material.
  11553. */
  11554. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  11555. /**
  11556. * Sets the Default image processing configuration used either in the this material.
  11557. *
  11558. * If sets to null, the scene one is in use.
  11559. */
  11560. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  11561. /**
  11562. * Attaches a new image processing configuration to the Standard Material.
  11563. * @param configuration
  11564. */
  11565. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  11566. /** @hidden */
  11567. protected _reset(): void;
  11568. /** @hidden */
  11569. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  11570. /**
  11571. * Instantiates a particle system.
  11572. * 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.
  11573. * @param name The name of the particle system
  11574. */
  11575. constructor(name: string);
  11576. /**
  11577. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  11578. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11579. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11580. * @returns the emitter
  11581. */
  11582. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  11583. /**
  11584. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  11585. * @param radius The radius of the hemisphere to emit from
  11586. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11587. * @returns the emitter
  11588. */
  11589. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  11590. /**
  11591. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  11592. * @param radius The radius of the sphere to emit from
  11593. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11594. * @returns the emitter
  11595. */
  11596. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  11597. /**
  11598. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  11599. * @param radius The radius of the sphere to emit from
  11600. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  11601. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  11602. * @returns the emitter
  11603. */
  11604. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  11605. /**
  11606. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  11607. * @param radius The radius of the emission cylinder
  11608. * @param height The height of the emission cylinder
  11609. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  11610. * @param directionRandomizer How much to randomize the particle direction [0-1]
  11611. * @returns the emitter
  11612. */
  11613. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  11614. /**
  11615. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  11616. * @param radius The radius of the cylinder to emit from
  11617. * @param height The height of the emission cylinder
  11618. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  11619. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  11620. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  11621. * @returns the emitter
  11622. */
  11623. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  11624. /**
  11625. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  11626. * @param radius The radius of the cone to emit from
  11627. * @param angle The base angle of the cone
  11628. * @returns the emitter
  11629. */
  11630. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  11631. /**
  11632. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  11633. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11634. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11635. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11636. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11637. * @returns the emitter
  11638. */
  11639. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  11640. }
  11641. }
  11642. declare module "babylonjs/Particles/subEmitter" {
  11643. import { Scene } from "babylonjs/scene";
  11644. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  11645. /**
  11646. * Type of sub emitter
  11647. */
  11648. export enum SubEmitterType {
  11649. /**
  11650. * Attached to the particle over it's lifetime
  11651. */
  11652. ATTACHED = 0,
  11653. /**
  11654. * Created when the particle dies
  11655. */
  11656. END = 1
  11657. }
  11658. /**
  11659. * Sub emitter class used to emit particles from an existing particle
  11660. */
  11661. export class SubEmitter {
  11662. /**
  11663. * the particle system to be used by the sub emitter
  11664. */
  11665. particleSystem: ParticleSystem;
  11666. /**
  11667. * Type of the submitter (Default: END)
  11668. */
  11669. type: SubEmitterType;
  11670. /**
  11671. * 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)
  11672. * Note: This only is supported when using an emitter of type Mesh
  11673. */
  11674. inheritDirection: boolean;
  11675. /**
  11676. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  11677. */
  11678. inheritedVelocityAmount: number;
  11679. /**
  11680. * Creates a sub emitter
  11681. * @param particleSystem the particle system to be used by the sub emitter
  11682. */
  11683. constructor(
  11684. /**
  11685. * the particle system to be used by the sub emitter
  11686. */
  11687. particleSystem: ParticleSystem);
  11688. /**
  11689. * Clones the sub emitter
  11690. * @returns the cloned sub emitter
  11691. */
  11692. clone(): SubEmitter;
  11693. /**
  11694. * Serialize current object to a JSON object
  11695. * @returns the serialized object
  11696. */
  11697. serialize(): any;
  11698. /** @hidden */
  11699. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  11700. /**
  11701. * Creates a new SubEmitter from a serialized JSON version
  11702. * @param serializationObject defines the JSON object to read from
  11703. * @param scene defines the hosting scene
  11704. * @param rootUrl defines the rootUrl for data loading
  11705. * @returns a new SubEmitter
  11706. */
  11707. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  11708. /** Release associated resources */
  11709. dispose(): void;
  11710. }
  11711. }
  11712. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  11713. /** @hidden */
  11714. export var imageProcessingDeclaration: {
  11715. name: string;
  11716. shader: string;
  11717. };
  11718. }
  11719. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  11720. /** @hidden */
  11721. export var imageProcessingFunctions: {
  11722. name: string;
  11723. shader: string;
  11724. };
  11725. }
  11726. declare module "babylonjs/Shaders/particles.fragment" {
  11727. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  11728. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  11729. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  11730. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  11731. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  11732. /** @hidden */
  11733. export var particlesPixelShader: {
  11734. name: string;
  11735. shader: string;
  11736. };
  11737. }
  11738. declare module "babylonjs/Shaders/particles.vertex" {
  11739. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  11740. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  11741. /** @hidden */
  11742. export var particlesVertexShader: {
  11743. name: string;
  11744. shader: string;
  11745. };
  11746. }
  11747. declare module "babylonjs/Particles/particleSystem" {
  11748. import { Nullable } from "babylonjs/types";
  11749. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  11750. import { Observable } from "babylonjs/Misc/observable";
  11751. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  11752. import { Effect } from "babylonjs/Materials/effect";
  11753. import { Scene, IDisposable } from "babylonjs/scene";
  11754. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  11755. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  11756. import { Particle } from "babylonjs/Particles/particle";
  11757. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  11758. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  11759. import "babylonjs/Shaders/particles.fragment";
  11760. import "babylonjs/Shaders/particles.vertex";
  11761. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11762. /**
  11763. * This represents a particle system in Babylon.
  11764. * 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.
  11765. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11766. * @example https://doc.babylonjs.com/babylon101/particles
  11767. */
  11768. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  11769. /**
  11770. * Billboard mode will only apply to Y axis
  11771. */
  11772. static readonly BILLBOARDMODE_Y: number;
  11773. /**
  11774. * Billboard mode will apply to all axes
  11775. */
  11776. static readonly BILLBOARDMODE_ALL: number;
  11777. /**
  11778. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  11779. */
  11780. static readonly BILLBOARDMODE_STRETCHED: number;
  11781. /**
  11782. * This function can be defined to provide custom update for active particles.
  11783. * This function will be called instead of regular update (age, position, color, etc.).
  11784. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  11785. */
  11786. updateFunction: (particles: Particle[]) => void;
  11787. private _emitterWorldMatrix;
  11788. /**
  11789. * This function can be defined to specify initial direction for every new particle.
  11790. * It by default use the emitterType defined function
  11791. */
  11792. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  11793. /**
  11794. * This function can be defined to specify initial position for every new particle.
  11795. * It by default use the emitterType defined function
  11796. */
  11797. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  11798. /**
  11799. * @hidden
  11800. */
  11801. _inheritedVelocityOffset: Vector3;
  11802. /**
  11803. * An event triggered when the system is disposed
  11804. */
  11805. onDisposeObservable: Observable<ParticleSystem>;
  11806. private _onDisposeObserver;
  11807. /**
  11808. * Sets a callback that will be triggered when the system is disposed
  11809. */
  11810. set onDispose(callback: () => void);
  11811. private _particles;
  11812. private _epsilon;
  11813. private _capacity;
  11814. private _stockParticles;
  11815. private _newPartsExcess;
  11816. private _vertexData;
  11817. private _vertexBuffer;
  11818. private _vertexBuffers;
  11819. private _spriteBuffer;
  11820. private _indexBuffer;
  11821. private _effect;
  11822. private _customEffect;
  11823. private _cachedDefines;
  11824. private _scaledColorStep;
  11825. private _colorDiff;
  11826. private _scaledDirection;
  11827. private _scaledGravity;
  11828. private _currentRenderId;
  11829. private _alive;
  11830. private _useInstancing;
  11831. private _started;
  11832. private _stopped;
  11833. private _actualFrame;
  11834. private _scaledUpdateSpeed;
  11835. private _vertexBufferSize;
  11836. /** @hidden */
  11837. _currentEmitRateGradient: Nullable<FactorGradient>;
  11838. /** @hidden */
  11839. _currentEmitRate1: number;
  11840. /** @hidden */
  11841. _currentEmitRate2: number;
  11842. /** @hidden */
  11843. _currentStartSizeGradient: Nullable<FactorGradient>;
  11844. /** @hidden */
  11845. _currentStartSize1: number;
  11846. /** @hidden */
  11847. _currentStartSize2: number;
  11848. private readonly _rawTextureWidth;
  11849. private _rampGradientsTexture;
  11850. private _useRampGradients;
  11851. /** Gets or sets a boolean indicating that ramp gradients must be used
  11852. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  11853. */
  11854. get useRampGradients(): boolean;
  11855. set useRampGradients(value: boolean);
  11856. /**
  11857. * 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.
  11858. * 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: [])
  11859. */
  11860. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  11861. private _subEmitters;
  11862. /**
  11863. * @hidden
  11864. * If the particle systems emitter should be disposed when the particle system is disposed
  11865. */
  11866. _disposeEmitterOnDispose: boolean;
  11867. /**
  11868. * The current active Sub-systems, this property is used by the root particle system only.
  11869. */
  11870. activeSubSystems: Array<ParticleSystem>;
  11871. private _rootParticleSystem;
  11872. /**
  11873. * Gets the current list of active particles
  11874. */
  11875. get particles(): Particle[];
  11876. /**
  11877. * Returns the string "ParticleSystem"
  11878. * @returns a string containing the class name
  11879. */
  11880. getClassName(): string;
  11881. /**
  11882. * Instantiates a particle system.
  11883. * 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.
  11884. * @param name The name of the particle system
  11885. * @param capacity The max number of particles alive at the same time
  11886. * @param scene The scene the particle system belongs to
  11887. * @param customEffect a custom effect used to change the way particles are rendered by default
  11888. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  11889. * @param epsilon Offset used to render the particles
  11890. */
  11891. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  11892. private _addFactorGradient;
  11893. private _removeFactorGradient;
  11894. /**
  11895. * Adds a new life time gradient
  11896. * @param gradient defines the gradient to use (between 0 and 1)
  11897. * @param factor defines the life time factor to affect to the specified gradient
  11898. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11899. * @returns the current particle system
  11900. */
  11901. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11902. /**
  11903. * Remove a specific life time gradient
  11904. * @param gradient defines the gradient to remove
  11905. * @returns the current particle system
  11906. */
  11907. removeLifeTimeGradient(gradient: number): IParticleSystem;
  11908. /**
  11909. * Adds a new size gradient
  11910. * @param gradient defines the gradient to use (between 0 and 1)
  11911. * @param factor defines the size factor to affect to the specified gradient
  11912. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11913. * @returns the current particle system
  11914. */
  11915. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11916. /**
  11917. * Remove a specific size gradient
  11918. * @param gradient defines the gradient to remove
  11919. * @returns the current particle system
  11920. */
  11921. removeSizeGradient(gradient: number): IParticleSystem;
  11922. /**
  11923. * Adds a new color remap gradient
  11924. * @param gradient defines the gradient to use (between 0 and 1)
  11925. * @param min defines the color remap minimal range
  11926. * @param max defines the color remap maximal range
  11927. * @returns the current particle system
  11928. */
  11929. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11930. /**
  11931. * Remove a specific color remap gradient
  11932. * @param gradient defines the gradient to remove
  11933. * @returns the current particle system
  11934. */
  11935. removeColorRemapGradient(gradient: number): IParticleSystem;
  11936. /**
  11937. * Adds a new alpha remap gradient
  11938. * @param gradient defines the gradient to use (between 0 and 1)
  11939. * @param min defines the alpha remap minimal range
  11940. * @param max defines the alpha remap maximal range
  11941. * @returns the current particle system
  11942. */
  11943. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11944. /**
  11945. * Remove a specific alpha remap gradient
  11946. * @param gradient defines the gradient to remove
  11947. * @returns the current particle system
  11948. */
  11949. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  11950. /**
  11951. * Adds a new angular speed gradient
  11952. * @param gradient defines the gradient to use (between 0 and 1)
  11953. * @param factor defines the angular speed to affect to the specified gradient
  11954. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11955. * @returns the current particle system
  11956. */
  11957. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11958. /**
  11959. * Remove a specific angular speed gradient
  11960. * @param gradient defines the gradient to remove
  11961. * @returns the current particle system
  11962. */
  11963. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  11964. /**
  11965. * Adds a new velocity gradient
  11966. * @param gradient defines the gradient to use (between 0 and 1)
  11967. * @param factor defines the velocity to affect to the specified gradient
  11968. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11969. * @returns the current particle system
  11970. */
  11971. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11972. /**
  11973. * Remove a specific velocity gradient
  11974. * @param gradient defines the gradient to remove
  11975. * @returns the current particle system
  11976. */
  11977. removeVelocityGradient(gradient: number): IParticleSystem;
  11978. /**
  11979. * Adds a new limit velocity gradient
  11980. * @param gradient defines the gradient to use (between 0 and 1)
  11981. * @param factor defines the limit velocity value to affect to the specified gradient
  11982. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11983. * @returns the current particle system
  11984. */
  11985. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11986. /**
  11987. * Remove a specific limit velocity gradient
  11988. * @param gradient defines the gradient to remove
  11989. * @returns the current particle system
  11990. */
  11991. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  11992. /**
  11993. * Adds a new drag gradient
  11994. * @param gradient defines the gradient to use (between 0 and 1)
  11995. * @param factor defines the drag value to affect to the specified gradient
  11996. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11997. * @returns the current particle system
  11998. */
  11999. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12000. /**
  12001. * Remove a specific drag gradient
  12002. * @param gradient defines the gradient to remove
  12003. * @returns the current particle system
  12004. */
  12005. removeDragGradient(gradient: number): IParticleSystem;
  12006. /**
  12007. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12008. * @param gradient defines the gradient to use (between 0 and 1)
  12009. * @param factor defines the emit rate value to affect to the specified gradient
  12010. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12011. * @returns the current particle system
  12012. */
  12013. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12014. /**
  12015. * Remove a specific emit rate gradient
  12016. * @param gradient defines the gradient to remove
  12017. * @returns the current particle system
  12018. */
  12019. removeEmitRateGradient(gradient: number): IParticleSystem;
  12020. /**
  12021. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12022. * @param gradient defines the gradient to use (between 0 and 1)
  12023. * @param factor defines the start size value to affect to the specified gradient
  12024. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12025. * @returns the current particle system
  12026. */
  12027. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12028. /**
  12029. * Remove a specific start size gradient
  12030. * @param gradient defines the gradient to remove
  12031. * @returns the current particle system
  12032. */
  12033. removeStartSizeGradient(gradient: number): IParticleSystem;
  12034. private _createRampGradientTexture;
  12035. /**
  12036. * Gets the current list of ramp gradients.
  12037. * You must use addRampGradient and removeRampGradient to udpate this list
  12038. * @returns the list of ramp gradients
  12039. */
  12040. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12041. /**
  12042. * Adds a new ramp gradient used to remap particle colors
  12043. * @param gradient defines the gradient to use (between 0 and 1)
  12044. * @param color defines the color to affect to the specified gradient
  12045. * @returns the current particle system
  12046. */
  12047. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12048. /**
  12049. * Remove a specific ramp gradient
  12050. * @param gradient defines the gradient to remove
  12051. * @returns the current particle system
  12052. */
  12053. removeRampGradient(gradient: number): ParticleSystem;
  12054. /**
  12055. * Adds a new color gradient
  12056. * @param gradient defines the gradient to use (between 0 and 1)
  12057. * @param color1 defines the color to affect to the specified gradient
  12058. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12059. * @returns this particle system
  12060. */
  12061. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12062. /**
  12063. * Remove a specific color gradient
  12064. * @param gradient defines the gradient to remove
  12065. * @returns this particle system
  12066. */
  12067. removeColorGradient(gradient: number): IParticleSystem;
  12068. private _fetchR;
  12069. protected _reset(): void;
  12070. private _resetEffect;
  12071. private _createVertexBuffers;
  12072. private _createIndexBuffer;
  12073. /**
  12074. * Gets the maximum number of particles active at the same time.
  12075. * @returns The max number of active particles.
  12076. */
  12077. getCapacity(): number;
  12078. /**
  12079. * Gets whether there are still active particles in the system.
  12080. * @returns True if it is alive, otherwise false.
  12081. */
  12082. isAlive(): boolean;
  12083. /**
  12084. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12085. * @returns True if it has been started, otherwise false.
  12086. */
  12087. isStarted(): boolean;
  12088. private _prepareSubEmitterInternalArray;
  12089. /**
  12090. * Starts the particle system and begins to emit
  12091. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12092. */
  12093. start(delay?: number): void;
  12094. /**
  12095. * Stops the particle system.
  12096. * @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.
  12097. */
  12098. stop(stopSubEmitters?: boolean): void;
  12099. /**
  12100. * Remove all active particles
  12101. */
  12102. reset(): void;
  12103. /**
  12104. * @hidden (for internal use only)
  12105. */
  12106. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12107. /**
  12108. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12109. * Its lifetime will start back at 0.
  12110. */
  12111. recycleParticle: (particle: Particle) => void;
  12112. private _stopSubEmitters;
  12113. private _createParticle;
  12114. private _removeFromRoot;
  12115. private _emitFromParticle;
  12116. private _update;
  12117. /** @hidden */
  12118. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12119. /** @hidden */
  12120. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12121. /** @hidden */
  12122. private _getEffect;
  12123. /**
  12124. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12125. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12126. */
  12127. animate(preWarmOnly?: boolean): void;
  12128. private _appendParticleVertices;
  12129. /**
  12130. * Rebuilds the particle system.
  12131. */
  12132. rebuild(): void;
  12133. /**
  12134. * Is this system ready to be used/rendered
  12135. * @return true if the system is ready
  12136. */
  12137. isReady(): boolean;
  12138. private _render;
  12139. /**
  12140. * Renders the particle system in its current state.
  12141. * @returns the current number of particles
  12142. */
  12143. render(): number;
  12144. /**
  12145. * Disposes the particle system and free the associated resources
  12146. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12147. */
  12148. dispose(disposeTexture?: boolean): void;
  12149. /**
  12150. * Clones the particle system.
  12151. * @param name The name of the cloned object
  12152. * @param newEmitter The new emitter to use
  12153. * @returns the cloned particle system
  12154. */
  12155. clone(name: string, newEmitter: any): ParticleSystem;
  12156. /**
  12157. * Serializes the particle system to a JSON object.
  12158. * @returns the JSON object
  12159. */
  12160. serialize(): any;
  12161. /** @hidden */
  12162. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  12163. /** @hidden */
  12164. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12165. /**
  12166. * Parses a JSON object to create a particle system.
  12167. * @param parsedParticleSystem The JSON object to parse
  12168. * @param scene The scene to create the particle system in
  12169. * @param rootUrl The root url to use to load external dependencies like texture
  12170. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12171. * @returns the Parsed particle system
  12172. */
  12173. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12174. }
  12175. }
  12176. declare module "babylonjs/Particles/particle" {
  12177. import { Nullable } from "babylonjs/types";
  12178. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  12179. import { Color4 } from "babylonjs/Maths/math.color";
  12180. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12181. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12182. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  12183. /**
  12184. * A particle represents one of the element emitted by a particle system.
  12185. * This is mainly define by its coordinates, direction, velocity and age.
  12186. */
  12187. export class Particle {
  12188. /**
  12189. * The particle system the particle belongs to.
  12190. */
  12191. particleSystem: ParticleSystem;
  12192. private static _Count;
  12193. /**
  12194. * Unique ID of the particle
  12195. */
  12196. id: number;
  12197. /**
  12198. * The world position of the particle in the scene.
  12199. */
  12200. position: Vector3;
  12201. /**
  12202. * The world direction of the particle in the scene.
  12203. */
  12204. direction: Vector3;
  12205. /**
  12206. * The color of the particle.
  12207. */
  12208. color: Color4;
  12209. /**
  12210. * The color change of the particle per step.
  12211. */
  12212. colorStep: Color4;
  12213. /**
  12214. * Defines how long will the life of the particle be.
  12215. */
  12216. lifeTime: number;
  12217. /**
  12218. * The current age of the particle.
  12219. */
  12220. age: number;
  12221. /**
  12222. * The current size of the particle.
  12223. */
  12224. size: number;
  12225. /**
  12226. * The current scale of the particle.
  12227. */
  12228. scale: Vector2;
  12229. /**
  12230. * The current angle of the particle.
  12231. */
  12232. angle: number;
  12233. /**
  12234. * Defines how fast is the angle changing.
  12235. */
  12236. angularSpeed: number;
  12237. /**
  12238. * Defines the cell index used by the particle to be rendered from a sprite.
  12239. */
  12240. cellIndex: number;
  12241. /**
  12242. * The information required to support color remapping
  12243. */
  12244. remapData: Vector4;
  12245. /** @hidden */
  12246. _randomCellOffset?: number;
  12247. /** @hidden */
  12248. _initialDirection: Nullable<Vector3>;
  12249. /** @hidden */
  12250. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12251. /** @hidden */
  12252. _initialStartSpriteCellID: number;
  12253. /** @hidden */
  12254. _initialEndSpriteCellID: number;
  12255. /** @hidden */
  12256. _currentColorGradient: Nullable<ColorGradient>;
  12257. /** @hidden */
  12258. _currentColor1: Color4;
  12259. /** @hidden */
  12260. _currentColor2: Color4;
  12261. /** @hidden */
  12262. _currentSizeGradient: Nullable<FactorGradient>;
  12263. /** @hidden */
  12264. _currentSize1: number;
  12265. /** @hidden */
  12266. _currentSize2: number;
  12267. /** @hidden */
  12268. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12269. /** @hidden */
  12270. _currentAngularSpeed1: number;
  12271. /** @hidden */
  12272. _currentAngularSpeed2: number;
  12273. /** @hidden */
  12274. _currentVelocityGradient: Nullable<FactorGradient>;
  12275. /** @hidden */
  12276. _currentVelocity1: number;
  12277. /** @hidden */
  12278. _currentVelocity2: number;
  12279. /** @hidden */
  12280. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12281. /** @hidden */
  12282. _currentLimitVelocity1: number;
  12283. /** @hidden */
  12284. _currentLimitVelocity2: number;
  12285. /** @hidden */
  12286. _currentDragGradient: Nullable<FactorGradient>;
  12287. /** @hidden */
  12288. _currentDrag1: number;
  12289. /** @hidden */
  12290. _currentDrag2: number;
  12291. /** @hidden */
  12292. _randomNoiseCoordinates1: Vector3;
  12293. /** @hidden */
  12294. _randomNoiseCoordinates2: Vector3;
  12295. /**
  12296. * Creates a new instance Particle
  12297. * @param particleSystem the particle system the particle belongs to
  12298. */
  12299. constructor(
  12300. /**
  12301. * The particle system the particle belongs to.
  12302. */
  12303. particleSystem: ParticleSystem);
  12304. private updateCellInfoFromSystem;
  12305. /**
  12306. * Defines how the sprite cell index is updated for the particle
  12307. */
  12308. updateCellIndex(): void;
  12309. /** @hidden */
  12310. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12311. /** @hidden */
  12312. _inheritParticleInfoToSubEmitters(): void;
  12313. /** @hidden */
  12314. _reset(): void;
  12315. /**
  12316. * Copy the properties of particle to another one.
  12317. * @param other the particle to copy the information to.
  12318. */
  12319. copyTo(other: Particle): void;
  12320. }
  12321. }
  12322. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  12323. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12324. import { Effect } from "babylonjs/Materials/effect";
  12325. import { Particle } from "babylonjs/Particles/particle";
  12326. import { Scene } from "babylonjs/scene";
  12327. /**
  12328. * Particle emitter represents a volume emitting particles.
  12329. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12330. */
  12331. export interface IParticleEmitterType {
  12332. /**
  12333. * Called by the particle System when the direction is computed for the created particle.
  12334. * @param worldMatrix is the world matrix of the particle system
  12335. * @param directionToUpdate is the direction vector to update with the result
  12336. * @param particle is the particle we are computed the direction for
  12337. */
  12338. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12339. /**
  12340. * Called by the particle System when the position is computed for the created particle.
  12341. * @param worldMatrix is the world matrix of the particle system
  12342. * @param positionToUpdate is the position vector to update with the result
  12343. * @param particle is the particle we are computed the position for
  12344. */
  12345. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12346. /**
  12347. * Clones the current emitter and returns a copy of it
  12348. * @returns the new emitter
  12349. */
  12350. clone(): IParticleEmitterType;
  12351. /**
  12352. * Called by the GPUParticleSystem to setup the update shader
  12353. * @param effect defines the update shader
  12354. */
  12355. applyToShader(effect: Effect): void;
  12356. /**
  12357. * Returns a string to use to update the GPU particles update shader
  12358. * @returns the effect defines string
  12359. */
  12360. getEffectDefines(): string;
  12361. /**
  12362. * Returns a string representing the class name
  12363. * @returns a string containing the class name
  12364. */
  12365. getClassName(): string;
  12366. /**
  12367. * Serializes the particle system to a JSON object.
  12368. * @returns the JSON object
  12369. */
  12370. serialize(): any;
  12371. /**
  12372. * Parse properties from a JSON object
  12373. * @param serializationObject defines the JSON object
  12374. * @param scene defines the hosting scene
  12375. */
  12376. parse(serializationObject: any, scene: Scene): void;
  12377. }
  12378. }
  12379. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  12380. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12381. import { Effect } from "babylonjs/Materials/effect";
  12382. import { Particle } from "babylonjs/Particles/particle";
  12383. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12384. /**
  12385. * Particle emitter emitting particles from the inside of a box.
  12386. * It emits the particles randomly between 2 given directions.
  12387. */
  12388. export class BoxParticleEmitter implements IParticleEmitterType {
  12389. /**
  12390. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12391. */
  12392. direction1: Vector3;
  12393. /**
  12394. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12395. */
  12396. direction2: Vector3;
  12397. /**
  12398. * 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.
  12399. */
  12400. minEmitBox: Vector3;
  12401. /**
  12402. * 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.
  12403. */
  12404. maxEmitBox: Vector3;
  12405. /**
  12406. * Creates a new instance BoxParticleEmitter
  12407. */
  12408. constructor();
  12409. /**
  12410. * Called by the particle System when the direction is computed for the created particle.
  12411. * @param worldMatrix is the world matrix of the particle system
  12412. * @param directionToUpdate is the direction vector to update with the result
  12413. * @param particle is the particle we are computed the direction for
  12414. */
  12415. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12416. /**
  12417. * Called by the particle System when the position is computed for the created particle.
  12418. * @param worldMatrix is the world matrix of the particle system
  12419. * @param positionToUpdate is the position vector to update with the result
  12420. * @param particle is the particle we are computed the position for
  12421. */
  12422. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12423. /**
  12424. * Clones the current emitter and returns a copy of it
  12425. * @returns the new emitter
  12426. */
  12427. clone(): BoxParticleEmitter;
  12428. /**
  12429. * Called by the GPUParticleSystem to setup the update shader
  12430. * @param effect defines the update shader
  12431. */
  12432. applyToShader(effect: Effect): void;
  12433. /**
  12434. * Returns a string to use to update the GPU particles update shader
  12435. * @returns a string containng the defines string
  12436. */
  12437. getEffectDefines(): string;
  12438. /**
  12439. * Returns the string "BoxParticleEmitter"
  12440. * @returns a string containing the class name
  12441. */
  12442. getClassName(): string;
  12443. /**
  12444. * Serializes the particle system to a JSON object.
  12445. * @returns the JSON object
  12446. */
  12447. serialize(): any;
  12448. /**
  12449. * Parse properties from a JSON object
  12450. * @param serializationObject defines the JSON object
  12451. */
  12452. parse(serializationObject: any): void;
  12453. }
  12454. }
  12455. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  12456. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12457. import { Effect } from "babylonjs/Materials/effect";
  12458. import { Particle } from "babylonjs/Particles/particle";
  12459. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12460. /**
  12461. * Particle emitter emitting particles from the inside of a cone.
  12462. * It emits the particles alongside the cone volume from the base to the particle.
  12463. * The emission direction might be randomized.
  12464. */
  12465. export class ConeParticleEmitter implements IParticleEmitterType {
  12466. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12467. directionRandomizer: number;
  12468. private _radius;
  12469. private _angle;
  12470. private _height;
  12471. /**
  12472. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  12473. */
  12474. radiusRange: number;
  12475. /**
  12476. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  12477. */
  12478. heightRange: number;
  12479. /**
  12480. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  12481. */
  12482. emitFromSpawnPointOnly: boolean;
  12483. /**
  12484. * Gets or sets the radius of the emission cone
  12485. */
  12486. get radius(): number;
  12487. set radius(value: number);
  12488. /**
  12489. * Gets or sets the angle of the emission cone
  12490. */
  12491. get angle(): number;
  12492. set angle(value: number);
  12493. private _buildHeight;
  12494. /**
  12495. * Creates a new instance ConeParticleEmitter
  12496. * @param radius the radius of the emission cone (1 by default)
  12497. * @param angle the cone base angle (PI by default)
  12498. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  12499. */
  12500. constructor(radius?: number, angle?: number,
  12501. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12502. directionRandomizer?: number);
  12503. /**
  12504. * Called by the particle System when the direction is computed for the created particle.
  12505. * @param worldMatrix is the world matrix of the particle system
  12506. * @param directionToUpdate is the direction vector to update with the result
  12507. * @param particle is the particle we are computed the direction for
  12508. */
  12509. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12510. /**
  12511. * Called by the particle System when the position is computed for the created particle.
  12512. * @param worldMatrix is the world matrix of the particle system
  12513. * @param positionToUpdate is the position vector to update with the result
  12514. * @param particle is the particle we are computed the position for
  12515. */
  12516. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12517. /**
  12518. * Clones the current emitter and returns a copy of it
  12519. * @returns the new emitter
  12520. */
  12521. clone(): ConeParticleEmitter;
  12522. /**
  12523. * Called by the GPUParticleSystem to setup the update shader
  12524. * @param effect defines the update shader
  12525. */
  12526. applyToShader(effect: Effect): void;
  12527. /**
  12528. * Returns a string to use to update the GPU particles update shader
  12529. * @returns a string containng the defines string
  12530. */
  12531. getEffectDefines(): string;
  12532. /**
  12533. * Returns the string "ConeParticleEmitter"
  12534. * @returns a string containing the class name
  12535. */
  12536. getClassName(): string;
  12537. /**
  12538. * Serializes the particle system to a JSON object.
  12539. * @returns the JSON object
  12540. */
  12541. serialize(): any;
  12542. /**
  12543. * Parse properties from a JSON object
  12544. * @param serializationObject defines the JSON object
  12545. */
  12546. parse(serializationObject: any): void;
  12547. }
  12548. }
  12549. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  12550. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12551. import { Effect } from "babylonjs/Materials/effect";
  12552. import { Particle } from "babylonjs/Particles/particle";
  12553. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12554. /**
  12555. * Particle emitter emitting particles from the inside of a cylinder.
  12556. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  12557. */
  12558. export class CylinderParticleEmitter implements IParticleEmitterType {
  12559. /**
  12560. * The radius of the emission cylinder.
  12561. */
  12562. radius: number;
  12563. /**
  12564. * The height of the emission cylinder.
  12565. */
  12566. height: number;
  12567. /**
  12568. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12569. */
  12570. radiusRange: number;
  12571. /**
  12572. * How much to randomize the particle direction [0-1].
  12573. */
  12574. directionRandomizer: number;
  12575. /**
  12576. * Creates a new instance CylinderParticleEmitter
  12577. * @param radius the radius of the emission cylinder (1 by default)
  12578. * @param height the height of the emission cylinder (1 by default)
  12579. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12580. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12581. */
  12582. constructor(
  12583. /**
  12584. * The radius of the emission cylinder.
  12585. */
  12586. radius?: number,
  12587. /**
  12588. * The height of the emission cylinder.
  12589. */
  12590. height?: number,
  12591. /**
  12592. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12593. */
  12594. radiusRange?: number,
  12595. /**
  12596. * How much to randomize the particle direction [0-1].
  12597. */
  12598. directionRandomizer?: number);
  12599. /**
  12600. * Called by the particle System when the direction is computed for the created particle.
  12601. * @param worldMatrix is the world matrix of the particle system
  12602. * @param directionToUpdate is the direction vector to update with the result
  12603. * @param particle is the particle we are computed the direction for
  12604. */
  12605. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12606. /**
  12607. * Called by the particle System when the position is computed for the created particle.
  12608. * @param worldMatrix is the world matrix of the particle system
  12609. * @param positionToUpdate is the position vector to update with the result
  12610. * @param particle is the particle we are computed the position for
  12611. */
  12612. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12613. /**
  12614. * Clones the current emitter and returns a copy of it
  12615. * @returns the new emitter
  12616. */
  12617. clone(): CylinderParticleEmitter;
  12618. /**
  12619. * Called by the GPUParticleSystem to setup the update shader
  12620. * @param effect defines the update shader
  12621. */
  12622. applyToShader(effect: Effect): void;
  12623. /**
  12624. * Returns a string to use to update the GPU particles update shader
  12625. * @returns a string containng the defines string
  12626. */
  12627. getEffectDefines(): string;
  12628. /**
  12629. * Returns the string "CylinderParticleEmitter"
  12630. * @returns a string containing the class name
  12631. */
  12632. getClassName(): string;
  12633. /**
  12634. * Serializes the particle system to a JSON object.
  12635. * @returns the JSON object
  12636. */
  12637. serialize(): any;
  12638. /**
  12639. * Parse properties from a JSON object
  12640. * @param serializationObject defines the JSON object
  12641. */
  12642. parse(serializationObject: any): void;
  12643. }
  12644. /**
  12645. * Particle emitter emitting particles from the inside of a cylinder.
  12646. * It emits the particles randomly between two vectors.
  12647. */
  12648. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  12649. /**
  12650. * The min limit of the emission direction.
  12651. */
  12652. direction1: Vector3;
  12653. /**
  12654. * The max limit of the emission direction.
  12655. */
  12656. direction2: Vector3;
  12657. /**
  12658. * Creates a new instance CylinderDirectedParticleEmitter
  12659. * @param radius the radius of the emission cylinder (1 by default)
  12660. * @param height the height of the emission cylinder (1 by default)
  12661. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12662. * @param direction1 the min limit of the emission direction (up vector by default)
  12663. * @param direction2 the max limit of the emission direction (up vector by default)
  12664. */
  12665. constructor(radius?: number, height?: number, radiusRange?: number,
  12666. /**
  12667. * The min limit of the emission direction.
  12668. */
  12669. direction1?: Vector3,
  12670. /**
  12671. * The max limit of the emission direction.
  12672. */
  12673. direction2?: Vector3);
  12674. /**
  12675. * Called by the particle System when the direction is computed for the created particle.
  12676. * @param worldMatrix is the world matrix of the particle system
  12677. * @param directionToUpdate is the direction vector to update with the result
  12678. * @param particle is the particle we are computed the direction for
  12679. */
  12680. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12681. /**
  12682. * Clones the current emitter and returns a copy of it
  12683. * @returns the new emitter
  12684. */
  12685. clone(): CylinderDirectedParticleEmitter;
  12686. /**
  12687. * Called by the GPUParticleSystem to setup the update shader
  12688. * @param effect defines the update shader
  12689. */
  12690. applyToShader(effect: Effect): void;
  12691. /**
  12692. * Returns a string to use to update the GPU particles update shader
  12693. * @returns a string containng the defines string
  12694. */
  12695. getEffectDefines(): string;
  12696. /**
  12697. * Returns the string "CylinderDirectedParticleEmitter"
  12698. * @returns a string containing the class name
  12699. */
  12700. getClassName(): string;
  12701. /**
  12702. * Serializes the particle system to a JSON object.
  12703. * @returns the JSON object
  12704. */
  12705. serialize(): any;
  12706. /**
  12707. * Parse properties from a JSON object
  12708. * @param serializationObject defines the JSON object
  12709. */
  12710. parse(serializationObject: any): void;
  12711. }
  12712. }
  12713. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  12714. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12715. import { Effect } from "babylonjs/Materials/effect";
  12716. import { Particle } from "babylonjs/Particles/particle";
  12717. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12718. /**
  12719. * Particle emitter emitting particles from the inside of a hemisphere.
  12720. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  12721. */
  12722. export class HemisphericParticleEmitter implements IParticleEmitterType {
  12723. /**
  12724. * The radius of the emission hemisphere.
  12725. */
  12726. radius: number;
  12727. /**
  12728. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12729. */
  12730. radiusRange: number;
  12731. /**
  12732. * How much to randomize the particle direction [0-1].
  12733. */
  12734. directionRandomizer: number;
  12735. /**
  12736. * Creates a new instance HemisphericParticleEmitter
  12737. * @param radius the radius of the emission hemisphere (1 by default)
  12738. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12739. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12740. */
  12741. constructor(
  12742. /**
  12743. * The radius of the emission hemisphere.
  12744. */
  12745. radius?: number,
  12746. /**
  12747. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12748. */
  12749. radiusRange?: number,
  12750. /**
  12751. * How much to randomize the particle direction [0-1].
  12752. */
  12753. directionRandomizer?: number);
  12754. /**
  12755. * Called by the particle System when the direction is computed for the created particle.
  12756. * @param worldMatrix is the world matrix of the particle system
  12757. * @param directionToUpdate is the direction vector to update with the result
  12758. * @param particle is the particle we are computed the direction for
  12759. */
  12760. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12761. /**
  12762. * Called by the particle System when the position is computed for the created particle.
  12763. * @param worldMatrix is the world matrix of the particle system
  12764. * @param positionToUpdate is the position vector to update with the result
  12765. * @param particle is the particle we are computed the position for
  12766. */
  12767. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12768. /**
  12769. * Clones the current emitter and returns a copy of it
  12770. * @returns the new emitter
  12771. */
  12772. clone(): HemisphericParticleEmitter;
  12773. /**
  12774. * Called by the GPUParticleSystem to setup the update shader
  12775. * @param effect defines the update shader
  12776. */
  12777. applyToShader(effect: Effect): void;
  12778. /**
  12779. * Returns a string to use to update the GPU particles update shader
  12780. * @returns a string containng the defines string
  12781. */
  12782. getEffectDefines(): string;
  12783. /**
  12784. * Returns the string "HemisphericParticleEmitter"
  12785. * @returns a string containing the class name
  12786. */
  12787. getClassName(): string;
  12788. /**
  12789. * Serializes the particle system to a JSON object.
  12790. * @returns the JSON object
  12791. */
  12792. serialize(): any;
  12793. /**
  12794. * Parse properties from a JSON object
  12795. * @param serializationObject defines the JSON object
  12796. */
  12797. parse(serializationObject: any): void;
  12798. }
  12799. }
  12800. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  12801. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12802. import { Effect } from "babylonjs/Materials/effect";
  12803. import { Particle } from "babylonjs/Particles/particle";
  12804. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12805. /**
  12806. * Particle emitter emitting particles from a point.
  12807. * It emits the particles randomly between 2 given directions.
  12808. */
  12809. export class PointParticleEmitter implements IParticleEmitterType {
  12810. /**
  12811. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12812. */
  12813. direction1: Vector3;
  12814. /**
  12815. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12816. */
  12817. direction2: Vector3;
  12818. /**
  12819. * Creates a new instance PointParticleEmitter
  12820. */
  12821. constructor();
  12822. /**
  12823. * Called by the particle System when the direction is computed for the created particle.
  12824. * @param worldMatrix is the world matrix of the particle system
  12825. * @param directionToUpdate is the direction vector to update with the result
  12826. * @param particle is the particle we are computed the direction for
  12827. */
  12828. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12829. /**
  12830. * Called by the particle System when the position is computed for the created particle.
  12831. * @param worldMatrix is the world matrix of the particle system
  12832. * @param positionToUpdate is the position vector to update with the result
  12833. * @param particle is the particle we are computed the position for
  12834. */
  12835. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12836. /**
  12837. * Clones the current emitter and returns a copy of it
  12838. * @returns the new emitter
  12839. */
  12840. clone(): PointParticleEmitter;
  12841. /**
  12842. * Called by the GPUParticleSystem to setup the update shader
  12843. * @param effect defines the update shader
  12844. */
  12845. applyToShader(effect: Effect): void;
  12846. /**
  12847. * Returns a string to use to update the GPU particles update shader
  12848. * @returns a string containng the defines string
  12849. */
  12850. getEffectDefines(): string;
  12851. /**
  12852. * Returns the string "PointParticleEmitter"
  12853. * @returns a string containing the class name
  12854. */
  12855. getClassName(): string;
  12856. /**
  12857. * Serializes the particle system to a JSON object.
  12858. * @returns the JSON object
  12859. */
  12860. serialize(): any;
  12861. /**
  12862. * Parse properties from a JSON object
  12863. * @param serializationObject defines the JSON object
  12864. */
  12865. parse(serializationObject: any): void;
  12866. }
  12867. }
  12868. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  12869. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12870. import { Effect } from "babylonjs/Materials/effect";
  12871. import { Particle } from "babylonjs/Particles/particle";
  12872. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12873. /**
  12874. * Particle emitter emitting particles from the inside of a sphere.
  12875. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  12876. */
  12877. export class SphereParticleEmitter implements IParticleEmitterType {
  12878. /**
  12879. * The radius of the emission sphere.
  12880. */
  12881. radius: number;
  12882. /**
  12883. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12884. */
  12885. radiusRange: number;
  12886. /**
  12887. * How much to randomize the particle direction [0-1].
  12888. */
  12889. directionRandomizer: number;
  12890. /**
  12891. * Creates a new instance SphereParticleEmitter
  12892. * @param radius the radius of the emission sphere (1 by default)
  12893. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12894. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12895. */
  12896. constructor(
  12897. /**
  12898. * The radius of the emission sphere.
  12899. */
  12900. radius?: number,
  12901. /**
  12902. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12903. */
  12904. radiusRange?: number,
  12905. /**
  12906. * How much to randomize the particle direction [0-1].
  12907. */
  12908. directionRandomizer?: number);
  12909. /**
  12910. * Called by the particle System when the direction is computed for the created particle.
  12911. * @param worldMatrix is the world matrix of the particle system
  12912. * @param directionToUpdate is the direction vector to update with the result
  12913. * @param particle is the particle we are computed the direction for
  12914. */
  12915. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12916. /**
  12917. * Called by the particle System when the position is computed for the created particle.
  12918. * @param worldMatrix is the world matrix of the particle system
  12919. * @param positionToUpdate is the position vector to update with the result
  12920. * @param particle is the particle we are computed the position for
  12921. */
  12922. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12923. /**
  12924. * Clones the current emitter and returns a copy of it
  12925. * @returns the new emitter
  12926. */
  12927. clone(): SphereParticleEmitter;
  12928. /**
  12929. * Called by the GPUParticleSystem to setup the update shader
  12930. * @param effect defines the update shader
  12931. */
  12932. applyToShader(effect: Effect): void;
  12933. /**
  12934. * Returns a string to use to update the GPU particles update shader
  12935. * @returns a string containng the defines string
  12936. */
  12937. getEffectDefines(): string;
  12938. /**
  12939. * Returns the string "SphereParticleEmitter"
  12940. * @returns a string containing the class name
  12941. */
  12942. getClassName(): string;
  12943. /**
  12944. * Serializes the particle system to a JSON object.
  12945. * @returns the JSON object
  12946. */
  12947. serialize(): any;
  12948. /**
  12949. * Parse properties from a JSON object
  12950. * @param serializationObject defines the JSON object
  12951. */
  12952. parse(serializationObject: any): void;
  12953. }
  12954. /**
  12955. * Particle emitter emitting particles from the inside of a sphere.
  12956. * It emits the particles randomly between two vectors.
  12957. */
  12958. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  12959. /**
  12960. * The min limit of the emission direction.
  12961. */
  12962. direction1: Vector3;
  12963. /**
  12964. * The max limit of the emission direction.
  12965. */
  12966. direction2: Vector3;
  12967. /**
  12968. * Creates a new instance SphereDirectedParticleEmitter
  12969. * @param radius the radius of the emission sphere (1 by default)
  12970. * @param direction1 the min limit of the emission direction (up vector by default)
  12971. * @param direction2 the max limit of the emission direction (up vector by default)
  12972. */
  12973. constructor(radius?: number,
  12974. /**
  12975. * The min limit of the emission direction.
  12976. */
  12977. direction1?: Vector3,
  12978. /**
  12979. * The max limit of the emission direction.
  12980. */
  12981. direction2?: Vector3);
  12982. /**
  12983. * Called by the particle System when the direction is computed for the created particle.
  12984. * @param worldMatrix is the world matrix of the particle system
  12985. * @param directionToUpdate is the direction vector to update with the result
  12986. * @param particle is the particle we are computed the direction for
  12987. */
  12988. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12989. /**
  12990. * Clones the current emitter and returns a copy of it
  12991. * @returns the new emitter
  12992. */
  12993. clone(): SphereDirectedParticleEmitter;
  12994. /**
  12995. * Called by the GPUParticleSystem to setup the update shader
  12996. * @param effect defines the update shader
  12997. */
  12998. applyToShader(effect: Effect): void;
  12999. /**
  13000. * Returns a string to use to update the GPU particles update shader
  13001. * @returns a string containng the defines string
  13002. */
  13003. getEffectDefines(): string;
  13004. /**
  13005. * Returns the string "SphereDirectedParticleEmitter"
  13006. * @returns a string containing the class name
  13007. */
  13008. getClassName(): string;
  13009. /**
  13010. * Serializes the particle system to a JSON object.
  13011. * @returns the JSON object
  13012. */
  13013. serialize(): any;
  13014. /**
  13015. * Parse properties from a JSON object
  13016. * @param serializationObject defines the JSON object
  13017. */
  13018. parse(serializationObject: any): void;
  13019. }
  13020. }
  13021. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  13022. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13023. import { Effect } from "babylonjs/Materials/effect";
  13024. import { Particle } from "babylonjs/Particles/particle";
  13025. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13026. import { Nullable } from "babylonjs/types";
  13027. /**
  13028. * Particle emitter emitting particles from a custom list of positions.
  13029. */
  13030. export class CustomParticleEmitter implements IParticleEmitterType {
  13031. /**
  13032. * Gets or sets the position generator that will create the inital position of each particle.
  13033. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13034. */
  13035. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13036. /**
  13037. * Gets or sets the destination generator that will create the final destination of each particle.
  13038. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13039. */
  13040. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13041. /**
  13042. * Creates a new instance CustomParticleEmitter
  13043. */
  13044. constructor();
  13045. /**
  13046. * Called by the particle System when the direction is computed for the created particle.
  13047. * @param worldMatrix is the world matrix of the particle system
  13048. * @param directionToUpdate is the direction vector to update with the result
  13049. * @param particle is the particle we are computed the direction for
  13050. */
  13051. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13052. /**
  13053. * Called by the particle System when the position is computed for the created particle.
  13054. * @param worldMatrix is the world matrix of the particle system
  13055. * @param positionToUpdate is the position vector to update with the result
  13056. * @param particle is the particle we are computed the position for
  13057. */
  13058. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  13059. /**
  13060. * Clones the current emitter and returns a copy of it
  13061. * @returns the new emitter
  13062. */
  13063. clone(): CustomParticleEmitter;
  13064. /**
  13065. * Called by the GPUParticleSystem to setup the update shader
  13066. * @param effect defines the update shader
  13067. */
  13068. applyToShader(effect: Effect): void;
  13069. /**
  13070. * Returns a string to use to update the GPU particles update shader
  13071. * @returns a string containng the defines string
  13072. */
  13073. getEffectDefines(): string;
  13074. /**
  13075. * Returns the string "PointParticleEmitter"
  13076. * @returns a string containing the class name
  13077. */
  13078. getClassName(): string;
  13079. /**
  13080. * Serializes the particle system to a JSON object.
  13081. * @returns the JSON object
  13082. */
  13083. serialize(): any;
  13084. /**
  13085. * Parse properties from a JSON object
  13086. * @param serializationObject defines the JSON object
  13087. */
  13088. parse(serializationObject: any): void;
  13089. }
  13090. }
  13091. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  13092. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13093. import { Effect } from "babylonjs/Materials/effect";
  13094. import { Particle } from "babylonjs/Particles/particle";
  13095. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13096. import { Scene } from "babylonjs/scene";
  13097. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13098. /**
  13099. * Particle emitter emitting particles from the inside of a box.
  13100. * It emits the particles randomly between 2 given directions.
  13101. */
  13102. export class MeshParticleEmitter implements IParticleEmitterType {
  13103. /** Defines the mesh to use as source */
  13104. mesh?: AbstractMesh | undefined;
  13105. private _indices;
  13106. private _positions;
  13107. private _normals;
  13108. private _storedNormal;
  13109. /**
  13110. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13111. */
  13112. direction1: Vector3;
  13113. /**
  13114. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13115. */
  13116. direction2: Vector3;
  13117. /**
  13118. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13119. */
  13120. useMeshNormalsForDirection: boolean;
  13121. /**
  13122. * Creates a new instance MeshParticleEmitter
  13123. * @param mesh defines the mesh to use as source
  13124. */
  13125. constructor(
  13126. /** Defines the mesh to use as source */
  13127. mesh?: AbstractMesh | undefined);
  13128. /**
  13129. * Called by the particle System when the direction is computed for the created particle.
  13130. * @param worldMatrix is the world matrix of the particle system
  13131. * @param directionToUpdate is the direction vector to update with the result
  13132. * @param particle is the particle we are computed the direction for
  13133. */
  13134. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13135. /**
  13136. * Called by the particle System when the position is computed for the created particle.
  13137. * @param worldMatrix is the world matrix of the particle system
  13138. * @param positionToUpdate is the position vector to update with the result
  13139. * @param particle is the particle we are computed the position for
  13140. */
  13141. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  13142. /**
  13143. * Clones the current emitter and returns a copy of it
  13144. * @returns the new emitter
  13145. */
  13146. clone(): MeshParticleEmitter;
  13147. /**
  13148. * Called by the GPUParticleSystem to setup the update shader
  13149. * @param effect defines the update shader
  13150. */
  13151. applyToShader(effect: Effect): void;
  13152. /**
  13153. * Returns a string to use to update the GPU particles update shader
  13154. * @returns a string containng the defines string
  13155. */
  13156. getEffectDefines(): string;
  13157. /**
  13158. * Returns the string "BoxParticleEmitter"
  13159. * @returns a string containing the class name
  13160. */
  13161. getClassName(): string;
  13162. /**
  13163. * Serializes the particle system to a JSON object.
  13164. * @returns the JSON object
  13165. */
  13166. serialize(): any;
  13167. /**
  13168. * Parse properties from a JSON object
  13169. * @param serializationObject defines the JSON object
  13170. * @param scene defines the hosting scene
  13171. */
  13172. parse(serializationObject: any, scene: Scene): void;
  13173. }
  13174. }
  13175. declare module "babylonjs/Particles/EmitterTypes/index" {
  13176. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  13177. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  13178. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  13179. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  13180. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13181. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  13182. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  13183. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  13184. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  13185. }
  13186. declare module "babylonjs/Particles/IParticleSystem" {
  13187. import { Nullable } from "babylonjs/types";
  13188. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  13189. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  13190. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13191. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  13192. import { Texture } from "babylonjs/Materials/Textures/texture";
  13193. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  13194. import { Scene } from "babylonjs/scene";
  13195. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  13196. import { Animation } from "babylonjs/Animations/animation";
  13197. /**
  13198. * Interface representing a particle system in Babylon.js.
  13199. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13200. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13201. */
  13202. export interface IParticleSystem {
  13203. /**
  13204. * List of animations used by the particle system.
  13205. */
  13206. animations: Animation[];
  13207. /**
  13208. * The id of the Particle system.
  13209. */
  13210. id: string;
  13211. /**
  13212. * The name of the Particle system.
  13213. */
  13214. name: string;
  13215. /**
  13216. * The emitter represents the Mesh or position we are attaching the particle system to.
  13217. */
  13218. emitter: Nullable<AbstractMesh | Vector3>;
  13219. /**
  13220. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13221. */
  13222. isBillboardBased: boolean;
  13223. /**
  13224. * The rendering group used by the Particle system to chose when to render.
  13225. */
  13226. renderingGroupId: number;
  13227. /**
  13228. * The layer mask we are rendering the particles through.
  13229. */
  13230. layerMask: number;
  13231. /**
  13232. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13233. */
  13234. updateSpeed: number;
  13235. /**
  13236. * The amount of time the particle system is running (depends of the overall update speed).
  13237. */
  13238. targetStopDuration: number;
  13239. /**
  13240. * The texture used to render each particle. (this can be a spritesheet)
  13241. */
  13242. particleTexture: Nullable<Texture>;
  13243. /**
  13244. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13245. */
  13246. blendMode: number;
  13247. /**
  13248. * Minimum life time of emitting particles.
  13249. */
  13250. minLifeTime: number;
  13251. /**
  13252. * Maximum life time of emitting particles.
  13253. */
  13254. maxLifeTime: number;
  13255. /**
  13256. * Minimum Size of emitting particles.
  13257. */
  13258. minSize: number;
  13259. /**
  13260. * Maximum Size of emitting particles.
  13261. */
  13262. maxSize: number;
  13263. /**
  13264. * Minimum scale of emitting particles on X axis.
  13265. */
  13266. minScaleX: number;
  13267. /**
  13268. * Maximum scale of emitting particles on X axis.
  13269. */
  13270. maxScaleX: number;
  13271. /**
  13272. * Minimum scale of emitting particles on Y axis.
  13273. */
  13274. minScaleY: number;
  13275. /**
  13276. * Maximum scale of emitting particles on Y axis.
  13277. */
  13278. maxScaleY: number;
  13279. /**
  13280. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13281. */
  13282. color1: Color4;
  13283. /**
  13284. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13285. */
  13286. color2: Color4;
  13287. /**
  13288. * Color the particle will have at the end of its lifetime.
  13289. */
  13290. colorDead: Color4;
  13291. /**
  13292. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13293. */
  13294. emitRate: number;
  13295. /**
  13296. * You can use gravity if you want to give an orientation to your particles.
  13297. */
  13298. gravity: Vector3;
  13299. /**
  13300. * Minimum power of emitting particles.
  13301. */
  13302. minEmitPower: number;
  13303. /**
  13304. * Maximum power of emitting particles.
  13305. */
  13306. maxEmitPower: number;
  13307. /**
  13308. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13309. */
  13310. minAngularSpeed: number;
  13311. /**
  13312. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13313. */
  13314. maxAngularSpeed: number;
  13315. /**
  13316. * Gets or sets the minimal initial rotation in radians.
  13317. */
  13318. minInitialRotation: number;
  13319. /**
  13320. * Gets or sets the maximal initial rotation in radians.
  13321. */
  13322. maxInitialRotation: number;
  13323. /**
  13324. * The particle emitter type defines the emitter used by the particle system.
  13325. * It can be for example box, sphere, or cone...
  13326. */
  13327. particleEmitterType: Nullable<IParticleEmitterType>;
  13328. /**
  13329. * Defines the delay in milliseconds before starting the system (0 by default)
  13330. */
  13331. startDelay: number;
  13332. /**
  13333. * 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
  13334. */
  13335. preWarmCycles: number;
  13336. /**
  13337. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13338. */
  13339. preWarmStepOffset: number;
  13340. /**
  13341. * 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)
  13342. */
  13343. spriteCellChangeSpeed: number;
  13344. /**
  13345. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13346. */
  13347. startSpriteCellID: number;
  13348. /**
  13349. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13350. */
  13351. endSpriteCellID: number;
  13352. /**
  13353. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13354. */
  13355. spriteCellWidth: number;
  13356. /**
  13357. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13358. */
  13359. spriteCellHeight: number;
  13360. /**
  13361. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13362. */
  13363. spriteRandomStartCell: boolean;
  13364. /**
  13365. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13366. */
  13367. isAnimationSheetEnabled: boolean;
  13368. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13369. translationPivot: Vector2;
  13370. /**
  13371. * Gets or sets a texture used to add random noise to particle positions
  13372. */
  13373. noiseTexture: Nullable<BaseTexture>;
  13374. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13375. noiseStrength: Vector3;
  13376. /**
  13377. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13378. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13379. */
  13380. billboardMode: number;
  13381. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13382. limitVelocityDamping: number;
  13383. /**
  13384. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13385. */
  13386. beginAnimationOnStart: boolean;
  13387. /**
  13388. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13389. */
  13390. beginAnimationFrom: number;
  13391. /**
  13392. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13393. */
  13394. beginAnimationTo: number;
  13395. /**
  13396. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13397. */
  13398. beginAnimationLoop: boolean;
  13399. /**
  13400. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13401. */
  13402. disposeOnStop: boolean;
  13403. /**
  13404. * Gets the maximum number of particles active at the same time.
  13405. * @returns The max number of active particles.
  13406. */
  13407. getCapacity(): number;
  13408. /**
  13409. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13410. * @returns True if it has been started, otherwise false.
  13411. */
  13412. isStarted(): boolean;
  13413. /**
  13414. * Animates the particle system for this frame.
  13415. */
  13416. animate(): void;
  13417. /**
  13418. * Renders the particle system in its current state.
  13419. * @returns the current number of particles
  13420. */
  13421. render(): number;
  13422. /**
  13423. * Dispose the particle system and frees its associated resources.
  13424. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13425. */
  13426. dispose(disposeTexture?: boolean): void;
  13427. /**
  13428. * Clones the particle system.
  13429. * @param name The name of the cloned object
  13430. * @param newEmitter The new emitter to use
  13431. * @returns the cloned particle system
  13432. */
  13433. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  13434. /**
  13435. * Serializes the particle system to a JSON object.
  13436. * @returns the JSON object
  13437. */
  13438. serialize(): any;
  13439. /**
  13440. * Rebuild the particle system
  13441. */
  13442. rebuild(): void;
  13443. /**
  13444. * Starts the particle system and begins to emit
  13445. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  13446. */
  13447. start(delay?: number): void;
  13448. /**
  13449. * Stops the particle system.
  13450. */
  13451. stop(): void;
  13452. /**
  13453. * Remove all active particles
  13454. */
  13455. reset(): void;
  13456. /**
  13457. * Is this system ready to be used/rendered
  13458. * @return true if the system is ready
  13459. */
  13460. isReady(): boolean;
  13461. /**
  13462. * Adds a new color gradient
  13463. * @param gradient defines the gradient to use (between 0 and 1)
  13464. * @param color1 defines the color to affect to the specified gradient
  13465. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13466. * @returns the current particle system
  13467. */
  13468. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13469. /**
  13470. * Remove a specific color gradient
  13471. * @param gradient defines the gradient to remove
  13472. * @returns the current particle system
  13473. */
  13474. removeColorGradient(gradient: number): IParticleSystem;
  13475. /**
  13476. * Adds a new size gradient
  13477. * @param gradient defines the gradient to use (between 0 and 1)
  13478. * @param factor defines the size factor to affect to the specified gradient
  13479. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13480. * @returns the current particle system
  13481. */
  13482. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13483. /**
  13484. * Remove a specific size gradient
  13485. * @param gradient defines the gradient to remove
  13486. * @returns the current particle system
  13487. */
  13488. removeSizeGradient(gradient: number): IParticleSystem;
  13489. /**
  13490. * Gets the current list of color gradients.
  13491. * You must use addColorGradient and removeColorGradient to udpate this list
  13492. * @returns the list of color gradients
  13493. */
  13494. getColorGradients(): Nullable<Array<ColorGradient>>;
  13495. /**
  13496. * Gets the current list of size gradients.
  13497. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13498. * @returns the list of size gradients
  13499. */
  13500. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13501. /**
  13502. * Gets the current list of angular speed gradients.
  13503. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13504. * @returns the list of angular speed gradients
  13505. */
  13506. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13507. /**
  13508. * Adds a new angular speed gradient
  13509. * @param gradient defines the gradient to use (between 0 and 1)
  13510. * @param factor defines the angular speed to affect to the specified gradient
  13511. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13512. * @returns the current particle system
  13513. */
  13514. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13515. /**
  13516. * Remove a specific angular speed gradient
  13517. * @param gradient defines the gradient to remove
  13518. * @returns the current particle system
  13519. */
  13520. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13521. /**
  13522. * Gets the current list of velocity gradients.
  13523. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13524. * @returns the list of velocity gradients
  13525. */
  13526. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13527. /**
  13528. * Adds a new velocity gradient
  13529. * @param gradient defines the gradient to use (between 0 and 1)
  13530. * @param factor defines the velocity to affect to the specified gradient
  13531. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13532. * @returns the current particle system
  13533. */
  13534. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13535. /**
  13536. * Remove a specific velocity gradient
  13537. * @param gradient defines the gradient to remove
  13538. * @returns the current particle system
  13539. */
  13540. removeVelocityGradient(gradient: number): IParticleSystem;
  13541. /**
  13542. * Gets the current list of limit velocity gradients.
  13543. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13544. * @returns the list of limit velocity gradients
  13545. */
  13546. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13547. /**
  13548. * Adds a new limit velocity gradient
  13549. * @param gradient defines the gradient to use (between 0 and 1)
  13550. * @param factor defines the limit velocity to affect to the specified gradient
  13551. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13552. * @returns the current particle system
  13553. */
  13554. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13555. /**
  13556. * Remove a specific limit velocity gradient
  13557. * @param gradient defines the gradient to remove
  13558. * @returns the current particle system
  13559. */
  13560. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13561. /**
  13562. * Adds a new drag gradient
  13563. * @param gradient defines the gradient to use (between 0 and 1)
  13564. * @param factor defines the drag to affect to the specified gradient
  13565. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13566. * @returns the current particle system
  13567. */
  13568. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13569. /**
  13570. * Remove a specific drag gradient
  13571. * @param gradient defines the gradient to remove
  13572. * @returns the current particle system
  13573. */
  13574. removeDragGradient(gradient: number): IParticleSystem;
  13575. /**
  13576. * Gets the current list of drag gradients.
  13577. * You must use addDragGradient and removeDragGradient to udpate this list
  13578. * @returns the list of drag gradients
  13579. */
  13580. getDragGradients(): Nullable<Array<FactorGradient>>;
  13581. /**
  13582. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13583. * @param gradient defines the gradient to use (between 0 and 1)
  13584. * @param factor defines the emit rate to affect to the specified gradient
  13585. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13586. * @returns the current particle system
  13587. */
  13588. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13589. /**
  13590. * Remove a specific emit rate gradient
  13591. * @param gradient defines the gradient to remove
  13592. * @returns the current particle system
  13593. */
  13594. removeEmitRateGradient(gradient: number): IParticleSystem;
  13595. /**
  13596. * Gets the current list of emit rate gradients.
  13597. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13598. * @returns the list of emit rate gradients
  13599. */
  13600. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13601. /**
  13602. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13603. * @param gradient defines the gradient to use (between 0 and 1)
  13604. * @param factor defines the start size to affect to the specified gradient
  13605. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13606. * @returns the current particle system
  13607. */
  13608. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13609. /**
  13610. * Remove a specific start size gradient
  13611. * @param gradient defines the gradient to remove
  13612. * @returns the current particle system
  13613. */
  13614. removeStartSizeGradient(gradient: number): IParticleSystem;
  13615. /**
  13616. * Gets the current list of start size gradients.
  13617. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13618. * @returns the list of start size gradients
  13619. */
  13620. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13621. /**
  13622. * Adds a new life time gradient
  13623. * @param gradient defines the gradient to use (between 0 and 1)
  13624. * @param factor defines the life time factor to affect to the specified gradient
  13625. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13626. * @returns the current particle system
  13627. */
  13628. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13629. /**
  13630. * Remove a specific life time gradient
  13631. * @param gradient defines the gradient to remove
  13632. * @returns the current particle system
  13633. */
  13634. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13635. /**
  13636. * Gets the current list of life time gradients.
  13637. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13638. * @returns the list of life time gradients
  13639. */
  13640. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13641. /**
  13642. * Gets the current list of color gradients.
  13643. * You must use addColorGradient and removeColorGradient to udpate this list
  13644. * @returns the list of color gradients
  13645. */
  13646. getColorGradients(): Nullable<Array<ColorGradient>>;
  13647. /**
  13648. * Adds a new ramp gradient used to remap particle colors
  13649. * @param gradient defines the gradient to use (between 0 and 1)
  13650. * @param color defines the color to affect to the specified gradient
  13651. * @returns the current particle system
  13652. */
  13653. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  13654. /**
  13655. * Gets the current list of ramp gradients.
  13656. * You must use addRampGradient and removeRampGradient to udpate this list
  13657. * @returns the list of ramp gradients
  13658. */
  13659. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13660. /** Gets or sets a boolean indicating that ramp gradients must be used
  13661. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13662. */
  13663. useRampGradients: boolean;
  13664. /**
  13665. * Adds a new color remap gradient
  13666. * @param gradient defines the gradient to use (between 0 and 1)
  13667. * @param min defines the color remap minimal range
  13668. * @param max defines the color remap maximal range
  13669. * @returns the current particle system
  13670. */
  13671. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13672. /**
  13673. * Gets the current list of color remap gradients.
  13674. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13675. * @returns the list of color remap gradients
  13676. */
  13677. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13678. /**
  13679. * Adds a new alpha remap gradient
  13680. * @param gradient defines the gradient to use (between 0 and 1)
  13681. * @param min defines the alpha remap minimal range
  13682. * @param max defines the alpha remap maximal range
  13683. * @returns the current particle system
  13684. */
  13685. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13686. /**
  13687. * Gets the current list of alpha remap gradients.
  13688. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13689. * @returns the list of alpha remap gradients
  13690. */
  13691. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13692. /**
  13693. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13694. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13695. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13696. * @returns the emitter
  13697. */
  13698. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13699. /**
  13700. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13701. * @param radius The radius of the hemisphere to emit from
  13702. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13703. * @returns the emitter
  13704. */
  13705. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  13706. /**
  13707. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13708. * @param radius The radius of the sphere to emit from
  13709. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13710. * @returns the emitter
  13711. */
  13712. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  13713. /**
  13714. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13715. * @param radius The radius of the sphere to emit from
  13716. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13717. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13718. * @returns the emitter
  13719. */
  13720. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13721. /**
  13722. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13723. * @param radius The radius of the emission cylinder
  13724. * @param height The height of the emission cylinder
  13725. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13726. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13727. * @returns the emitter
  13728. */
  13729. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  13730. /**
  13731. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13732. * @param radius The radius of the cylinder to emit from
  13733. * @param height The height of the emission cylinder
  13734. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13735. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13736. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13737. * @returns the emitter
  13738. */
  13739. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13740. /**
  13741. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13742. * @param radius The radius of the cone to emit from
  13743. * @param angle The base angle of the cone
  13744. * @returns the emitter
  13745. */
  13746. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  13747. /**
  13748. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13749. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13750. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13751. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13752. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13753. * @returns the emitter
  13754. */
  13755. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13756. /**
  13757. * Get hosting scene
  13758. * @returns the scene
  13759. */
  13760. getScene(): Scene;
  13761. }
  13762. }
  13763. declare module "babylonjs/Meshes/transformNode" {
  13764. import { DeepImmutable } from "babylonjs/types";
  13765. import { Observable } from "babylonjs/Misc/observable";
  13766. import { Nullable } from "babylonjs/types";
  13767. import { Camera } from "babylonjs/Cameras/camera";
  13768. import { Scene } from "babylonjs/scene";
  13769. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  13770. import { Node } from "babylonjs/node";
  13771. import { Bone } from "babylonjs/Bones/bone";
  13772. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13773. import { Space } from "babylonjs/Maths/math.axis";
  13774. /**
  13775. * 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.
  13776. * @see https://doc.babylonjs.com/how_to/transformnode
  13777. */
  13778. export class TransformNode extends Node {
  13779. /**
  13780. * Object will not rotate to face the camera
  13781. */
  13782. static BILLBOARDMODE_NONE: number;
  13783. /**
  13784. * Object will rotate to face the camera but only on the x axis
  13785. */
  13786. static BILLBOARDMODE_X: number;
  13787. /**
  13788. * Object will rotate to face the camera but only on the y axis
  13789. */
  13790. static BILLBOARDMODE_Y: number;
  13791. /**
  13792. * Object will rotate to face the camera but only on the z axis
  13793. */
  13794. static BILLBOARDMODE_Z: number;
  13795. /**
  13796. * Object will rotate to face the camera
  13797. */
  13798. static BILLBOARDMODE_ALL: number;
  13799. /**
  13800. * Object will rotate to face the camera's position instead of orientation
  13801. */
  13802. static BILLBOARDMODE_USE_POSITION: number;
  13803. private _forward;
  13804. private _forwardInverted;
  13805. private _up;
  13806. private _right;
  13807. private _rightInverted;
  13808. private _position;
  13809. private _rotation;
  13810. private _rotationQuaternion;
  13811. protected _scaling: Vector3;
  13812. protected _isDirty: boolean;
  13813. private _transformToBoneReferal;
  13814. private _isAbsoluteSynced;
  13815. private _billboardMode;
  13816. /**
  13817. * Gets or sets the billboard mode. Default is 0.
  13818. *
  13819. * | Value | Type | Description |
  13820. * | --- | --- | --- |
  13821. * | 0 | BILLBOARDMODE_NONE | |
  13822. * | 1 | BILLBOARDMODE_X | |
  13823. * | 2 | BILLBOARDMODE_Y | |
  13824. * | 4 | BILLBOARDMODE_Z | |
  13825. * | 7 | BILLBOARDMODE_ALL | |
  13826. *
  13827. */
  13828. get billboardMode(): number;
  13829. set billboardMode(value: number);
  13830. private _preserveParentRotationForBillboard;
  13831. /**
  13832. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13833. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13834. */
  13835. get preserveParentRotationForBillboard(): boolean;
  13836. set preserveParentRotationForBillboard(value: boolean);
  13837. /**
  13838. * 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
  13839. */
  13840. scalingDeterminant: number;
  13841. private _infiniteDistance;
  13842. /**
  13843. * Gets or sets the distance of the object to max, often used by skybox
  13844. */
  13845. get infiniteDistance(): boolean;
  13846. set infiniteDistance(value: boolean);
  13847. /**
  13848. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13849. * By default the system will update normals to compensate
  13850. */
  13851. ignoreNonUniformScaling: boolean;
  13852. /**
  13853. * 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
  13854. */
  13855. reIntegrateRotationIntoRotationQuaternion: boolean;
  13856. /** @hidden */
  13857. _poseMatrix: Nullable<Matrix>;
  13858. /** @hidden */
  13859. _localMatrix: Matrix;
  13860. private _usePivotMatrix;
  13861. private _absolutePosition;
  13862. private _absoluteScaling;
  13863. private _absoluteRotationQuaternion;
  13864. private _pivotMatrix;
  13865. private _pivotMatrixInverse;
  13866. protected _postMultiplyPivotMatrix: boolean;
  13867. protected _isWorldMatrixFrozen: boolean;
  13868. /** @hidden */
  13869. _indexInSceneTransformNodesArray: number;
  13870. /**
  13871. * An event triggered after the world matrix is updated
  13872. */
  13873. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13874. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13875. /**
  13876. * Gets a string identifying the name of the class
  13877. * @returns "TransformNode" string
  13878. */
  13879. getClassName(): string;
  13880. /**
  13881. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13882. */
  13883. get position(): Vector3;
  13884. set position(newPosition: Vector3);
  13885. /**
  13886. * 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)).
  13887. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13888. */
  13889. get rotation(): Vector3;
  13890. set rotation(newRotation: Vector3);
  13891. /**
  13892. * 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)).
  13893. */
  13894. get scaling(): Vector3;
  13895. set scaling(newScaling: Vector3);
  13896. /**
  13897. * 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).
  13898. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13899. */
  13900. get rotationQuaternion(): Nullable<Quaternion>;
  13901. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  13902. /**
  13903. * The forward direction of that transform in world space.
  13904. */
  13905. get forward(): Vector3;
  13906. /**
  13907. * The up direction of that transform in world space.
  13908. */
  13909. get up(): Vector3;
  13910. /**
  13911. * The right direction of that transform in world space.
  13912. */
  13913. get right(): Vector3;
  13914. /**
  13915. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13916. * @param matrix the matrix to copy the pose from
  13917. * @returns this TransformNode.
  13918. */
  13919. updatePoseMatrix(matrix: Matrix): TransformNode;
  13920. /**
  13921. * Returns the mesh Pose matrix.
  13922. * @returns the pose matrix
  13923. */
  13924. getPoseMatrix(): Matrix;
  13925. /** @hidden */
  13926. _isSynchronized(): boolean;
  13927. /** @hidden */
  13928. _initCache(): void;
  13929. /**
  13930. * Flag the transform node as dirty (Forcing it to update everything)
  13931. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13932. * @returns this transform node
  13933. */
  13934. markAsDirty(property: string): TransformNode;
  13935. /**
  13936. * Returns the current mesh absolute position.
  13937. * Returns a Vector3.
  13938. */
  13939. get absolutePosition(): Vector3;
  13940. /**
  13941. * Returns the current mesh absolute scaling.
  13942. * Returns a Vector3.
  13943. */
  13944. get absoluteScaling(): Vector3;
  13945. /**
  13946. * Returns the current mesh absolute rotation.
  13947. * Returns a Quaternion.
  13948. */
  13949. get absoluteRotationQuaternion(): Quaternion;
  13950. /**
  13951. * Sets a new matrix to apply before all other transformation
  13952. * @param matrix defines the transform matrix
  13953. * @returns the current TransformNode
  13954. */
  13955. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13956. /**
  13957. * Sets a new pivot matrix to the current node
  13958. * @param matrix defines the new pivot matrix to use
  13959. * @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
  13960. * @returns the current TransformNode
  13961. */
  13962. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13963. /**
  13964. * Returns the mesh pivot matrix.
  13965. * Default : Identity.
  13966. * @returns the matrix
  13967. */
  13968. getPivotMatrix(): Matrix;
  13969. /**
  13970. * Instantiate (when possible) or clone that node with its hierarchy
  13971. * @param newParent defines the new parent to use for the instance (or clone)
  13972. * @param options defines options to configure how copy is done
  13973. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  13974. * @returns an instance (or a clone) of the current node with its hiearchy
  13975. */
  13976. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  13977. doNotInstantiate: boolean;
  13978. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  13979. /**
  13980. * Prevents the World matrix to be computed any longer
  13981. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13982. * @returns the TransformNode.
  13983. */
  13984. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13985. /**
  13986. * Allows back the World matrix computation.
  13987. * @returns the TransformNode.
  13988. */
  13989. unfreezeWorldMatrix(): this;
  13990. /**
  13991. * True if the World matrix has been frozen.
  13992. */
  13993. get isWorldMatrixFrozen(): boolean;
  13994. /**
  13995. * Retuns the mesh absolute position in the World.
  13996. * @returns a Vector3.
  13997. */
  13998. getAbsolutePosition(): Vector3;
  13999. /**
  14000. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14001. * @param absolutePosition the absolute position to set
  14002. * @returns the TransformNode.
  14003. */
  14004. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14005. /**
  14006. * Sets the mesh position in its local space.
  14007. * @param vector3 the position to set in localspace
  14008. * @returns the TransformNode.
  14009. */
  14010. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14011. /**
  14012. * Returns the mesh position in the local space from the current World matrix values.
  14013. * @returns a new Vector3.
  14014. */
  14015. getPositionExpressedInLocalSpace(): Vector3;
  14016. /**
  14017. * Translates the mesh along the passed Vector3 in its local space.
  14018. * @param vector3 the distance to translate in localspace
  14019. * @returns the TransformNode.
  14020. */
  14021. locallyTranslate(vector3: Vector3): TransformNode;
  14022. private static _lookAtVectorCache;
  14023. /**
  14024. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14025. * @param targetPoint the position (must be in same space as current mesh) to look at
  14026. * @param yawCor optional yaw (y-axis) correction in radians
  14027. * @param pitchCor optional pitch (x-axis) correction in radians
  14028. * @param rollCor optional roll (z-axis) correction in radians
  14029. * @param space the choosen space of the target
  14030. * @returns the TransformNode.
  14031. */
  14032. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14033. /**
  14034. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14035. * This Vector3 is expressed in the World space.
  14036. * @param localAxis axis to rotate
  14037. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14038. */
  14039. getDirection(localAxis: Vector3): Vector3;
  14040. /**
  14041. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14042. * localAxis is expressed in the mesh local space.
  14043. * result is computed in the Wordl space from the mesh World matrix.
  14044. * @param localAxis axis to rotate
  14045. * @param result the resulting transformnode
  14046. * @returns this TransformNode.
  14047. */
  14048. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14049. /**
  14050. * Sets this transform node rotation to the given local axis.
  14051. * @param localAxis the axis in local space
  14052. * @param yawCor optional yaw (y-axis) correction in radians
  14053. * @param pitchCor optional pitch (x-axis) correction in radians
  14054. * @param rollCor optional roll (z-axis) correction in radians
  14055. * @returns this TransformNode
  14056. */
  14057. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14058. /**
  14059. * Sets a new pivot point to the current node
  14060. * @param point defines the new pivot point to use
  14061. * @param space defines if the point is in world or local space (local by default)
  14062. * @returns the current TransformNode
  14063. */
  14064. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14065. /**
  14066. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14067. * @returns the pivot point
  14068. */
  14069. getPivotPoint(): Vector3;
  14070. /**
  14071. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14072. * @param result the vector3 to store the result
  14073. * @returns this TransformNode.
  14074. */
  14075. getPivotPointToRef(result: Vector3): TransformNode;
  14076. /**
  14077. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14078. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14079. */
  14080. getAbsolutePivotPoint(): Vector3;
  14081. /**
  14082. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14083. * @param result vector3 to store the result
  14084. * @returns this TransformNode.
  14085. */
  14086. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14087. /**
  14088. * Defines the passed node as the parent of the current node.
  14089. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14090. * @see https://doc.babylonjs.com/how_to/parenting
  14091. * @param node the node ot set as the parent
  14092. * @returns this TransformNode.
  14093. */
  14094. setParent(node: Nullable<Node>): TransformNode;
  14095. private _nonUniformScaling;
  14096. /**
  14097. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14098. */
  14099. get nonUniformScaling(): boolean;
  14100. /** @hidden */
  14101. _updateNonUniformScalingState(value: boolean): boolean;
  14102. /**
  14103. * Attach the current TransformNode to another TransformNode associated with a bone
  14104. * @param bone Bone affecting the TransformNode
  14105. * @param affectedTransformNode TransformNode associated with the bone
  14106. * @returns this object
  14107. */
  14108. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14109. /**
  14110. * Detach the transform node if its associated with a bone
  14111. * @returns this object
  14112. */
  14113. detachFromBone(): TransformNode;
  14114. private static _rotationAxisCache;
  14115. /**
  14116. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14117. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14118. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14119. * The passed axis is also normalized.
  14120. * @param axis the axis to rotate around
  14121. * @param amount the amount to rotate in radians
  14122. * @param space Space to rotate in (Default: local)
  14123. * @returns the TransformNode.
  14124. */
  14125. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14126. /**
  14127. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14128. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14129. * The passed axis is also normalized. .
  14130. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14131. * @param point the point to rotate around
  14132. * @param axis the axis to rotate around
  14133. * @param amount the amount to rotate in radians
  14134. * @returns the TransformNode
  14135. */
  14136. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14137. /**
  14138. * Translates the mesh along the axis vector for the passed distance in the given space.
  14139. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14140. * @param axis the axis to translate in
  14141. * @param distance the distance to translate
  14142. * @param space Space to rotate in (Default: local)
  14143. * @returns the TransformNode.
  14144. */
  14145. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14146. /**
  14147. * Adds a rotation step to the mesh current rotation.
  14148. * x, y, z are Euler angles expressed in radians.
  14149. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14150. * This means this rotation is made in the mesh local space only.
  14151. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14152. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14153. * ```javascript
  14154. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14155. * ```
  14156. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14157. * 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.
  14158. * @param x Rotation to add
  14159. * @param y Rotation to add
  14160. * @param z Rotation to add
  14161. * @returns the TransformNode.
  14162. */
  14163. addRotation(x: number, y: number, z: number): TransformNode;
  14164. /**
  14165. * @hidden
  14166. */
  14167. protected _getEffectiveParent(): Nullable<Node>;
  14168. /**
  14169. * Computes the world matrix of the node
  14170. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14171. * @returns the world matrix
  14172. */
  14173. computeWorldMatrix(force?: boolean): Matrix;
  14174. /**
  14175. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14176. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14177. */
  14178. resetLocalMatrix(independentOfChildren?: boolean): void;
  14179. protected _afterComputeWorldMatrix(): void;
  14180. /**
  14181. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14182. * @param func callback function to add
  14183. *
  14184. * @returns the TransformNode.
  14185. */
  14186. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14187. /**
  14188. * Removes a registered callback function.
  14189. * @param func callback function to remove
  14190. * @returns the TransformNode.
  14191. */
  14192. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14193. /**
  14194. * Gets the position of the current mesh in camera space
  14195. * @param camera defines the camera to use
  14196. * @returns a position
  14197. */
  14198. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14199. /**
  14200. * Returns the distance from the mesh to the active camera
  14201. * @param camera defines the camera to use
  14202. * @returns the distance
  14203. */
  14204. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14205. /**
  14206. * Clone the current transform node
  14207. * @param name Name of the new clone
  14208. * @param newParent New parent for the clone
  14209. * @param doNotCloneChildren Do not clone children hierarchy
  14210. * @returns the new transform node
  14211. */
  14212. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14213. /**
  14214. * Serializes the objects information.
  14215. * @param currentSerializationObject defines the object to serialize in
  14216. * @returns the serialized object
  14217. */
  14218. serialize(currentSerializationObject?: any): any;
  14219. /**
  14220. * Returns a new TransformNode object parsed from the source provided.
  14221. * @param parsedTransformNode is the source.
  14222. * @param scene the scne the object belongs to
  14223. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14224. * @returns a new TransformNode object parsed from the source provided.
  14225. */
  14226. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14227. /**
  14228. * Get all child-transformNodes of this node
  14229. * @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
  14230. * @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
  14231. * @returns an array of TransformNode
  14232. */
  14233. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14234. /**
  14235. * Releases resources associated with this transform node.
  14236. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14237. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14238. */
  14239. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14240. /**
  14241. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14242. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14243. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14244. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14245. * @returns the current mesh
  14246. */
  14247. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14248. private _syncAbsoluteScalingAndRotation;
  14249. }
  14250. }
  14251. declare module "babylonjs/Animations/animationPropertiesOverride" {
  14252. /**
  14253. * Class used to override all child animations of a given target
  14254. */
  14255. export class AnimationPropertiesOverride {
  14256. /**
  14257. * Gets or sets a value indicating if animation blending must be used
  14258. */
  14259. enableBlending: boolean;
  14260. /**
  14261. * Gets or sets the blending speed to use when enableBlending is true
  14262. */
  14263. blendingSpeed: number;
  14264. /**
  14265. * Gets or sets the default loop mode to use
  14266. */
  14267. loopMode: number;
  14268. }
  14269. }
  14270. declare module "babylonjs/Bones/bone" {
  14271. import { Skeleton } from "babylonjs/Bones/skeleton";
  14272. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  14273. import { Nullable } from "babylonjs/types";
  14274. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14275. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14276. import { Node } from "babylonjs/node";
  14277. import { Space } from "babylonjs/Maths/math.axis";
  14278. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  14279. /**
  14280. * Class used to store bone information
  14281. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14282. */
  14283. export class Bone extends Node {
  14284. /**
  14285. * defines the bone name
  14286. */
  14287. name: string;
  14288. private static _tmpVecs;
  14289. private static _tmpQuat;
  14290. private static _tmpMats;
  14291. /**
  14292. * Gets the list of child bones
  14293. */
  14294. children: Bone[];
  14295. /** Gets the animations associated with this bone */
  14296. animations: import("babylonjs/Animations/animation").Animation[];
  14297. /**
  14298. * Gets or sets bone length
  14299. */
  14300. length: number;
  14301. /**
  14302. * @hidden Internal only
  14303. * Set this value to map this bone to a different index in the transform matrices
  14304. * Set this value to -1 to exclude the bone from the transform matrices
  14305. */
  14306. _index: Nullable<number>;
  14307. private _skeleton;
  14308. private _localMatrix;
  14309. private _restPose;
  14310. private _baseMatrix;
  14311. private _absoluteTransform;
  14312. private _invertedAbsoluteTransform;
  14313. private _parent;
  14314. private _scalingDeterminant;
  14315. private _worldTransform;
  14316. private _localScaling;
  14317. private _localRotation;
  14318. private _localPosition;
  14319. private _needToDecompose;
  14320. private _needToCompose;
  14321. /** @hidden */
  14322. _linkedTransformNode: Nullable<TransformNode>;
  14323. /** @hidden */
  14324. _waitingTransformNodeId: Nullable<string>;
  14325. /** @hidden */
  14326. get _matrix(): Matrix;
  14327. /** @hidden */
  14328. set _matrix(value: Matrix);
  14329. /**
  14330. * Create a new bone
  14331. * @param name defines the bone name
  14332. * @param skeleton defines the parent skeleton
  14333. * @param parentBone defines the parent (can be null if the bone is the root)
  14334. * @param localMatrix defines the local matrix
  14335. * @param restPose defines the rest pose matrix
  14336. * @param baseMatrix defines the base matrix
  14337. * @param index defines index of the bone in the hiearchy
  14338. */
  14339. constructor(
  14340. /**
  14341. * defines the bone name
  14342. */
  14343. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14344. /**
  14345. * Gets the current object class name.
  14346. * @return the class name
  14347. */
  14348. getClassName(): string;
  14349. /**
  14350. * Gets the parent skeleton
  14351. * @returns a skeleton
  14352. */
  14353. getSkeleton(): Skeleton;
  14354. /**
  14355. * Gets parent bone
  14356. * @returns a bone or null if the bone is the root of the bone hierarchy
  14357. */
  14358. getParent(): Nullable<Bone>;
  14359. /**
  14360. * Returns an array containing the root bones
  14361. * @returns an array containing the root bones
  14362. */
  14363. getChildren(): Array<Bone>;
  14364. /**
  14365. * Gets the node index in matrix array generated for rendering
  14366. * @returns the node index
  14367. */
  14368. getIndex(): number;
  14369. /**
  14370. * Sets the parent bone
  14371. * @param parent defines the parent (can be null if the bone is the root)
  14372. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14373. */
  14374. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14375. /**
  14376. * Gets the local matrix
  14377. * @returns a matrix
  14378. */
  14379. getLocalMatrix(): Matrix;
  14380. /**
  14381. * Gets the base matrix (initial matrix which remains unchanged)
  14382. * @returns a matrix
  14383. */
  14384. getBaseMatrix(): Matrix;
  14385. /**
  14386. * Gets the rest pose matrix
  14387. * @returns a matrix
  14388. */
  14389. getRestPose(): Matrix;
  14390. /**
  14391. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14392. */
  14393. getWorldMatrix(): Matrix;
  14394. /**
  14395. * Sets the local matrix to rest pose matrix
  14396. */
  14397. returnToRest(): void;
  14398. /**
  14399. * Gets the inverse of the absolute transform matrix.
  14400. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14401. * @returns a matrix
  14402. */
  14403. getInvertedAbsoluteTransform(): Matrix;
  14404. /**
  14405. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14406. * @returns a matrix
  14407. */
  14408. getAbsoluteTransform(): Matrix;
  14409. /**
  14410. * Links with the given transform node.
  14411. * The local matrix of this bone is copied from the transform node every frame.
  14412. * @param transformNode defines the transform node to link to
  14413. */
  14414. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14415. /**
  14416. * Gets the node used to drive the bone's transformation
  14417. * @returns a transform node or null
  14418. */
  14419. getTransformNode(): Nullable<TransformNode>;
  14420. /** Gets or sets current position (in local space) */
  14421. get position(): Vector3;
  14422. set position(newPosition: Vector3);
  14423. /** Gets or sets current rotation (in local space) */
  14424. get rotation(): Vector3;
  14425. set rotation(newRotation: Vector3);
  14426. /** Gets or sets current rotation quaternion (in local space) */
  14427. get rotationQuaternion(): Quaternion;
  14428. set rotationQuaternion(newRotation: Quaternion);
  14429. /** Gets or sets current scaling (in local space) */
  14430. get scaling(): Vector3;
  14431. set scaling(newScaling: Vector3);
  14432. /**
  14433. * Gets the animation properties override
  14434. */
  14435. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14436. private _decompose;
  14437. private _compose;
  14438. /**
  14439. * Update the base and local matrices
  14440. * @param matrix defines the new base or local matrix
  14441. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14442. * @param updateLocalMatrix defines if the local matrix should be updated
  14443. */
  14444. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14445. /** @hidden */
  14446. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14447. /**
  14448. * Flag the bone as dirty (Forcing it to update everything)
  14449. */
  14450. markAsDirty(): void;
  14451. /** @hidden */
  14452. _markAsDirtyAndCompose(): void;
  14453. private _markAsDirtyAndDecompose;
  14454. /**
  14455. * Translate the bone in local or world space
  14456. * @param vec The amount to translate the bone
  14457. * @param space The space that the translation is in
  14458. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14459. */
  14460. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14461. /**
  14462. * Set the postion of the bone in local or world space
  14463. * @param position The position to set the bone
  14464. * @param space The space that the position is in
  14465. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14466. */
  14467. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14468. /**
  14469. * Set the absolute position of the bone (world space)
  14470. * @param position The position to set the bone
  14471. * @param mesh The mesh that this bone is attached to
  14472. */
  14473. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14474. /**
  14475. * Scale the bone on the x, y and z axes (in local space)
  14476. * @param x The amount to scale the bone on the x axis
  14477. * @param y The amount to scale the bone on the y axis
  14478. * @param z The amount to scale the bone on the z axis
  14479. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14480. */
  14481. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14482. /**
  14483. * Set the bone scaling in local space
  14484. * @param scale defines the scaling vector
  14485. */
  14486. setScale(scale: Vector3): void;
  14487. /**
  14488. * Gets the current scaling in local space
  14489. * @returns the current scaling vector
  14490. */
  14491. getScale(): Vector3;
  14492. /**
  14493. * Gets the current scaling in local space and stores it in a target vector
  14494. * @param result defines the target vector
  14495. */
  14496. getScaleToRef(result: Vector3): void;
  14497. /**
  14498. * Set the yaw, pitch, and roll of the bone in local or world space
  14499. * @param yaw The rotation of the bone on the y axis
  14500. * @param pitch The rotation of the bone on the x axis
  14501. * @param roll The rotation of the bone on the z axis
  14502. * @param space The space that the axes of rotation are in
  14503. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14504. */
  14505. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14506. /**
  14507. * Add a rotation to the bone on an axis in local or world space
  14508. * @param axis The axis to rotate the bone on
  14509. * @param amount The amount to rotate the bone
  14510. * @param space The space that the axis is in
  14511. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14512. */
  14513. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14514. /**
  14515. * Set the rotation of the bone to a particular axis angle in local or world space
  14516. * @param axis The axis to rotate the bone on
  14517. * @param angle The angle that the bone should be rotated to
  14518. * @param space The space that the axis is in
  14519. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14520. */
  14521. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14522. /**
  14523. * Set the euler rotation of the bone in local of world space
  14524. * @param rotation The euler rotation that the bone should be set to
  14525. * @param space The space that the rotation is in
  14526. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14527. */
  14528. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14529. /**
  14530. * Set the quaternion rotation of the bone in local of world space
  14531. * @param quat The quaternion rotation that the bone should be set to
  14532. * @param space The space that the rotation is in
  14533. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14534. */
  14535. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14536. /**
  14537. * Set the rotation matrix of the bone in local of world space
  14538. * @param rotMat The rotation matrix that the bone should be set to
  14539. * @param space The space that the rotation is in
  14540. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14541. */
  14542. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14543. private _rotateWithMatrix;
  14544. private _getNegativeRotationToRef;
  14545. /**
  14546. * Get the position of the bone in local or world space
  14547. * @param space The space that the returned position is in
  14548. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14549. * @returns The position of the bone
  14550. */
  14551. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14552. /**
  14553. * Copy the position of the bone to a vector3 in local or world space
  14554. * @param space The space that the returned position is in
  14555. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14556. * @param result The vector3 to copy the position to
  14557. */
  14558. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14559. /**
  14560. * Get the absolute position of the bone (world space)
  14561. * @param mesh The mesh that this bone is attached to
  14562. * @returns The absolute position of the bone
  14563. */
  14564. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14565. /**
  14566. * Copy the absolute position of the bone (world space) to the result param
  14567. * @param mesh The mesh that this bone is attached to
  14568. * @param result The vector3 to copy the absolute position to
  14569. */
  14570. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14571. /**
  14572. * Compute the absolute transforms of this bone and its children
  14573. */
  14574. computeAbsoluteTransforms(): void;
  14575. /**
  14576. * Get the world direction from an axis that is in the local space of the bone
  14577. * @param localAxis The local direction that is used to compute the world direction
  14578. * @param mesh The mesh that this bone is attached to
  14579. * @returns The world direction
  14580. */
  14581. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14582. /**
  14583. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14584. * @param localAxis The local direction that is used to compute the world direction
  14585. * @param mesh The mesh that this bone is attached to
  14586. * @param result The vector3 that the world direction will be copied to
  14587. */
  14588. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14589. /**
  14590. * Get the euler rotation of the bone in local or world space
  14591. * @param space The space that the rotation should be in
  14592. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14593. * @returns The euler rotation
  14594. */
  14595. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14596. /**
  14597. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14598. * @param space The space that the rotation should be in
  14599. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14600. * @param result The vector3 that the rotation should be copied to
  14601. */
  14602. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14603. /**
  14604. * Get the quaternion rotation of the bone in either local or world space
  14605. * @param space The space that the rotation should be in
  14606. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14607. * @returns The quaternion rotation
  14608. */
  14609. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14610. /**
  14611. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14612. * @param space The space that the rotation should be in
  14613. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14614. * @param result The quaternion that the rotation should be copied to
  14615. */
  14616. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14617. /**
  14618. * Get the rotation matrix of the bone in local or world space
  14619. * @param space The space that the rotation should be in
  14620. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14621. * @returns The rotation matrix
  14622. */
  14623. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14624. /**
  14625. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14626. * @param space The space that the rotation should be in
  14627. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14628. * @param result The quaternion that the rotation should be copied to
  14629. */
  14630. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14631. /**
  14632. * Get the world position of a point that is in the local space of the bone
  14633. * @param position The local position
  14634. * @param mesh The mesh that this bone is attached to
  14635. * @returns The world position
  14636. */
  14637. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14638. /**
  14639. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14640. * @param position The local position
  14641. * @param mesh The mesh that this bone is attached to
  14642. * @param result The vector3 that the world position should be copied to
  14643. */
  14644. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14645. /**
  14646. * Get the local position of a point that is in world space
  14647. * @param position The world position
  14648. * @param mesh The mesh that this bone is attached to
  14649. * @returns The local position
  14650. */
  14651. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14652. /**
  14653. * Get the local position of a point that is in world space and copy it to the result param
  14654. * @param position The world position
  14655. * @param mesh The mesh that this bone is attached to
  14656. * @param result The vector3 that the local position should be copied to
  14657. */
  14658. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14659. }
  14660. }
  14661. declare module "babylonjs/Animations/runtimeAnimation" {
  14662. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  14663. import { Animatable } from "babylonjs/Animations/animatable";
  14664. import { Scene } from "babylonjs/scene";
  14665. /**
  14666. * Defines a runtime animation
  14667. */
  14668. export class RuntimeAnimation {
  14669. private _events;
  14670. /**
  14671. * The current frame of the runtime animation
  14672. */
  14673. private _currentFrame;
  14674. /**
  14675. * The animation used by the runtime animation
  14676. */
  14677. private _animation;
  14678. /**
  14679. * The target of the runtime animation
  14680. */
  14681. private _target;
  14682. /**
  14683. * The initiating animatable
  14684. */
  14685. private _host;
  14686. /**
  14687. * The original value of the runtime animation
  14688. */
  14689. private _originalValue;
  14690. /**
  14691. * The original blend value of the runtime animation
  14692. */
  14693. private _originalBlendValue;
  14694. /**
  14695. * The offsets cache of the runtime animation
  14696. */
  14697. private _offsetsCache;
  14698. /**
  14699. * The high limits cache of the runtime animation
  14700. */
  14701. private _highLimitsCache;
  14702. /**
  14703. * Specifies if the runtime animation has been stopped
  14704. */
  14705. private _stopped;
  14706. /**
  14707. * The blending factor of the runtime animation
  14708. */
  14709. private _blendingFactor;
  14710. /**
  14711. * The BabylonJS scene
  14712. */
  14713. private _scene;
  14714. /**
  14715. * The current value of the runtime animation
  14716. */
  14717. private _currentValue;
  14718. /** @hidden */
  14719. _animationState: _IAnimationState;
  14720. /**
  14721. * The active target of the runtime animation
  14722. */
  14723. private _activeTargets;
  14724. private _currentActiveTarget;
  14725. private _directTarget;
  14726. /**
  14727. * The target path of the runtime animation
  14728. */
  14729. private _targetPath;
  14730. /**
  14731. * The weight of the runtime animation
  14732. */
  14733. private _weight;
  14734. /**
  14735. * The ratio offset of the runtime animation
  14736. */
  14737. private _ratioOffset;
  14738. /**
  14739. * The previous delay of the runtime animation
  14740. */
  14741. private _previousDelay;
  14742. /**
  14743. * The previous ratio of the runtime animation
  14744. */
  14745. private _previousRatio;
  14746. private _enableBlending;
  14747. private _keys;
  14748. private _minFrame;
  14749. private _maxFrame;
  14750. private _minValue;
  14751. private _maxValue;
  14752. private _targetIsArray;
  14753. /**
  14754. * Gets the current frame of the runtime animation
  14755. */
  14756. get currentFrame(): number;
  14757. /**
  14758. * Gets the weight of the runtime animation
  14759. */
  14760. get weight(): number;
  14761. /**
  14762. * Gets the current value of the runtime animation
  14763. */
  14764. get currentValue(): any;
  14765. /**
  14766. * Gets the target path of the runtime animation
  14767. */
  14768. get targetPath(): string;
  14769. /**
  14770. * Gets the actual target of the runtime animation
  14771. */
  14772. get target(): any;
  14773. /** @hidden */
  14774. _onLoop: () => void;
  14775. /**
  14776. * Create a new RuntimeAnimation object
  14777. * @param target defines the target of the animation
  14778. * @param animation defines the source animation object
  14779. * @param scene defines the hosting scene
  14780. * @param host defines the initiating Animatable
  14781. */
  14782. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  14783. private _preparePath;
  14784. /**
  14785. * Gets the animation from the runtime animation
  14786. */
  14787. get animation(): Animation;
  14788. /**
  14789. * Resets the runtime animation to the beginning
  14790. * @param restoreOriginal defines whether to restore the target property to the original value
  14791. */
  14792. reset(restoreOriginal?: boolean): void;
  14793. /**
  14794. * Specifies if the runtime animation is stopped
  14795. * @returns Boolean specifying if the runtime animation is stopped
  14796. */
  14797. isStopped(): boolean;
  14798. /**
  14799. * Disposes of the runtime animation
  14800. */
  14801. dispose(): void;
  14802. /**
  14803. * Apply the interpolated value to the target
  14804. * @param currentValue defines the value computed by the animation
  14805. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  14806. */
  14807. setValue(currentValue: any, weight: number): void;
  14808. private _getOriginalValues;
  14809. private _setValue;
  14810. /**
  14811. * Gets the loop pmode of the runtime animation
  14812. * @returns Loop Mode
  14813. */
  14814. private _getCorrectLoopMode;
  14815. /**
  14816. * Move the current animation to a given frame
  14817. * @param frame defines the frame to move to
  14818. */
  14819. goToFrame(frame: number): void;
  14820. /**
  14821. * @hidden Internal use only
  14822. */
  14823. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  14824. /**
  14825. * Execute the current animation
  14826. * @param delay defines the delay to add to the current frame
  14827. * @param from defines the lower bound of the animation range
  14828. * @param to defines the upper bound of the animation range
  14829. * @param loop defines if the current animation must loop
  14830. * @param speedRatio defines the current speed ratio
  14831. * @param weight defines the weight of the animation (default is -1 so no weight)
  14832. * @param onLoop optional callback called when animation loops
  14833. * @returns a boolean indicating if the animation is running
  14834. */
  14835. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  14836. }
  14837. }
  14838. declare module "babylonjs/Animations/animatable" {
  14839. import { Animation } from "babylonjs/Animations/animation";
  14840. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  14841. import { Nullable } from "babylonjs/types";
  14842. import { Observable } from "babylonjs/Misc/observable";
  14843. import { Scene } from "babylonjs/scene";
  14844. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  14845. import { Node } from "babylonjs/node";
  14846. /**
  14847. * Class used to store an actual running animation
  14848. */
  14849. export class Animatable {
  14850. /** defines the target object */
  14851. target: any;
  14852. /** defines the starting frame number (default is 0) */
  14853. fromFrame: number;
  14854. /** defines the ending frame number (default is 100) */
  14855. toFrame: number;
  14856. /** defines if the animation must loop (default is false) */
  14857. loopAnimation: boolean;
  14858. /** defines a callback to call when animation ends if it is not looping */
  14859. onAnimationEnd?: (() => void) | null | undefined;
  14860. /** defines a callback to call when animation loops */
  14861. onAnimationLoop?: (() => void) | null | undefined;
  14862. private _localDelayOffset;
  14863. private _pausedDelay;
  14864. private _runtimeAnimations;
  14865. private _paused;
  14866. private _scene;
  14867. private _speedRatio;
  14868. private _weight;
  14869. private _syncRoot;
  14870. /**
  14871. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  14872. * This will only apply for non looping animation (default is true)
  14873. */
  14874. disposeOnEnd: boolean;
  14875. /**
  14876. * Gets a boolean indicating if the animation has started
  14877. */
  14878. animationStarted: boolean;
  14879. /**
  14880. * Observer raised when the animation ends
  14881. */
  14882. onAnimationEndObservable: Observable<Animatable>;
  14883. /**
  14884. * Observer raised when the animation loops
  14885. */
  14886. onAnimationLoopObservable: Observable<Animatable>;
  14887. /**
  14888. * Gets the root Animatable used to synchronize and normalize animations
  14889. */
  14890. get syncRoot(): Nullable<Animatable>;
  14891. /**
  14892. * Gets the current frame of the first RuntimeAnimation
  14893. * Used to synchronize Animatables
  14894. */
  14895. get masterFrame(): number;
  14896. /**
  14897. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  14898. */
  14899. get weight(): number;
  14900. set weight(value: number);
  14901. /**
  14902. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  14903. */
  14904. get speedRatio(): number;
  14905. set speedRatio(value: number);
  14906. /**
  14907. * Creates a new Animatable
  14908. * @param scene defines the hosting scene
  14909. * @param target defines the target object
  14910. * @param fromFrame defines the starting frame number (default is 0)
  14911. * @param toFrame defines the ending frame number (default is 100)
  14912. * @param loopAnimation defines if the animation must loop (default is false)
  14913. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  14914. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  14915. * @param animations defines a group of animation to add to the new Animatable
  14916. * @param onAnimationLoop defines a callback to call when animation loops
  14917. */
  14918. constructor(scene: Scene,
  14919. /** defines the target object */
  14920. target: any,
  14921. /** defines the starting frame number (default is 0) */
  14922. fromFrame?: number,
  14923. /** defines the ending frame number (default is 100) */
  14924. toFrame?: number,
  14925. /** defines if the animation must loop (default is false) */
  14926. loopAnimation?: boolean, speedRatio?: number,
  14927. /** defines a callback to call when animation ends if it is not looping */
  14928. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  14929. /** defines a callback to call when animation loops */
  14930. onAnimationLoop?: (() => void) | null | undefined);
  14931. /**
  14932. * Synchronize and normalize current Animatable with a source Animatable
  14933. * This is useful when using animation weights and when animations are not of the same length
  14934. * @param root defines the root Animatable to synchronize with
  14935. * @returns the current Animatable
  14936. */
  14937. syncWith(root: Animatable): Animatable;
  14938. /**
  14939. * Gets the list of runtime animations
  14940. * @returns an array of RuntimeAnimation
  14941. */
  14942. getAnimations(): RuntimeAnimation[];
  14943. /**
  14944. * Adds more animations to the current animatable
  14945. * @param target defines the target of the animations
  14946. * @param animations defines the new animations to add
  14947. */
  14948. appendAnimations(target: any, animations: Animation[]): void;
  14949. /**
  14950. * Gets the source animation for a specific property
  14951. * @param property defines the propertyu to look for
  14952. * @returns null or the source animation for the given property
  14953. */
  14954. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  14955. /**
  14956. * Gets the runtime animation for a specific property
  14957. * @param property defines the propertyu to look for
  14958. * @returns null or the runtime animation for the given property
  14959. */
  14960. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  14961. /**
  14962. * Resets the animatable to its original state
  14963. */
  14964. reset(): void;
  14965. /**
  14966. * Allows the animatable to blend with current running animations
  14967. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14968. * @param blendingSpeed defines the blending speed to use
  14969. */
  14970. enableBlending(blendingSpeed: number): void;
  14971. /**
  14972. * Disable animation blending
  14973. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14974. */
  14975. disableBlending(): void;
  14976. /**
  14977. * Jump directly to a given frame
  14978. * @param frame defines the frame to jump to
  14979. */
  14980. goToFrame(frame: number): void;
  14981. /**
  14982. * Pause the animation
  14983. */
  14984. pause(): void;
  14985. /**
  14986. * Restart the animation
  14987. */
  14988. restart(): void;
  14989. private _raiseOnAnimationEnd;
  14990. /**
  14991. * Stop and delete the current animation
  14992. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  14993. * @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)
  14994. */
  14995. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  14996. /**
  14997. * Wait asynchronously for the animation to end
  14998. * @returns a promise which will be fullfilled when the animation ends
  14999. */
  15000. waitAsync(): Promise<Animatable>;
  15001. /** @hidden */
  15002. _animate(delay: number): boolean;
  15003. }
  15004. module "babylonjs/scene" {
  15005. interface Scene {
  15006. /** @hidden */
  15007. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15008. /** @hidden */
  15009. _processLateAnimationBindingsForMatrices(holder: {
  15010. totalWeight: number;
  15011. animations: RuntimeAnimation[];
  15012. originalValue: Matrix;
  15013. }): any;
  15014. /** @hidden */
  15015. _processLateAnimationBindingsForQuaternions(holder: {
  15016. totalWeight: number;
  15017. animations: RuntimeAnimation[];
  15018. originalValue: Quaternion;
  15019. }, refQuaternion: Quaternion): Quaternion;
  15020. /** @hidden */
  15021. _processLateAnimationBindings(): void;
  15022. /**
  15023. * Will start the animation sequence of a given target
  15024. * @param target defines the target
  15025. * @param from defines from which frame should animation start
  15026. * @param to defines until which frame should animation run.
  15027. * @param weight defines the weight to apply to the animation (1.0 by default)
  15028. * @param loop defines if the animation loops
  15029. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15030. * @param onAnimationEnd defines the function to be executed when the animation ends
  15031. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15032. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15033. * @param onAnimationLoop defines the callback to call when an animation loops
  15034. * @returns the animatable object created for this animation
  15035. */
  15036. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  15037. /**
  15038. * Will start the animation sequence of a given target
  15039. * @param target defines the target
  15040. * @param from defines from which frame should animation start
  15041. * @param to defines until which frame should animation run.
  15042. * @param loop defines if the animation loops
  15043. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15044. * @param onAnimationEnd defines the function to be executed when the animation ends
  15045. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15046. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15047. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15048. * @param onAnimationLoop defines the callback to call when an animation loops
  15049. * @returns the animatable object created for this animation
  15050. */
  15051. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  15052. /**
  15053. * Will start the animation sequence of a given target and its hierarchy
  15054. * @param target defines the target
  15055. * @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.
  15056. * @param from defines from which frame should animation start
  15057. * @param to defines until which frame should animation run.
  15058. * @param loop defines if the animation loops
  15059. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15060. * @param onAnimationEnd defines the function to be executed when the animation ends
  15061. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15062. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15063. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15064. * @param onAnimationLoop defines the callback to call when an animation loops
  15065. * @returns the list of created animatables
  15066. */
  15067. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable[];
  15068. /**
  15069. * Begin a new animation on a given node
  15070. * @param target defines the target where the animation will take place
  15071. * @param animations defines the list of animations to start
  15072. * @param from defines the initial value
  15073. * @param to defines the final value
  15074. * @param loop defines if you want animation to loop (off by default)
  15075. * @param speedRatio defines the speed ratio to apply to all animations
  15076. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15077. * @param onAnimationLoop defines the callback to call when an animation loops
  15078. * @returns the list of created animatables
  15079. */
  15080. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  15081. /**
  15082. * Begin a new animation on a given node and its hierarchy
  15083. * @param target defines the root node where the animation will take place
  15084. * @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.
  15085. * @param animations defines the list of animations to start
  15086. * @param from defines the initial value
  15087. * @param to defines the final value
  15088. * @param loop defines if you want animation to loop (off by default)
  15089. * @param speedRatio defines the speed ratio to apply to all animations
  15090. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15091. * @param onAnimationLoop defines the callback to call when an animation loops
  15092. * @returns the list of animatables created for all nodes
  15093. */
  15094. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  15095. /**
  15096. * Gets the animatable associated with a specific target
  15097. * @param target defines the target of the animatable
  15098. * @returns the required animatable if found
  15099. */
  15100. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15101. /**
  15102. * Gets all animatables associated with a given target
  15103. * @param target defines the target to look animatables for
  15104. * @returns an array of Animatables
  15105. */
  15106. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15107. /**
  15108. * Stops and removes all animations that have been applied to the scene
  15109. */
  15110. stopAllAnimations(): void;
  15111. /**
  15112. * Gets the current delta time used by animation engine
  15113. */
  15114. deltaTime: number;
  15115. }
  15116. }
  15117. module "babylonjs/Bones/bone" {
  15118. interface Bone {
  15119. /**
  15120. * Copy an animation range from another bone
  15121. * @param source defines the source bone
  15122. * @param rangeName defines the range name to copy
  15123. * @param frameOffset defines the frame offset
  15124. * @param rescaleAsRequired defines if rescaling must be applied if required
  15125. * @param skelDimensionsRatio defines the scaling ratio
  15126. * @returns true if operation was successful
  15127. */
  15128. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15129. }
  15130. }
  15131. }
  15132. declare module "babylonjs/Bones/skeleton" {
  15133. import { Bone } from "babylonjs/Bones/bone";
  15134. import { Observable } from "babylonjs/Misc/observable";
  15135. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15136. import { Scene } from "babylonjs/scene";
  15137. import { Nullable } from "babylonjs/types";
  15138. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15139. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  15140. import { Animatable } from "babylonjs/Animations/animatable";
  15141. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15142. import { Animation } from "babylonjs/Animations/animation";
  15143. import { AnimationRange } from "babylonjs/Animations/animationRange";
  15144. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15145. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  15146. /**
  15147. * Class used to handle skinning animations
  15148. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15149. */
  15150. export class Skeleton implements IAnimatable {
  15151. /** defines the skeleton name */
  15152. name: string;
  15153. /** defines the skeleton Id */
  15154. id: string;
  15155. /**
  15156. * Defines the list of child bones
  15157. */
  15158. bones: Bone[];
  15159. /**
  15160. * Defines an estimate of the dimension of the skeleton at rest
  15161. */
  15162. dimensionsAtRest: Vector3;
  15163. /**
  15164. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15165. */
  15166. needInitialSkinMatrix: boolean;
  15167. /**
  15168. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15169. */
  15170. overrideMesh: Nullable<AbstractMesh>;
  15171. /**
  15172. * Gets the list of animations attached to this skeleton
  15173. */
  15174. animations: Array<Animation>;
  15175. private _scene;
  15176. private _isDirty;
  15177. private _transformMatrices;
  15178. private _transformMatrixTexture;
  15179. private _meshesWithPoseMatrix;
  15180. private _animatables;
  15181. private _identity;
  15182. private _synchronizedWithMesh;
  15183. private _ranges;
  15184. private _lastAbsoluteTransformsUpdateId;
  15185. private _canUseTextureForBones;
  15186. private _uniqueId;
  15187. /** @hidden */
  15188. _numBonesWithLinkedTransformNode: number;
  15189. /** @hidden */
  15190. _hasWaitingData: Nullable<boolean>;
  15191. /**
  15192. * Specifies if the skeleton should be serialized
  15193. */
  15194. doNotSerialize: boolean;
  15195. private _useTextureToStoreBoneMatrices;
  15196. /**
  15197. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15198. * Please note that this option is not available if the hardware does not support it
  15199. */
  15200. get useTextureToStoreBoneMatrices(): boolean;
  15201. set useTextureToStoreBoneMatrices(value: boolean);
  15202. private _animationPropertiesOverride;
  15203. /**
  15204. * Gets or sets the animation properties override
  15205. */
  15206. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15207. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15208. /**
  15209. * List of inspectable custom properties (used by the Inspector)
  15210. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15211. */
  15212. inspectableCustomProperties: IInspectable[];
  15213. /**
  15214. * An observable triggered before computing the skeleton's matrices
  15215. */
  15216. onBeforeComputeObservable: Observable<Skeleton>;
  15217. /**
  15218. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15219. */
  15220. get isUsingTextureForMatrices(): boolean;
  15221. /**
  15222. * Gets the unique ID of this skeleton
  15223. */
  15224. get uniqueId(): number;
  15225. /**
  15226. * Creates a new skeleton
  15227. * @param name defines the skeleton name
  15228. * @param id defines the skeleton Id
  15229. * @param scene defines the hosting scene
  15230. */
  15231. constructor(
  15232. /** defines the skeleton name */
  15233. name: string,
  15234. /** defines the skeleton Id */
  15235. id: string, scene: Scene);
  15236. /**
  15237. * Gets the current object class name.
  15238. * @return the class name
  15239. */
  15240. getClassName(): string;
  15241. /**
  15242. * Returns an array containing the root bones
  15243. * @returns an array containing the root bones
  15244. */
  15245. getChildren(): Array<Bone>;
  15246. /**
  15247. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15248. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15249. * @returns a Float32Array containing matrices data
  15250. */
  15251. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15252. /**
  15253. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15254. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15255. * @returns a raw texture containing the data
  15256. */
  15257. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15258. /**
  15259. * Gets the current hosting scene
  15260. * @returns a scene object
  15261. */
  15262. getScene(): Scene;
  15263. /**
  15264. * Gets a string representing the current skeleton data
  15265. * @param fullDetails defines a boolean indicating if we want a verbose version
  15266. * @returns a string representing the current skeleton data
  15267. */
  15268. toString(fullDetails?: boolean): string;
  15269. /**
  15270. * Get bone's index searching by name
  15271. * @param name defines bone's name to search for
  15272. * @return the indice of the bone. Returns -1 if not found
  15273. */
  15274. getBoneIndexByName(name: string): number;
  15275. /**
  15276. * Creater a new animation range
  15277. * @param name defines the name of the range
  15278. * @param from defines the start key
  15279. * @param to defines the end key
  15280. */
  15281. createAnimationRange(name: string, from: number, to: number): void;
  15282. /**
  15283. * Delete a specific animation range
  15284. * @param name defines the name of the range
  15285. * @param deleteFrames defines if frames must be removed as well
  15286. */
  15287. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  15288. /**
  15289. * Gets a specific animation range
  15290. * @param name defines the name of the range to look for
  15291. * @returns the requested animation range or null if not found
  15292. */
  15293. getAnimationRange(name: string): Nullable<AnimationRange>;
  15294. /**
  15295. * Gets the list of all animation ranges defined on this skeleton
  15296. * @returns an array
  15297. */
  15298. getAnimationRanges(): Nullable<AnimationRange>[];
  15299. /**
  15300. * Copy animation range from a source skeleton.
  15301. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  15302. * @param source defines the source skeleton
  15303. * @param name defines the name of the range to copy
  15304. * @param rescaleAsRequired defines if rescaling must be applied if required
  15305. * @returns true if operation was successful
  15306. */
  15307. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  15308. /**
  15309. * Forces the skeleton to go to rest pose
  15310. */
  15311. returnToRest(): void;
  15312. private _getHighestAnimationFrame;
  15313. /**
  15314. * Begin a specific animation range
  15315. * @param name defines the name of the range to start
  15316. * @param loop defines if looping must be turned on (false by default)
  15317. * @param speedRatio defines the speed ratio to apply (1 by default)
  15318. * @param onAnimationEnd defines a callback which will be called when animation will end
  15319. * @returns a new animatable
  15320. */
  15321. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  15322. /** @hidden */
  15323. _markAsDirty(): void;
  15324. /** @hidden */
  15325. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15326. /** @hidden */
  15327. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15328. private _computeTransformMatrices;
  15329. /**
  15330. * Build all resources required to render a skeleton
  15331. */
  15332. prepare(): void;
  15333. /**
  15334. * Gets the list of animatables currently running for this skeleton
  15335. * @returns an array of animatables
  15336. */
  15337. getAnimatables(): IAnimatable[];
  15338. /**
  15339. * Clone the current skeleton
  15340. * @param name defines the name of the new skeleton
  15341. * @param id defines the id of the new skeleton
  15342. * @returns the new skeleton
  15343. */
  15344. clone(name: string, id?: string): Skeleton;
  15345. /**
  15346. * Enable animation blending for this skeleton
  15347. * @param blendingSpeed defines the blending speed to apply
  15348. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15349. */
  15350. enableBlending(blendingSpeed?: number): void;
  15351. /**
  15352. * Releases all resources associated with the current skeleton
  15353. */
  15354. dispose(): void;
  15355. /**
  15356. * Serialize the skeleton in a JSON object
  15357. * @returns a JSON object
  15358. */
  15359. serialize(): any;
  15360. /**
  15361. * Creates a new skeleton from serialized data
  15362. * @param parsedSkeleton defines the serialized data
  15363. * @param scene defines the hosting scene
  15364. * @returns a new skeleton
  15365. */
  15366. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  15367. /**
  15368. * Compute all node absolute transforms
  15369. * @param forceUpdate defines if computation must be done even if cache is up to date
  15370. */
  15371. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15372. /**
  15373. * Gets the root pose matrix
  15374. * @returns a matrix
  15375. */
  15376. getPoseMatrix(): Nullable<Matrix>;
  15377. /**
  15378. * Sorts bones per internal index
  15379. */
  15380. sortBones(): void;
  15381. private _sortBones;
  15382. }
  15383. }
  15384. declare module "babylonjs/Meshes/instancedMesh" {
  15385. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  15386. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15387. import { Camera } from "babylonjs/Cameras/camera";
  15388. import { Node } from "babylonjs/node";
  15389. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15390. import { Mesh } from "babylonjs/Meshes/mesh";
  15391. import { Material } from "babylonjs/Materials/material";
  15392. import { Skeleton } from "babylonjs/Bones/skeleton";
  15393. import { Light } from "babylonjs/Lights/light";
  15394. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  15395. /**
  15396. * Creates an instance based on a source mesh.
  15397. */
  15398. export class InstancedMesh extends AbstractMesh {
  15399. private _sourceMesh;
  15400. private _currentLOD;
  15401. /** @hidden */
  15402. _indexInSourceMeshInstanceArray: number;
  15403. constructor(name: string, source: Mesh);
  15404. /**
  15405. * Returns the string "InstancedMesh".
  15406. */
  15407. getClassName(): string;
  15408. /** Gets the list of lights affecting that mesh */
  15409. get lightSources(): Light[];
  15410. _resyncLightSources(): void;
  15411. _resyncLightSource(light: Light): void;
  15412. _removeLightSource(light: Light, dispose: boolean): void;
  15413. /**
  15414. * If the source mesh receives shadows
  15415. */
  15416. get receiveShadows(): boolean;
  15417. /**
  15418. * The material of the source mesh
  15419. */
  15420. get material(): Nullable<Material>;
  15421. /**
  15422. * Visibility of the source mesh
  15423. */
  15424. get visibility(): number;
  15425. /**
  15426. * Skeleton of the source mesh
  15427. */
  15428. get skeleton(): Nullable<Skeleton>;
  15429. /**
  15430. * Rendering ground id of the source mesh
  15431. */
  15432. get renderingGroupId(): number;
  15433. set renderingGroupId(value: number);
  15434. /**
  15435. * Returns the total number of vertices (integer).
  15436. */
  15437. getTotalVertices(): number;
  15438. /**
  15439. * Returns a positive integer : the total number of indices in this mesh geometry.
  15440. * @returns the numner of indices or zero if the mesh has no geometry.
  15441. */
  15442. getTotalIndices(): number;
  15443. /**
  15444. * The source mesh of the instance
  15445. */
  15446. get sourceMesh(): Mesh;
  15447. /**
  15448. * Is this node ready to be used/rendered
  15449. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15450. * @return {boolean} is it ready
  15451. */
  15452. isReady(completeCheck?: boolean): boolean;
  15453. /**
  15454. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15455. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15456. * @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.
  15457. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15458. */
  15459. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15460. /**
  15461. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15462. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15463. * The `data` are either a numeric array either a Float32Array.
  15464. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15465. * 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).
  15466. * Note that a new underlying VertexBuffer object is created each call.
  15467. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15468. *
  15469. * Possible `kind` values :
  15470. * - VertexBuffer.PositionKind
  15471. * - VertexBuffer.UVKind
  15472. * - VertexBuffer.UV2Kind
  15473. * - VertexBuffer.UV3Kind
  15474. * - VertexBuffer.UV4Kind
  15475. * - VertexBuffer.UV5Kind
  15476. * - VertexBuffer.UV6Kind
  15477. * - VertexBuffer.ColorKind
  15478. * - VertexBuffer.MatricesIndicesKind
  15479. * - VertexBuffer.MatricesIndicesExtraKind
  15480. * - VertexBuffer.MatricesWeightsKind
  15481. * - VertexBuffer.MatricesWeightsExtraKind
  15482. *
  15483. * Returns the Mesh.
  15484. */
  15485. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  15486. /**
  15487. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15488. * If the mesh has no geometry, it is simply returned as it is.
  15489. * The `data` are either a numeric array either a Float32Array.
  15490. * No new underlying VertexBuffer object is created.
  15491. * 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.
  15492. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15493. *
  15494. * Possible `kind` values :
  15495. * - VertexBuffer.PositionKind
  15496. * - VertexBuffer.UVKind
  15497. * - VertexBuffer.UV2Kind
  15498. * - VertexBuffer.UV3Kind
  15499. * - VertexBuffer.UV4Kind
  15500. * - VertexBuffer.UV5Kind
  15501. * - VertexBuffer.UV6Kind
  15502. * - VertexBuffer.ColorKind
  15503. * - VertexBuffer.MatricesIndicesKind
  15504. * - VertexBuffer.MatricesIndicesExtraKind
  15505. * - VertexBuffer.MatricesWeightsKind
  15506. * - VertexBuffer.MatricesWeightsExtraKind
  15507. *
  15508. * Returns the Mesh.
  15509. */
  15510. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15511. /**
  15512. * Sets the mesh indices.
  15513. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15514. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15515. * This method creates a new index buffer each call.
  15516. * Returns the Mesh.
  15517. */
  15518. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15519. /**
  15520. * Boolean : True if the mesh owns the requested kind of data.
  15521. */
  15522. isVerticesDataPresent(kind: string): boolean;
  15523. /**
  15524. * Returns an array of indices (IndicesArray).
  15525. */
  15526. getIndices(): Nullable<IndicesArray>;
  15527. get _positions(): Nullable<Vector3[]>;
  15528. /**
  15529. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15530. * This means the mesh underlying bounding box and sphere are recomputed.
  15531. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15532. * @returns the current mesh
  15533. */
  15534. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15535. /** @hidden */
  15536. _preActivate(): InstancedMesh;
  15537. /** @hidden */
  15538. _activate(renderId: number, intermediateRendering: boolean): boolean;
  15539. /** @hidden */
  15540. _postActivate(): void;
  15541. getWorldMatrix(): Matrix;
  15542. get isAnInstance(): boolean;
  15543. /**
  15544. * Returns the current associated LOD AbstractMesh.
  15545. */
  15546. getLOD(camera: Camera): AbstractMesh;
  15547. /** @hidden */
  15548. _syncSubMeshes(): InstancedMesh;
  15549. /** @hidden */
  15550. _generatePointsArray(): boolean;
  15551. /**
  15552. * Creates a new InstancedMesh from the current mesh.
  15553. * - name (string) : the cloned mesh name
  15554. * - newParent (optional Node) : the optional Node to parent the clone to.
  15555. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15556. *
  15557. * Returns the clone.
  15558. */
  15559. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  15560. /**
  15561. * Disposes the InstancedMesh.
  15562. * Returns nothing.
  15563. */
  15564. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15565. }
  15566. module "babylonjs/Meshes/mesh" {
  15567. interface Mesh {
  15568. /**
  15569. * Register a custom buffer that will be instanced
  15570. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15571. * @param kind defines the buffer kind
  15572. * @param stride defines the stride in floats
  15573. */
  15574. registerInstancedBuffer(kind: string, stride: number): void;
  15575. /** @hidden */
  15576. _userInstancedBuffersStorage: {
  15577. data: {
  15578. [key: string]: Float32Array;
  15579. };
  15580. sizes: {
  15581. [key: string]: number;
  15582. };
  15583. vertexBuffers: {
  15584. [key: string]: Nullable<VertexBuffer>;
  15585. };
  15586. strides: {
  15587. [key: string]: number;
  15588. };
  15589. };
  15590. }
  15591. }
  15592. module "babylonjs/Meshes/abstractMesh" {
  15593. interface AbstractMesh {
  15594. /**
  15595. * Object used to store instanced buffers defined by user
  15596. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15597. */
  15598. instancedBuffers: {
  15599. [key: string]: any;
  15600. };
  15601. }
  15602. }
  15603. }
  15604. declare module "babylonjs/Materials/shaderMaterial" {
  15605. import { Scene } from "babylonjs/scene";
  15606. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  15607. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15608. import { Mesh } from "babylonjs/Meshes/mesh";
  15609. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  15610. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15611. import { Texture } from "babylonjs/Materials/Textures/texture";
  15612. import { Material } from "babylonjs/Materials/material";
  15613. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  15614. /**
  15615. * Defines the options associated with the creation of a shader material.
  15616. */
  15617. export interface IShaderMaterialOptions {
  15618. /**
  15619. * Does the material work in alpha blend mode
  15620. */
  15621. needAlphaBlending: boolean;
  15622. /**
  15623. * Does the material work in alpha test mode
  15624. */
  15625. needAlphaTesting: boolean;
  15626. /**
  15627. * The list of attribute names used in the shader
  15628. */
  15629. attributes: string[];
  15630. /**
  15631. * The list of unifrom names used in the shader
  15632. */
  15633. uniforms: string[];
  15634. /**
  15635. * The list of UBO names used in the shader
  15636. */
  15637. uniformBuffers: string[];
  15638. /**
  15639. * The list of sampler names used in the shader
  15640. */
  15641. samplers: string[];
  15642. /**
  15643. * The list of defines used in the shader
  15644. */
  15645. defines: string[];
  15646. }
  15647. /**
  15648. * 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.
  15649. *
  15650. * This returned material effects how the mesh will look based on the code in the shaders.
  15651. *
  15652. * @see http://doc.babylonjs.com/how_to/shader_material
  15653. */
  15654. export class ShaderMaterial extends Material {
  15655. private _shaderPath;
  15656. private _options;
  15657. private _textures;
  15658. private _textureArrays;
  15659. private _floats;
  15660. private _ints;
  15661. private _floatsArrays;
  15662. private _colors3;
  15663. private _colors3Arrays;
  15664. private _colors4;
  15665. private _colors4Arrays;
  15666. private _vectors2;
  15667. private _vectors3;
  15668. private _vectors4;
  15669. private _matrices;
  15670. private _matrixArrays;
  15671. private _matrices3x3;
  15672. private _matrices2x2;
  15673. private _vectors2Arrays;
  15674. private _vectors3Arrays;
  15675. private _vectors4Arrays;
  15676. private _cachedWorldViewMatrix;
  15677. private _cachedWorldViewProjectionMatrix;
  15678. private _renderId;
  15679. private _multiview;
  15680. /**
  15681. * Instantiate a new shader material.
  15682. * 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.
  15683. * This returned material effects how the mesh will look based on the code in the shaders.
  15684. * @see http://doc.babylonjs.com/how_to/shader_material
  15685. * @param name Define the name of the material in the scene
  15686. * @param scene Define the scene the material belongs to
  15687. * @param shaderPath Defines the route to the shader code in one of three ways:
  15688. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15689. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  15690. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  15691. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15692. * @param options Define the options used to create the shader
  15693. */
  15694. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15695. /**
  15696. * Gets the shader path used to define the shader code
  15697. * It can be modified to trigger a new compilation
  15698. */
  15699. get shaderPath(): any;
  15700. /**
  15701. * Sets the shader path used to define the shader code
  15702. * It can be modified to trigger a new compilation
  15703. */
  15704. set shaderPath(shaderPath: any);
  15705. /**
  15706. * Gets the options used to compile the shader.
  15707. * They can be modified to trigger a new compilation
  15708. */
  15709. get options(): IShaderMaterialOptions;
  15710. /**
  15711. * Gets the current class name of the material e.g. "ShaderMaterial"
  15712. * Mainly use in serialization.
  15713. * @returns the class name
  15714. */
  15715. getClassName(): string;
  15716. /**
  15717. * Specifies if the material will require alpha blending
  15718. * @returns a boolean specifying if alpha blending is needed
  15719. */
  15720. needAlphaBlending(): boolean;
  15721. /**
  15722. * Specifies if this material should be rendered in alpha test mode
  15723. * @returns a boolean specifying if an alpha test is needed.
  15724. */
  15725. needAlphaTesting(): boolean;
  15726. private _checkUniform;
  15727. /**
  15728. * Set a texture in the shader.
  15729. * @param name Define the name of the uniform samplers as defined in the shader
  15730. * @param texture Define the texture to bind to this sampler
  15731. * @return the material itself allowing "fluent" like uniform updates
  15732. */
  15733. setTexture(name: string, texture: Texture): ShaderMaterial;
  15734. /**
  15735. * Set a texture array in the shader.
  15736. * @param name Define the name of the uniform sampler array as defined in the shader
  15737. * @param textures Define the list of textures to bind to this sampler
  15738. * @return the material itself allowing "fluent" like uniform updates
  15739. */
  15740. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  15741. /**
  15742. * Set a float in the shader.
  15743. * @param name Define the name of the uniform as defined in the shader
  15744. * @param value Define the value to give to the uniform
  15745. * @return the material itself allowing "fluent" like uniform updates
  15746. */
  15747. setFloat(name: string, value: number): ShaderMaterial;
  15748. /**
  15749. * Set a int in the shader.
  15750. * @param name Define the name of the uniform as defined in the shader
  15751. * @param value Define the value to give to the uniform
  15752. * @return the material itself allowing "fluent" like uniform updates
  15753. */
  15754. setInt(name: string, value: number): ShaderMaterial;
  15755. /**
  15756. * Set an array of floats in the shader.
  15757. * @param name Define the name of the uniform as defined in the shader
  15758. * @param value Define the value to give to the uniform
  15759. * @return the material itself allowing "fluent" like uniform updates
  15760. */
  15761. setFloats(name: string, value: number[]): ShaderMaterial;
  15762. /**
  15763. * Set a vec3 in the shader from a Color3.
  15764. * @param name Define the name of the uniform as defined in the shader
  15765. * @param value Define the value to give to the uniform
  15766. * @return the material itself allowing "fluent" like uniform updates
  15767. */
  15768. setColor3(name: string, value: Color3): ShaderMaterial;
  15769. /**
  15770. * Set a vec3 array in the shader from a Color3 array.
  15771. * @param name Define the name of the uniform as defined in the shader
  15772. * @param value Define the value to give to the uniform
  15773. * @return the material itself allowing "fluent" like uniform updates
  15774. */
  15775. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15776. /**
  15777. * Set a vec4 in the shader from a Color4.
  15778. * @param name Define the name of the uniform as defined in the shader
  15779. * @param value Define the value to give to the uniform
  15780. * @return the material itself allowing "fluent" like uniform updates
  15781. */
  15782. setColor4(name: string, value: Color4): ShaderMaterial;
  15783. /**
  15784. * Set a vec4 array in the shader from a Color4 array.
  15785. * @param name Define the name of the uniform as defined in the shader
  15786. * @param value Define the value to give to the uniform
  15787. * @return the material itself allowing "fluent" like uniform updates
  15788. */
  15789. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  15790. /**
  15791. * Set a vec2 in the shader from a Vector2.
  15792. * @param name Define the name of the uniform as defined in the shader
  15793. * @param value Define the value to give to the uniform
  15794. * @return the material itself allowing "fluent" like uniform updates
  15795. */
  15796. setVector2(name: string, value: Vector2): ShaderMaterial;
  15797. /**
  15798. * Set a vec3 in the shader from a Vector3.
  15799. * @param name Define the name of the uniform as defined in the shader
  15800. * @param value Define the value to give to the uniform
  15801. * @return the material itself allowing "fluent" like uniform updates
  15802. */
  15803. setVector3(name: string, value: Vector3): ShaderMaterial;
  15804. /**
  15805. * Set a vec4 in the shader from a Vector4.
  15806. * @param name Define the name of the uniform as defined in the shader
  15807. * @param value Define the value to give to the uniform
  15808. * @return the material itself allowing "fluent" like uniform updates
  15809. */
  15810. setVector4(name: string, value: Vector4): ShaderMaterial;
  15811. /**
  15812. * Set a mat4 in the shader from a Matrix.
  15813. * @param name Define the name of the uniform as defined in the shader
  15814. * @param value Define the value to give to the uniform
  15815. * @return the material itself allowing "fluent" like uniform updates
  15816. */
  15817. setMatrix(name: string, value: Matrix): ShaderMaterial;
  15818. /**
  15819. * Set a float32Array in the shader from a matrix array.
  15820. * @param name Define the name of the uniform as defined in the shader
  15821. * @param value Define the value to give to the uniform
  15822. * @return the material itself allowing "fluent" like uniform updates
  15823. */
  15824. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  15825. /**
  15826. * Set a mat3 in the shader from a Float32Array.
  15827. * @param name Define the name of the uniform as defined in the shader
  15828. * @param value Define the value to give to the uniform
  15829. * @return the material itself allowing "fluent" like uniform updates
  15830. */
  15831. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  15832. /**
  15833. * Set a mat2 in the shader from a Float32Array.
  15834. * @param name Define the name of the uniform as defined in the shader
  15835. * @param value Define the value to give to the uniform
  15836. * @return the material itself allowing "fluent" like uniform updates
  15837. */
  15838. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  15839. /**
  15840. * Set a vec2 array in the shader from a number array.
  15841. * @param name Define the name of the uniform as defined in the shader
  15842. * @param value Define the value to give to the uniform
  15843. * @return the material itself allowing "fluent" like uniform updates
  15844. */
  15845. setArray2(name: string, value: number[]): ShaderMaterial;
  15846. /**
  15847. * Set a vec3 array in the shader from a number array.
  15848. * @param name Define the name of the uniform as defined in the shader
  15849. * @param value Define the value to give to the uniform
  15850. * @return the material itself allowing "fluent" like uniform updates
  15851. */
  15852. setArray3(name: string, value: number[]): ShaderMaterial;
  15853. /**
  15854. * Set a vec4 array in the shader from a number array.
  15855. * @param name Define the name of the uniform as defined in the shader
  15856. * @param value Define the value to give to the uniform
  15857. * @return the material itself allowing "fluent" like uniform updates
  15858. */
  15859. setArray4(name: string, value: number[]): ShaderMaterial;
  15860. private _checkCache;
  15861. /**
  15862. * Specifies that the submesh is ready to be used
  15863. * @param mesh defines the mesh to check
  15864. * @param subMesh defines which submesh to check
  15865. * @param useInstances specifies that instances should be used
  15866. * @returns a boolean indicating that the submesh is ready or not
  15867. */
  15868. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  15869. /**
  15870. * Checks if the material is ready to render the requested mesh
  15871. * @param mesh Define the mesh to render
  15872. * @param useInstances Define whether or not the material is used with instances
  15873. * @returns true if ready, otherwise false
  15874. */
  15875. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  15876. /**
  15877. * Binds the world matrix to the material
  15878. * @param world defines the world transformation matrix
  15879. */
  15880. bindOnlyWorldMatrix(world: Matrix): void;
  15881. /**
  15882. * Binds the material to the mesh
  15883. * @param world defines the world transformation matrix
  15884. * @param mesh defines the mesh to bind the material to
  15885. */
  15886. bind(world: Matrix, mesh?: Mesh): void;
  15887. /**
  15888. * Gets the active textures from the material
  15889. * @returns an array of textures
  15890. */
  15891. getActiveTextures(): BaseTexture[];
  15892. /**
  15893. * Specifies if the material uses a texture
  15894. * @param texture defines the texture to check against the material
  15895. * @returns a boolean specifying if the material uses the texture
  15896. */
  15897. hasTexture(texture: BaseTexture): boolean;
  15898. /**
  15899. * Makes a duplicate of the material, and gives it a new name
  15900. * @param name defines the new name for the duplicated material
  15901. * @returns the cloned material
  15902. */
  15903. clone(name: string): ShaderMaterial;
  15904. /**
  15905. * Disposes the material
  15906. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  15907. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  15908. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  15909. */
  15910. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  15911. /**
  15912. * Serializes this material in a JSON representation
  15913. * @returns the serialized material object
  15914. */
  15915. serialize(): any;
  15916. /**
  15917. * Creates a shader material from parsed shader material data
  15918. * @param source defines the JSON represnetation of the material
  15919. * @param scene defines the hosting scene
  15920. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  15921. * @returns a new material
  15922. */
  15923. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  15924. }
  15925. }
  15926. declare module "babylonjs/Shaders/color.fragment" {
  15927. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  15928. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  15929. /** @hidden */
  15930. export var colorPixelShader: {
  15931. name: string;
  15932. shader: string;
  15933. };
  15934. }
  15935. declare module "babylonjs/Shaders/color.vertex" {
  15936. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  15937. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  15938. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  15939. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  15940. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  15941. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  15942. /** @hidden */
  15943. export var colorVertexShader: {
  15944. name: string;
  15945. shader: string;
  15946. };
  15947. }
  15948. declare module "babylonjs/Meshes/linesMesh" {
  15949. import { Nullable } from "babylonjs/types";
  15950. import { Scene } from "babylonjs/scene";
  15951. import { Color3 } from "babylonjs/Maths/math.color";
  15952. import { Node } from "babylonjs/node";
  15953. import { SubMesh } from "babylonjs/Meshes/subMesh";
  15954. import { Mesh } from "babylonjs/Meshes/mesh";
  15955. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  15956. import { Effect } from "babylonjs/Materials/effect";
  15957. import { Material } from "babylonjs/Materials/material";
  15958. import "babylonjs/Shaders/color.fragment";
  15959. import "babylonjs/Shaders/color.vertex";
  15960. /**
  15961. * Line mesh
  15962. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  15963. */
  15964. export class LinesMesh extends Mesh {
  15965. /**
  15966. * If vertex color should be applied to the mesh
  15967. */
  15968. readonly useVertexColor?: boolean | undefined;
  15969. /**
  15970. * If vertex alpha should be applied to the mesh
  15971. */
  15972. readonly useVertexAlpha?: boolean | undefined;
  15973. /**
  15974. * Color of the line (Default: White)
  15975. */
  15976. color: Color3;
  15977. /**
  15978. * Alpha of the line (Default: 1)
  15979. */
  15980. alpha: number;
  15981. /**
  15982. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15983. * This margin is expressed in world space coordinates, so its value may vary.
  15984. * Default value is 0.1
  15985. */
  15986. intersectionThreshold: number;
  15987. private _colorShader;
  15988. private color4;
  15989. /**
  15990. * Creates a new LinesMesh
  15991. * @param name defines the name
  15992. * @param scene defines the hosting scene
  15993. * @param parent defines the parent mesh if any
  15994. * @param source defines the optional source LinesMesh used to clone data from
  15995. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  15996. * When false, achieved by calling a clone(), also passing False.
  15997. * This will make creation of children, recursive.
  15998. * @param useVertexColor defines if this LinesMesh supports vertex color
  15999. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16000. */
  16001. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16002. /**
  16003. * If vertex color should be applied to the mesh
  16004. */
  16005. useVertexColor?: boolean | undefined,
  16006. /**
  16007. * If vertex alpha should be applied to the mesh
  16008. */
  16009. useVertexAlpha?: boolean | undefined);
  16010. private _addClipPlaneDefine;
  16011. private _removeClipPlaneDefine;
  16012. isReady(): boolean;
  16013. /**
  16014. * Returns the string "LineMesh"
  16015. */
  16016. getClassName(): string;
  16017. /**
  16018. * @hidden
  16019. */
  16020. get material(): Material;
  16021. /**
  16022. * @hidden
  16023. */
  16024. set material(value: Material);
  16025. /**
  16026. * @hidden
  16027. */
  16028. get checkCollisions(): boolean;
  16029. /** @hidden */
  16030. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16031. /** @hidden */
  16032. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16033. /**
  16034. * Disposes of the line mesh
  16035. * @param doNotRecurse If children should be disposed
  16036. */
  16037. dispose(doNotRecurse?: boolean): void;
  16038. /**
  16039. * Returns a new LineMesh object cloned from the current one.
  16040. */
  16041. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16042. /**
  16043. * Creates a new InstancedLinesMesh object from the mesh model.
  16044. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16045. * @param name defines the name of the new instance
  16046. * @returns a new InstancedLinesMesh
  16047. */
  16048. createInstance(name: string): InstancedLinesMesh;
  16049. }
  16050. /**
  16051. * Creates an instance based on a source LinesMesh
  16052. */
  16053. export class InstancedLinesMesh extends InstancedMesh {
  16054. /**
  16055. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16056. * This margin is expressed in world space coordinates, so its value may vary.
  16057. * Initilized with the intersectionThreshold value of the source LinesMesh
  16058. */
  16059. intersectionThreshold: number;
  16060. constructor(name: string, source: LinesMesh);
  16061. /**
  16062. * Returns the string "InstancedLinesMesh".
  16063. */
  16064. getClassName(): string;
  16065. }
  16066. }
  16067. declare module "babylonjs/Shaders/line.fragment" {
  16068. /** @hidden */
  16069. export var linePixelShader: {
  16070. name: string;
  16071. shader: string;
  16072. };
  16073. }
  16074. declare module "babylonjs/Shaders/line.vertex" {
  16075. /** @hidden */
  16076. export var lineVertexShader: {
  16077. name: string;
  16078. shader: string;
  16079. };
  16080. }
  16081. declare module "babylonjs/Rendering/edgesRenderer" {
  16082. import { Nullable } from "babylonjs/types";
  16083. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16084. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16085. import { Vector3 } from "babylonjs/Maths/math.vector";
  16086. import { IDisposable } from "babylonjs/scene";
  16087. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  16088. import "babylonjs/Shaders/line.fragment";
  16089. import "babylonjs/Shaders/line.vertex";
  16090. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  16091. module "babylonjs/Meshes/abstractMesh" {
  16092. interface AbstractMesh {
  16093. /**
  16094. * Gets the edgesRenderer associated with the mesh
  16095. */
  16096. edgesRenderer: Nullable<EdgesRenderer>;
  16097. }
  16098. }
  16099. module "babylonjs/Meshes/linesMesh" {
  16100. interface LinesMesh {
  16101. /**
  16102. * Enables the edge rendering mode on the mesh.
  16103. * This mode makes the mesh edges visible
  16104. * @param epsilon defines the maximal distance between two angles to detect a face
  16105. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16106. * @returns the currentAbstractMesh
  16107. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16108. */
  16109. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16110. }
  16111. }
  16112. module "babylonjs/Meshes/linesMesh" {
  16113. interface InstancedLinesMesh {
  16114. /**
  16115. * Enables the edge rendering mode on the mesh.
  16116. * This mode makes the mesh edges visible
  16117. * @param epsilon defines the maximal distance between two angles to detect a face
  16118. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16119. * @returns the current InstancedLinesMesh
  16120. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16121. */
  16122. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16123. }
  16124. }
  16125. /**
  16126. * Defines the minimum contract an Edges renderer should follow.
  16127. */
  16128. export interface IEdgesRenderer extends IDisposable {
  16129. /**
  16130. * Gets or sets a boolean indicating if the edgesRenderer is active
  16131. */
  16132. isEnabled: boolean;
  16133. /**
  16134. * Renders the edges of the attached mesh,
  16135. */
  16136. render(): void;
  16137. /**
  16138. * Checks wether or not the edges renderer is ready to render.
  16139. * @return true if ready, otherwise false.
  16140. */
  16141. isReady(): boolean;
  16142. }
  16143. /**
  16144. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16145. */
  16146. export class EdgesRenderer implements IEdgesRenderer {
  16147. /**
  16148. * Define the size of the edges with an orthographic camera
  16149. */
  16150. edgesWidthScalerForOrthographic: number;
  16151. /**
  16152. * Define the size of the edges with a perspective camera
  16153. */
  16154. edgesWidthScalerForPerspective: number;
  16155. protected _source: AbstractMesh;
  16156. protected _linesPositions: number[];
  16157. protected _linesNormals: number[];
  16158. protected _linesIndices: number[];
  16159. protected _epsilon: number;
  16160. protected _indicesCount: number;
  16161. protected _lineShader: ShaderMaterial;
  16162. protected _ib: DataBuffer;
  16163. protected _buffers: {
  16164. [key: string]: Nullable<VertexBuffer>;
  16165. };
  16166. protected _checkVerticesInsteadOfIndices: boolean;
  16167. private _meshRebuildObserver;
  16168. private _meshDisposeObserver;
  16169. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16170. isEnabled: boolean;
  16171. /**
  16172. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16173. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16174. * @param source Mesh used to create edges
  16175. * @param epsilon sum of angles in adjacency to check for edge
  16176. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16177. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16178. */
  16179. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16180. protected _prepareRessources(): void;
  16181. /** @hidden */
  16182. _rebuild(): void;
  16183. /**
  16184. * Releases the required resources for the edges renderer
  16185. */
  16186. dispose(): void;
  16187. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16188. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16189. /**
  16190. * Checks if the pair of p0 and p1 is en edge
  16191. * @param faceIndex
  16192. * @param edge
  16193. * @param faceNormals
  16194. * @param p0
  16195. * @param p1
  16196. * @private
  16197. */
  16198. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16199. /**
  16200. * push line into the position, normal and index buffer
  16201. * @protected
  16202. */
  16203. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16204. /**
  16205. * Generates lines edges from adjacencjes
  16206. * @private
  16207. */
  16208. _generateEdgesLines(): void;
  16209. /**
  16210. * Checks wether or not the edges renderer is ready to render.
  16211. * @return true if ready, otherwise false.
  16212. */
  16213. isReady(): boolean;
  16214. /**
  16215. * Renders the edges of the attached mesh,
  16216. */
  16217. render(): void;
  16218. }
  16219. /**
  16220. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16221. */
  16222. export class LineEdgesRenderer extends EdgesRenderer {
  16223. /**
  16224. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16225. * @param source LineMesh used to generate edges
  16226. * @param epsilon not important (specified angle for edge detection)
  16227. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16228. */
  16229. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16230. /**
  16231. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16232. */
  16233. _generateEdgesLines(): void;
  16234. }
  16235. }
  16236. declare module "babylonjs/Rendering/renderingGroup" {
  16237. import { SmartArray } from "babylonjs/Misc/smartArray";
  16238. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16239. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16240. import { Nullable } from "babylonjs/types";
  16241. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  16242. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  16243. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16244. import { Material } from "babylonjs/Materials/material";
  16245. import { Scene } from "babylonjs/scene";
  16246. /**
  16247. * This represents the object necessary to create a rendering group.
  16248. * This is exclusively used and created by the rendering manager.
  16249. * To modify the behavior, you use the available helpers in your scene or meshes.
  16250. * @hidden
  16251. */
  16252. export class RenderingGroup {
  16253. index: number;
  16254. private static _zeroVector;
  16255. private _scene;
  16256. private _opaqueSubMeshes;
  16257. private _transparentSubMeshes;
  16258. private _alphaTestSubMeshes;
  16259. private _depthOnlySubMeshes;
  16260. private _particleSystems;
  16261. private _spriteManagers;
  16262. private _opaqueSortCompareFn;
  16263. private _alphaTestSortCompareFn;
  16264. private _transparentSortCompareFn;
  16265. private _renderOpaque;
  16266. private _renderAlphaTest;
  16267. private _renderTransparent;
  16268. /** @hidden */
  16269. _edgesRenderers: SmartArray<IEdgesRenderer>;
  16270. onBeforeTransparentRendering: () => void;
  16271. /**
  16272. * Set the opaque sort comparison function.
  16273. * If null the sub meshes will be render in the order they were created
  16274. */
  16275. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16276. /**
  16277. * Set the alpha test sort comparison function.
  16278. * If null the sub meshes will be render in the order they were created
  16279. */
  16280. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16281. /**
  16282. * Set the transparent sort comparison function.
  16283. * If null the sub meshes will be render in the order they were created
  16284. */
  16285. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16286. /**
  16287. * Creates a new rendering group.
  16288. * @param index The rendering group index
  16289. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16290. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16291. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16292. */
  16293. 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>);
  16294. /**
  16295. * Render all the sub meshes contained in the group.
  16296. * @param customRenderFunction Used to override the default render behaviour of the group.
  16297. * @returns true if rendered some submeshes.
  16298. */
  16299. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16300. /**
  16301. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16302. * @param subMeshes The submeshes to render
  16303. */
  16304. private renderOpaqueSorted;
  16305. /**
  16306. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16307. * @param subMeshes The submeshes to render
  16308. */
  16309. private renderAlphaTestSorted;
  16310. /**
  16311. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16312. * @param subMeshes The submeshes to render
  16313. */
  16314. private renderTransparentSorted;
  16315. /**
  16316. * Renders the submeshes in a specified order.
  16317. * @param subMeshes The submeshes to sort before render
  16318. * @param sortCompareFn The comparison function use to sort
  16319. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16320. * @param transparent Specifies to activate blending if true
  16321. */
  16322. private static renderSorted;
  16323. /**
  16324. * Renders the submeshes in the order they were dispatched (no sort applied).
  16325. * @param subMeshes The submeshes to render
  16326. */
  16327. private static renderUnsorted;
  16328. /**
  16329. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16330. * are rendered back to front if in the same alpha index.
  16331. *
  16332. * @param a The first submesh
  16333. * @param b The second submesh
  16334. * @returns The result of the comparison
  16335. */
  16336. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16337. /**
  16338. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16339. * are rendered back to front.
  16340. *
  16341. * @param a The first submesh
  16342. * @param b The second submesh
  16343. * @returns The result of the comparison
  16344. */
  16345. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16346. /**
  16347. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16348. * are rendered front to back (prevent overdraw).
  16349. *
  16350. * @param a The first submesh
  16351. * @param b The second submesh
  16352. * @returns The result of the comparison
  16353. */
  16354. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16355. /**
  16356. * Resets the different lists of submeshes to prepare a new frame.
  16357. */
  16358. prepare(): void;
  16359. dispose(): void;
  16360. /**
  16361. * Inserts the submesh in its correct queue depending on its material.
  16362. * @param subMesh The submesh to dispatch
  16363. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16364. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16365. */
  16366. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16367. dispatchSprites(spriteManager: ISpriteManager): void;
  16368. dispatchParticles(particleSystem: IParticleSystem): void;
  16369. private _renderParticles;
  16370. private _renderSprites;
  16371. }
  16372. }
  16373. declare module "babylonjs/Rendering/renderingManager" {
  16374. import { Nullable } from "babylonjs/types";
  16375. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16376. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16377. import { SmartArray } from "babylonjs/Misc/smartArray";
  16378. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16379. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  16380. import { Material } from "babylonjs/Materials/material";
  16381. import { Scene } from "babylonjs/scene";
  16382. import { Camera } from "babylonjs/Cameras/camera";
  16383. /**
  16384. * Interface describing the different options available in the rendering manager
  16385. * regarding Auto Clear between groups.
  16386. */
  16387. export interface IRenderingManagerAutoClearSetup {
  16388. /**
  16389. * Defines whether or not autoclear is enable.
  16390. */
  16391. autoClear: boolean;
  16392. /**
  16393. * Defines whether or not to autoclear the depth buffer.
  16394. */
  16395. depth: boolean;
  16396. /**
  16397. * Defines whether or not to autoclear the stencil buffer.
  16398. */
  16399. stencil: boolean;
  16400. }
  16401. /**
  16402. * This class is used by the onRenderingGroupObservable
  16403. */
  16404. export class RenderingGroupInfo {
  16405. /**
  16406. * The Scene that being rendered
  16407. */
  16408. scene: Scene;
  16409. /**
  16410. * The camera currently used for the rendering pass
  16411. */
  16412. camera: Nullable<Camera>;
  16413. /**
  16414. * The ID of the renderingGroup being processed
  16415. */
  16416. renderingGroupId: number;
  16417. }
  16418. /**
  16419. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16420. * It is enable to manage the different groups as well as the different necessary sort functions.
  16421. * This should not be used directly aside of the few static configurations
  16422. */
  16423. export class RenderingManager {
  16424. /**
  16425. * The max id used for rendering groups (not included)
  16426. */
  16427. static MAX_RENDERINGGROUPS: number;
  16428. /**
  16429. * The min id used for rendering groups (included)
  16430. */
  16431. static MIN_RENDERINGGROUPS: number;
  16432. /**
  16433. * Used to globally prevent autoclearing scenes.
  16434. */
  16435. static AUTOCLEAR: boolean;
  16436. /**
  16437. * @hidden
  16438. */
  16439. _useSceneAutoClearSetup: boolean;
  16440. private _scene;
  16441. private _renderingGroups;
  16442. private _depthStencilBufferAlreadyCleaned;
  16443. private _autoClearDepthStencil;
  16444. private _customOpaqueSortCompareFn;
  16445. private _customAlphaTestSortCompareFn;
  16446. private _customTransparentSortCompareFn;
  16447. private _renderingGroupInfo;
  16448. /**
  16449. * Instantiates a new rendering group for a particular scene
  16450. * @param scene Defines the scene the groups belongs to
  16451. */
  16452. constructor(scene: Scene);
  16453. private _clearDepthStencilBuffer;
  16454. /**
  16455. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16456. * @hidden
  16457. */
  16458. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16459. /**
  16460. * Resets the different information of the group to prepare a new frame
  16461. * @hidden
  16462. */
  16463. reset(): void;
  16464. /**
  16465. * Dispose and release the group and its associated resources.
  16466. * @hidden
  16467. */
  16468. dispose(): void;
  16469. /**
  16470. * Clear the info related to rendering groups preventing retention points during dispose.
  16471. */
  16472. freeRenderingGroups(): void;
  16473. private _prepareRenderingGroup;
  16474. /**
  16475. * Add a sprite manager to the rendering manager in order to render it this frame.
  16476. * @param spriteManager Define the sprite manager to render
  16477. */
  16478. dispatchSprites(spriteManager: ISpriteManager): void;
  16479. /**
  16480. * Add a particle system to the rendering manager in order to render it this frame.
  16481. * @param particleSystem Define the particle system to render
  16482. */
  16483. dispatchParticles(particleSystem: IParticleSystem): void;
  16484. /**
  16485. * Add a submesh to the manager in order to render it this frame
  16486. * @param subMesh The submesh to dispatch
  16487. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16488. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16489. */
  16490. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16491. /**
  16492. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16493. * This allowed control for front to back rendering or reversly depending of the special needs.
  16494. *
  16495. * @param renderingGroupId The rendering group id corresponding to its index
  16496. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16497. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16498. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16499. */
  16500. 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;
  16501. /**
  16502. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16503. *
  16504. * @param renderingGroupId The rendering group id corresponding to its index
  16505. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16506. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16507. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16508. */
  16509. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16510. /**
  16511. * Gets the current auto clear configuration for one rendering group of the rendering
  16512. * manager.
  16513. * @param index the rendering group index to get the information for
  16514. * @returns The auto clear setup for the requested rendering group
  16515. */
  16516. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16517. }
  16518. }
  16519. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  16520. import { SmartArray } from "babylonjs/Misc/smartArray";
  16521. import { Nullable } from "babylonjs/types";
  16522. import { Scene } from "babylonjs/scene";
  16523. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  16524. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16525. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16526. import { Mesh } from "babylonjs/Meshes/mesh";
  16527. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  16528. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  16529. import { Effect } from "babylonjs/Materials/effect";
  16530. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16531. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16532. import "babylonjs/Shaders/shadowMap.fragment";
  16533. import "babylonjs/Shaders/shadowMap.vertex";
  16534. import "babylonjs/Shaders/depthBoxBlur.fragment";
  16535. import { Observable } from "babylonjs/Misc/observable";
  16536. /**
  16537. * Defines the options associated with the creation of a custom shader for a shadow generator.
  16538. */
  16539. export interface ICustomShaderOptions {
  16540. /**
  16541. * Gets or sets the custom shader name to use
  16542. */
  16543. shaderName: string;
  16544. /**
  16545. * The list of attribute names used in the shader
  16546. */
  16547. attributes?: string[];
  16548. /**
  16549. * The list of unifrom names used in the shader
  16550. */
  16551. uniforms?: string[];
  16552. /**
  16553. * The list of sampler names used in the shader
  16554. */
  16555. samplers?: string[];
  16556. /**
  16557. * The list of defines used in the shader
  16558. */
  16559. defines?: string[];
  16560. }
  16561. /**
  16562. * Interface to implement to create a shadow generator compatible with BJS.
  16563. */
  16564. export interface IShadowGenerator {
  16565. /**
  16566. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16567. * @returns The render target texture if present otherwise, null
  16568. */
  16569. getShadowMap(): Nullable<RenderTargetTexture>;
  16570. /**
  16571. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16572. * @param subMesh The submesh we want to render in the shadow map
  16573. * @param useInstances Defines wether will draw in the map using instances
  16574. * @returns true if ready otherwise, false
  16575. */
  16576. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16577. /**
  16578. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16579. * @param defines Defines of the material we want to update
  16580. * @param lightIndex Index of the light in the enabled light list of the material
  16581. */
  16582. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  16583. /**
  16584. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16585. * defined in the generator but impacting the effect).
  16586. * It implies the unifroms available on the materials are the standard BJS ones.
  16587. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16588. * @param effect The effect we are binfing the information for
  16589. */
  16590. bindShadowLight(lightIndex: string, effect: Effect): void;
  16591. /**
  16592. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16593. * (eq to shadow prjection matrix * light transform matrix)
  16594. * @returns The transform matrix used to create the shadow map
  16595. */
  16596. getTransformMatrix(): Matrix;
  16597. /**
  16598. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16599. * Cube and 2D textures for instance.
  16600. */
  16601. recreateShadowMap(): void;
  16602. /**
  16603. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16604. * @param onCompiled Callback triggered at the and of the effects compilation
  16605. * @param options Sets of optional options forcing the compilation with different modes
  16606. */
  16607. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16608. useInstances: boolean;
  16609. }>): void;
  16610. /**
  16611. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16612. * @param options Sets of optional options forcing the compilation with different modes
  16613. * @returns A promise that resolves when the compilation completes
  16614. */
  16615. forceCompilationAsync(options?: Partial<{
  16616. useInstances: boolean;
  16617. }>): Promise<void>;
  16618. /**
  16619. * Serializes the shadow generator setup to a json object.
  16620. * @returns The serialized JSON object
  16621. */
  16622. serialize(): any;
  16623. /**
  16624. * Disposes the Shadow map and related Textures and effects.
  16625. */
  16626. dispose(): void;
  16627. }
  16628. /**
  16629. * Default implementation IShadowGenerator.
  16630. * This is the main object responsible of generating shadows in the framework.
  16631. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  16632. */
  16633. export class ShadowGenerator implements IShadowGenerator {
  16634. /**
  16635. * Name of the shadow generator class
  16636. */
  16637. static CLASSNAME: string;
  16638. /**
  16639. * Shadow generator mode None: no filtering applied.
  16640. */
  16641. static readonly FILTER_NONE: number;
  16642. /**
  16643. * Shadow generator mode ESM: Exponential Shadow Mapping.
  16644. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16645. */
  16646. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  16647. /**
  16648. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  16649. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  16650. */
  16651. static readonly FILTER_POISSONSAMPLING: number;
  16652. /**
  16653. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  16654. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16655. */
  16656. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  16657. /**
  16658. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  16659. * edge artifacts on steep falloff.
  16660. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16661. */
  16662. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  16663. /**
  16664. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  16665. * edge artifacts on steep falloff.
  16666. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16667. */
  16668. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  16669. /**
  16670. * Shadow generator mode PCF: Percentage Closer Filtering
  16671. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16672. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  16673. */
  16674. static readonly FILTER_PCF: number;
  16675. /**
  16676. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  16677. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16678. * Contact Hardening
  16679. */
  16680. static readonly FILTER_PCSS: number;
  16681. /**
  16682. * Reserved for PCF and PCSS
  16683. * Highest Quality.
  16684. *
  16685. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  16686. *
  16687. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  16688. */
  16689. static readonly QUALITY_HIGH: number;
  16690. /**
  16691. * Reserved for PCF and PCSS
  16692. * Good tradeoff for quality/perf cross devices
  16693. *
  16694. * Execute PCF on a 3*3 kernel.
  16695. *
  16696. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  16697. */
  16698. static readonly QUALITY_MEDIUM: number;
  16699. /**
  16700. * Reserved for PCF and PCSS
  16701. * The lowest quality but the fastest.
  16702. *
  16703. * Execute PCF on a 1*1 kernel.
  16704. *
  16705. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  16706. */
  16707. static readonly QUALITY_LOW: number;
  16708. /** Gets or sets the custom shader name to use */
  16709. customShaderOptions: ICustomShaderOptions;
  16710. /**
  16711. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  16712. */
  16713. onBeforeShadowMapRenderObservable: Observable<Effect>;
  16714. /**
  16715. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  16716. */
  16717. onAfterShadowMapRenderObservable: Observable<Effect>;
  16718. /**
  16719. * Observable triggered before a mesh is rendered in the shadow map.
  16720. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  16721. */
  16722. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  16723. /**
  16724. * Observable triggered after a mesh is rendered in the shadow map.
  16725. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  16726. */
  16727. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  16728. protected _bias: number;
  16729. /**
  16730. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  16731. */
  16732. get bias(): number;
  16733. /**
  16734. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  16735. */
  16736. set bias(bias: number);
  16737. protected _normalBias: number;
  16738. /**
  16739. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16740. */
  16741. get normalBias(): number;
  16742. /**
  16743. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16744. */
  16745. set normalBias(normalBias: number);
  16746. protected _blurBoxOffset: number;
  16747. /**
  16748. * Gets the blur box offset: offset applied during the blur pass.
  16749. * Only useful if useKernelBlur = false
  16750. */
  16751. get blurBoxOffset(): number;
  16752. /**
  16753. * Sets the blur box offset: offset applied during the blur pass.
  16754. * Only useful if useKernelBlur = false
  16755. */
  16756. set blurBoxOffset(value: number);
  16757. protected _blurScale: number;
  16758. /**
  16759. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  16760. * 2 means half of the size.
  16761. */
  16762. get blurScale(): number;
  16763. /**
  16764. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  16765. * 2 means half of the size.
  16766. */
  16767. set blurScale(value: number);
  16768. protected _blurKernel: number;
  16769. /**
  16770. * Gets the blur kernel: kernel size of the blur pass.
  16771. * Only useful if useKernelBlur = true
  16772. */
  16773. get blurKernel(): number;
  16774. /**
  16775. * Sets the blur kernel: kernel size of the blur pass.
  16776. * Only useful if useKernelBlur = true
  16777. */
  16778. set blurKernel(value: number);
  16779. protected _useKernelBlur: boolean;
  16780. /**
  16781. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  16782. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16783. */
  16784. get useKernelBlur(): boolean;
  16785. /**
  16786. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  16787. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16788. */
  16789. set useKernelBlur(value: boolean);
  16790. protected _depthScale: number;
  16791. /**
  16792. * Gets the depth scale used in ESM mode.
  16793. */
  16794. get depthScale(): number;
  16795. /**
  16796. * Sets the depth scale used in ESM mode.
  16797. * This can override the scale stored on the light.
  16798. */
  16799. set depthScale(value: number);
  16800. protected _validateFilter(filter: number): number;
  16801. protected _filter: number;
  16802. /**
  16803. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  16804. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16805. */
  16806. get filter(): number;
  16807. /**
  16808. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  16809. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16810. */
  16811. set filter(value: number);
  16812. /**
  16813. * Gets if the current filter is set to Poisson Sampling.
  16814. */
  16815. get usePoissonSampling(): boolean;
  16816. /**
  16817. * Sets the current filter to Poisson Sampling.
  16818. */
  16819. set usePoissonSampling(value: boolean);
  16820. /**
  16821. * Gets if the current filter is set to ESM.
  16822. */
  16823. get useExponentialShadowMap(): boolean;
  16824. /**
  16825. * Sets the current filter is to ESM.
  16826. */
  16827. set useExponentialShadowMap(value: boolean);
  16828. /**
  16829. * Gets if the current filter is set to filtered ESM.
  16830. */
  16831. get useBlurExponentialShadowMap(): boolean;
  16832. /**
  16833. * Gets if the current filter is set to filtered ESM.
  16834. */
  16835. set useBlurExponentialShadowMap(value: boolean);
  16836. /**
  16837. * Gets if the current filter is set to "close ESM" (using the inverse of the
  16838. * exponential to prevent steep falloff artifacts).
  16839. */
  16840. get useCloseExponentialShadowMap(): boolean;
  16841. /**
  16842. * Sets the current filter to "close ESM" (using the inverse of the
  16843. * exponential to prevent steep falloff artifacts).
  16844. */
  16845. set useCloseExponentialShadowMap(value: boolean);
  16846. /**
  16847. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  16848. * exponential to prevent steep falloff artifacts).
  16849. */
  16850. get useBlurCloseExponentialShadowMap(): boolean;
  16851. /**
  16852. * Sets the current filter to filtered "close ESM" (using the inverse of the
  16853. * exponential to prevent steep falloff artifacts).
  16854. */
  16855. set useBlurCloseExponentialShadowMap(value: boolean);
  16856. /**
  16857. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  16858. */
  16859. get usePercentageCloserFiltering(): boolean;
  16860. /**
  16861. * Sets the current filter to "PCF" (percentage closer filtering).
  16862. */
  16863. set usePercentageCloserFiltering(value: boolean);
  16864. protected _filteringQuality: number;
  16865. /**
  16866. * Gets the PCF or PCSS Quality.
  16867. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16868. */
  16869. get filteringQuality(): number;
  16870. /**
  16871. * Sets the PCF or PCSS Quality.
  16872. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16873. */
  16874. set filteringQuality(filteringQuality: number);
  16875. /**
  16876. * Gets if the current filter is set to "PCSS" (contact hardening).
  16877. */
  16878. get useContactHardeningShadow(): boolean;
  16879. /**
  16880. * Sets the current filter to "PCSS" (contact hardening).
  16881. */
  16882. set useContactHardeningShadow(value: boolean);
  16883. protected _contactHardeningLightSizeUVRatio: number;
  16884. /**
  16885. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16886. * Using a ratio helps keeping shape stability independently of the map size.
  16887. *
  16888. * It does not account for the light projection as it was having too much
  16889. * instability during the light setup or during light position changes.
  16890. *
  16891. * Only valid if useContactHardeningShadow is true.
  16892. */
  16893. get contactHardeningLightSizeUVRatio(): number;
  16894. /**
  16895. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16896. * Using a ratio helps keeping shape stability independently of the map size.
  16897. *
  16898. * It does not account for the light projection as it was having too much
  16899. * instability during the light setup or during light position changes.
  16900. *
  16901. * Only valid if useContactHardeningShadow is true.
  16902. */
  16903. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  16904. protected _darkness: number;
  16905. /** Gets or sets the actual darkness of a shadow */
  16906. get darkness(): number;
  16907. set darkness(value: number);
  16908. /**
  16909. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  16910. * 0 means strongest and 1 would means no shadow.
  16911. * @returns the darkness.
  16912. */
  16913. getDarkness(): number;
  16914. /**
  16915. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  16916. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  16917. * @returns the shadow generator allowing fluent coding.
  16918. */
  16919. setDarkness(darkness: number): ShadowGenerator;
  16920. protected _transparencyShadow: boolean;
  16921. /** Gets or sets the ability to have transparent shadow */
  16922. get transparencyShadow(): boolean;
  16923. set transparencyShadow(value: boolean);
  16924. /**
  16925. * Sets the ability to have transparent shadow (boolean).
  16926. * @param transparent True if transparent else False
  16927. * @returns the shadow generator allowing fluent coding
  16928. */
  16929. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  16930. protected _shadowMap: Nullable<RenderTargetTexture>;
  16931. protected _shadowMap2: Nullable<RenderTargetTexture>;
  16932. /**
  16933. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16934. * @returns The render target texture if present otherwise, null
  16935. */
  16936. getShadowMap(): Nullable<RenderTargetTexture>;
  16937. /**
  16938. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  16939. * @returns The render target texture if the shadow map is present otherwise, null
  16940. */
  16941. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  16942. /**
  16943. * Gets the class name of that object
  16944. * @returns "ShadowGenerator"
  16945. */
  16946. getClassName(): string;
  16947. /**
  16948. * Helper function to add a mesh and its descendants to the list of shadow casters.
  16949. * @param mesh Mesh to add
  16950. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  16951. * @returns the Shadow Generator itself
  16952. */
  16953. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16954. /**
  16955. * Helper function to remove a mesh and its descendants from the list of shadow casters
  16956. * @param mesh Mesh to remove
  16957. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  16958. * @returns the Shadow Generator itself
  16959. */
  16960. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16961. /**
  16962. * Controls the extent to which the shadows fade out at the edge of the frustum
  16963. */
  16964. frustumEdgeFalloff: number;
  16965. protected _light: IShadowLight;
  16966. /**
  16967. * Returns the associated light object.
  16968. * @returns the light generating the shadow
  16969. */
  16970. getLight(): IShadowLight;
  16971. /**
  16972. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  16973. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  16974. * It might on the other hand introduce peter panning.
  16975. */
  16976. forceBackFacesOnly: boolean;
  16977. protected _scene: Scene;
  16978. protected _lightDirection: Vector3;
  16979. protected _effect: Effect;
  16980. protected _viewMatrix: Matrix;
  16981. protected _projectionMatrix: Matrix;
  16982. protected _transformMatrix: Matrix;
  16983. protected _cachedPosition: Vector3;
  16984. protected _cachedDirection: Vector3;
  16985. protected _cachedDefines: string;
  16986. protected _currentRenderID: number;
  16987. protected _boxBlurPostprocess: Nullable<PostProcess>;
  16988. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  16989. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  16990. protected _blurPostProcesses: PostProcess[];
  16991. protected _mapSize: number;
  16992. protected _currentFaceIndex: number;
  16993. protected _currentFaceIndexCache: number;
  16994. protected _textureType: number;
  16995. protected _defaultTextureMatrix: Matrix;
  16996. protected _storedUniqueId: Nullable<number>;
  16997. /** @hidden */
  16998. static _SceneComponentInitialization: (scene: Scene) => void;
  16999. /**
  17000. * Creates a ShadowGenerator object.
  17001. * A ShadowGenerator is the required tool to use the shadows.
  17002. * Each light casting shadows needs to use its own ShadowGenerator.
  17003. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17004. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17005. * @param light The light object generating the shadows.
  17006. * @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.
  17007. */
  17008. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17009. protected _initializeGenerator(): void;
  17010. protected _createTargetRenderTexture(): void;
  17011. protected _initializeShadowMap(): void;
  17012. protected _initializeBlurRTTAndPostProcesses(): void;
  17013. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17014. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  17015. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  17016. protected _applyFilterValues(): void;
  17017. /**
  17018. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17019. * @param onCompiled Callback triggered at the and of the effects compilation
  17020. * @param options Sets of optional options forcing the compilation with different modes
  17021. */
  17022. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17023. useInstances: boolean;
  17024. }>): void;
  17025. /**
  17026. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17027. * @param options Sets of optional options forcing the compilation with different modes
  17028. * @returns A promise that resolves when the compilation completes
  17029. */
  17030. forceCompilationAsync(options?: Partial<{
  17031. useInstances: boolean;
  17032. }>): Promise<void>;
  17033. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17034. /**
  17035. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17036. * @param subMesh The submesh we want to render in the shadow map
  17037. * @param useInstances Defines wether will draw in the map using instances
  17038. * @returns true if ready otherwise, false
  17039. */
  17040. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  17041. /**
  17042. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17043. * @param defines Defines of the material we want to update
  17044. * @param lightIndex Index of the light in the enabled light list of the material
  17045. */
  17046. prepareDefines(defines: any, lightIndex: number): void;
  17047. /**
  17048. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17049. * defined in the generator but impacting the effect).
  17050. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17051. * @param effect The effect we are binfing the information for
  17052. */
  17053. bindShadowLight(lightIndex: string, effect: Effect): void;
  17054. /**
  17055. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17056. * (eq to shadow prjection matrix * light transform matrix)
  17057. * @returns The transform matrix used to create the shadow map
  17058. */
  17059. getTransformMatrix(): Matrix;
  17060. /**
  17061. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17062. * Cube and 2D textures for instance.
  17063. */
  17064. recreateShadowMap(): void;
  17065. protected _disposeBlurPostProcesses(): void;
  17066. protected _disposeRTTandPostProcesses(): void;
  17067. /**
  17068. * Disposes the ShadowGenerator.
  17069. * Returns nothing.
  17070. */
  17071. dispose(): void;
  17072. /**
  17073. * Serializes the shadow generator setup to a json object.
  17074. * @returns The serialized JSON object
  17075. */
  17076. serialize(): any;
  17077. /**
  17078. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17079. * @param parsedShadowGenerator The JSON object to parse
  17080. * @param scene The scene to create the shadow map for
  17081. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17082. * @returns The parsed shadow generator
  17083. */
  17084. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  17085. }
  17086. }
  17087. declare module "babylonjs/Lights/light" {
  17088. import { Nullable } from "babylonjs/types";
  17089. import { Scene } from "babylonjs/scene";
  17090. import { Vector3 } from "babylonjs/Maths/math.vector";
  17091. import { Color3 } from "babylonjs/Maths/math.color";
  17092. import { Node } from "babylonjs/node";
  17093. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17094. import { Effect } from "babylonjs/Materials/effect";
  17095. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  17096. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  17097. /**
  17098. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  17099. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  17100. * 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.
  17101. */
  17102. export abstract class Light extends Node {
  17103. /**
  17104. * Falloff Default: light is falling off following the material specification:
  17105. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  17106. */
  17107. static readonly FALLOFF_DEFAULT: number;
  17108. /**
  17109. * Falloff Physical: light is falling off following the inverse squared distance law.
  17110. */
  17111. static readonly FALLOFF_PHYSICAL: number;
  17112. /**
  17113. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  17114. * to enhance interoperability with other engines.
  17115. */
  17116. static readonly FALLOFF_GLTF: number;
  17117. /**
  17118. * Falloff Standard: light is falling off like in the standard material
  17119. * to enhance interoperability with other materials.
  17120. */
  17121. static readonly FALLOFF_STANDARD: number;
  17122. /**
  17123. * If every light affecting the material is in this lightmapMode,
  17124. * material.lightmapTexture adds or multiplies
  17125. * (depends on material.useLightmapAsShadowmap)
  17126. * after every other light calculations.
  17127. */
  17128. static readonly LIGHTMAP_DEFAULT: number;
  17129. /**
  17130. * material.lightmapTexture as only diffuse lighting from this light
  17131. * adds only specular lighting from this light
  17132. * adds dynamic shadows
  17133. */
  17134. static readonly LIGHTMAP_SPECULAR: number;
  17135. /**
  17136. * material.lightmapTexture as only lighting
  17137. * no light calculation from this light
  17138. * only adds dynamic shadows from this light
  17139. */
  17140. static readonly LIGHTMAP_SHADOWSONLY: number;
  17141. /**
  17142. * Each light type uses the default quantity according to its type:
  17143. * point/spot lights use luminous intensity
  17144. * directional lights use illuminance
  17145. */
  17146. static readonly INTENSITYMODE_AUTOMATIC: number;
  17147. /**
  17148. * lumen (lm)
  17149. */
  17150. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  17151. /**
  17152. * candela (lm/sr)
  17153. */
  17154. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  17155. /**
  17156. * lux (lm/m^2)
  17157. */
  17158. static readonly INTENSITYMODE_ILLUMINANCE: number;
  17159. /**
  17160. * nit (cd/m^2)
  17161. */
  17162. static readonly INTENSITYMODE_LUMINANCE: number;
  17163. /**
  17164. * Light type const id of the point light.
  17165. */
  17166. static readonly LIGHTTYPEID_POINTLIGHT: number;
  17167. /**
  17168. * Light type const id of the directional light.
  17169. */
  17170. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  17171. /**
  17172. * Light type const id of the spot light.
  17173. */
  17174. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  17175. /**
  17176. * Light type const id of the hemispheric light.
  17177. */
  17178. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  17179. /**
  17180. * Diffuse gives the basic color to an object.
  17181. */
  17182. diffuse: Color3;
  17183. /**
  17184. * Specular produces a highlight color on an object.
  17185. * Note: This is note affecting PBR materials.
  17186. */
  17187. specular: Color3;
  17188. /**
  17189. * Defines the falloff type for this light. This lets overrriding how punctual light are
  17190. * falling off base on range or angle.
  17191. * This can be set to any values in Light.FALLOFF_x.
  17192. *
  17193. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  17194. * other types of materials.
  17195. */
  17196. falloffType: number;
  17197. /**
  17198. * Strength of the light.
  17199. * Note: By default it is define in the framework own unit.
  17200. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  17201. */
  17202. intensity: number;
  17203. private _range;
  17204. protected _inverseSquaredRange: number;
  17205. /**
  17206. * Defines how far from the source the light is impacting in scene units.
  17207. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17208. */
  17209. get range(): number;
  17210. /**
  17211. * Defines how far from the source the light is impacting in scene units.
  17212. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17213. */
  17214. set range(value: number);
  17215. /**
  17216. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  17217. * of light.
  17218. */
  17219. private _photometricScale;
  17220. private _intensityMode;
  17221. /**
  17222. * Gets the photometric scale used to interpret the intensity.
  17223. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17224. */
  17225. get intensityMode(): number;
  17226. /**
  17227. * Sets the photometric scale used to interpret the intensity.
  17228. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17229. */
  17230. set intensityMode(value: number);
  17231. private _radius;
  17232. /**
  17233. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17234. */
  17235. get radius(): number;
  17236. /**
  17237. * sets the light radius used by PBR Materials to simulate soft area lights.
  17238. */
  17239. set radius(value: number);
  17240. private _renderPriority;
  17241. /**
  17242. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17243. * exceeding the number allowed of the materials.
  17244. */
  17245. renderPriority: number;
  17246. private _shadowEnabled;
  17247. /**
  17248. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17249. * the current shadow generator.
  17250. */
  17251. get shadowEnabled(): boolean;
  17252. /**
  17253. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17254. * the current shadow generator.
  17255. */
  17256. set shadowEnabled(value: boolean);
  17257. private _includedOnlyMeshes;
  17258. /**
  17259. * Gets the only meshes impacted by this light.
  17260. */
  17261. get includedOnlyMeshes(): AbstractMesh[];
  17262. /**
  17263. * Sets the only meshes impacted by this light.
  17264. */
  17265. set includedOnlyMeshes(value: AbstractMesh[]);
  17266. private _excludedMeshes;
  17267. /**
  17268. * Gets the meshes not impacted by this light.
  17269. */
  17270. get excludedMeshes(): AbstractMesh[];
  17271. /**
  17272. * Sets the meshes not impacted by this light.
  17273. */
  17274. set excludedMeshes(value: AbstractMesh[]);
  17275. private _excludeWithLayerMask;
  17276. /**
  17277. * Gets the layer id use to find what meshes are not impacted by the light.
  17278. * Inactive if 0
  17279. */
  17280. get excludeWithLayerMask(): number;
  17281. /**
  17282. * Sets the layer id use to find what meshes are not impacted by the light.
  17283. * Inactive if 0
  17284. */
  17285. set excludeWithLayerMask(value: number);
  17286. private _includeOnlyWithLayerMask;
  17287. /**
  17288. * Gets the layer id use to find what meshes are impacted by the light.
  17289. * Inactive if 0
  17290. */
  17291. get includeOnlyWithLayerMask(): number;
  17292. /**
  17293. * Sets the layer id use to find what meshes are impacted by the light.
  17294. * Inactive if 0
  17295. */
  17296. set includeOnlyWithLayerMask(value: number);
  17297. private _lightmapMode;
  17298. /**
  17299. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17300. */
  17301. get lightmapMode(): number;
  17302. /**
  17303. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17304. */
  17305. set lightmapMode(value: number);
  17306. /**
  17307. * Shadow generator associted to the light.
  17308. * @hidden Internal use only.
  17309. */
  17310. _shadowGenerator: Nullable<IShadowGenerator>;
  17311. /**
  17312. * @hidden Internal use only.
  17313. */
  17314. _excludedMeshesIds: string[];
  17315. /**
  17316. * @hidden Internal use only.
  17317. */
  17318. _includedOnlyMeshesIds: string[];
  17319. /**
  17320. * The current light unifom buffer.
  17321. * @hidden Internal use only.
  17322. */
  17323. _uniformBuffer: UniformBuffer;
  17324. /** @hidden */
  17325. _renderId: number;
  17326. /**
  17327. * Creates a Light object in the scene.
  17328. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17329. * @param name The firendly name of the light
  17330. * @param scene The scene the light belongs too
  17331. */
  17332. constructor(name: string, scene: Scene);
  17333. protected abstract _buildUniformLayout(): void;
  17334. /**
  17335. * Sets the passed Effect "effect" with the Light information.
  17336. * @param effect The effect to update
  17337. * @param lightIndex The index of the light in the effect to update
  17338. * @returns The light
  17339. */
  17340. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  17341. /**
  17342. * Sets the passed Effect "effect" with the Light textures.
  17343. * @param effect The effect to update
  17344. * @param lightIndex The index of the light in the effect to update
  17345. * @returns The light
  17346. */
  17347. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  17348. /**
  17349. * Binds the lights information from the scene to the effect for the given mesh.
  17350. * @param lightIndex Light index
  17351. * @param scene The scene where the light belongs to
  17352. * @param effect The effect we are binding the data to
  17353. * @param useSpecular Defines if specular is supported
  17354. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  17355. */
  17356. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  17357. /**
  17358. * Sets the passed Effect "effect" with the Light information.
  17359. * @param effect The effect to update
  17360. * @param lightDataUniformName The uniform used to store light data (position or direction)
  17361. * @returns The light
  17362. */
  17363. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  17364. /**
  17365. * Returns the string "Light".
  17366. * @returns the class name
  17367. */
  17368. getClassName(): string;
  17369. /** @hidden */
  17370. readonly _isLight: boolean;
  17371. /**
  17372. * Converts the light information to a readable string for debug purpose.
  17373. * @param fullDetails Supports for multiple levels of logging within scene loading
  17374. * @returns the human readable light info
  17375. */
  17376. toString(fullDetails?: boolean): string;
  17377. /** @hidden */
  17378. protected _syncParentEnabledState(): void;
  17379. /**
  17380. * Set the enabled state of this node.
  17381. * @param value - the new enabled state
  17382. */
  17383. setEnabled(value: boolean): void;
  17384. /**
  17385. * Returns the Light associated shadow generator if any.
  17386. * @return the associated shadow generator.
  17387. */
  17388. getShadowGenerator(): Nullable<IShadowGenerator>;
  17389. /**
  17390. * Returns a Vector3, the absolute light position in the World.
  17391. * @returns the world space position of the light
  17392. */
  17393. getAbsolutePosition(): Vector3;
  17394. /**
  17395. * Specifies if the light will affect the passed mesh.
  17396. * @param mesh The mesh to test against the light
  17397. * @return true the mesh is affected otherwise, false.
  17398. */
  17399. canAffectMesh(mesh: AbstractMesh): boolean;
  17400. /**
  17401. * Sort function to order lights for rendering.
  17402. * @param a First Light object to compare to second.
  17403. * @param b Second Light object to compare first.
  17404. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  17405. */
  17406. static CompareLightsPriority(a: Light, b: Light): number;
  17407. /**
  17408. * Releases resources associated with this node.
  17409. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  17410. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  17411. */
  17412. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17413. /**
  17414. * Returns the light type ID (integer).
  17415. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17416. */
  17417. getTypeID(): number;
  17418. /**
  17419. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  17420. * @returns the scaled intensity in intensity mode unit
  17421. */
  17422. getScaledIntensity(): number;
  17423. /**
  17424. * Returns a new Light object, named "name", from the current one.
  17425. * @param name The name of the cloned light
  17426. * @returns the new created light
  17427. */
  17428. clone(name: string): Nullable<Light>;
  17429. /**
  17430. * Serializes the current light into a Serialization object.
  17431. * @returns the serialized object.
  17432. */
  17433. serialize(): any;
  17434. /**
  17435. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  17436. * This new light is named "name" and added to the passed scene.
  17437. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  17438. * @param name The friendly name of the light
  17439. * @param scene The scene the new light will belong to
  17440. * @returns the constructor function
  17441. */
  17442. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  17443. /**
  17444. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  17445. * @param parsedLight The JSON representation of the light
  17446. * @param scene The scene to create the parsed light in
  17447. * @returns the created light after parsing
  17448. */
  17449. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  17450. private _hookArrayForExcluded;
  17451. private _hookArrayForIncludedOnly;
  17452. private _resyncMeshes;
  17453. /**
  17454. * Forces the meshes to update their light related information in their rendering used effects
  17455. * @hidden Internal Use Only
  17456. */
  17457. _markMeshesAsLightDirty(): void;
  17458. /**
  17459. * Recomputes the cached photometric scale if needed.
  17460. */
  17461. private _computePhotometricScale;
  17462. /**
  17463. * Returns the Photometric Scale according to the light type and intensity mode.
  17464. */
  17465. private _getPhotometricScale;
  17466. /**
  17467. * Reorder the light in the scene according to their defined priority.
  17468. * @hidden Internal Use Only
  17469. */
  17470. _reorderLightsInScene(): void;
  17471. /**
  17472. * Prepares the list of defines specific to the light type.
  17473. * @param defines the list of defines
  17474. * @param lightIndex defines the index of the light for the effect
  17475. */
  17476. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17477. }
  17478. }
  17479. declare module "babylonjs/Actions/action" {
  17480. import { Observable } from "babylonjs/Misc/observable";
  17481. import { Condition } from "babylonjs/Actions/condition";
  17482. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  17483. import { ActionManager } from "babylonjs/Actions/actionManager";
  17484. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  17485. /**
  17486. * Interface used to define Action
  17487. */
  17488. export interface IAction {
  17489. /**
  17490. * Trigger for the action
  17491. */
  17492. trigger: number;
  17493. /** Options of the trigger */
  17494. triggerOptions: any;
  17495. /**
  17496. * Gets the trigger parameters
  17497. * @returns the trigger parameters
  17498. */
  17499. getTriggerParameter(): any;
  17500. /**
  17501. * Internal only - executes current action event
  17502. * @hidden
  17503. */
  17504. _executeCurrent(evt?: ActionEvent): void;
  17505. /**
  17506. * Serialize placeholder for child classes
  17507. * @param parent of child
  17508. * @returns the serialized object
  17509. */
  17510. serialize(parent: any): any;
  17511. /**
  17512. * Internal only
  17513. * @hidden
  17514. */
  17515. _prepare(): void;
  17516. /**
  17517. * Internal only - manager for action
  17518. * @hidden
  17519. */
  17520. _actionManager: AbstractActionManager;
  17521. /**
  17522. * Adds action to chain of actions, may be a DoNothingAction
  17523. * @param action defines the next action to execute
  17524. * @returns The action passed in
  17525. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17526. */
  17527. then(action: IAction): IAction;
  17528. }
  17529. /**
  17530. * The action to be carried out following a trigger
  17531. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  17532. */
  17533. export class Action implements IAction {
  17534. /** the trigger, with or without parameters, for the action */
  17535. triggerOptions: any;
  17536. /**
  17537. * Trigger for the action
  17538. */
  17539. trigger: number;
  17540. /**
  17541. * Internal only - manager for action
  17542. * @hidden
  17543. */
  17544. _actionManager: ActionManager;
  17545. private _nextActiveAction;
  17546. private _child;
  17547. private _condition?;
  17548. private _triggerParameter;
  17549. /**
  17550. * An event triggered prior to action being executed.
  17551. */
  17552. onBeforeExecuteObservable: Observable<Action>;
  17553. /**
  17554. * Creates a new Action
  17555. * @param triggerOptions the trigger, with or without parameters, for the action
  17556. * @param condition an optional determinant of action
  17557. */
  17558. constructor(
  17559. /** the trigger, with or without parameters, for the action */
  17560. triggerOptions: any, condition?: Condition);
  17561. /**
  17562. * Internal only
  17563. * @hidden
  17564. */
  17565. _prepare(): void;
  17566. /**
  17567. * Gets the trigger parameters
  17568. * @returns the trigger parameters
  17569. */
  17570. getTriggerParameter(): any;
  17571. /**
  17572. * Internal only - executes current action event
  17573. * @hidden
  17574. */
  17575. _executeCurrent(evt?: ActionEvent): void;
  17576. /**
  17577. * Execute placeholder for child classes
  17578. * @param evt optional action event
  17579. */
  17580. execute(evt?: ActionEvent): void;
  17581. /**
  17582. * Skips to next active action
  17583. */
  17584. skipToNextActiveAction(): void;
  17585. /**
  17586. * Adds action to chain of actions, may be a DoNothingAction
  17587. * @param action defines the next action to execute
  17588. * @returns The action passed in
  17589. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17590. */
  17591. then(action: Action): Action;
  17592. /**
  17593. * Internal only
  17594. * @hidden
  17595. */
  17596. _getProperty(propertyPath: string): string;
  17597. /**
  17598. * Internal only
  17599. * @hidden
  17600. */
  17601. _getEffectiveTarget(target: any, propertyPath: string): any;
  17602. /**
  17603. * Serialize placeholder for child classes
  17604. * @param parent of child
  17605. * @returns the serialized object
  17606. */
  17607. serialize(parent: any): any;
  17608. /**
  17609. * Internal only called by serialize
  17610. * @hidden
  17611. */
  17612. protected _serialize(serializedAction: any, parent?: any): any;
  17613. /**
  17614. * Internal only
  17615. * @hidden
  17616. */
  17617. static _SerializeValueAsString: (value: any) => string;
  17618. /**
  17619. * Internal only
  17620. * @hidden
  17621. */
  17622. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  17623. name: string;
  17624. targetType: string;
  17625. value: string;
  17626. };
  17627. }
  17628. }
  17629. declare module "babylonjs/Actions/condition" {
  17630. import { ActionManager } from "babylonjs/Actions/actionManager";
  17631. /**
  17632. * A Condition applied to an Action
  17633. */
  17634. export class Condition {
  17635. /**
  17636. * Internal only - manager for action
  17637. * @hidden
  17638. */
  17639. _actionManager: ActionManager;
  17640. /**
  17641. * Internal only
  17642. * @hidden
  17643. */
  17644. _evaluationId: number;
  17645. /**
  17646. * Internal only
  17647. * @hidden
  17648. */
  17649. _currentResult: boolean;
  17650. /**
  17651. * Creates a new Condition
  17652. * @param actionManager the manager of the action the condition is applied to
  17653. */
  17654. constructor(actionManager: ActionManager);
  17655. /**
  17656. * Check if the current condition is valid
  17657. * @returns a boolean
  17658. */
  17659. isValid(): boolean;
  17660. /**
  17661. * Internal only
  17662. * @hidden
  17663. */
  17664. _getProperty(propertyPath: string): string;
  17665. /**
  17666. * Internal only
  17667. * @hidden
  17668. */
  17669. _getEffectiveTarget(target: any, propertyPath: string): any;
  17670. /**
  17671. * Serialize placeholder for child classes
  17672. * @returns the serialized object
  17673. */
  17674. serialize(): any;
  17675. /**
  17676. * Internal only
  17677. * @hidden
  17678. */
  17679. protected _serialize(serializedCondition: any): any;
  17680. }
  17681. /**
  17682. * Defines specific conditional operators as extensions of Condition
  17683. */
  17684. export class ValueCondition extends Condition {
  17685. /** path to specify the property of the target the conditional operator uses */
  17686. propertyPath: string;
  17687. /** the value compared by the conditional operator against the current value of the property */
  17688. value: any;
  17689. /** the conditional operator, default ValueCondition.IsEqual */
  17690. operator: number;
  17691. /**
  17692. * Internal only
  17693. * @hidden
  17694. */
  17695. private static _IsEqual;
  17696. /**
  17697. * Internal only
  17698. * @hidden
  17699. */
  17700. private static _IsDifferent;
  17701. /**
  17702. * Internal only
  17703. * @hidden
  17704. */
  17705. private static _IsGreater;
  17706. /**
  17707. * Internal only
  17708. * @hidden
  17709. */
  17710. private static _IsLesser;
  17711. /**
  17712. * returns the number for IsEqual
  17713. */
  17714. static get IsEqual(): number;
  17715. /**
  17716. * Returns the number for IsDifferent
  17717. */
  17718. static get IsDifferent(): number;
  17719. /**
  17720. * Returns the number for IsGreater
  17721. */
  17722. static get IsGreater(): number;
  17723. /**
  17724. * Returns the number for IsLesser
  17725. */
  17726. static get IsLesser(): number;
  17727. /**
  17728. * Internal only The action manager for the condition
  17729. * @hidden
  17730. */
  17731. _actionManager: ActionManager;
  17732. /**
  17733. * Internal only
  17734. * @hidden
  17735. */
  17736. private _target;
  17737. /**
  17738. * Internal only
  17739. * @hidden
  17740. */
  17741. private _effectiveTarget;
  17742. /**
  17743. * Internal only
  17744. * @hidden
  17745. */
  17746. private _property;
  17747. /**
  17748. * Creates a new ValueCondition
  17749. * @param actionManager manager for the action the condition applies to
  17750. * @param target for the action
  17751. * @param propertyPath path to specify the property of the target the conditional operator uses
  17752. * @param value the value compared by the conditional operator against the current value of the property
  17753. * @param operator the conditional operator, default ValueCondition.IsEqual
  17754. */
  17755. constructor(actionManager: ActionManager, target: any,
  17756. /** path to specify the property of the target the conditional operator uses */
  17757. propertyPath: string,
  17758. /** the value compared by the conditional operator against the current value of the property */
  17759. value: any,
  17760. /** the conditional operator, default ValueCondition.IsEqual */
  17761. operator?: number);
  17762. /**
  17763. * Compares the given value with the property value for the specified conditional operator
  17764. * @returns the result of the comparison
  17765. */
  17766. isValid(): boolean;
  17767. /**
  17768. * Serialize the ValueCondition into a JSON compatible object
  17769. * @returns serialization object
  17770. */
  17771. serialize(): any;
  17772. /**
  17773. * Gets the name of the conditional operator for the ValueCondition
  17774. * @param operator the conditional operator
  17775. * @returns the name
  17776. */
  17777. static GetOperatorName(operator: number): string;
  17778. }
  17779. /**
  17780. * Defines a predicate condition as an extension of Condition
  17781. */
  17782. export class PredicateCondition extends Condition {
  17783. /** defines the predicate function used to validate the condition */
  17784. predicate: () => boolean;
  17785. /**
  17786. * Internal only - manager for action
  17787. * @hidden
  17788. */
  17789. _actionManager: ActionManager;
  17790. /**
  17791. * Creates a new PredicateCondition
  17792. * @param actionManager manager for the action the condition applies to
  17793. * @param predicate defines the predicate function used to validate the condition
  17794. */
  17795. constructor(actionManager: ActionManager,
  17796. /** defines the predicate function used to validate the condition */
  17797. predicate: () => boolean);
  17798. /**
  17799. * @returns the validity of the predicate condition
  17800. */
  17801. isValid(): boolean;
  17802. }
  17803. /**
  17804. * Defines a state condition as an extension of Condition
  17805. */
  17806. export class StateCondition extends Condition {
  17807. /** Value to compare with target state */
  17808. value: string;
  17809. /**
  17810. * Internal only - manager for action
  17811. * @hidden
  17812. */
  17813. _actionManager: ActionManager;
  17814. /**
  17815. * Internal only
  17816. * @hidden
  17817. */
  17818. private _target;
  17819. /**
  17820. * Creates a new StateCondition
  17821. * @param actionManager manager for the action the condition applies to
  17822. * @param target of the condition
  17823. * @param value to compare with target state
  17824. */
  17825. constructor(actionManager: ActionManager, target: any,
  17826. /** Value to compare with target state */
  17827. value: string);
  17828. /**
  17829. * Gets a boolean indicating if the current condition is met
  17830. * @returns the validity of the state
  17831. */
  17832. isValid(): boolean;
  17833. /**
  17834. * Serialize the StateCondition into a JSON compatible object
  17835. * @returns serialization object
  17836. */
  17837. serialize(): any;
  17838. }
  17839. }
  17840. declare module "babylonjs/Actions/directActions" {
  17841. import { Action } from "babylonjs/Actions/action";
  17842. import { Condition } from "babylonjs/Actions/condition";
  17843. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  17844. /**
  17845. * This defines an action responsible to toggle a boolean once triggered.
  17846. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17847. */
  17848. export class SwitchBooleanAction extends Action {
  17849. /**
  17850. * The path to the boolean property in the target object
  17851. */
  17852. propertyPath: string;
  17853. private _target;
  17854. private _effectiveTarget;
  17855. private _property;
  17856. /**
  17857. * Instantiate the action
  17858. * @param triggerOptions defines the trigger options
  17859. * @param target defines the object containing the boolean
  17860. * @param propertyPath defines the path to the boolean property in the target object
  17861. * @param condition defines the trigger related conditions
  17862. */
  17863. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  17864. /** @hidden */
  17865. _prepare(): void;
  17866. /**
  17867. * Execute the action toggle the boolean value.
  17868. */
  17869. execute(): void;
  17870. /**
  17871. * Serializes the actions and its related information.
  17872. * @param parent defines the object to serialize in
  17873. * @returns the serialized object
  17874. */
  17875. serialize(parent: any): any;
  17876. }
  17877. /**
  17878. * This defines an action responsible to set a the state field of the target
  17879. * to a desired value once triggered.
  17880. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17881. */
  17882. export class SetStateAction extends Action {
  17883. /**
  17884. * The value to store in the state field.
  17885. */
  17886. value: string;
  17887. private _target;
  17888. /**
  17889. * Instantiate the action
  17890. * @param triggerOptions defines the trigger options
  17891. * @param target defines the object containing the state property
  17892. * @param value defines the value to store in the state field
  17893. * @param condition defines the trigger related conditions
  17894. */
  17895. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  17896. /**
  17897. * Execute the action and store the value on the target state property.
  17898. */
  17899. execute(): void;
  17900. /**
  17901. * Serializes the actions and its related information.
  17902. * @param parent defines the object to serialize in
  17903. * @returns the serialized object
  17904. */
  17905. serialize(parent: any): any;
  17906. }
  17907. /**
  17908. * This defines an action responsible to set a property of the target
  17909. * to a desired value once triggered.
  17910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17911. */
  17912. export class SetValueAction extends Action {
  17913. /**
  17914. * The path of the property to set in the target.
  17915. */
  17916. propertyPath: string;
  17917. /**
  17918. * The value to set in the property
  17919. */
  17920. value: any;
  17921. private _target;
  17922. private _effectiveTarget;
  17923. private _property;
  17924. /**
  17925. * Instantiate the action
  17926. * @param triggerOptions defines the trigger options
  17927. * @param target defines the object containing the property
  17928. * @param propertyPath defines the path of the property to set in the target
  17929. * @param value defines the value to set in the property
  17930. * @param condition defines the trigger related conditions
  17931. */
  17932. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17933. /** @hidden */
  17934. _prepare(): void;
  17935. /**
  17936. * Execute the action and set the targetted property to the desired value.
  17937. */
  17938. execute(): void;
  17939. /**
  17940. * Serializes the actions and its related information.
  17941. * @param parent defines the object to serialize in
  17942. * @returns the serialized object
  17943. */
  17944. serialize(parent: any): any;
  17945. }
  17946. /**
  17947. * This defines an action responsible to increment the target value
  17948. * to a desired value once triggered.
  17949. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17950. */
  17951. export class IncrementValueAction extends Action {
  17952. /**
  17953. * The path of the property to increment in the target.
  17954. */
  17955. propertyPath: string;
  17956. /**
  17957. * The value we should increment the property by.
  17958. */
  17959. value: any;
  17960. private _target;
  17961. private _effectiveTarget;
  17962. private _property;
  17963. /**
  17964. * Instantiate the action
  17965. * @param triggerOptions defines the trigger options
  17966. * @param target defines the object containing the property
  17967. * @param propertyPath defines the path of the property to increment in the target
  17968. * @param value defines the value value we should increment the property by
  17969. * @param condition defines the trigger related conditions
  17970. */
  17971. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17972. /** @hidden */
  17973. _prepare(): void;
  17974. /**
  17975. * Execute the action and increment the target of the value amount.
  17976. */
  17977. execute(): void;
  17978. /**
  17979. * Serializes the actions and its related information.
  17980. * @param parent defines the object to serialize in
  17981. * @returns the serialized object
  17982. */
  17983. serialize(parent: any): any;
  17984. }
  17985. /**
  17986. * This defines an action responsible to start an animation once triggered.
  17987. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17988. */
  17989. export class PlayAnimationAction extends Action {
  17990. /**
  17991. * Where the animation should start (animation frame)
  17992. */
  17993. from: number;
  17994. /**
  17995. * Where the animation should stop (animation frame)
  17996. */
  17997. to: number;
  17998. /**
  17999. * Define if the animation should loop or stop after the first play.
  18000. */
  18001. loop?: boolean;
  18002. private _target;
  18003. /**
  18004. * Instantiate the action
  18005. * @param triggerOptions defines the trigger options
  18006. * @param target defines the target animation or animation name
  18007. * @param from defines from where the animation should start (animation frame)
  18008. * @param end defines where the animation should stop (animation frame)
  18009. * @param loop defines if the animation should loop or stop after the first play
  18010. * @param condition defines the trigger related conditions
  18011. */
  18012. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  18013. /** @hidden */
  18014. _prepare(): void;
  18015. /**
  18016. * Execute the action and play the animation.
  18017. */
  18018. execute(): void;
  18019. /**
  18020. * Serializes the actions and its related information.
  18021. * @param parent defines the object to serialize in
  18022. * @returns the serialized object
  18023. */
  18024. serialize(parent: any): any;
  18025. }
  18026. /**
  18027. * This defines an action responsible to stop an animation once triggered.
  18028. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18029. */
  18030. export class StopAnimationAction extends Action {
  18031. private _target;
  18032. /**
  18033. * Instantiate the action
  18034. * @param triggerOptions defines the trigger options
  18035. * @param target defines the target animation or animation name
  18036. * @param condition defines the trigger related conditions
  18037. */
  18038. constructor(triggerOptions: any, target: any, condition?: Condition);
  18039. /** @hidden */
  18040. _prepare(): void;
  18041. /**
  18042. * Execute the action and stop the animation.
  18043. */
  18044. execute(): void;
  18045. /**
  18046. * Serializes the actions and its related information.
  18047. * @param parent defines the object to serialize in
  18048. * @returns the serialized object
  18049. */
  18050. serialize(parent: any): any;
  18051. }
  18052. /**
  18053. * This defines an action responsible that does nothing once triggered.
  18054. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18055. */
  18056. export class DoNothingAction extends Action {
  18057. /**
  18058. * Instantiate the action
  18059. * @param triggerOptions defines the trigger options
  18060. * @param condition defines the trigger related conditions
  18061. */
  18062. constructor(triggerOptions?: any, condition?: Condition);
  18063. /**
  18064. * Execute the action and do nothing.
  18065. */
  18066. execute(): void;
  18067. /**
  18068. * Serializes the actions and its related information.
  18069. * @param parent defines the object to serialize in
  18070. * @returns the serialized object
  18071. */
  18072. serialize(parent: any): any;
  18073. }
  18074. /**
  18075. * This defines an action responsible to trigger several actions once triggered.
  18076. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18077. */
  18078. export class CombineAction extends Action {
  18079. /**
  18080. * The list of aggregated animations to run.
  18081. */
  18082. children: Action[];
  18083. /**
  18084. * Instantiate the action
  18085. * @param triggerOptions defines the trigger options
  18086. * @param children defines the list of aggregated animations to run
  18087. * @param condition defines the trigger related conditions
  18088. */
  18089. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  18090. /** @hidden */
  18091. _prepare(): void;
  18092. /**
  18093. * Execute the action and executes all the aggregated actions.
  18094. */
  18095. execute(evt: ActionEvent): void;
  18096. /**
  18097. * Serializes the actions and its related information.
  18098. * @param parent defines the object to serialize in
  18099. * @returns the serialized object
  18100. */
  18101. serialize(parent: any): any;
  18102. }
  18103. /**
  18104. * This defines an action responsible to run code (external event) once triggered.
  18105. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18106. */
  18107. export class ExecuteCodeAction extends Action {
  18108. /**
  18109. * The callback function to run.
  18110. */
  18111. func: (evt: ActionEvent) => void;
  18112. /**
  18113. * Instantiate the action
  18114. * @param triggerOptions defines the trigger options
  18115. * @param func defines the callback function to run
  18116. * @param condition defines the trigger related conditions
  18117. */
  18118. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  18119. /**
  18120. * Execute the action and run the attached code.
  18121. */
  18122. execute(evt: ActionEvent): void;
  18123. }
  18124. /**
  18125. * This defines an action responsible to set the parent property of the target once triggered.
  18126. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18127. */
  18128. export class SetParentAction extends Action {
  18129. private _parent;
  18130. private _target;
  18131. /**
  18132. * Instantiate the action
  18133. * @param triggerOptions defines the trigger options
  18134. * @param target defines the target containing the parent property
  18135. * @param parent defines from where the animation should start (animation frame)
  18136. * @param condition defines the trigger related conditions
  18137. */
  18138. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  18139. /** @hidden */
  18140. _prepare(): void;
  18141. /**
  18142. * Execute the action and set the parent property.
  18143. */
  18144. execute(): void;
  18145. /**
  18146. * Serializes the actions and its related information.
  18147. * @param parent defines the object to serialize in
  18148. * @returns the serialized object
  18149. */
  18150. serialize(parent: any): any;
  18151. }
  18152. }
  18153. declare module "babylonjs/Actions/actionManager" {
  18154. import { Nullable } from "babylonjs/types";
  18155. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18156. import { Scene } from "babylonjs/scene";
  18157. import { IAction } from "babylonjs/Actions/action";
  18158. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  18159. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  18160. /**
  18161. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  18162. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  18163. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18164. */
  18165. export class ActionManager extends AbstractActionManager {
  18166. /**
  18167. * Nothing
  18168. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18169. */
  18170. static readonly NothingTrigger: number;
  18171. /**
  18172. * On pick
  18173. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18174. */
  18175. static readonly OnPickTrigger: number;
  18176. /**
  18177. * On left pick
  18178. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18179. */
  18180. static readonly OnLeftPickTrigger: number;
  18181. /**
  18182. * On right pick
  18183. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18184. */
  18185. static readonly OnRightPickTrigger: number;
  18186. /**
  18187. * On center pick
  18188. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18189. */
  18190. static readonly OnCenterPickTrigger: number;
  18191. /**
  18192. * On pick down
  18193. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18194. */
  18195. static readonly OnPickDownTrigger: number;
  18196. /**
  18197. * On double pick
  18198. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18199. */
  18200. static readonly OnDoublePickTrigger: number;
  18201. /**
  18202. * On pick up
  18203. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18204. */
  18205. static readonly OnPickUpTrigger: number;
  18206. /**
  18207. * On pick out.
  18208. * This trigger will only be raised if you also declared a OnPickDown
  18209. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18210. */
  18211. static readonly OnPickOutTrigger: number;
  18212. /**
  18213. * On long press
  18214. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18215. */
  18216. static readonly OnLongPressTrigger: number;
  18217. /**
  18218. * On pointer over
  18219. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18220. */
  18221. static readonly OnPointerOverTrigger: number;
  18222. /**
  18223. * On pointer out
  18224. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18225. */
  18226. static readonly OnPointerOutTrigger: number;
  18227. /**
  18228. * On every frame
  18229. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18230. */
  18231. static readonly OnEveryFrameTrigger: number;
  18232. /**
  18233. * On intersection enter
  18234. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18235. */
  18236. static readonly OnIntersectionEnterTrigger: number;
  18237. /**
  18238. * On intersection exit
  18239. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18240. */
  18241. static readonly OnIntersectionExitTrigger: number;
  18242. /**
  18243. * On key down
  18244. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18245. */
  18246. static readonly OnKeyDownTrigger: number;
  18247. /**
  18248. * On key up
  18249. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18250. */
  18251. static readonly OnKeyUpTrigger: number;
  18252. private _scene;
  18253. /**
  18254. * Creates a new action manager
  18255. * @param scene defines the hosting scene
  18256. */
  18257. constructor(scene: Scene);
  18258. /**
  18259. * Releases all associated resources
  18260. */
  18261. dispose(): void;
  18262. /**
  18263. * Gets hosting scene
  18264. * @returns the hosting scene
  18265. */
  18266. getScene(): Scene;
  18267. /**
  18268. * Does this action manager handles actions of any of the given triggers
  18269. * @param triggers defines the triggers to be tested
  18270. * @return a boolean indicating whether one (or more) of the triggers is handled
  18271. */
  18272. hasSpecificTriggers(triggers: number[]): boolean;
  18273. /**
  18274. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  18275. * speed.
  18276. * @param triggerA defines the trigger to be tested
  18277. * @param triggerB defines the trigger to be tested
  18278. * @return a boolean indicating whether one (or more) of the triggers is handled
  18279. */
  18280. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  18281. /**
  18282. * Does this action manager handles actions of a given trigger
  18283. * @param trigger defines the trigger to be tested
  18284. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  18285. * @return whether the trigger is handled
  18286. */
  18287. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  18288. /**
  18289. * Does this action manager has pointer triggers
  18290. */
  18291. get hasPointerTriggers(): boolean;
  18292. /**
  18293. * Does this action manager has pick triggers
  18294. */
  18295. get hasPickTriggers(): boolean;
  18296. /**
  18297. * Registers an action to this action manager
  18298. * @param action defines the action to be registered
  18299. * @return the action amended (prepared) after registration
  18300. */
  18301. registerAction(action: IAction): Nullable<IAction>;
  18302. /**
  18303. * Unregisters an action to this action manager
  18304. * @param action defines the action to be unregistered
  18305. * @return a boolean indicating whether the action has been unregistered
  18306. */
  18307. unregisterAction(action: IAction): Boolean;
  18308. /**
  18309. * Process a specific trigger
  18310. * @param trigger defines the trigger to process
  18311. * @param evt defines the event details to be processed
  18312. */
  18313. processTrigger(trigger: number, evt?: IActionEvent): void;
  18314. /** @hidden */
  18315. _getEffectiveTarget(target: any, propertyPath: string): any;
  18316. /** @hidden */
  18317. _getProperty(propertyPath: string): string;
  18318. /**
  18319. * Serialize this manager to a JSON object
  18320. * @param name defines the property name to store this manager
  18321. * @returns a JSON representation of this manager
  18322. */
  18323. serialize(name: string): any;
  18324. /**
  18325. * Creates a new ActionManager from a JSON data
  18326. * @param parsedActions defines the JSON data to read from
  18327. * @param object defines the hosting mesh
  18328. * @param scene defines the hosting scene
  18329. */
  18330. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  18331. /**
  18332. * Get a trigger name by index
  18333. * @param trigger defines the trigger index
  18334. * @returns a trigger name
  18335. */
  18336. static GetTriggerName(trigger: number): string;
  18337. }
  18338. }
  18339. declare module "babylonjs/Sprites/sprite" {
  18340. import { Vector3 } from "babylonjs/Maths/math.vector";
  18341. import { Nullable } from "babylonjs/types";
  18342. import { ActionManager } from "babylonjs/Actions/actionManager";
  18343. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  18344. import { Color4 } from "babylonjs/Maths/math.color";
  18345. /**
  18346. * Class used to represent a sprite
  18347. * @see http://doc.babylonjs.com/babylon101/sprites
  18348. */
  18349. export class Sprite {
  18350. /** defines the name */
  18351. name: string;
  18352. /** Gets or sets the current world position */
  18353. position: Vector3;
  18354. /** Gets or sets the main color */
  18355. color: Color4;
  18356. /** Gets or sets the width */
  18357. width: number;
  18358. /** Gets or sets the height */
  18359. height: number;
  18360. /** Gets or sets rotation angle */
  18361. angle: number;
  18362. /** Gets or sets the cell index in the sprite sheet */
  18363. cellIndex: number;
  18364. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  18365. cellRef: string;
  18366. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  18367. invertU: number;
  18368. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  18369. invertV: number;
  18370. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  18371. disposeWhenFinishedAnimating: boolean;
  18372. /** Gets the list of attached animations */
  18373. animations: Animation[];
  18374. /** Gets or sets a boolean indicating if the sprite can be picked */
  18375. isPickable: boolean;
  18376. /**
  18377. * Gets or sets the associated action manager
  18378. */
  18379. actionManager: Nullable<ActionManager>;
  18380. private _animationStarted;
  18381. private _loopAnimation;
  18382. private _fromIndex;
  18383. private _toIndex;
  18384. private _delay;
  18385. private _direction;
  18386. private _manager;
  18387. private _time;
  18388. private _onAnimationEnd;
  18389. /**
  18390. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  18391. */
  18392. isVisible: boolean;
  18393. /**
  18394. * Gets or sets the sprite size
  18395. */
  18396. get size(): number;
  18397. set size(value: number);
  18398. /**
  18399. * Creates a new Sprite
  18400. * @param name defines the name
  18401. * @param manager defines the manager
  18402. */
  18403. constructor(
  18404. /** defines the name */
  18405. name: string, manager: ISpriteManager);
  18406. /**
  18407. * Starts an animation
  18408. * @param from defines the initial key
  18409. * @param to defines the end key
  18410. * @param loop defines if the animation must loop
  18411. * @param delay defines the start delay (in ms)
  18412. * @param onAnimationEnd defines a callback to call when animation ends
  18413. */
  18414. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  18415. /** Stops current animation (if any) */
  18416. stopAnimation(): void;
  18417. /** @hidden */
  18418. _animate(deltaTime: number): void;
  18419. /** Release associated resources */
  18420. dispose(): void;
  18421. }
  18422. }
  18423. declare module "babylonjs/Collisions/pickingInfo" {
  18424. import { Nullable } from "babylonjs/types";
  18425. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18426. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18427. import { Sprite } from "babylonjs/Sprites/sprite";
  18428. import { Ray } from "babylonjs/Culling/ray";
  18429. /**
  18430. * Information about the result of picking within a scene
  18431. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  18432. */
  18433. export class PickingInfo {
  18434. /** @hidden */
  18435. _pickingUnavailable: boolean;
  18436. /**
  18437. * If the pick collided with an object
  18438. */
  18439. hit: boolean;
  18440. /**
  18441. * Distance away where the pick collided
  18442. */
  18443. distance: number;
  18444. /**
  18445. * The location of pick collision
  18446. */
  18447. pickedPoint: Nullable<Vector3>;
  18448. /**
  18449. * The mesh corresponding the the pick collision
  18450. */
  18451. pickedMesh: Nullable<AbstractMesh>;
  18452. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  18453. bu: number;
  18454. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  18455. bv: number;
  18456. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  18457. faceId: number;
  18458. /** Id of the the submesh that was picked */
  18459. subMeshId: number;
  18460. /** If a sprite was picked, this will be the sprite the pick collided with */
  18461. pickedSprite: Nullable<Sprite>;
  18462. /**
  18463. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  18464. */
  18465. originMesh: Nullable<AbstractMesh>;
  18466. /**
  18467. * The ray that was used to perform the picking.
  18468. */
  18469. ray: Nullable<Ray>;
  18470. /**
  18471. * Gets the normal correspodning to the face the pick collided with
  18472. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  18473. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  18474. * @returns The normal correspodning to the face the pick collided with
  18475. */
  18476. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  18477. /**
  18478. * Gets the texture coordinates of where the pick occured
  18479. * @returns the vector containing the coordnates of the texture
  18480. */
  18481. getTextureCoordinates(): Nullable<Vector2>;
  18482. }
  18483. }
  18484. declare module "babylonjs/Events/pointerEvents" {
  18485. import { Nullable } from "babylonjs/types";
  18486. import { Vector2 } from "babylonjs/Maths/math.vector";
  18487. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  18488. import { Ray } from "babylonjs/Culling/ray";
  18489. /**
  18490. * Gather the list of pointer event types as constants.
  18491. */
  18492. export class PointerEventTypes {
  18493. /**
  18494. * 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.
  18495. */
  18496. static readonly POINTERDOWN: number;
  18497. /**
  18498. * The pointerup event is fired when a pointer is no longer active.
  18499. */
  18500. static readonly POINTERUP: number;
  18501. /**
  18502. * The pointermove event is fired when a pointer changes coordinates.
  18503. */
  18504. static readonly POINTERMOVE: number;
  18505. /**
  18506. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18507. */
  18508. static readonly POINTERWHEEL: number;
  18509. /**
  18510. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18511. */
  18512. static readonly POINTERPICK: number;
  18513. /**
  18514. * The pointertap event is fired when a the object has been touched and released without drag.
  18515. */
  18516. static readonly POINTERTAP: number;
  18517. /**
  18518. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18519. */
  18520. static readonly POINTERDOUBLETAP: number;
  18521. }
  18522. /**
  18523. * Base class of pointer info types.
  18524. */
  18525. export class PointerInfoBase {
  18526. /**
  18527. * Defines the type of event (PointerEventTypes)
  18528. */
  18529. type: number;
  18530. /**
  18531. * Defines the related dom event
  18532. */
  18533. event: PointerEvent | MouseWheelEvent;
  18534. /**
  18535. * Instantiates the base class of pointers info.
  18536. * @param type Defines the type of event (PointerEventTypes)
  18537. * @param event Defines the related dom event
  18538. */
  18539. constructor(
  18540. /**
  18541. * Defines the type of event (PointerEventTypes)
  18542. */
  18543. type: number,
  18544. /**
  18545. * Defines the related dom event
  18546. */
  18547. event: PointerEvent | MouseWheelEvent);
  18548. }
  18549. /**
  18550. * This class is used to store pointer related info for the onPrePointerObservable event.
  18551. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18552. */
  18553. export class PointerInfoPre extends PointerInfoBase {
  18554. /**
  18555. * Ray from a pointer if availible (eg. 6dof controller)
  18556. */
  18557. ray: Nullable<Ray>;
  18558. /**
  18559. * Defines the local position of the pointer on the canvas.
  18560. */
  18561. localPosition: Vector2;
  18562. /**
  18563. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18564. */
  18565. skipOnPointerObservable: boolean;
  18566. /**
  18567. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18568. * @param type Defines the type of event (PointerEventTypes)
  18569. * @param event Defines the related dom event
  18570. * @param localX Defines the local x coordinates of the pointer when the event occured
  18571. * @param localY Defines the local y coordinates of the pointer when the event occured
  18572. */
  18573. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18574. }
  18575. /**
  18576. * This type contains all the data related to a pointer event in Babylon.js.
  18577. * 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.
  18578. */
  18579. export class PointerInfo extends PointerInfoBase {
  18580. /**
  18581. * Defines the picking info associated to the info (if any)\
  18582. */
  18583. pickInfo: Nullable<PickingInfo>;
  18584. /**
  18585. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18586. * @param type Defines the type of event (PointerEventTypes)
  18587. * @param event Defines the related dom event
  18588. * @param pickInfo Defines the picking info associated to the info (if any)\
  18589. */
  18590. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18591. /**
  18592. * Defines the picking info associated to the info (if any)\
  18593. */
  18594. pickInfo: Nullable<PickingInfo>);
  18595. }
  18596. /**
  18597. * Data relating to a touch event on the screen.
  18598. */
  18599. export interface PointerTouch {
  18600. /**
  18601. * X coordinate of touch.
  18602. */
  18603. x: number;
  18604. /**
  18605. * Y coordinate of touch.
  18606. */
  18607. y: number;
  18608. /**
  18609. * Id of touch. Unique for each finger.
  18610. */
  18611. pointerId: number;
  18612. /**
  18613. * Event type passed from DOM.
  18614. */
  18615. type: any;
  18616. }
  18617. }
  18618. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  18619. import { Observable } from "babylonjs/Misc/observable";
  18620. import { Nullable } from "babylonjs/types";
  18621. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18622. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18623. /**
  18624. * Manage the mouse inputs to control the movement of a free camera.
  18625. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18626. */
  18627. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18628. /**
  18629. * Define if touch is enabled in the mouse input
  18630. */
  18631. touchEnabled: boolean;
  18632. /**
  18633. * Defines the camera the input is attached to.
  18634. */
  18635. camera: FreeCamera;
  18636. /**
  18637. * Defines the buttons associated with the input to handle camera move.
  18638. */
  18639. buttons: number[];
  18640. /**
  18641. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18642. */
  18643. angularSensibility: number;
  18644. private _pointerInput;
  18645. private _onMouseMove;
  18646. private _observer;
  18647. private previousPosition;
  18648. /**
  18649. * Observable for when a pointer move event occurs containing the move offset
  18650. */
  18651. onPointerMovedObservable: Observable<{
  18652. offsetX: number;
  18653. offsetY: number;
  18654. }>;
  18655. /**
  18656. * @hidden
  18657. * If the camera should be rotated automatically based on pointer movement
  18658. */
  18659. _allowCameraRotation: boolean;
  18660. /**
  18661. * Manage the mouse inputs to control the movement of a free camera.
  18662. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18663. * @param touchEnabled Defines if touch is enabled or not
  18664. */
  18665. constructor(
  18666. /**
  18667. * Define if touch is enabled in the mouse input
  18668. */
  18669. touchEnabled?: boolean);
  18670. /**
  18671. * Attach the input controls to a specific dom element to get the input from.
  18672. * @param element Defines the element the controls should be listened from
  18673. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18674. */
  18675. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18676. /**
  18677. * Called on JS contextmenu event.
  18678. * Override this method to provide functionality.
  18679. */
  18680. protected onContextMenu(evt: PointerEvent): void;
  18681. /**
  18682. * Detach the current controls from the specified dom element.
  18683. * @param element Defines the element to stop listening the inputs from
  18684. */
  18685. detachControl(element: Nullable<HTMLElement>): void;
  18686. /**
  18687. * Gets the class name of the current intput.
  18688. * @returns the class name
  18689. */
  18690. getClassName(): string;
  18691. /**
  18692. * Get the friendly name associated with the input class.
  18693. * @returns the input friendly name
  18694. */
  18695. getSimpleName(): string;
  18696. }
  18697. }
  18698. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  18699. import { Nullable } from "babylonjs/types";
  18700. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18701. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18702. /**
  18703. * Manage the touch inputs to control the movement of a free camera.
  18704. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18705. */
  18706. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18707. /**
  18708. * Defines the camera the input is attached to.
  18709. */
  18710. camera: FreeCamera;
  18711. /**
  18712. * Defines the touch sensibility for rotation.
  18713. * The higher the faster.
  18714. */
  18715. touchAngularSensibility: number;
  18716. /**
  18717. * Defines the touch sensibility for move.
  18718. * The higher the faster.
  18719. */
  18720. touchMoveSensibility: number;
  18721. private _offsetX;
  18722. private _offsetY;
  18723. private _pointerPressed;
  18724. private _pointerInput;
  18725. private _observer;
  18726. private _onLostFocus;
  18727. /**
  18728. * Attach the input controls to a specific dom element to get the input from.
  18729. * @param element Defines the element the controls should be listened from
  18730. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18731. */
  18732. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18733. /**
  18734. * Detach the current controls from the specified dom element.
  18735. * @param element Defines the element to stop listening the inputs from
  18736. */
  18737. detachControl(element: Nullable<HTMLElement>): void;
  18738. /**
  18739. * Update the current camera state depending on the inputs that have been used this frame.
  18740. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18741. */
  18742. checkInputs(): void;
  18743. /**
  18744. * Gets the class name of the current intput.
  18745. * @returns the class name
  18746. */
  18747. getClassName(): string;
  18748. /**
  18749. * Get the friendly name associated with the input class.
  18750. * @returns the input friendly name
  18751. */
  18752. getSimpleName(): string;
  18753. }
  18754. }
  18755. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  18756. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18757. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  18758. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  18759. import { Nullable } from "babylonjs/types";
  18760. /**
  18761. * Default Inputs manager for the FreeCamera.
  18762. * It groups all the default supported inputs for ease of use.
  18763. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18764. */
  18765. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18766. /**
  18767. * @hidden
  18768. */
  18769. _mouseInput: Nullable<FreeCameraMouseInput>;
  18770. /**
  18771. * Instantiates a new FreeCameraInputsManager.
  18772. * @param camera Defines the camera the inputs belong to
  18773. */
  18774. constructor(camera: FreeCamera);
  18775. /**
  18776. * Add keyboard input support to the input manager.
  18777. * @returns the current input manager
  18778. */
  18779. addKeyboard(): FreeCameraInputsManager;
  18780. /**
  18781. * Add mouse input support to the input manager.
  18782. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18783. * @returns the current input manager
  18784. */
  18785. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18786. /**
  18787. * Removes the mouse input support from the manager
  18788. * @returns the current input manager
  18789. */
  18790. removeMouse(): FreeCameraInputsManager;
  18791. /**
  18792. * Add touch input support to the input manager.
  18793. * @returns the current input manager
  18794. */
  18795. addTouch(): FreeCameraInputsManager;
  18796. /**
  18797. * Remove all attached input methods from a camera
  18798. */
  18799. clear(): void;
  18800. }
  18801. }
  18802. declare module "babylonjs/Cameras/freeCamera" {
  18803. import { Vector3 } from "babylonjs/Maths/math.vector";
  18804. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18805. import { Scene } from "babylonjs/scene";
  18806. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  18807. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  18808. /**
  18809. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18810. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18811. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18812. */
  18813. export class FreeCamera extends TargetCamera {
  18814. /**
  18815. * Define the collision ellipsoid of the camera.
  18816. * This is helpful to simulate a camera body like the player body around the camera
  18817. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18818. */
  18819. ellipsoid: Vector3;
  18820. /**
  18821. * Define an offset for the position of the ellipsoid around the camera.
  18822. * This can be helpful to determine the center of the body near the gravity center of the body
  18823. * instead of its head.
  18824. */
  18825. ellipsoidOffset: Vector3;
  18826. /**
  18827. * Enable or disable collisions of the camera with the rest of the scene objects.
  18828. */
  18829. checkCollisions: boolean;
  18830. /**
  18831. * Enable or disable gravity on the camera.
  18832. */
  18833. applyGravity: boolean;
  18834. /**
  18835. * Define the input manager associated to the camera.
  18836. */
  18837. inputs: FreeCameraInputsManager;
  18838. /**
  18839. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18840. * Higher values reduce sensitivity.
  18841. */
  18842. get angularSensibility(): number;
  18843. /**
  18844. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18845. * Higher values reduce sensitivity.
  18846. */
  18847. set angularSensibility(value: number);
  18848. /**
  18849. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18850. */
  18851. get keysUp(): number[];
  18852. set keysUp(value: number[]);
  18853. /**
  18854. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18855. */
  18856. get keysDown(): number[];
  18857. set keysDown(value: number[]);
  18858. /**
  18859. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18860. */
  18861. get keysLeft(): number[];
  18862. set keysLeft(value: number[]);
  18863. /**
  18864. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18865. */
  18866. get keysRight(): number[];
  18867. set keysRight(value: number[]);
  18868. /**
  18869. * Event raised when the camera collide with a mesh in the scene.
  18870. */
  18871. onCollide: (collidedMesh: AbstractMesh) => void;
  18872. private _collider;
  18873. private _needMoveForGravity;
  18874. private _oldPosition;
  18875. private _diffPosition;
  18876. private _newPosition;
  18877. /** @hidden */
  18878. _localDirection: Vector3;
  18879. /** @hidden */
  18880. _transformedDirection: Vector3;
  18881. /**
  18882. * Instantiates a Free Camera.
  18883. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18884. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18885. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18886. * @param name Define the name of the camera in the scene
  18887. * @param position Define the start position of the camera in the scene
  18888. * @param scene Define the scene the camera belongs to
  18889. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18890. */
  18891. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18892. /**
  18893. * Attached controls to the current camera.
  18894. * @param element Defines the element the controls should be listened from
  18895. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18896. */
  18897. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18898. /**
  18899. * Detach the current controls from the camera.
  18900. * The camera will stop reacting to inputs.
  18901. * @param element Defines the element to stop listening the inputs from
  18902. */
  18903. detachControl(element: HTMLElement): void;
  18904. private _collisionMask;
  18905. /**
  18906. * Define a collision mask to limit the list of object the camera can collide with
  18907. */
  18908. get collisionMask(): number;
  18909. set collisionMask(mask: number);
  18910. /** @hidden */
  18911. _collideWithWorld(displacement: Vector3): void;
  18912. private _onCollisionPositionChange;
  18913. /** @hidden */
  18914. _checkInputs(): void;
  18915. /** @hidden */
  18916. _decideIfNeedsToMove(): boolean;
  18917. /** @hidden */
  18918. _updatePosition(): void;
  18919. /**
  18920. * Destroy the camera and release the current resources hold by it.
  18921. */
  18922. dispose(): void;
  18923. /**
  18924. * Gets the current object class name.
  18925. * @return the class name
  18926. */
  18927. getClassName(): string;
  18928. }
  18929. }
  18930. declare module "babylonjs/Gamepads/gamepad" {
  18931. import { Observable } from "babylonjs/Misc/observable";
  18932. /**
  18933. * Represents a gamepad control stick position
  18934. */
  18935. export class StickValues {
  18936. /**
  18937. * The x component of the control stick
  18938. */
  18939. x: number;
  18940. /**
  18941. * The y component of the control stick
  18942. */
  18943. y: number;
  18944. /**
  18945. * Initializes the gamepad x and y control stick values
  18946. * @param x The x component of the gamepad control stick value
  18947. * @param y The y component of the gamepad control stick value
  18948. */
  18949. constructor(
  18950. /**
  18951. * The x component of the control stick
  18952. */
  18953. x: number,
  18954. /**
  18955. * The y component of the control stick
  18956. */
  18957. y: number);
  18958. }
  18959. /**
  18960. * An interface which manages callbacks for gamepad button changes
  18961. */
  18962. export interface GamepadButtonChanges {
  18963. /**
  18964. * Called when a gamepad has been changed
  18965. */
  18966. changed: boolean;
  18967. /**
  18968. * Called when a gamepad press event has been triggered
  18969. */
  18970. pressChanged: boolean;
  18971. /**
  18972. * Called when a touch event has been triggered
  18973. */
  18974. touchChanged: boolean;
  18975. /**
  18976. * Called when a value has changed
  18977. */
  18978. valueChanged: boolean;
  18979. }
  18980. /**
  18981. * Represents a gamepad
  18982. */
  18983. export class Gamepad {
  18984. /**
  18985. * The id of the gamepad
  18986. */
  18987. id: string;
  18988. /**
  18989. * The index of the gamepad
  18990. */
  18991. index: number;
  18992. /**
  18993. * The browser gamepad
  18994. */
  18995. browserGamepad: any;
  18996. /**
  18997. * Specifies what type of gamepad this represents
  18998. */
  18999. type: number;
  19000. private _leftStick;
  19001. private _rightStick;
  19002. /** @hidden */
  19003. _isConnected: boolean;
  19004. private _leftStickAxisX;
  19005. private _leftStickAxisY;
  19006. private _rightStickAxisX;
  19007. private _rightStickAxisY;
  19008. /**
  19009. * Triggered when the left control stick has been changed
  19010. */
  19011. private _onleftstickchanged;
  19012. /**
  19013. * Triggered when the right control stick has been changed
  19014. */
  19015. private _onrightstickchanged;
  19016. /**
  19017. * Represents a gamepad controller
  19018. */
  19019. static GAMEPAD: number;
  19020. /**
  19021. * Represents a generic controller
  19022. */
  19023. static GENERIC: number;
  19024. /**
  19025. * Represents an XBox controller
  19026. */
  19027. static XBOX: number;
  19028. /**
  19029. * Represents a pose-enabled controller
  19030. */
  19031. static POSE_ENABLED: number;
  19032. /**
  19033. * Represents an Dual Shock controller
  19034. */
  19035. static DUALSHOCK: number;
  19036. /**
  19037. * Specifies whether the left control stick should be Y-inverted
  19038. */
  19039. protected _invertLeftStickY: boolean;
  19040. /**
  19041. * Specifies if the gamepad has been connected
  19042. */
  19043. get isConnected(): boolean;
  19044. /**
  19045. * Initializes the gamepad
  19046. * @param id The id of the gamepad
  19047. * @param index The index of the gamepad
  19048. * @param browserGamepad The browser gamepad
  19049. * @param leftStickX The x component of the left joystick
  19050. * @param leftStickY The y component of the left joystick
  19051. * @param rightStickX The x component of the right joystick
  19052. * @param rightStickY The y component of the right joystick
  19053. */
  19054. constructor(
  19055. /**
  19056. * The id of the gamepad
  19057. */
  19058. id: string,
  19059. /**
  19060. * The index of the gamepad
  19061. */
  19062. index: number,
  19063. /**
  19064. * The browser gamepad
  19065. */
  19066. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19067. /**
  19068. * Callback triggered when the left joystick has changed
  19069. * @param callback
  19070. */
  19071. onleftstickchanged(callback: (values: StickValues) => void): void;
  19072. /**
  19073. * Callback triggered when the right joystick has changed
  19074. * @param callback
  19075. */
  19076. onrightstickchanged(callback: (values: StickValues) => void): void;
  19077. /**
  19078. * Gets the left joystick
  19079. */
  19080. get leftStick(): StickValues;
  19081. /**
  19082. * Sets the left joystick values
  19083. */
  19084. set leftStick(newValues: StickValues);
  19085. /**
  19086. * Gets the right joystick
  19087. */
  19088. get rightStick(): StickValues;
  19089. /**
  19090. * Sets the right joystick value
  19091. */
  19092. set rightStick(newValues: StickValues);
  19093. /**
  19094. * Updates the gamepad joystick positions
  19095. */
  19096. update(): void;
  19097. /**
  19098. * Disposes the gamepad
  19099. */
  19100. dispose(): void;
  19101. }
  19102. /**
  19103. * Represents a generic gamepad
  19104. */
  19105. export class GenericPad extends Gamepad {
  19106. private _buttons;
  19107. private _onbuttondown;
  19108. private _onbuttonup;
  19109. /**
  19110. * Observable triggered when a button has been pressed
  19111. */
  19112. onButtonDownObservable: Observable<number>;
  19113. /**
  19114. * Observable triggered when a button has been released
  19115. */
  19116. onButtonUpObservable: Observable<number>;
  19117. /**
  19118. * Callback triggered when a button has been pressed
  19119. * @param callback Called when a button has been pressed
  19120. */
  19121. onbuttondown(callback: (buttonPressed: number) => void): void;
  19122. /**
  19123. * Callback triggered when a button has been released
  19124. * @param callback Called when a button has been released
  19125. */
  19126. onbuttonup(callback: (buttonReleased: number) => void): void;
  19127. /**
  19128. * Initializes the generic gamepad
  19129. * @param id The id of the generic gamepad
  19130. * @param index The index of the generic gamepad
  19131. * @param browserGamepad The browser gamepad
  19132. */
  19133. constructor(id: string, index: number, browserGamepad: any);
  19134. private _setButtonValue;
  19135. /**
  19136. * Updates the generic gamepad
  19137. */
  19138. update(): void;
  19139. /**
  19140. * Disposes the generic gamepad
  19141. */
  19142. dispose(): void;
  19143. }
  19144. }
  19145. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19146. import { Observable } from "babylonjs/Misc/observable";
  19147. import { Nullable } from "babylonjs/types";
  19148. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19149. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19150. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19151. import { Ray } from "babylonjs/Culling/ray";
  19152. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19153. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19154. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19155. /**
  19156. * Defines the types of pose enabled controllers that are supported
  19157. */
  19158. export enum PoseEnabledControllerType {
  19159. /**
  19160. * HTC Vive
  19161. */
  19162. VIVE = 0,
  19163. /**
  19164. * Oculus Rift
  19165. */
  19166. OCULUS = 1,
  19167. /**
  19168. * Windows mixed reality
  19169. */
  19170. WINDOWS = 2,
  19171. /**
  19172. * Samsung gear VR
  19173. */
  19174. GEAR_VR = 3,
  19175. /**
  19176. * Google Daydream
  19177. */
  19178. DAYDREAM = 4,
  19179. /**
  19180. * Generic
  19181. */
  19182. GENERIC = 5
  19183. }
  19184. /**
  19185. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19186. */
  19187. export interface MutableGamepadButton {
  19188. /**
  19189. * Value of the button/trigger
  19190. */
  19191. value: number;
  19192. /**
  19193. * If the button/trigger is currently touched
  19194. */
  19195. touched: boolean;
  19196. /**
  19197. * If the button/trigger is currently pressed
  19198. */
  19199. pressed: boolean;
  19200. }
  19201. /**
  19202. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19203. * @hidden
  19204. */
  19205. export interface ExtendedGamepadButton extends GamepadButton {
  19206. /**
  19207. * If the button/trigger is currently pressed
  19208. */
  19209. readonly pressed: boolean;
  19210. /**
  19211. * If the button/trigger is currently touched
  19212. */
  19213. readonly touched: boolean;
  19214. /**
  19215. * Value of the button/trigger
  19216. */
  19217. readonly value: number;
  19218. }
  19219. /** @hidden */
  19220. export interface _GamePadFactory {
  19221. /**
  19222. * Returns whether or not the current gamepad can be created for this type of controller.
  19223. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19224. * @returns true if it can be created, otherwise false
  19225. */
  19226. canCreate(gamepadInfo: any): boolean;
  19227. /**
  19228. * Creates a new instance of the Gamepad.
  19229. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19230. * @returns the new gamepad instance
  19231. */
  19232. create(gamepadInfo: any): Gamepad;
  19233. }
  19234. /**
  19235. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19236. */
  19237. export class PoseEnabledControllerHelper {
  19238. /** @hidden */
  19239. static _ControllerFactories: _GamePadFactory[];
  19240. /** @hidden */
  19241. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19242. /**
  19243. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19244. * @param vrGamepad the gamepad to initialized
  19245. * @returns a vr controller of the type the gamepad identified as
  19246. */
  19247. static InitiateController(vrGamepad: any): Gamepad;
  19248. }
  19249. /**
  19250. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19251. */
  19252. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19253. /**
  19254. * If the controller is used in a webXR session
  19255. */
  19256. isXR: boolean;
  19257. private _deviceRoomPosition;
  19258. private _deviceRoomRotationQuaternion;
  19259. /**
  19260. * The device position in babylon space
  19261. */
  19262. devicePosition: Vector3;
  19263. /**
  19264. * The device rotation in babylon space
  19265. */
  19266. deviceRotationQuaternion: Quaternion;
  19267. /**
  19268. * The scale factor of the device in babylon space
  19269. */
  19270. deviceScaleFactor: number;
  19271. /**
  19272. * (Likely devicePosition should be used instead) The device position in its room space
  19273. */
  19274. position: Vector3;
  19275. /**
  19276. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19277. */
  19278. rotationQuaternion: Quaternion;
  19279. /**
  19280. * The type of controller (Eg. Windows mixed reality)
  19281. */
  19282. controllerType: PoseEnabledControllerType;
  19283. protected _calculatedPosition: Vector3;
  19284. private _calculatedRotation;
  19285. /**
  19286. * The raw pose from the device
  19287. */
  19288. rawPose: DevicePose;
  19289. private _trackPosition;
  19290. private _maxRotationDistFromHeadset;
  19291. private _draggedRoomRotation;
  19292. /**
  19293. * @hidden
  19294. */
  19295. _disableTrackPosition(fixedPosition: Vector3): void;
  19296. /**
  19297. * Internal, the mesh attached to the controller
  19298. * @hidden
  19299. */
  19300. _mesh: Nullable<AbstractMesh>;
  19301. private _poseControlledCamera;
  19302. private _leftHandSystemQuaternion;
  19303. /**
  19304. * Internal, matrix used to convert room space to babylon space
  19305. * @hidden
  19306. */
  19307. _deviceToWorld: Matrix;
  19308. /**
  19309. * Node to be used when casting a ray from the controller
  19310. * @hidden
  19311. */
  19312. _pointingPoseNode: Nullable<TransformNode>;
  19313. /**
  19314. * Name of the child mesh that can be used to cast a ray from the controller
  19315. */
  19316. static readonly POINTING_POSE: string;
  19317. /**
  19318. * Creates a new PoseEnabledController from a gamepad
  19319. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19320. */
  19321. constructor(browserGamepad: any);
  19322. private _workingMatrix;
  19323. /**
  19324. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19325. */
  19326. update(): void;
  19327. /**
  19328. * Updates only the pose device and mesh without doing any button event checking
  19329. */
  19330. protected _updatePoseAndMesh(): void;
  19331. /**
  19332. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19333. * @param poseData raw pose fromthe device
  19334. */
  19335. updateFromDevice(poseData: DevicePose): void;
  19336. /**
  19337. * @hidden
  19338. */
  19339. _meshAttachedObservable: Observable<AbstractMesh>;
  19340. /**
  19341. * Attaches a mesh to the controller
  19342. * @param mesh the mesh to be attached
  19343. */
  19344. attachToMesh(mesh: AbstractMesh): void;
  19345. /**
  19346. * Attaches the controllers mesh to a camera
  19347. * @param camera the camera the mesh should be attached to
  19348. */
  19349. attachToPoseControlledCamera(camera: TargetCamera): void;
  19350. /**
  19351. * Disposes of the controller
  19352. */
  19353. dispose(): void;
  19354. /**
  19355. * The mesh that is attached to the controller
  19356. */
  19357. get mesh(): Nullable<AbstractMesh>;
  19358. /**
  19359. * Gets the ray of the controller in the direction the controller is pointing
  19360. * @param length the length the resulting ray should be
  19361. * @returns a ray in the direction the controller is pointing
  19362. */
  19363. getForwardRay(length?: number): Ray;
  19364. }
  19365. }
  19366. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  19367. import { Observable } from "babylonjs/Misc/observable";
  19368. import { Scene } from "babylonjs/scene";
  19369. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19370. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  19371. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  19372. import { Nullable } from "babylonjs/types";
  19373. /**
  19374. * Defines the WebVRController object that represents controllers tracked in 3D space
  19375. */
  19376. export abstract class WebVRController extends PoseEnabledController {
  19377. /**
  19378. * Internal, the default controller model for the controller
  19379. */
  19380. protected _defaultModel: Nullable<AbstractMesh>;
  19381. /**
  19382. * Fired when the trigger state has changed
  19383. */
  19384. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19385. /**
  19386. * Fired when the main button state has changed
  19387. */
  19388. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19389. /**
  19390. * Fired when the secondary button state has changed
  19391. */
  19392. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19393. /**
  19394. * Fired when the pad state has changed
  19395. */
  19396. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19397. /**
  19398. * Fired when controllers stick values have changed
  19399. */
  19400. onPadValuesChangedObservable: Observable<StickValues>;
  19401. /**
  19402. * Array of button availible on the controller
  19403. */
  19404. protected _buttons: Array<MutableGamepadButton>;
  19405. private _onButtonStateChange;
  19406. /**
  19407. * Fired when a controller button's state has changed
  19408. * @param callback the callback containing the button that was modified
  19409. */
  19410. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19411. /**
  19412. * X and Y axis corresponding to the controllers joystick
  19413. */
  19414. pad: StickValues;
  19415. /**
  19416. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19417. */
  19418. hand: string;
  19419. /**
  19420. * The default controller model for the controller
  19421. */
  19422. get defaultModel(): Nullable<AbstractMesh>;
  19423. /**
  19424. * Creates a new WebVRController from a gamepad
  19425. * @param vrGamepad the gamepad that the WebVRController should be created from
  19426. */
  19427. constructor(vrGamepad: any);
  19428. /**
  19429. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19430. */
  19431. update(): void;
  19432. /**
  19433. * Function to be called when a button is modified
  19434. */
  19435. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19436. /**
  19437. * Loads a mesh and attaches it to the controller
  19438. * @param scene the scene the mesh should be added to
  19439. * @param meshLoaded callback for when the mesh has been loaded
  19440. */
  19441. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19442. private _setButtonValue;
  19443. private _changes;
  19444. private _checkChanges;
  19445. /**
  19446. * Disposes of th webVRCOntroller
  19447. */
  19448. dispose(): void;
  19449. }
  19450. }
  19451. declare module "babylonjs/Lights/hemisphericLight" {
  19452. import { Nullable } from "babylonjs/types";
  19453. import { Scene } from "babylonjs/scene";
  19454. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19455. import { Color3 } from "babylonjs/Maths/math.color";
  19456. import { Effect } from "babylonjs/Materials/effect";
  19457. import { Light } from "babylonjs/Lights/light";
  19458. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  19459. /**
  19460. * The HemisphericLight simulates the ambient environment light,
  19461. * so the passed direction is the light reflection direction, not the incoming direction.
  19462. */
  19463. export class HemisphericLight extends Light {
  19464. /**
  19465. * The groundColor is the light in the opposite direction to the one specified during creation.
  19466. * 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.
  19467. */
  19468. groundColor: Color3;
  19469. /**
  19470. * The light reflection direction, not the incoming direction.
  19471. */
  19472. direction: Vector3;
  19473. /**
  19474. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19475. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19476. * The HemisphericLight can't cast shadows.
  19477. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19478. * @param name The friendly name of the light
  19479. * @param direction The direction of the light reflection
  19480. * @param scene The scene the light belongs to
  19481. */
  19482. constructor(name: string, direction: Vector3, scene: Scene);
  19483. protected _buildUniformLayout(): void;
  19484. /**
  19485. * Returns the string "HemisphericLight".
  19486. * @return The class name
  19487. */
  19488. getClassName(): string;
  19489. /**
  19490. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19491. * Returns the updated direction.
  19492. * @param target The target the direction should point to
  19493. * @return The computed direction
  19494. */
  19495. setDirectionToTarget(target: Vector3): Vector3;
  19496. /**
  19497. * Returns the shadow generator associated to the light.
  19498. * @returns Always null for hemispheric lights because it does not support shadows.
  19499. */
  19500. getShadowGenerator(): Nullable<IShadowGenerator>;
  19501. /**
  19502. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19503. * @param effect The effect to update
  19504. * @param lightIndex The index of the light in the effect to update
  19505. * @returns The hemispheric light
  19506. */
  19507. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19508. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19509. /**
  19510. * Computes the world matrix of the node
  19511. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19512. * @param useWasUpdatedFlag defines a reserved property
  19513. * @returns the world matrix
  19514. */
  19515. computeWorldMatrix(): Matrix;
  19516. /**
  19517. * Returns the integer 3.
  19518. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19519. */
  19520. getTypeID(): number;
  19521. /**
  19522. * Prepares the list of defines specific to the light type.
  19523. * @param defines the list of defines
  19524. * @param lightIndex defines the index of the light for the effect
  19525. */
  19526. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19527. }
  19528. }
  19529. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  19530. /** @hidden */
  19531. export var vrMultiviewToSingleviewPixelShader: {
  19532. name: string;
  19533. shader: string;
  19534. };
  19535. }
  19536. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  19537. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19538. import { Scene } from "babylonjs/scene";
  19539. /**
  19540. * Renders to multiple views with a single draw call
  19541. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19542. */
  19543. export class MultiviewRenderTarget extends RenderTargetTexture {
  19544. /**
  19545. * Creates a multiview render target
  19546. * @param scene scene used with the render target
  19547. * @param size the size of the render target (used for each view)
  19548. */
  19549. constructor(scene: Scene, size?: number | {
  19550. width: number;
  19551. height: number;
  19552. } | {
  19553. ratio: number;
  19554. });
  19555. /**
  19556. * @hidden
  19557. * @param faceIndex the face index, if its a cube texture
  19558. */
  19559. _bindFrameBuffer(faceIndex?: number): void;
  19560. /**
  19561. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19562. * @returns the view count
  19563. */
  19564. getViewCount(): number;
  19565. }
  19566. }
  19567. declare module "babylonjs/Maths/math.frustum" {
  19568. import { Matrix } from "babylonjs/Maths/math.vector";
  19569. import { DeepImmutable } from "babylonjs/types";
  19570. import { Plane } from "babylonjs/Maths/math.plane";
  19571. /**
  19572. * Represents a camera frustum
  19573. */
  19574. export class Frustum {
  19575. /**
  19576. * Gets the planes representing the frustum
  19577. * @param transform matrix to be applied to the returned planes
  19578. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  19579. */
  19580. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  19581. /**
  19582. * Gets the near frustum plane transformed by the transform matrix
  19583. * @param transform transformation matrix to be applied to the resulting frustum plane
  19584. * @param frustumPlane the resuling frustum plane
  19585. */
  19586. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19587. /**
  19588. * Gets the far frustum plane transformed by the transform matrix
  19589. * @param transform transformation matrix to be applied to the resulting frustum plane
  19590. * @param frustumPlane the resuling frustum plane
  19591. */
  19592. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19593. /**
  19594. * Gets the left frustum plane transformed by the transform matrix
  19595. * @param transform transformation matrix to be applied to the resulting frustum plane
  19596. * @param frustumPlane the resuling frustum plane
  19597. */
  19598. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19599. /**
  19600. * Gets the right frustum plane transformed by the transform matrix
  19601. * @param transform transformation matrix to be applied to the resulting frustum plane
  19602. * @param frustumPlane the resuling frustum plane
  19603. */
  19604. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19605. /**
  19606. * Gets the top frustum plane transformed by the transform matrix
  19607. * @param transform transformation matrix to be applied to the resulting frustum plane
  19608. * @param frustumPlane the resuling frustum plane
  19609. */
  19610. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19611. /**
  19612. * Gets the bottom frustum plane transformed by the transform matrix
  19613. * @param transform transformation matrix to be applied to the resulting frustum plane
  19614. * @param frustumPlane the resuling frustum plane
  19615. */
  19616. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19617. /**
  19618. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  19619. * @param transform transformation matrix to be applied to the resulting frustum planes
  19620. * @param frustumPlanes the resuling frustum planes
  19621. */
  19622. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  19623. }
  19624. }
  19625. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  19626. import { Camera } from "babylonjs/Cameras/camera";
  19627. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  19628. import { Nullable } from "babylonjs/types";
  19629. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19630. import { Matrix } from "babylonjs/Maths/math.vector";
  19631. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  19632. module "babylonjs/Engines/engine" {
  19633. interface Engine {
  19634. /**
  19635. * Creates a new multiview render target
  19636. * @param width defines the width of the texture
  19637. * @param height defines the height of the texture
  19638. * @returns the created multiview texture
  19639. */
  19640. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19641. /**
  19642. * Binds a multiview framebuffer to be drawn to
  19643. * @param multiviewTexture texture to bind
  19644. */
  19645. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19646. }
  19647. }
  19648. module "babylonjs/Cameras/camera" {
  19649. interface Camera {
  19650. /**
  19651. * @hidden
  19652. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  19653. */
  19654. _useMultiviewToSingleView: boolean;
  19655. /**
  19656. * @hidden
  19657. * 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)
  19658. */
  19659. _multiviewTexture: Nullable<RenderTargetTexture>;
  19660. /**
  19661. * @hidden
  19662. * ensures the multiview texture of the camera exists and has the specified width/height
  19663. * @param width height to set on the multiview texture
  19664. * @param height width to set on the multiview texture
  19665. */
  19666. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19667. }
  19668. }
  19669. module "babylonjs/scene" {
  19670. interface Scene {
  19671. /** @hidden */
  19672. _transformMatrixR: Matrix;
  19673. /** @hidden */
  19674. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19675. /** @hidden */
  19676. _createMultiviewUbo(): void;
  19677. /** @hidden */
  19678. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19679. /** @hidden */
  19680. _renderMultiviewToSingleView(camera: Camera): void;
  19681. }
  19682. }
  19683. }
  19684. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  19685. import { Camera } from "babylonjs/Cameras/camera";
  19686. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  19687. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  19688. import "babylonjs/Engines/Extensions/engine.multiview";
  19689. /**
  19690. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19691. * This will not be used for webXR as it supports displaying texture arrays directly
  19692. */
  19693. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19694. /**
  19695. * Initializes a VRMultiviewToSingleview
  19696. * @param name name of the post process
  19697. * @param camera camera to be applied to
  19698. * @param scaleFactor scaling factor to the size of the output texture
  19699. */
  19700. constructor(name: string, camera: Camera, scaleFactor: number);
  19701. }
  19702. }
  19703. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  19704. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  19705. import { Nullable } from "babylonjs/types";
  19706. import { Size } from "babylonjs/Maths/math.size";
  19707. import { Observable } from "babylonjs/Misc/observable";
  19708. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  19709. /**
  19710. * Interface used to define additional presentation attributes
  19711. */
  19712. export interface IVRPresentationAttributes {
  19713. /**
  19714. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19715. */
  19716. highRefreshRate: boolean;
  19717. /**
  19718. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19719. */
  19720. foveationLevel: number;
  19721. }
  19722. module "babylonjs/Engines/engine" {
  19723. interface Engine {
  19724. /** @hidden */
  19725. _vrDisplay: any;
  19726. /** @hidden */
  19727. _vrSupported: boolean;
  19728. /** @hidden */
  19729. _oldSize: Size;
  19730. /** @hidden */
  19731. _oldHardwareScaleFactor: number;
  19732. /** @hidden */
  19733. _vrExclusivePointerMode: boolean;
  19734. /** @hidden */
  19735. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19736. /** @hidden */
  19737. _onVRDisplayPointerRestricted: () => void;
  19738. /** @hidden */
  19739. _onVRDisplayPointerUnrestricted: () => void;
  19740. /** @hidden */
  19741. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19742. /** @hidden */
  19743. _onVrDisplayDisconnect: Nullable<() => void>;
  19744. /** @hidden */
  19745. _onVrDisplayPresentChange: Nullable<() => void>;
  19746. /**
  19747. * Observable signaled when VR display mode changes
  19748. */
  19749. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19750. /**
  19751. * Observable signaled when VR request present is complete
  19752. */
  19753. onVRRequestPresentComplete: Observable<boolean>;
  19754. /**
  19755. * Observable signaled when VR request present starts
  19756. */
  19757. onVRRequestPresentStart: Observable<Engine>;
  19758. /**
  19759. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19760. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19761. */
  19762. isInVRExclusivePointerMode: boolean;
  19763. /**
  19764. * Gets a boolean indicating if a webVR device was detected
  19765. * @returns true if a webVR device was detected
  19766. */
  19767. isVRDevicePresent(): boolean;
  19768. /**
  19769. * Gets the current webVR device
  19770. * @returns the current webVR device (or null)
  19771. */
  19772. getVRDevice(): any;
  19773. /**
  19774. * Initializes a webVR display and starts listening to display change events
  19775. * The onVRDisplayChangedObservable will be notified upon these changes
  19776. * @returns A promise containing a VRDisplay and if vr is supported
  19777. */
  19778. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19779. /** @hidden */
  19780. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19781. /**
  19782. * Gets or sets the presentation attributes used to configure VR rendering
  19783. */
  19784. vrPresentationAttributes?: IVRPresentationAttributes;
  19785. /**
  19786. * Call this function to switch to webVR mode
  19787. * Will do nothing if webVR is not supported or if there is no webVR device
  19788. * @param options the webvr options provided to the camera. mainly used for multiview
  19789. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19790. */
  19791. enableVR(options: WebVROptions): void;
  19792. /** @hidden */
  19793. _onVRFullScreenTriggered(): void;
  19794. }
  19795. }
  19796. }
  19797. declare module "babylonjs/Cameras/VR/webVRCamera" {
  19798. import { Nullable } from "babylonjs/types";
  19799. import { Observable } from "babylonjs/Misc/observable";
  19800. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19801. import { Scene } from "babylonjs/scene";
  19802. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19803. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  19804. import { Node } from "babylonjs/node";
  19805. import { Ray } from "babylonjs/Culling/ray";
  19806. import "babylonjs/Cameras/RigModes/webVRRigMode";
  19807. import "babylonjs/Engines/Extensions/engine.webVR";
  19808. /**
  19809. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19810. * IMPORTANT!! The data is right-hand data.
  19811. * @export
  19812. * @interface DevicePose
  19813. */
  19814. export interface DevicePose {
  19815. /**
  19816. * The position of the device, values in array are [x,y,z].
  19817. */
  19818. readonly position: Nullable<Float32Array>;
  19819. /**
  19820. * The linearVelocity of the device, values in array are [x,y,z].
  19821. */
  19822. readonly linearVelocity: Nullable<Float32Array>;
  19823. /**
  19824. * The linearAcceleration of the device, values in array are [x,y,z].
  19825. */
  19826. readonly linearAcceleration: Nullable<Float32Array>;
  19827. /**
  19828. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19829. */
  19830. readonly orientation: Nullable<Float32Array>;
  19831. /**
  19832. * The angularVelocity of the device, values in array are [x,y,z].
  19833. */
  19834. readonly angularVelocity: Nullable<Float32Array>;
  19835. /**
  19836. * The angularAcceleration of the device, values in array are [x,y,z].
  19837. */
  19838. readonly angularAcceleration: Nullable<Float32Array>;
  19839. }
  19840. /**
  19841. * Interface representing a pose controlled object in Babylon.
  19842. * A pose controlled object has both regular pose values as well as pose values
  19843. * from an external device such as a VR head mounted display
  19844. */
  19845. export interface PoseControlled {
  19846. /**
  19847. * The position of the object in babylon space.
  19848. */
  19849. position: Vector3;
  19850. /**
  19851. * The rotation quaternion of the object in babylon space.
  19852. */
  19853. rotationQuaternion: Quaternion;
  19854. /**
  19855. * The position of the device in babylon space.
  19856. */
  19857. devicePosition?: Vector3;
  19858. /**
  19859. * The rotation quaternion of the device in babylon space.
  19860. */
  19861. deviceRotationQuaternion: Quaternion;
  19862. /**
  19863. * The raw pose coming from the device.
  19864. */
  19865. rawPose: Nullable<DevicePose>;
  19866. /**
  19867. * The scale of the device to be used when translating from device space to babylon space.
  19868. */
  19869. deviceScaleFactor: number;
  19870. /**
  19871. * Updates the poseControlled values based on the input device pose.
  19872. * @param poseData the pose data to update the object with
  19873. */
  19874. updateFromDevice(poseData: DevicePose): void;
  19875. }
  19876. /**
  19877. * Set of options to customize the webVRCamera
  19878. */
  19879. export interface WebVROptions {
  19880. /**
  19881. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19882. */
  19883. trackPosition?: boolean;
  19884. /**
  19885. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19886. */
  19887. positionScale?: number;
  19888. /**
  19889. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19890. */
  19891. displayName?: string;
  19892. /**
  19893. * Should the native controller meshes be initialized. (default: true)
  19894. */
  19895. controllerMeshes?: boolean;
  19896. /**
  19897. * Creating a default HemiLight only on controllers. (default: true)
  19898. */
  19899. defaultLightingOnControllers?: boolean;
  19900. /**
  19901. * If you don't want to use the default VR button of the helper. (default: false)
  19902. */
  19903. useCustomVRButton?: boolean;
  19904. /**
  19905. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19906. */
  19907. customVRButton?: HTMLButtonElement;
  19908. /**
  19909. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19910. */
  19911. rayLength?: number;
  19912. /**
  19913. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19914. */
  19915. defaultHeight?: number;
  19916. /**
  19917. * If multiview should be used if availible (default: false)
  19918. */
  19919. useMultiview?: boolean;
  19920. }
  19921. /**
  19922. * This represents a WebVR camera.
  19923. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19924. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19925. */
  19926. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19927. private webVROptions;
  19928. /**
  19929. * @hidden
  19930. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19931. */
  19932. _vrDevice: any;
  19933. /**
  19934. * The rawPose of the vrDevice.
  19935. */
  19936. rawPose: Nullable<DevicePose>;
  19937. private _onVREnabled;
  19938. private _specsVersion;
  19939. private _attached;
  19940. private _frameData;
  19941. protected _descendants: Array<Node>;
  19942. private _deviceRoomPosition;
  19943. /** @hidden */
  19944. _deviceRoomRotationQuaternion: Quaternion;
  19945. private _standingMatrix;
  19946. /**
  19947. * Represents device position in babylon space.
  19948. */
  19949. devicePosition: Vector3;
  19950. /**
  19951. * Represents device rotation in babylon space.
  19952. */
  19953. deviceRotationQuaternion: Quaternion;
  19954. /**
  19955. * The scale of the device to be used when translating from device space to babylon space.
  19956. */
  19957. deviceScaleFactor: number;
  19958. private _deviceToWorld;
  19959. private _worldToDevice;
  19960. /**
  19961. * References to the webVR controllers for the vrDevice.
  19962. */
  19963. controllers: Array<WebVRController>;
  19964. /**
  19965. * Emits an event when a controller is attached.
  19966. */
  19967. onControllersAttachedObservable: Observable<WebVRController[]>;
  19968. /**
  19969. * Emits an event when a controller's mesh has been loaded;
  19970. */
  19971. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19972. /**
  19973. * Emits an event when the HMD's pose has been updated.
  19974. */
  19975. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19976. private _poseSet;
  19977. /**
  19978. * If the rig cameras be used as parent instead of this camera.
  19979. */
  19980. rigParenting: boolean;
  19981. private _lightOnControllers;
  19982. private _defaultHeight?;
  19983. /**
  19984. * Instantiates a WebVRFreeCamera.
  19985. * @param name The name of the WebVRFreeCamera
  19986. * @param position The starting anchor position for the camera
  19987. * @param scene The scene the camera belongs to
  19988. * @param webVROptions a set of customizable options for the webVRCamera
  19989. */
  19990. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19991. /**
  19992. * Gets the device distance from the ground in meters.
  19993. * @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.
  19994. */
  19995. deviceDistanceToRoomGround(): number;
  19996. /**
  19997. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19998. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19999. */
  20000. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20001. /**
  20002. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20003. * @returns A promise with a boolean set to if the standing matrix is supported.
  20004. */
  20005. useStandingMatrixAsync(): Promise<boolean>;
  20006. /**
  20007. * Disposes the camera
  20008. */
  20009. dispose(): void;
  20010. /**
  20011. * Gets a vrController by name.
  20012. * @param name The name of the controller to retreive
  20013. * @returns the controller matching the name specified or null if not found
  20014. */
  20015. getControllerByName(name: string): Nullable<WebVRController>;
  20016. private _leftController;
  20017. /**
  20018. * The controller corresponding to the users left hand.
  20019. */
  20020. get leftController(): Nullable<WebVRController>;
  20021. private _rightController;
  20022. /**
  20023. * The controller corresponding to the users right hand.
  20024. */
  20025. get rightController(): Nullable<WebVRController>;
  20026. /**
  20027. * Casts a ray forward from the vrCamera's gaze.
  20028. * @param length Length of the ray (default: 100)
  20029. * @returns the ray corresponding to the gaze
  20030. */
  20031. getForwardRay(length?: number): Ray;
  20032. /**
  20033. * @hidden
  20034. * Updates the camera based on device's frame data
  20035. */
  20036. _checkInputs(): void;
  20037. /**
  20038. * Updates the poseControlled values based on the input device pose.
  20039. * @param poseData Pose coming from the device
  20040. */
  20041. updateFromDevice(poseData: DevicePose): void;
  20042. private _htmlElementAttached;
  20043. private _detachIfAttached;
  20044. /**
  20045. * WebVR's attach control will start broadcasting frames to the device.
  20046. * Note that in certain browsers (chrome for example) this function must be called
  20047. * within a user-interaction callback. Example:
  20048. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20049. *
  20050. * @param element html element to attach the vrDevice to
  20051. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20052. */
  20053. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20054. /**
  20055. * Detaches the camera from the html element and disables VR
  20056. *
  20057. * @param element html element to detach from
  20058. */
  20059. detachControl(element: HTMLElement): void;
  20060. /**
  20061. * @returns the name of this class
  20062. */
  20063. getClassName(): string;
  20064. /**
  20065. * Calls resetPose on the vrDisplay
  20066. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20067. */
  20068. resetToCurrentRotation(): void;
  20069. /**
  20070. * @hidden
  20071. * Updates the rig cameras (left and right eye)
  20072. */
  20073. _updateRigCameras(): void;
  20074. private _workingVector;
  20075. private _oneVector;
  20076. private _workingMatrix;
  20077. private updateCacheCalled;
  20078. private _correctPositionIfNotTrackPosition;
  20079. /**
  20080. * @hidden
  20081. * Updates the cached values of the camera
  20082. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20083. */
  20084. _updateCache(ignoreParentClass?: boolean): void;
  20085. /**
  20086. * @hidden
  20087. * Get current device position in babylon world
  20088. */
  20089. _computeDevicePosition(): void;
  20090. /**
  20091. * Updates the current device position and rotation in the babylon world
  20092. */
  20093. update(): void;
  20094. /**
  20095. * @hidden
  20096. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20097. * @returns an identity matrix
  20098. */
  20099. _getViewMatrix(): Matrix;
  20100. private _tmpMatrix;
  20101. /**
  20102. * This function is called by the two RIG cameras.
  20103. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20104. * @hidden
  20105. */
  20106. _getWebVRViewMatrix(): Matrix;
  20107. /** @hidden */
  20108. _getWebVRProjectionMatrix(): Matrix;
  20109. private _onGamepadConnectedObserver;
  20110. private _onGamepadDisconnectedObserver;
  20111. private _updateCacheWhenTrackingDisabledObserver;
  20112. /**
  20113. * Initializes the controllers and their meshes
  20114. */
  20115. initControllers(): void;
  20116. }
  20117. }
  20118. declare module "babylonjs/PostProcesses/postProcess" {
  20119. import { Nullable } from "babylonjs/types";
  20120. import { SmartArray } from "babylonjs/Misc/smartArray";
  20121. import { Observable } from "babylonjs/Misc/observable";
  20122. import { Vector2 } from "babylonjs/Maths/math.vector";
  20123. import { Camera } from "babylonjs/Cameras/camera";
  20124. import { Effect } from "babylonjs/Materials/effect";
  20125. import "babylonjs/Shaders/postprocess.vertex";
  20126. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20127. import { Engine } from "babylonjs/Engines/engine";
  20128. import { Color4 } from "babylonjs/Maths/math.color";
  20129. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20130. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20131. /**
  20132. * Size options for a post process
  20133. */
  20134. export type PostProcessOptions = {
  20135. width: number;
  20136. height: number;
  20137. };
  20138. /**
  20139. * PostProcess can be used to apply a shader to a texture after it has been rendered
  20140. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20141. */
  20142. export class PostProcess {
  20143. /** Name of the PostProcess. */
  20144. name: string;
  20145. /**
  20146. * Gets or sets the unique id of the post process
  20147. */
  20148. uniqueId: number;
  20149. /**
  20150. * Width of the texture to apply the post process on
  20151. */
  20152. width: number;
  20153. /**
  20154. * Height of the texture to apply the post process on
  20155. */
  20156. height: number;
  20157. /**
  20158. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  20159. * @hidden
  20160. */
  20161. _outputTexture: Nullable<InternalTexture>;
  20162. /**
  20163. * Sampling mode used by the shader
  20164. * See https://doc.babylonjs.com/classes/3.1/texture
  20165. */
  20166. renderTargetSamplingMode: number;
  20167. /**
  20168. * Clear color to use when screen clearing
  20169. */
  20170. clearColor: Color4;
  20171. /**
  20172. * If the buffer needs to be cleared before applying the post process. (default: true)
  20173. * Should be set to false if shader will overwrite all previous pixels.
  20174. */
  20175. autoClear: boolean;
  20176. /**
  20177. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  20178. */
  20179. alphaMode: number;
  20180. /**
  20181. * Sets the setAlphaBlendConstants of the babylon engine
  20182. */
  20183. alphaConstants: Color4;
  20184. /**
  20185. * Animations to be used for the post processing
  20186. */
  20187. animations: import("babylonjs/Animations/animation").Animation[];
  20188. /**
  20189. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  20190. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  20191. */
  20192. enablePixelPerfectMode: boolean;
  20193. /**
  20194. * Force the postprocess to be applied without taking in account viewport
  20195. */
  20196. forceFullscreenViewport: boolean;
  20197. /**
  20198. * List of inspectable custom properties (used by the Inspector)
  20199. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20200. */
  20201. inspectableCustomProperties: IInspectable[];
  20202. /**
  20203. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  20204. *
  20205. * | Value | Type | Description |
  20206. * | ----- | ----------------------------------- | ----------- |
  20207. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  20208. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  20209. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  20210. *
  20211. */
  20212. scaleMode: number;
  20213. /**
  20214. * Force textures to be a power of two (default: false)
  20215. */
  20216. alwaysForcePOT: boolean;
  20217. private _samples;
  20218. /**
  20219. * Number of sample textures (default: 1)
  20220. */
  20221. get samples(): number;
  20222. set samples(n: number);
  20223. /**
  20224. * Modify the scale of the post process to be the same as the viewport (default: false)
  20225. */
  20226. adaptScaleToCurrentViewport: boolean;
  20227. private _camera;
  20228. private _scene;
  20229. private _engine;
  20230. private _options;
  20231. private _reusable;
  20232. private _textureType;
  20233. private _textureFormat;
  20234. /**
  20235. * Smart array of input and output textures for the post process.
  20236. * @hidden
  20237. */
  20238. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  20239. /**
  20240. * The index in _textures that corresponds to the output texture.
  20241. * @hidden
  20242. */
  20243. _currentRenderTextureInd: number;
  20244. private _effect;
  20245. private _samplers;
  20246. private _fragmentUrl;
  20247. private _vertexUrl;
  20248. private _parameters;
  20249. private _scaleRatio;
  20250. protected _indexParameters: any;
  20251. private _shareOutputWithPostProcess;
  20252. private _texelSize;
  20253. private _forcedOutputTexture;
  20254. /**
  20255. * Returns the fragment url or shader name used in the post process.
  20256. * @returns the fragment url or name in the shader store.
  20257. */
  20258. getEffectName(): string;
  20259. /**
  20260. * An event triggered when the postprocess is activated.
  20261. */
  20262. onActivateObservable: Observable<Camera>;
  20263. private _onActivateObserver;
  20264. /**
  20265. * A function that is added to the onActivateObservable
  20266. */
  20267. set onActivate(callback: Nullable<(camera: Camera) => void>);
  20268. /**
  20269. * An event triggered when the postprocess changes its size.
  20270. */
  20271. onSizeChangedObservable: Observable<PostProcess>;
  20272. private _onSizeChangedObserver;
  20273. /**
  20274. * A function that is added to the onSizeChangedObservable
  20275. */
  20276. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  20277. /**
  20278. * An event triggered when the postprocess applies its effect.
  20279. */
  20280. onApplyObservable: Observable<Effect>;
  20281. private _onApplyObserver;
  20282. /**
  20283. * A function that is added to the onApplyObservable
  20284. */
  20285. set onApply(callback: (effect: Effect) => void);
  20286. /**
  20287. * An event triggered before rendering the postprocess
  20288. */
  20289. onBeforeRenderObservable: Observable<Effect>;
  20290. private _onBeforeRenderObserver;
  20291. /**
  20292. * A function that is added to the onBeforeRenderObservable
  20293. */
  20294. set onBeforeRender(callback: (effect: Effect) => void);
  20295. /**
  20296. * An event triggered after rendering the postprocess
  20297. */
  20298. onAfterRenderObservable: Observable<Effect>;
  20299. private _onAfterRenderObserver;
  20300. /**
  20301. * A function that is added to the onAfterRenderObservable
  20302. */
  20303. set onAfterRender(callback: (efect: Effect) => void);
  20304. /**
  20305. * 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
  20306. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  20307. */
  20308. get inputTexture(): InternalTexture;
  20309. set inputTexture(value: InternalTexture);
  20310. /**
  20311. * Gets the camera which post process is applied to.
  20312. * @returns The camera the post process is applied to.
  20313. */
  20314. getCamera(): Camera;
  20315. /**
  20316. * Gets the texel size of the postprocess.
  20317. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  20318. */
  20319. get texelSize(): Vector2;
  20320. /**
  20321. * Creates a new instance PostProcess
  20322. * @param name The name of the PostProcess.
  20323. * @param fragmentUrl The url of the fragment shader to be used.
  20324. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  20325. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  20326. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20327. * @param camera The camera to apply the render pass to.
  20328. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20329. * @param engine The engine which the post process will be applied. (default: current engine)
  20330. * @param reusable If the post process can be reused on the same frame. (default: false)
  20331. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  20332. * @param textureType Type of textures used when performing the post process. (default: 0)
  20333. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  20334. * @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
  20335. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  20336. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  20337. */
  20338. constructor(
  20339. /** Name of the PostProcess. */
  20340. 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);
  20341. /**
  20342. * Gets a string idenfifying the name of the class
  20343. * @returns "PostProcess" string
  20344. */
  20345. getClassName(): string;
  20346. /**
  20347. * Gets the engine which this post process belongs to.
  20348. * @returns The engine the post process was enabled with.
  20349. */
  20350. getEngine(): Engine;
  20351. /**
  20352. * The effect that is created when initializing the post process.
  20353. * @returns The created effect corresponding the the postprocess.
  20354. */
  20355. getEffect(): Effect;
  20356. /**
  20357. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  20358. * @param postProcess The post process to share the output with.
  20359. * @returns This post process.
  20360. */
  20361. shareOutputWith(postProcess: PostProcess): PostProcess;
  20362. /**
  20363. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  20364. * This should be called if the post process that shares output with this post process is disabled/disposed.
  20365. */
  20366. useOwnOutput(): void;
  20367. /**
  20368. * Updates the effect with the current post process compile time values and recompiles the shader.
  20369. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20370. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20371. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20372. * @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
  20373. * @param onCompiled Called when the shader has been compiled.
  20374. * @param onError Called if there is an error when compiling a shader.
  20375. */
  20376. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20377. /**
  20378. * The post process is reusable if it can be used multiple times within one frame.
  20379. * @returns If the post process is reusable
  20380. */
  20381. isReusable(): boolean;
  20382. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  20383. markTextureDirty(): void;
  20384. /**
  20385. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  20386. * 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.
  20387. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  20388. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  20389. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  20390. * @returns The target texture that was bound to be written to.
  20391. */
  20392. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  20393. /**
  20394. * If the post process is supported.
  20395. */
  20396. get isSupported(): boolean;
  20397. /**
  20398. * The aspect ratio of the output texture.
  20399. */
  20400. get aspectRatio(): number;
  20401. /**
  20402. * Get a value indicating if the post-process is ready to be used
  20403. * @returns true if the post-process is ready (shader is compiled)
  20404. */
  20405. isReady(): boolean;
  20406. /**
  20407. * Binds all textures and uniforms to the shader, this will be run on every pass.
  20408. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  20409. */
  20410. apply(): Nullable<Effect>;
  20411. private _disposeTextures;
  20412. /**
  20413. * Disposes the post process.
  20414. * @param camera The camera to dispose the post process on.
  20415. */
  20416. dispose(camera?: Camera): void;
  20417. }
  20418. }
  20419. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  20420. /** @hidden */
  20421. export var kernelBlurVaryingDeclaration: {
  20422. name: string;
  20423. shader: string;
  20424. };
  20425. }
  20426. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  20427. /** @hidden */
  20428. export var kernelBlurFragment: {
  20429. name: string;
  20430. shader: string;
  20431. };
  20432. }
  20433. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  20434. /** @hidden */
  20435. export var kernelBlurFragment2: {
  20436. name: string;
  20437. shader: string;
  20438. };
  20439. }
  20440. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  20441. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  20442. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  20443. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  20444. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  20445. /** @hidden */
  20446. export var kernelBlurPixelShader: {
  20447. name: string;
  20448. shader: string;
  20449. };
  20450. }
  20451. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  20452. /** @hidden */
  20453. export var kernelBlurVertex: {
  20454. name: string;
  20455. shader: string;
  20456. };
  20457. }
  20458. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  20459. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  20460. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  20461. /** @hidden */
  20462. export var kernelBlurVertexShader: {
  20463. name: string;
  20464. shader: string;
  20465. };
  20466. }
  20467. declare module "babylonjs/PostProcesses/blurPostProcess" {
  20468. import { Vector2 } from "babylonjs/Maths/math.vector";
  20469. import { Nullable } from "babylonjs/types";
  20470. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  20471. import { Camera } from "babylonjs/Cameras/camera";
  20472. import { Effect } from "babylonjs/Materials/effect";
  20473. import { Engine } from "babylonjs/Engines/engine";
  20474. import "babylonjs/Shaders/kernelBlur.fragment";
  20475. import "babylonjs/Shaders/kernelBlur.vertex";
  20476. /**
  20477. * The Blur Post Process which blurs an image based on a kernel and direction.
  20478. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  20479. */
  20480. export class BlurPostProcess extends PostProcess {
  20481. /** The direction in which to blur the image. */
  20482. direction: Vector2;
  20483. private blockCompilation;
  20484. protected _kernel: number;
  20485. protected _idealKernel: number;
  20486. protected _packedFloat: boolean;
  20487. private _staticDefines;
  20488. /**
  20489. * Sets the length in pixels of the blur sample region
  20490. */
  20491. set kernel(v: number);
  20492. /**
  20493. * Gets the length in pixels of the blur sample region
  20494. */
  20495. get kernel(): number;
  20496. /**
  20497. * Sets wether or not the blur needs to unpack/repack floats
  20498. */
  20499. set packedFloat(v: boolean);
  20500. /**
  20501. * Gets wether or not the blur is unpacking/repacking floats
  20502. */
  20503. get packedFloat(): boolean;
  20504. /**
  20505. * Creates a new instance BlurPostProcess
  20506. * @param name The name of the effect.
  20507. * @param direction The direction in which to blur the image.
  20508. * @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.
  20509. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20510. * @param camera The camera to apply the render pass to.
  20511. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20512. * @param engine The engine which the post process will be applied. (default: current engine)
  20513. * @param reusable If the post process can be reused on the same frame. (default: false)
  20514. * @param textureType Type of textures used when performing the post process. (default: 0)
  20515. * @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)
  20516. */
  20517. constructor(name: string,
  20518. /** The direction in which to blur the image. */
  20519. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  20520. /**
  20521. * Updates the effect with the current post process compile time values and recompiles the shader.
  20522. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20523. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20524. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20525. * @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
  20526. * @param onCompiled Called when the shader has been compiled.
  20527. * @param onError Called if there is an error when compiling a shader.
  20528. */
  20529. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20530. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20531. /**
  20532. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  20533. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  20534. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  20535. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  20536. * The gaps between physical kernels are compensated for in the weighting of the samples
  20537. * @param idealKernel Ideal blur kernel.
  20538. * @return Nearest best kernel.
  20539. */
  20540. protected _nearestBestKernel(idealKernel: number): number;
  20541. /**
  20542. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  20543. * @param x The point on the Gaussian distribution to sample.
  20544. * @return the value of the Gaussian function at x.
  20545. */
  20546. protected _gaussianWeight(x: number): number;
  20547. /**
  20548. * Generates a string that can be used as a floating point number in GLSL.
  20549. * @param x Value to print.
  20550. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  20551. * @return GLSL float string.
  20552. */
  20553. protected _glslFloat(x: number, decimalFigures?: number): string;
  20554. }
  20555. }
  20556. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  20557. import { Scene } from "babylonjs/scene";
  20558. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20559. import { Plane } from "babylonjs/Maths/math.plane";
  20560. /**
  20561. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20562. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20563. * You can then easily use it as a reflectionTexture on a flat surface.
  20564. * In case the surface is not a plane, please consider relying on reflection probes.
  20565. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20566. */
  20567. export class MirrorTexture extends RenderTargetTexture {
  20568. private scene;
  20569. /**
  20570. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  20571. * 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.
  20572. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20573. */
  20574. mirrorPlane: Plane;
  20575. /**
  20576. * Define the blur ratio used to blur the reflection if needed.
  20577. */
  20578. set blurRatio(value: number);
  20579. get blurRatio(): number;
  20580. /**
  20581. * Define the adaptive blur kernel used to blur the reflection if needed.
  20582. * This will autocompute the closest best match for the `blurKernel`
  20583. */
  20584. set adaptiveBlurKernel(value: number);
  20585. /**
  20586. * Define the blur kernel used to blur the reflection if needed.
  20587. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20588. */
  20589. set blurKernel(value: number);
  20590. /**
  20591. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  20592. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20593. */
  20594. set blurKernelX(value: number);
  20595. get blurKernelX(): number;
  20596. /**
  20597. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  20598. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20599. */
  20600. set blurKernelY(value: number);
  20601. get blurKernelY(): number;
  20602. private _autoComputeBlurKernel;
  20603. protected _onRatioRescale(): void;
  20604. private _updateGammaSpace;
  20605. private _imageProcessingConfigChangeObserver;
  20606. private _transformMatrix;
  20607. private _mirrorMatrix;
  20608. private _savedViewMatrix;
  20609. private _blurX;
  20610. private _blurY;
  20611. private _adaptiveBlurKernel;
  20612. private _blurKernelX;
  20613. private _blurKernelY;
  20614. private _blurRatio;
  20615. /**
  20616. * Instantiates a Mirror Texture.
  20617. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20618. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20619. * You can then easily use it as a reflectionTexture on a flat surface.
  20620. * In case the surface is not a plane, please consider relying on reflection probes.
  20621. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20622. * @param name
  20623. * @param size
  20624. * @param scene
  20625. * @param generateMipMaps
  20626. * @param type
  20627. * @param samplingMode
  20628. * @param generateDepthBuffer
  20629. */
  20630. constructor(name: string, size: number | {
  20631. width: number;
  20632. height: number;
  20633. } | {
  20634. ratio: number;
  20635. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  20636. private _preparePostProcesses;
  20637. /**
  20638. * Clone the mirror texture.
  20639. * @returns the cloned texture
  20640. */
  20641. clone(): MirrorTexture;
  20642. /**
  20643. * Serialize the texture to a JSON representation you could use in Parse later on
  20644. * @returns the serialized JSON representation
  20645. */
  20646. serialize(): any;
  20647. /**
  20648. * Dispose the texture and release its associated resources.
  20649. */
  20650. dispose(): void;
  20651. }
  20652. }
  20653. declare module "babylonjs/Materials/Textures/texture" {
  20654. import { Observable } from "babylonjs/Misc/observable";
  20655. import { Nullable } from "babylonjs/types";
  20656. import { Matrix } from "babylonjs/Maths/math.vector";
  20657. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20658. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20659. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  20660. import { Scene } from "babylonjs/scene";
  20661. /**
  20662. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20663. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20664. */
  20665. export class Texture extends BaseTexture {
  20666. /**
  20667. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  20668. */
  20669. static SerializeBuffers: boolean;
  20670. /** @hidden */
  20671. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  20672. /** @hidden */
  20673. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  20674. /** @hidden */
  20675. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  20676. /** nearest is mag = nearest and min = nearest and mip = linear */
  20677. static readonly NEAREST_SAMPLINGMODE: number;
  20678. /** nearest is mag = nearest and min = nearest and mip = linear */
  20679. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  20680. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20681. static readonly BILINEAR_SAMPLINGMODE: number;
  20682. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20683. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  20684. /** Trilinear is mag = linear and min = linear and mip = linear */
  20685. static readonly TRILINEAR_SAMPLINGMODE: number;
  20686. /** Trilinear is mag = linear and min = linear and mip = linear */
  20687. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  20688. /** mag = nearest and min = nearest and mip = nearest */
  20689. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  20690. /** mag = nearest and min = linear and mip = nearest */
  20691. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  20692. /** mag = nearest and min = linear and mip = linear */
  20693. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  20694. /** mag = nearest and min = linear and mip = none */
  20695. static readonly NEAREST_LINEAR: number;
  20696. /** mag = nearest and min = nearest and mip = none */
  20697. static readonly NEAREST_NEAREST: number;
  20698. /** mag = linear and min = nearest and mip = nearest */
  20699. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  20700. /** mag = linear and min = nearest and mip = linear */
  20701. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  20702. /** mag = linear and min = linear and mip = none */
  20703. static readonly LINEAR_LINEAR: number;
  20704. /** mag = linear and min = nearest and mip = none */
  20705. static readonly LINEAR_NEAREST: number;
  20706. /** Explicit coordinates mode */
  20707. static readonly EXPLICIT_MODE: number;
  20708. /** Spherical coordinates mode */
  20709. static readonly SPHERICAL_MODE: number;
  20710. /** Planar coordinates mode */
  20711. static readonly PLANAR_MODE: number;
  20712. /** Cubic coordinates mode */
  20713. static readonly CUBIC_MODE: number;
  20714. /** Projection coordinates mode */
  20715. static readonly PROJECTION_MODE: number;
  20716. /** Inverse Cubic coordinates mode */
  20717. static readonly SKYBOX_MODE: number;
  20718. /** Inverse Cubic coordinates mode */
  20719. static readonly INVCUBIC_MODE: number;
  20720. /** Equirectangular coordinates mode */
  20721. static readonly EQUIRECTANGULAR_MODE: number;
  20722. /** Equirectangular Fixed coordinates mode */
  20723. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  20724. /** Equirectangular Fixed Mirrored coordinates mode */
  20725. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  20726. /** Texture is not repeating outside of 0..1 UVs */
  20727. static readonly CLAMP_ADDRESSMODE: number;
  20728. /** Texture is repeating outside of 0..1 UVs */
  20729. static readonly WRAP_ADDRESSMODE: number;
  20730. /** Texture is repeating and mirrored */
  20731. static readonly MIRROR_ADDRESSMODE: number;
  20732. /**
  20733. * 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
  20734. */
  20735. static UseSerializedUrlIfAny: boolean;
  20736. /**
  20737. * Define the url of the texture.
  20738. */
  20739. url: Nullable<string>;
  20740. /**
  20741. * Define an offset on the texture to offset the u coordinates of the UVs
  20742. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20743. */
  20744. uOffset: number;
  20745. /**
  20746. * Define an offset on the texture to offset the v coordinates of the UVs
  20747. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20748. */
  20749. vOffset: number;
  20750. /**
  20751. * Define an offset on the texture to scale the u coordinates of the UVs
  20752. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20753. */
  20754. uScale: number;
  20755. /**
  20756. * Define an offset on the texture to scale the v coordinates of the UVs
  20757. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20758. */
  20759. vScale: number;
  20760. /**
  20761. * Define an offset on the texture to rotate around the u coordinates of the UVs
  20762. * @see http://doc.babylonjs.com/how_to/more_materials
  20763. */
  20764. uAng: number;
  20765. /**
  20766. * Define an offset on the texture to rotate around the v coordinates of the UVs
  20767. * @see http://doc.babylonjs.com/how_to/more_materials
  20768. */
  20769. vAng: number;
  20770. /**
  20771. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  20772. * @see http://doc.babylonjs.com/how_to/more_materials
  20773. */
  20774. wAng: number;
  20775. /**
  20776. * Defines the center of rotation (U)
  20777. */
  20778. uRotationCenter: number;
  20779. /**
  20780. * Defines the center of rotation (V)
  20781. */
  20782. vRotationCenter: number;
  20783. /**
  20784. * Defines the center of rotation (W)
  20785. */
  20786. wRotationCenter: number;
  20787. /**
  20788. * Are mip maps generated for this texture or not.
  20789. */
  20790. get noMipmap(): boolean;
  20791. /**
  20792. * List of inspectable custom properties (used by the Inspector)
  20793. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20794. */
  20795. inspectableCustomProperties: Nullable<IInspectable[]>;
  20796. private _noMipmap;
  20797. /** @hidden */
  20798. _invertY: boolean;
  20799. private _rowGenerationMatrix;
  20800. private _cachedTextureMatrix;
  20801. private _projectionModeMatrix;
  20802. private _t0;
  20803. private _t1;
  20804. private _t2;
  20805. private _cachedUOffset;
  20806. private _cachedVOffset;
  20807. private _cachedUScale;
  20808. private _cachedVScale;
  20809. private _cachedUAng;
  20810. private _cachedVAng;
  20811. private _cachedWAng;
  20812. private _cachedProjectionMatrixId;
  20813. private _cachedCoordinatesMode;
  20814. /** @hidden */
  20815. protected _initialSamplingMode: number;
  20816. /** @hidden */
  20817. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  20818. private _deleteBuffer;
  20819. protected _format: Nullable<number>;
  20820. private _delayedOnLoad;
  20821. private _delayedOnError;
  20822. private _mimeType?;
  20823. /**
  20824. * Observable triggered once the texture has been loaded.
  20825. */
  20826. onLoadObservable: Observable<Texture>;
  20827. protected _isBlocking: boolean;
  20828. /**
  20829. * Is the texture preventing material to render while loading.
  20830. * If false, a default texture will be used instead of the loading one during the preparation step.
  20831. */
  20832. set isBlocking(value: boolean);
  20833. get isBlocking(): boolean;
  20834. /**
  20835. * Get the current sampling mode associated with the texture.
  20836. */
  20837. get samplingMode(): number;
  20838. /**
  20839. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  20840. */
  20841. get invertY(): boolean;
  20842. /**
  20843. * Instantiates a new texture.
  20844. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20845. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20846. * @param url defines the url of the picture to load as a texture
  20847. * @param scene defines the scene or engine the texture will belong to
  20848. * @param noMipmap defines if the texture will require mip maps or not
  20849. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  20850. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20851. * @param onLoad defines a callback triggered when the texture has been loaded
  20852. * @param onError defines a callback triggered when an error occurred during the loading session
  20853. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  20854. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  20855. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20856. * @param mimeType defines an optional mime type information
  20857. */
  20858. 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);
  20859. /**
  20860. * Update the url (and optional buffer) of this texture if url was null during construction.
  20861. * @param url the url of the texture
  20862. * @param buffer the buffer of the texture (defaults to null)
  20863. * @param onLoad callback called when the texture is loaded (defaults to null)
  20864. */
  20865. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  20866. /**
  20867. * Finish the loading sequence of a texture flagged as delayed load.
  20868. * @hidden
  20869. */
  20870. delayLoad(): void;
  20871. private _prepareRowForTextureGeneration;
  20872. /**
  20873. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  20874. * @returns the transform matrix of the texture.
  20875. */
  20876. getTextureMatrix(uBase?: number): Matrix;
  20877. /**
  20878. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  20879. * @returns The reflection texture transform
  20880. */
  20881. getReflectionTextureMatrix(): Matrix;
  20882. /**
  20883. * Clones the texture.
  20884. * @returns the cloned texture
  20885. */
  20886. clone(): Texture;
  20887. /**
  20888. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20889. * @returns The JSON representation of the texture
  20890. */
  20891. serialize(): any;
  20892. /**
  20893. * Get the current class name of the texture useful for serialization or dynamic coding.
  20894. * @returns "Texture"
  20895. */
  20896. getClassName(): string;
  20897. /**
  20898. * Dispose the texture and release its associated resources.
  20899. */
  20900. dispose(): void;
  20901. /**
  20902. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  20903. * @param parsedTexture Define the JSON representation of the texture
  20904. * @param scene Define the scene the parsed texture should be instantiated in
  20905. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  20906. * @returns The parsed texture if successful
  20907. */
  20908. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  20909. /**
  20910. * Creates a texture from its base 64 representation.
  20911. * @param data Define the base64 payload without the data: prefix
  20912. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20913. * @param scene Define the scene the texture should belong to
  20914. * @param noMipmap Forces the texture to not create mip map information if true
  20915. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20916. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20917. * @param onLoad define a callback triggered when the texture has been loaded
  20918. * @param onError define a callback triggered when an error occurred during the loading session
  20919. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20920. * @returns the created texture
  20921. */
  20922. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  20923. /**
  20924. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  20925. * @param data Define the base64 payload without the data: prefix
  20926. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20927. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  20928. * @param scene Define the scene the texture should belong to
  20929. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  20930. * @param noMipmap Forces the texture to not create mip map information if true
  20931. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20932. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20933. * @param onLoad define a callback triggered when the texture has been loaded
  20934. * @param onError define a callback triggered when an error occurred during the loading session
  20935. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20936. * @returns the created texture
  20937. */
  20938. 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;
  20939. }
  20940. }
  20941. declare module "babylonjs/PostProcesses/postProcessManager" {
  20942. import { Nullable } from "babylonjs/types";
  20943. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20944. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20945. import { Scene } from "babylonjs/scene";
  20946. /**
  20947. * PostProcessManager is used to manage one or more post processes or post process pipelines
  20948. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20949. */
  20950. export class PostProcessManager {
  20951. private _scene;
  20952. private _indexBuffer;
  20953. private _vertexBuffers;
  20954. /**
  20955. * Creates a new instance PostProcess
  20956. * @param scene The scene that the post process is associated with.
  20957. */
  20958. constructor(scene: Scene);
  20959. private _prepareBuffers;
  20960. private _buildIndexBuffer;
  20961. /**
  20962. * Rebuilds the vertex buffers of the manager.
  20963. * @hidden
  20964. */
  20965. _rebuild(): void;
  20966. /**
  20967. * Prepares a frame to be run through a post process.
  20968. * @param sourceTexture The input texture to the post procesess. (default: null)
  20969. * @param postProcesses An array of post processes to be run. (default: null)
  20970. * @returns True if the post processes were able to be run.
  20971. * @hidden
  20972. */
  20973. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  20974. /**
  20975. * Manually render a set of post processes to a texture.
  20976. * @param postProcesses An array of post processes to be run.
  20977. * @param targetTexture The target texture to render to.
  20978. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  20979. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  20980. * @param lodLevel defines which lod of the texture to render to
  20981. */
  20982. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  20983. /**
  20984. * Finalize the result of the output of the postprocesses.
  20985. * @param doNotPresent If true the result will not be displayed to the screen.
  20986. * @param targetTexture The target texture to render to.
  20987. * @param faceIndex The index of the face to bind the target texture to.
  20988. * @param postProcesses The array of post processes to render.
  20989. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  20990. * @hidden
  20991. */
  20992. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  20993. /**
  20994. * Disposes of the post process manager.
  20995. */
  20996. dispose(): void;
  20997. }
  20998. }
  20999. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  21000. import { Observable } from "babylonjs/Misc/observable";
  21001. import { SmartArray } from "babylonjs/Misc/smartArray";
  21002. import { Nullable, Immutable } from "babylonjs/types";
  21003. import { Camera } from "babylonjs/Cameras/camera";
  21004. import { Scene } from "babylonjs/scene";
  21005. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21006. import { Color4 } from "babylonjs/Maths/math.color";
  21007. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  21008. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21009. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21010. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  21011. import { Texture } from "babylonjs/Materials/Textures/texture";
  21012. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  21013. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  21014. import "babylonjs/Engines/Extensions/engine.renderTarget";
  21015. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  21016. import { Engine } from "babylonjs/Engines/engine";
  21017. /**
  21018. * This Helps creating a texture that will be created from a camera in your scene.
  21019. * It is basically a dynamic texture that could be used to create special effects for instance.
  21020. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  21021. */
  21022. export class RenderTargetTexture extends Texture {
  21023. isCube: boolean;
  21024. /**
  21025. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  21026. */
  21027. static readonly REFRESHRATE_RENDER_ONCE: number;
  21028. /**
  21029. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  21030. */
  21031. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  21032. /**
  21033. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  21034. * the central point of your effect and can save a lot of performances.
  21035. */
  21036. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  21037. /**
  21038. * Use this predicate to dynamically define the list of mesh you want to render.
  21039. * If set, the renderList property will be overwritten.
  21040. */
  21041. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  21042. private _renderList;
  21043. /**
  21044. * Use this list to define the list of mesh you want to render.
  21045. */
  21046. get renderList(): Nullable<Array<AbstractMesh>>;
  21047. set renderList(value: Nullable<Array<AbstractMesh>>);
  21048. /**
  21049. * Use this function to overload the renderList array at rendering time.
  21050. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  21051. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  21052. * the cube (if the RTT is a cube, else layerOrFace=0).
  21053. * The renderList passed to the function is the current render list (the one that will be used if the function returns null)
  21054. */
  21055. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>) => Nullable<Array<AbstractMesh>>;
  21056. private _hookArray;
  21057. /**
  21058. * Define if particles should be rendered in your texture.
  21059. */
  21060. renderParticles: boolean;
  21061. /**
  21062. * Define if sprites should be rendered in your texture.
  21063. */
  21064. renderSprites: boolean;
  21065. /**
  21066. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  21067. */
  21068. coordinatesMode: number;
  21069. /**
  21070. * Define the camera used to render the texture.
  21071. */
  21072. activeCamera: Nullable<Camera>;
  21073. /**
  21074. * Override the render function of the texture with your own one.
  21075. */
  21076. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  21077. /**
  21078. * Define if camera post processes should be use while rendering the texture.
  21079. */
  21080. useCameraPostProcesses: boolean;
  21081. /**
  21082. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  21083. */
  21084. ignoreCameraViewport: boolean;
  21085. private _postProcessManager;
  21086. private _postProcesses;
  21087. private _resizeObserver;
  21088. /**
  21089. * An event triggered when the texture is unbind.
  21090. */
  21091. onBeforeBindObservable: Observable<RenderTargetTexture>;
  21092. /**
  21093. * An event triggered when the texture is unbind.
  21094. */
  21095. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  21096. private _onAfterUnbindObserver;
  21097. /**
  21098. * Set a after unbind callback in the texture.
  21099. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  21100. */
  21101. set onAfterUnbind(callback: () => void);
  21102. /**
  21103. * An event triggered before rendering the texture
  21104. */
  21105. onBeforeRenderObservable: Observable<number>;
  21106. private _onBeforeRenderObserver;
  21107. /**
  21108. * Set a before render callback in the texture.
  21109. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  21110. */
  21111. set onBeforeRender(callback: (faceIndex: number) => void);
  21112. /**
  21113. * An event triggered after rendering the texture
  21114. */
  21115. onAfterRenderObservable: Observable<number>;
  21116. private _onAfterRenderObserver;
  21117. /**
  21118. * Set a after render callback in the texture.
  21119. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  21120. */
  21121. set onAfterRender(callback: (faceIndex: number) => void);
  21122. /**
  21123. * An event triggered after the texture clear
  21124. */
  21125. onClearObservable: Observable<Engine>;
  21126. private _onClearObserver;
  21127. /**
  21128. * Set a clear callback in the texture.
  21129. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  21130. */
  21131. set onClear(callback: (Engine: Engine) => void);
  21132. /**
  21133. * An event triggered when the texture is resized.
  21134. */
  21135. onResizeObservable: Observable<RenderTargetTexture>;
  21136. /**
  21137. * Define the clear color of the Render Target if it should be different from the scene.
  21138. */
  21139. clearColor: Color4;
  21140. protected _size: number | {
  21141. width: number;
  21142. height: number;
  21143. layers?: number;
  21144. };
  21145. protected _initialSizeParameter: number | {
  21146. width: number;
  21147. height: number;
  21148. } | {
  21149. ratio: number;
  21150. };
  21151. protected _sizeRatio: Nullable<number>;
  21152. /** @hidden */
  21153. _generateMipMaps: boolean;
  21154. protected _renderingManager: RenderingManager;
  21155. /** @hidden */
  21156. _waitingRenderList: string[];
  21157. protected _doNotChangeAspectRatio: boolean;
  21158. protected _currentRefreshId: number;
  21159. protected _refreshRate: number;
  21160. protected _textureMatrix: Matrix;
  21161. protected _samples: number;
  21162. protected _renderTargetOptions: RenderTargetCreationOptions;
  21163. /**
  21164. * Gets render target creation options that were used.
  21165. */
  21166. get renderTargetOptions(): RenderTargetCreationOptions;
  21167. protected _engine: Engine;
  21168. protected _onRatioRescale(): void;
  21169. /**
  21170. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  21171. * It must define where the camera used to render the texture is set
  21172. */
  21173. boundingBoxPosition: Vector3;
  21174. private _boundingBoxSize;
  21175. /**
  21176. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  21177. * When defined, the cubemap will switch to local mode
  21178. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  21179. * @example https://www.babylonjs-playground.com/#RNASML
  21180. */
  21181. set boundingBoxSize(value: Vector3);
  21182. get boundingBoxSize(): Vector3;
  21183. /**
  21184. * In case the RTT has been created with a depth texture, get the associated
  21185. * depth texture.
  21186. * Otherwise, return null.
  21187. */
  21188. get depthStencilTexture(): Nullable<InternalTexture>;
  21189. /**
  21190. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  21191. * or used a shadow, depth texture...
  21192. * @param name The friendly name of the texture
  21193. * @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)
  21194. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  21195. * @param generateMipMaps True if mip maps need to be generated after render.
  21196. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  21197. * @param type The type of the buffer in the RTT (int, half float, float...)
  21198. * @param isCube True if a cube texture needs to be created
  21199. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  21200. * @param generateDepthBuffer True to generate a depth buffer
  21201. * @param generateStencilBuffer True to generate a stencil buffer
  21202. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  21203. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  21204. * @param delayAllocation if the texture allocation should be delayed (default: false)
  21205. */
  21206. constructor(name: string, size: number | {
  21207. width: number;
  21208. height: number;
  21209. layers?: number;
  21210. } | {
  21211. ratio: number;
  21212. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  21213. /**
  21214. * Creates a depth stencil texture.
  21215. * This is only available in WebGL 2 or with the depth texture extension available.
  21216. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  21217. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  21218. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  21219. */
  21220. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  21221. private _processSizeParameter;
  21222. /**
  21223. * Define the number of samples to use in case of MSAA.
  21224. * It defaults to one meaning no MSAA has been enabled.
  21225. */
  21226. get samples(): number;
  21227. set samples(value: number);
  21228. /**
  21229. * Resets the refresh counter of the texture and start bak from scratch.
  21230. * Could be useful to regenerate the texture if it is setup to render only once.
  21231. */
  21232. resetRefreshCounter(): void;
  21233. /**
  21234. * Define the refresh rate of the texture or the rendering frequency.
  21235. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  21236. */
  21237. get refreshRate(): number;
  21238. set refreshRate(value: number);
  21239. /**
  21240. * Adds a post process to the render target rendering passes.
  21241. * @param postProcess define the post process to add
  21242. */
  21243. addPostProcess(postProcess: PostProcess): void;
  21244. /**
  21245. * Clear all the post processes attached to the render target
  21246. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  21247. */
  21248. clearPostProcesses(dispose?: boolean): void;
  21249. /**
  21250. * Remove one of the post process from the list of attached post processes to the texture
  21251. * @param postProcess define the post process to remove from the list
  21252. */
  21253. removePostProcess(postProcess: PostProcess): void;
  21254. /** @hidden */
  21255. _shouldRender(): boolean;
  21256. /**
  21257. * Gets the actual render size of the texture.
  21258. * @returns the width of the render size
  21259. */
  21260. getRenderSize(): number;
  21261. /**
  21262. * Gets the actual render width of the texture.
  21263. * @returns the width of the render size
  21264. */
  21265. getRenderWidth(): number;
  21266. /**
  21267. * Gets the actual render height of the texture.
  21268. * @returns the height of the render size
  21269. */
  21270. getRenderHeight(): number;
  21271. /**
  21272. * Gets the actual number of layers of the texture.
  21273. * @returns the number of layers
  21274. */
  21275. getRenderLayers(): number;
  21276. /**
  21277. * Get if the texture can be rescaled or not.
  21278. */
  21279. get canRescale(): boolean;
  21280. /**
  21281. * Resize the texture using a ratio.
  21282. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  21283. */
  21284. scale(ratio: number): void;
  21285. /**
  21286. * Get the texture reflection matrix used to rotate/transform the reflection.
  21287. * @returns the reflection matrix
  21288. */
  21289. getReflectionTextureMatrix(): Matrix;
  21290. /**
  21291. * Resize the texture to a new desired size.
  21292. * Be carrefull as it will recreate all the data in the new texture.
  21293. * @param size Define the new size. It can be:
  21294. * - a number for squared texture,
  21295. * - an object containing { width: number, height: number }
  21296. * - or an object containing a ratio { ratio: number }
  21297. */
  21298. resize(size: number | {
  21299. width: number;
  21300. height: number;
  21301. } | {
  21302. ratio: number;
  21303. }): void;
  21304. private _defaultRenderListPrepared;
  21305. /**
  21306. * Renders all the objects from the render list into the texture.
  21307. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  21308. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  21309. */
  21310. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  21311. private _bestReflectionRenderTargetDimension;
  21312. private _prepareRenderingManager;
  21313. /**
  21314. * @hidden
  21315. * @param faceIndex face index to bind to if this is a cubetexture
  21316. * @param layer defines the index of the texture to bind in the array
  21317. */
  21318. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  21319. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  21320. private renderToTarget;
  21321. /**
  21322. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  21323. * This allowed control for front to back rendering or reversly depending of the special needs.
  21324. *
  21325. * @param renderingGroupId The rendering group id corresponding to its index
  21326. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  21327. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  21328. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  21329. */
  21330. 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;
  21331. /**
  21332. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21333. *
  21334. * @param renderingGroupId The rendering group id corresponding to its index
  21335. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21336. */
  21337. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  21338. /**
  21339. * Clones the texture.
  21340. * @returns the cloned texture
  21341. */
  21342. clone(): RenderTargetTexture;
  21343. /**
  21344. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  21345. * @returns The JSON representation of the texture
  21346. */
  21347. serialize(): any;
  21348. /**
  21349. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  21350. */
  21351. disposeFramebufferObjects(): void;
  21352. /**
  21353. * Dispose the texture and release its associated resources.
  21354. */
  21355. dispose(): void;
  21356. /** @hidden */
  21357. _rebuild(): void;
  21358. /**
  21359. * Clear the info related to rendering groups preventing retention point in material dispose.
  21360. */
  21361. freeRenderingGroups(): void;
  21362. /**
  21363. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  21364. * @returns the view count
  21365. */
  21366. getViewCount(): number;
  21367. }
  21368. }
  21369. declare module "babylonjs/Materials/material" {
  21370. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  21371. import { SmartArray } from "babylonjs/Misc/smartArray";
  21372. import { Observable } from "babylonjs/Misc/observable";
  21373. import { Nullable } from "babylonjs/types";
  21374. import { Scene } from "babylonjs/scene";
  21375. import { Matrix } from "babylonjs/Maths/math.vector";
  21376. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21377. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21378. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21379. import { Effect } from "babylonjs/Materials/effect";
  21380. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21381. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21382. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21383. import { IInspectable } from "babylonjs/Misc/iInspectable";
  21384. import { Mesh } from "babylonjs/Meshes/mesh";
  21385. import { Animation } from "babylonjs/Animations/animation";
  21386. /**
  21387. * Options for compiling materials.
  21388. */
  21389. export interface IMaterialCompilationOptions {
  21390. /**
  21391. * Defines whether clip planes are enabled.
  21392. */
  21393. clipPlane: boolean;
  21394. /**
  21395. * Defines whether instances are enabled.
  21396. */
  21397. useInstances: boolean;
  21398. }
  21399. /**
  21400. * Base class for the main features of a material in Babylon.js
  21401. */
  21402. export class Material implements IAnimatable {
  21403. /**
  21404. * Returns the triangle fill mode
  21405. */
  21406. static readonly TriangleFillMode: number;
  21407. /**
  21408. * Returns the wireframe mode
  21409. */
  21410. static readonly WireFrameFillMode: number;
  21411. /**
  21412. * Returns the point fill mode
  21413. */
  21414. static readonly PointFillMode: number;
  21415. /**
  21416. * Returns the point list draw mode
  21417. */
  21418. static readonly PointListDrawMode: number;
  21419. /**
  21420. * Returns the line list draw mode
  21421. */
  21422. static readonly LineListDrawMode: number;
  21423. /**
  21424. * Returns the line loop draw mode
  21425. */
  21426. static readonly LineLoopDrawMode: number;
  21427. /**
  21428. * Returns the line strip draw mode
  21429. */
  21430. static readonly LineStripDrawMode: number;
  21431. /**
  21432. * Returns the triangle strip draw mode
  21433. */
  21434. static readonly TriangleStripDrawMode: number;
  21435. /**
  21436. * Returns the triangle fan draw mode
  21437. */
  21438. static readonly TriangleFanDrawMode: number;
  21439. /**
  21440. * Stores the clock-wise side orientation
  21441. */
  21442. static readonly ClockWiseSideOrientation: number;
  21443. /**
  21444. * Stores the counter clock-wise side orientation
  21445. */
  21446. static readonly CounterClockWiseSideOrientation: number;
  21447. /**
  21448. * The dirty texture flag value
  21449. */
  21450. static readonly TextureDirtyFlag: number;
  21451. /**
  21452. * The dirty light flag value
  21453. */
  21454. static readonly LightDirtyFlag: number;
  21455. /**
  21456. * The dirty fresnel flag value
  21457. */
  21458. static readonly FresnelDirtyFlag: number;
  21459. /**
  21460. * The dirty attribute flag value
  21461. */
  21462. static readonly AttributesDirtyFlag: number;
  21463. /**
  21464. * The dirty misc flag value
  21465. */
  21466. static readonly MiscDirtyFlag: number;
  21467. /**
  21468. * The all dirty flag value
  21469. */
  21470. static readonly AllDirtyFlag: number;
  21471. /**
  21472. * The ID of the material
  21473. */
  21474. id: string;
  21475. /**
  21476. * Gets or sets the unique id of the material
  21477. */
  21478. uniqueId: number;
  21479. /**
  21480. * The name of the material
  21481. */
  21482. name: string;
  21483. /**
  21484. * Gets or sets user defined metadata
  21485. */
  21486. metadata: any;
  21487. /**
  21488. * For internal use only. Please do not use.
  21489. */
  21490. reservedDataStore: any;
  21491. /**
  21492. * Specifies if the ready state should be checked on each call
  21493. */
  21494. checkReadyOnEveryCall: boolean;
  21495. /**
  21496. * Specifies if the ready state should be checked once
  21497. */
  21498. checkReadyOnlyOnce: boolean;
  21499. /**
  21500. * The state of the material
  21501. */
  21502. state: string;
  21503. /**
  21504. * The alpha value of the material
  21505. */
  21506. protected _alpha: number;
  21507. /**
  21508. * List of inspectable custom properties (used by the Inspector)
  21509. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21510. */
  21511. inspectableCustomProperties: IInspectable[];
  21512. /**
  21513. * Sets the alpha value of the material
  21514. */
  21515. set alpha(value: number);
  21516. /**
  21517. * Gets the alpha value of the material
  21518. */
  21519. get alpha(): number;
  21520. /**
  21521. * Specifies if back face culling is enabled
  21522. */
  21523. protected _backFaceCulling: boolean;
  21524. /**
  21525. * Sets the back-face culling state
  21526. */
  21527. set backFaceCulling(value: boolean);
  21528. /**
  21529. * Gets the back-face culling state
  21530. */
  21531. get backFaceCulling(): boolean;
  21532. /**
  21533. * Stores the value for side orientation
  21534. */
  21535. sideOrientation: number;
  21536. /**
  21537. * Callback triggered when the material is compiled
  21538. */
  21539. onCompiled: Nullable<(effect: Effect) => void>;
  21540. /**
  21541. * Callback triggered when an error occurs
  21542. */
  21543. onError: Nullable<(effect: Effect, errors: string) => void>;
  21544. /**
  21545. * Callback triggered to get the render target textures
  21546. */
  21547. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21548. /**
  21549. * Gets a boolean indicating that current material needs to register RTT
  21550. */
  21551. get hasRenderTargetTextures(): boolean;
  21552. /**
  21553. * Specifies if the material should be serialized
  21554. */
  21555. doNotSerialize: boolean;
  21556. /**
  21557. * @hidden
  21558. */
  21559. _storeEffectOnSubMeshes: boolean;
  21560. /**
  21561. * Stores the animations for the material
  21562. */
  21563. animations: Nullable<Array<Animation>>;
  21564. /**
  21565. * An event triggered when the material is disposed
  21566. */
  21567. onDisposeObservable: Observable<Material>;
  21568. /**
  21569. * An observer which watches for dispose events
  21570. */
  21571. private _onDisposeObserver;
  21572. private _onUnBindObservable;
  21573. /**
  21574. * Called during a dispose event
  21575. */
  21576. set onDispose(callback: () => void);
  21577. private _onBindObservable;
  21578. /**
  21579. * An event triggered when the material is bound
  21580. */
  21581. get onBindObservable(): Observable<AbstractMesh>;
  21582. /**
  21583. * An observer which watches for bind events
  21584. */
  21585. private _onBindObserver;
  21586. /**
  21587. * Called during a bind event
  21588. */
  21589. set onBind(callback: (Mesh: AbstractMesh) => void);
  21590. /**
  21591. * An event triggered when the material is unbound
  21592. */
  21593. get onUnBindObservable(): Observable<Material>;
  21594. /**
  21595. * Stores the value of the alpha mode
  21596. */
  21597. private _alphaMode;
  21598. /**
  21599. * Sets the value of the alpha mode.
  21600. *
  21601. * | Value | Type | Description |
  21602. * | --- | --- | --- |
  21603. * | 0 | ALPHA_DISABLE | |
  21604. * | 1 | ALPHA_ADD | |
  21605. * | 2 | ALPHA_COMBINE | |
  21606. * | 3 | ALPHA_SUBTRACT | |
  21607. * | 4 | ALPHA_MULTIPLY | |
  21608. * | 5 | ALPHA_MAXIMIZED | |
  21609. * | 6 | ALPHA_ONEONE | |
  21610. * | 7 | ALPHA_PREMULTIPLIED | |
  21611. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21612. * | 9 | ALPHA_INTERPOLATE | |
  21613. * | 10 | ALPHA_SCREENMODE | |
  21614. *
  21615. */
  21616. set alphaMode(value: number);
  21617. /**
  21618. * Gets the value of the alpha mode
  21619. */
  21620. get alphaMode(): number;
  21621. /**
  21622. * Stores the state of the need depth pre-pass value
  21623. */
  21624. private _needDepthPrePass;
  21625. /**
  21626. * Sets the need depth pre-pass value
  21627. */
  21628. set needDepthPrePass(value: boolean);
  21629. /**
  21630. * Gets the depth pre-pass value
  21631. */
  21632. get needDepthPrePass(): boolean;
  21633. /**
  21634. * Specifies if depth writing should be disabled
  21635. */
  21636. disableDepthWrite: boolean;
  21637. /**
  21638. * Specifies if depth writing should be forced
  21639. */
  21640. forceDepthWrite: boolean;
  21641. /**
  21642. * Specifies the depth function that should be used. 0 means the default engine function
  21643. */
  21644. depthFunction: number;
  21645. /**
  21646. * Specifies if there should be a separate pass for culling
  21647. */
  21648. separateCullingPass: boolean;
  21649. /**
  21650. * Stores the state specifing if fog should be enabled
  21651. */
  21652. private _fogEnabled;
  21653. /**
  21654. * Sets the state for enabling fog
  21655. */
  21656. set fogEnabled(value: boolean);
  21657. /**
  21658. * Gets the value of the fog enabled state
  21659. */
  21660. get fogEnabled(): boolean;
  21661. /**
  21662. * Stores the size of points
  21663. */
  21664. pointSize: number;
  21665. /**
  21666. * Stores the z offset value
  21667. */
  21668. zOffset: number;
  21669. /**
  21670. * Gets a value specifying if wireframe mode is enabled
  21671. */
  21672. get wireframe(): boolean;
  21673. /**
  21674. * Sets the state of wireframe mode
  21675. */
  21676. set wireframe(value: boolean);
  21677. /**
  21678. * Gets the value specifying if point clouds are enabled
  21679. */
  21680. get pointsCloud(): boolean;
  21681. /**
  21682. * Sets the state of point cloud mode
  21683. */
  21684. set pointsCloud(value: boolean);
  21685. /**
  21686. * Gets the material fill mode
  21687. */
  21688. get fillMode(): number;
  21689. /**
  21690. * Sets the material fill mode
  21691. */
  21692. set fillMode(value: number);
  21693. /**
  21694. * @hidden
  21695. * Stores the effects for the material
  21696. */
  21697. _effect: Nullable<Effect>;
  21698. /**
  21699. * Specifies if uniform buffers should be used
  21700. */
  21701. private _useUBO;
  21702. /**
  21703. * Stores a reference to the scene
  21704. */
  21705. private _scene;
  21706. /**
  21707. * Stores the fill mode state
  21708. */
  21709. private _fillMode;
  21710. /**
  21711. * Specifies if the depth write state should be cached
  21712. */
  21713. private _cachedDepthWriteState;
  21714. /**
  21715. * Specifies if the depth function state should be cached
  21716. */
  21717. private _cachedDepthFunctionState;
  21718. /**
  21719. * Stores the uniform buffer
  21720. */
  21721. protected _uniformBuffer: UniformBuffer;
  21722. /** @hidden */
  21723. _indexInSceneMaterialArray: number;
  21724. /** @hidden */
  21725. meshMap: Nullable<{
  21726. [id: string]: AbstractMesh | undefined;
  21727. }>;
  21728. /**
  21729. * Creates a material instance
  21730. * @param name defines the name of the material
  21731. * @param scene defines the scene to reference
  21732. * @param doNotAdd specifies if the material should be added to the scene
  21733. */
  21734. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21735. /**
  21736. * Returns a string representation of the current material
  21737. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21738. * @returns a string with material information
  21739. */
  21740. toString(fullDetails?: boolean): string;
  21741. /**
  21742. * Gets the class name of the material
  21743. * @returns a string with the class name of the material
  21744. */
  21745. getClassName(): string;
  21746. /**
  21747. * Specifies if updates for the material been locked
  21748. */
  21749. get isFrozen(): boolean;
  21750. /**
  21751. * Locks updates for the material
  21752. */
  21753. freeze(): void;
  21754. /**
  21755. * Unlocks updates for the material
  21756. */
  21757. unfreeze(): void;
  21758. /**
  21759. * Specifies if the material is ready to be used
  21760. * @param mesh defines the mesh to check
  21761. * @param useInstances specifies if instances should be used
  21762. * @returns a boolean indicating if the material is ready to be used
  21763. */
  21764. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21765. /**
  21766. * Specifies that the submesh is ready to be used
  21767. * @param mesh defines the mesh to check
  21768. * @param subMesh defines which submesh to check
  21769. * @param useInstances specifies that instances should be used
  21770. * @returns a boolean indicating that the submesh is ready or not
  21771. */
  21772. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21773. /**
  21774. * Returns the material effect
  21775. * @returns the effect associated with the material
  21776. */
  21777. getEffect(): Nullable<Effect>;
  21778. /**
  21779. * Returns the current scene
  21780. * @returns a Scene
  21781. */
  21782. getScene(): Scene;
  21783. /**
  21784. * Specifies if the material will require alpha blending
  21785. * @returns a boolean specifying if alpha blending is needed
  21786. */
  21787. needAlphaBlending(): boolean;
  21788. /**
  21789. * Specifies if the mesh will require alpha blending
  21790. * @param mesh defines the mesh to check
  21791. * @returns a boolean specifying if alpha blending is needed for the mesh
  21792. */
  21793. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21794. /**
  21795. * Specifies if this material should be rendered in alpha test mode
  21796. * @returns a boolean specifying if an alpha test is needed.
  21797. */
  21798. needAlphaTesting(): boolean;
  21799. /**
  21800. * Gets the texture used for the alpha test
  21801. * @returns the texture to use for alpha testing
  21802. */
  21803. getAlphaTestTexture(): Nullable<BaseTexture>;
  21804. /**
  21805. * Marks the material to indicate that it needs to be re-calculated
  21806. */
  21807. markDirty(): void;
  21808. /** @hidden */
  21809. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21810. /**
  21811. * Binds the material to the mesh
  21812. * @param world defines the world transformation matrix
  21813. * @param mesh defines the mesh to bind the material to
  21814. */
  21815. bind(world: Matrix, mesh?: Mesh): void;
  21816. /**
  21817. * Binds the submesh to the material
  21818. * @param world defines the world transformation matrix
  21819. * @param mesh defines the mesh containing the submesh
  21820. * @param subMesh defines the submesh to bind the material to
  21821. */
  21822. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21823. /**
  21824. * Binds the world matrix to the material
  21825. * @param world defines the world transformation matrix
  21826. */
  21827. bindOnlyWorldMatrix(world: Matrix): void;
  21828. /**
  21829. * Binds the scene's uniform buffer to the effect.
  21830. * @param effect defines the effect to bind to the scene uniform buffer
  21831. * @param sceneUbo defines the uniform buffer storing scene data
  21832. */
  21833. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21834. /**
  21835. * Binds the view matrix to the effect
  21836. * @param effect defines the effect to bind the view matrix to
  21837. */
  21838. bindView(effect: Effect): void;
  21839. /**
  21840. * Binds the view projection matrix to the effect
  21841. * @param effect defines the effect to bind the view projection matrix to
  21842. */
  21843. bindViewProjection(effect: Effect): void;
  21844. /**
  21845. * Specifies if material alpha testing should be turned on for the mesh
  21846. * @param mesh defines the mesh to check
  21847. */
  21848. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21849. /**
  21850. * Processes to execute after binding the material to a mesh
  21851. * @param mesh defines the rendered mesh
  21852. */
  21853. protected _afterBind(mesh?: Mesh): void;
  21854. /**
  21855. * Unbinds the material from the mesh
  21856. */
  21857. unbind(): void;
  21858. /**
  21859. * Gets the active textures from the material
  21860. * @returns an array of textures
  21861. */
  21862. getActiveTextures(): BaseTexture[];
  21863. /**
  21864. * Specifies if the material uses a texture
  21865. * @param texture defines the texture to check against the material
  21866. * @returns a boolean specifying if the material uses the texture
  21867. */
  21868. hasTexture(texture: BaseTexture): boolean;
  21869. /**
  21870. * Makes a duplicate of the material, and gives it a new name
  21871. * @param name defines the new name for the duplicated material
  21872. * @returns the cloned material
  21873. */
  21874. clone(name: string): Nullable<Material>;
  21875. /**
  21876. * Gets the meshes bound to the material
  21877. * @returns an array of meshes bound to the material
  21878. */
  21879. getBindedMeshes(): AbstractMesh[];
  21880. /**
  21881. * Force shader compilation
  21882. * @param mesh defines the mesh associated with this material
  21883. * @param onCompiled defines a function to execute once the material is compiled
  21884. * @param options defines the options to configure the compilation
  21885. * @param onError defines a function to execute if the material fails compiling
  21886. */
  21887. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21888. /**
  21889. * Force shader compilation
  21890. * @param mesh defines the mesh that will use this material
  21891. * @param options defines additional options for compiling the shaders
  21892. * @returns a promise that resolves when the compilation completes
  21893. */
  21894. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21895. private static readonly _AllDirtyCallBack;
  21896. private static readonly _ImageProcessingDirtyCallBack;
  21897. private static readonly _TextureDirtyCallBack;
  21898. private static readonly _FresnelDirtyCallBack;
  21899. private static readonly _MiscDirtyCallBack;
  21900. private static readonly _LightsDirtyCallBack;
  21901. private static readonly _AttributeDirtyCallBack;
  21902. private static _FresnelAndMiscDirtyCallBack;
  21903. private static _TextureAndMiscDirtyCallBack;
  21904. private static readonly _DirtyCallbackArray;
  21905. private static readonly _RunDirtyCallBacks;
  21906. /**
  21907. * Marks a define in the material to indicate that it needs to be re-computed
  21908. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21909. */
  21910. markAsDirty(flag: number): void;
  21911. /**
  21912. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21913. * @param func defines a function which checks material defines against the submeshes
  21914. */
  21915. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21916. /**
  21917. * Indicates that we need to re-calculated for all submeshes
  21918. */
  21919. protected _markAllSubMeshesAsAllDirty(): void;
  21920. /**
  21921. * Indicates that image processing needs to be re-calculated for all submeshes
  21922. */
  21923. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21924. /**
  21925. * Indicates that textures need to be re-calculated for all submeshes
  21926. */
  21927. protected _markAllSubMeshesAsTexturesDirty(): void;
  21928. /**
  21929. * Indicates that fresnel needs to be re-calculated for all submeshes
  21930. */
  21931. protected _markAllSubMeshesAsFresnelDirty(): void;
  21932. /**
  21933. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21934. */
  21935. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21936. /**
  21937. * Indicates that lights need to be re-calculated for all submeshes
  21938. */
  21939. protected _markAllSubMeshesAsLightsDirty(): void;
  21940. /**
  21941. * Indicates that attributes need to be re-calculated for all submeshes
  21942. */
  21943. protected _markAllSubMeshesAsAttributesDirty(): void;
  21944. /**
  21945. * Indicates that misc needs to be re-calculated for all submeshes
  21946. */
  21947. protected _markAllSubMeshesAsMiscDirty(): void;
  21948. /**
  21949. * Indicates that textures and misc need to be re-calculated for all submeshes
  21950. */
  21951. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21952. /**
  21953. * Disposes the material
  21954. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21955. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21956. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21957. */
  21958. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21959. /** @hidden */
  21960. private releaseVertexArrayObject;
  21961. /**
  21962. * Serializes this material
  21963. * @returns the serialized material object
  21964. */
  21965. serialize(): any;
  21966. /**
  21967. * Creates a material from parsed material data
  21968. * @param parsedMaterial defines parsed material data
  21969. * @param scene defines the hosting scene
  21970. * @param rootUrl defines the root URL to use to load textures
  21971. * @returns a new material
  21972. */
  21973. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21974. }
  21975. }
  21976. declare module "babylonjs/Materials/multiMaterial" {
  21977. import { Nullable } from "babylonjs/types";
  21978. import { Scene } from "babylonjs/scene";
  21979. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21980. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21981. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21982. import { Material } from "babylonjs/Materials/material";
  21983. /**
  21984. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21985. * separate meshes. This can be use to improve performances.
  21986. * @see http://doc.babylonjs.com/how_to/multi_materials
  21987. */
  21988. export class MultiMaterial extends Material {
  21989. private _subMaterials;
  21990. /**
  21991. * Gets or Sets the list of Materials used within the multi material.
  21992. * They need to be ordered according to the submeshes order in the associated mesh
  21993. */
  21994. get subMaterials(): Nullable<Material>[];
  21995. set subMaterials(value: Nullable<Material>[]);
  21996. /**
  21997. * Function used to align with Node.getChildren()
  21998. * @returns the list of Materials used within the multi material
  21999. */
  22000. getChildren(): Nullable<Material>[];
  22001. /**
  22002. * Instantiates a new Multi Material
  22003. * A multi-material is used to apply different materials to different parts of the same object without the need of
  22004. * separate meshes. This can be use to improve performances.
  22005. * @see http://doc.babylonjs.com/how_to/multi_materials
  22006. * @param name Define the name in the scene
  22007. * @param scene Define the scene the material belongs to
  22008. */
  22009. constructor(name: string, scene: Scene);
  22010. private _hookArray;
  22011. /**
  22012. * Get one of the submaterial by its index in the submaterials array
  22013. * @param index The index to look the sub material at
  22014. * @returns The Material if the index has been defined
  22015. */
  22016. getSubMaterial(index: number): Nullable<Material>;
  22017. /**
  22018. * Get the list of active textures for the whole sub materials list.
  22019. * @returns All the textures that will be used during the rendering
  22020. */
  22021. getActiveTextures(): BaseTexture[];
  22022. /**
  22023. * Gets the current class name of the material e.g. "MultiMaterial"
  22024. * Mainly use in serialization.
  22025. * @returns the class name
  22026. */
  22027. getClassName(): string;
  22028. /**
  22029. * Checks if the material is ready to render the requested sub mesh
  22030. * @param mesh Define the mesh the submesh belongs to
  22031. * @param subMesh Define the sub mesh to look readyness for
  22032. * @param useInstances Define whether or not the material is used with instances
  22033. * @returns true if ready, otherwise false
  22034. */
  22035. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22036. /**
  22037. * Clones the current material and its related sub materials
  22038. * @param name Define the name of the newly cloned material
  22039. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  22040. * @returns the cloned material
  22041. */
  22042. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  22043. /**
  22044. * Serializes the materials into a JSON representation.
  22045. * @returns the JSON representation
  22046. */
  22047. serialize(): any;
  22048. /**
  22049. * Dispose the material and release its associated resources
  22050. * @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)
  22051. * @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)
  22052. * @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)
  22053. */
  22054. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  22055. /**
  22056. * Creates a MultiMaterial from parsed MultiMaterial data.
  22057. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  22058. * @param scene defines the hosting scene
  22059. * @returns a new MultiMaterial
  22060. */
  22061. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  22062. }
  22063. }
  22064. declare module "babylonjs/Meshes/subMesh" {
  22065. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  22066. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  22067. import { Engine } from "babylonjs/Engines/engine";
  22068. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  22069. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22070. import { Effect } from "babylonjs/Materials/effect";
  22071. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22072. import { Plane } from "babylonjs/Maths/math.plane";
  22073. import { Collider } from "babylonjs/Collisions/collider";
  22074. import { Material } from "babylonjs/Materials/material";
  22075. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22076. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22077. import { Mesh } from "babylonjs/Meshes/mesh";
  22078. import { Ray } from "babylonjs/Culling/ray";
  22079. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  22080. /**
  22081. * Base class for submeshes
  22082. */
  22083. export class BaseSubMesh {
  22084. /** @hidden */
  22085. _materialDefines: Nullable<MaterialDefines>;
  22086. /** @hidden */
  22087. _materialEffect: Nullable<Effect>;
  22088. /**
  22089. * Gets material defines used by the effect associated to the sub mesh
  22090. */
  22091. get materialDefines(): Nullable<MaterialDefines>;
  22092. /**
  22093. * Sets material defines used by the effect associated to the sub mesh
  22094. */
  22095. set materialDefines(defines: Nullable<MaterialDefines>);
  22096. /**
  22097. * Gets associated effect
  22098. */
  22099. get effect(): Nullable<Effect>;
  22100. /**
  22101. * Sets associated effect (effect used to render this submesh)
  22102. * @param effect defines the effect to associate with
  22103. * @param defines defines the set of defines used to compile this effect
  22104. */
  22105. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22106. }
  22107. /**
  22108. * Defines a subdivision inside a mesh
  22109. */
  22110. export class SubMesh extends BaseSubMesh implements ICullable {
  22111. /** the material index to use */
  22112. materialIndex: number;
  22113. /** vertex index start */
  22114. verticesStart: number;
  22115. /** vertices count */
  22116. verticesCount: number;
  22117. /** index start */
  22118. indexStart: number;
  22119. /** indices count */
  22120. indexCount: number;
  22121. /** @hidden */
  22122. _linesIndexCount: number;
  22123. private _mesh;
  22124. private _renderingMesh;
  22125. private _boundingInfo;
  22126. private _linesIndexBuffer;
  22127. /** @hidden */
  22128. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22129. /** @hidden */
  22130. _trianglePlanes: Plane[];
  22131. /** @hidden */
  22132. _lastColliderTransformMatrix: Nullable<Matrix>;
  22133. /** @hidden */
  22134. _renderId: number;
  22135. /** @hidden */
  22136. _alphaIndex: number;
  22137. /** @hidden */
  22138. _distanceToCamera: number;
  22139. /** @hidden */
  22140. _id: number;
  22141. private _currentMaterial;
  22142. /**
  22143. * Add a new submesh to a mesh
  22144. * @param materialIndex defines the material index to use
  22145. * @param verticesStart defines vertex index start
  22146. * @param verticesCount defines vertices count
  22147. * @param indexStart defines index start
  22148. * @param indexCount defines indices count
  22149. * @param mesh defines the parent mesh
  22150. * @param renderingMesh defines an optional rendering mesh
  22151. * @param createBoundingBox defines if bounding box should be created for this submesh
  22152. * @returns the new submesh
  22153. */
  22154. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22155. /**
  22156. * Creates a new submesh
  22157. * @param materialIndex defines the material index to use
  22158. * @param verticesStart defines vertex index start
  22159. * @param verticesCount defines vertices count
  22160. * @param indexStart defines index start
  22161. * @param indexCount defines indices count
  22162. * @param mesh defines the parent mesh
  22163. * @param renderingMesh defines an optional rendering mesh
  22164. * @param createBoundingBox defines if bounding box should be created for this submesh
  22165. */
  22166. constructor(
  22167. /** the material index to use */
  22168. materialIndex: number,
  22169. /** vertex index start */
  22170. verticesStart: number,
  22171. /** vertices count */
  22172. verticesCount: number,
  22173. /** index start */
  22174. indexStart: number,
  22175. /** indices count */
  22176. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22177. /**
  22178. * Returns true if this submesh covers the entire parent mesh
  22179. * @ignorenaming
  22180. */
  22181. get IsGlobal(): boolean;
  22182. /**
  22183. * Returns the submesh BoudingInfo object
  22184. * @returns current bounding info (or mesh's one if the submesh is global)
  22185. */
  22186. getBoundingInfo(): BoundingInfo;
  22187. /**
  22188. * Sets the submesh BoundingInfo
  22189. * @param boundingInfo defines the new bounding info to use
  22190. * @returns the SubMesh
  22191. */
  22192. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22193. /**
  22194. * Returns the mesh of the current submesh
  22195. * @return the parent mesh
  22196. */
  22197. getMesh(): AbstractMesh;
  22198. /**
  22199. * Returns the rendering mesh of the submesh
  22200. * @returns the rendering mesh (could be different from parent mesh)
  22201. */
  22202. getRenderingMesh(): Mesh;
  22203. /**
  22204. * Returns the submesh material
  22205. * @returns null or the current material
  22206. */
  22207. getMaterial(): Nullable<Material>;
  22208. /**
  22209. * Sets a new updated BoundingInfo object to the submesh
  22210. * @param data defines an optional position array to use to determine the bounding info
  22211. * @returns the SubMesh
  22212. */
  22213. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22214. /** @hidden */
  22215. _checkCollision(collider: Collider): boolean;
  22216. /**
  22217. * Updates the submesh BoundingInfo
  22218. * @param world defines the world matrix to use to update the bounding info
  22219. * @returns the submesh
  22220. */
  22221. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22222. /**
  22223. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22224. * @param frustumPlanes defines the frustum planes
  22225. * @returns true if the submesh is intersecting with the frustum
  22226. */
  22227. isInFrustum(frustumPlanes: Plane[]): boolean;
  22228. /**
  22229. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22230. * @param frustumPlanes defines the frustum planes
  22231. * @returns true if the submesh is inside the frustum
  22232. */
  22233. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22234. /**
  22235. * Renders the submesh
  22236. * @param enableAlphaMode defines if alpha needs to be used
  22237. * @returns the submesh
  22238. */
  22239. render(enableAlphaMode: boolean): SubMesh;
  22240. /**
  22241. * @hidden
  22242. */
  22243. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22244. /**
  22245. * Checks if the submesh intersects with a ray
  22246. * @param ray defines the ray to test
  22247. * @returns true is the passed ray intersects the submesh bounding box
  22248. */
  22249. canIntersects(ray: Ray): boolean;
  22250. /**
  22251. * Intersects current submesh with a ray
  22252. * @param ray defines the ray to test
  22253. * @param positions defines mesh's positions array
  22254. * @param indices defines mesh's indices array
  22255. * @param fastCheck defines if only bounding info should be used
  22256. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22257. * @returns intersection info or null if no intersection
  22258. */
  22259. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22260. /** @hidden */
  22261. private _intersectLines;
  22262. /** @hidden */
  22263. private _intersectUnIndexedLines;
  22264. /** @hidden */
  22265. private _intersectTriangles;
  22266. /** @hidden */
  22267. private _intersectUnIndexedTriangles;
  22268. /** @hidden */
  22269. _rebuild(): void;
  22270. /**
  22271. * Creates a new submesh from the passed mesh
  22272. * @param newMesh defines the new hosting mesh
  22273. * @param newRenderingMesh defines an optional rendering mesh
  22274. * @returns the new submesh
  22275. */
  22276. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22277. /**
  22278. * Release associated resources
  22279. */
  22280. dispose(): void;
  22281. /**
  22282. * Gets the class name
  22283. * @returns the string "SubMesh".
  22284. */
  22285. getClassName(): string;
  22286. /**
  22287. * Creates a new submesh from indices data
  22288. * @param materialIndex the index of the main mesh material
  22289. * @param startIndex the index where to start the copy in the mesh indices array
  22290. * @param indexCount the number of indices to copy then from the startIndex
  22291. * @param mesh the main mesh to create the submesh from
  22292. * @param renderingMesh the optional rendering mesh
  22293. * @returns a new submesh
  22294. */
  22295. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22296. }
  22297. }
  22298. declare module "babylonjs/Loading/sceneLoaderFlags" {
  22299. /**
  22300. * Class used to represent data loading progression
  22301. */
  22302. export class SceneLoaderFlags {
  22303. private static _ForceFullSceneLoadingForIncremental;
  22304. private static _ShowLoadingScreen;
  22305. private static _CleanBoneMatrixWeights;
  22306. private static _loggingLevel;
  22307. /**
  22308. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  22309. */
  22310. static get ForceFullSceneLoadingForIncremental(): boolean;
  22311. static set ForceFullSceneLoadingForIncremental(value: boolean);
  22312. /**
  22313. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  22314. */
  22315. static get ShowLoadingScreen(): boolean;
  22316. static set ShowLoadingScreen(value: boolean);
  22317. /**
  22318. * Defines the current logging level (while loading the scene)
  22319. * @ignorenaming
  22320. */
  22321. static get loggingLevel(): number;
  22322. static set loggingLevel(value: number);
  22323. /**
  22324. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  22325. */
  22326. static get CleanBoneMatrixWeights(): boolean;
  22327. static set CleanBoneMatrixWeights(value: boolean);
  22328. }
  22329. }
  22330. declare module "babylonjs/Meshes/geometry" {
  22331. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22332. import { Scene } from "babylonjs/scene";
  22333. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  22334. import { Engine } from "babylonjs/Engines/engine";
  22335. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22336. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22337. import { Effect } from "babylonjs/Materials/effect";
  22338. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22339. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22340. import { Mesh } from "babylonjs/Meshes/mesh";
  22341. /**
  22342. * Class used to store geometry data (vertex buffers + index buffer)
  22343. */
  22344. export class Geometry implements IGetSetVerticesData {
  22345. /**
  22346. * Gets or sets the ID of the geometry
  22347. */
  22348. id: string;
  22349. /**
  22350. * Gets or sets the unique ID of the geometry
  22351. */
  22352. uniqueId: number;
  22353. /**
  22354. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22355. */
  22356. delayLoadState: number;
  22357. /**
  22358. * Gets the file containing the data to load when running in delay load state
  22359. */
  22360. delayLoadingFile: Nullable<string>;
  22361. /**
  22362. * Callback called when the geometry is updated
  22363. */
  22364. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22365. private _scene;
  22366. private _engine;
  22367. private _meshes;
  22368. private _totalVertices;
  22369. /** @hidden */
  22370. _indices: IndicesArray;
  22371. /** @hidden */
  22372. _vertexBuffers: {
  22373. [key: string]: VertexBuffer;
  22374. };
  22375. private _isDisposed;
  22376. private _extend;
  22377. private _boundingBias;
  22378. /** @hidden */
  22379. _delayInfo: Array<string>;
  22380. private _indexBuffer;
  22381. private _indexBufferIsUpdatable;
  22382. /** @hidden */
  22383. _boundingInfo: Nullable<BoundingInfo>;
  22384. /** @hidden */
  22385. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22386. /** @hidden */
  22387. _softwareSkinningFrameId: number;
  22388. private _vertexArrayObjects;
  22389. private _updatable;
  22390. /** @hidden */
  22391. _positions: Nullable<Vector3[]>;
  22392. /**
  22393. * 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
  22394. */
  22395. get boundingBias(): Vector2;
  22396. /**
  22397. * 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
  22398. */
  22399. set boundingBias(value: Vector2);
  22400. /**
  22401. * Static function used to attach a new empty geometry to a mesh
  22402. * @param mesh defines the mesh to attach the geometry to
  22403. * @returns the new Geometry
  22404. */
  22405. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22406. /**
  22407. * Creates a new geometry
  22408. * @param id defines the unique ID
  22409. * @param scene defines the hosting scene
  22410. * @param vertexData defines the VertexData used to get geometry data
  22411. * @param updatable defines if geometry must be updatable (false by default)
  22412. * @param mesh defines the mesh that will be associated with the geometry
  22413. */
  22414. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22415. /**
  22416. * Gets the current extend of the geometry
  22417. */
  22418. get extend(): {
  22419. minimum: Vector3;
  22420. maximum: Vector3;
  22421. };
  22422. /**
  22423. * Gets the hosting scene
  22424. * @returns the hosting Scene
  22425. */
  22426. getScene(): Scene;
  22427. /**
  22428. * Gets the hosting engine
  22429. * @returns the hosting Engine
  22430. */
  22431. getEngine(): Engine;
  22432. /**
  22433. * Defines if the geometry is ready to use
  22434. * @returns true if the geometry is ready to be used
  22435. */
  22436. isReady(): boolean;
  22437. /**
  22438. * Gets a value indicating that the geometry should not be serialized
  22439. */
  22440. get doNotSerialize(): boolean;
  22441. /** @hidden */
  22442. _rebuild(): void;
  22443. /**
  22444. * Affects all geometry data in one call
  22445. * @param vertexData defines the geometry data
  22446. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22447. */
  22448. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22449. /**
  22450. * Set specific vertex data
  22451. * @param kind defines the data kind (Position, normal, etc...)
  22452. * @param data defines the vertex data to use
  22453. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22454. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22455. */
  22456. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22457. /**
  22458. * Removes a specific vertex data
  22459. * @param kind defines the data kind (Position, normal, etc...)
  22460. */
  22461. removeVerticesData(kind: string): void;
  22462. /**
  22463. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22464. * @param buffer defines the vertex buffer to use
  22465. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22466. */
  22467. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22468. /**
  22469. * Update a specific vertex buffer
  22470. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22471. * It will do nothing if the buffer is not updatable
  22472. * @param kind defines the data kind (Position, normal, etc...)
  22473. * @param data defines the data to use
  22474. * @param offset defines the offset in the target buffer where to store the data
  22475. * @param useBytes set to true if the offset is in bytes
  22476. */
  22477. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22478. /**
  22479. * Update a specific vertex buffer
  22480. * This function will create a new buffer if the current one is not updatable
  22481. * @param kind defines the data kind (Position, normal, etc...)
  22482. * @param data defines the data to use
  22483. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22484. */
  22485. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22486. private _updateBoundingInfo;
  22487. /** @hidden */
  22488. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22489. /**
  22490. * Gets total number of vertices
  22491. * @returns the total number of vertices
  22492. */
  22493. getTotalVertices(): number;
  22494. /**
  22495. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22496. * @param kind defines the data kind (Position, normal, etc...)
  22497. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22498. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22499. * @returns a float array containing vertex data
  22500. */
  22501. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22502. /**
  22503. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22504. * @param kind defines the data kind (Position, normal, etc...)
  22505. * @returns true if the vertex buffer with the specified kind is updatable
  22506. */
  22507. isVertexBufferUpdatable(kind: string): boolean;
  22508. /**
  22509. * Gets a specific vertex buffer
  22510. * @param kind defines the data kind (Position, normal, etc...)
  22511. * @returns a VertexBuffer
  22512. */
  22513. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22514. /**
  22515. * Returns all vertex buffers
  22516. * @return an object holding all vertex buffers indexed by kind
  22517. */
  22518. getVertexBuffers(): Nullable<{
  22519. [key: string]: VertexBuffer;
  22520. }>;
  22521. /**
  22522. * Gets a boolean indicating if specific vertex buffer is present
  22523. * @param kind defines the data kind (Position, normal, etc...)
  22524. * @returns true if data is present
  22525. */
  22526. isVerticesDataPresent(kind: string): boolean;
  22527. /**
  22528. * Gets a list of all attached data kinds (Position, normal, etc...)
  22529. * @returns a list of string containing all kinds
  22530. */
  22531. getVerticesDataKinds(): string[];
  22532. /**
  22533. * Update index buffer
  22534. * @param indices defines the indices to store in the index buffer
  22535. * @param offset defines the offset in the target buffer where to store the data
  22536. * @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)
  22537. */
  22538. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22539. /**
  22540. * Creates a new index buffer
  22541. * @param indices defines the indices to store in the index buffer
  22542. * @param totalVertices defines the total number of vertices (could be null)
  22543. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22544. */
  22545. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22546. /**
  22547. * Return the total number of indices
  22548. * @returns the total number of indices
  22549. */
  22550. getTotalIndices(): number;
  22551. /**
  22552. * Gets the index buffer array
  22553. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22554. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22555. * @returns the index buffer array
  22556. */
  22557. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22558. /**
  22559. * Gets the index buffer
  22560. * @return the index buffer
  22561. */
  22562. getIndexBuffer(): Nullable<DataBuffer>;
  22563. /** @hidden */
  22564. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22565. /**
  22566. * Release the associated resources for a specific mesh
  22567. * @param mesh defines the source mesh
  22568. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22569. */
  22570. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22571. /**
  22572. * Apply current geometry to a given mesh
  22573. * @param mesh defines the mesh to apply geometry to
  22574. */
  22575. applyToMesh(mesh: Mesh): void;
  22576. private _updateExtend;
  22577. private _applyToMesh;
  22578. private notifyUpdate;
  22579. /**
  22580. * Load the geometry if it was flagged as delay loaded
  22581. * @param scene defines the hosting scene
  22582. * @param onLoaded defines a callback called when the geometry is loaded
  22583. */
  22584. load(scene: Scene, onLoaded?: () => void): void;
  22585. private _queueLoad;
  22586. /**
  22587. * Invert the geometry to move from a right handed system to a left handed one.
  22588. */
  22589. toLeftHanded(): void;
  22590. /** @hidden */
  22591. _resetPointsArrayCache(): void;
  22592. /** @hidden */
  22593. _generatePointsArray(): boolean;
  22594. /**
  22595. * Gets a value indicating if the geometry is disposed
  22596. * @returns true if the geometry was disposed
  22597. */
  22598. isDisposed(): boolean;
  22599. private _disposeVertexArrayObjects;
  22600. /**
  22601. * Free all associated resources
  22602. */
  22603. dispose(): void;
  22604. /**
  22605. * Clone the current geometry into a new geometry
  22606. * @param id defines the unique ID of the new geometry
  22607. * @returns a new geometry object
  22608. */
  22609. copy(id: string): Geometry;
  22610. /**
  22611. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22612. * @return a JSON representation of the current geometry data (without the vertices data)
  22613. */
  22614. serialize(): any;
  22615. private toNumberArray;
  22616. /**
  22617. * Serialize all vertices data into a JSON oject
  22618. * @returns a JSON representation of the current geometry data
  22619. */
  22620. serializeVerticeData(): any;
  22621. /**
  22622. * Extracts a clone of a mesh geometry
  22623. * @param mesh defines the source mesh
  22624. * @param id defines the unique ID of the new geometry object
  22625. * @returns the new geometry object
  22626. */
  22627. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22628. /**
  22629. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22630. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22631. * Be aware Math.random() could cause collisions, but:
  22632. * "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"
  22633. * @returns a string containing a new GUID
  22634. */
  22635. static RandomId(): string;
  22636. /** @hidden */
  22637. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22638. private static _CleanMatricesWeights;
  22639. /**
  22640. * Create a new geometry from persisted data (Using .babylon file format)
  22641. * @param parsedVertexData defines the persisted data
  22642. * @param scene defines the hosting scene
  22643. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22644. * @returns the new geometry object
  22645. */
  22646. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22647. }
  22648. }
  22649. declare module "babylonjs/Meshes/mesh.vertexData" {
  22650. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22651. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22652. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22653. import { Geometry } from "babylonjs/Meshes/geometry";
  22654. import { Mesh } from "babylonjs/Meshes/mesh";
  22655. /**
  22656. * Define an interface for all classes that will get and set the data on vertices
  22657. */
  22658. export interface IGetSetVerticesData {
  22659. /**
  22660. * Gets a boolean indicating if specific vertex data is present
  22661. * @param kind defines the vertex data kind to use
  22662. * @returns true is data kind is present
  22663. */
  22664. isVerticesDataPresent(kind: string): boolean;
  22665. /**
  22666. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22667. * @param kind defines the data kind (Position, normal, etc...)
  22668. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22669. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22670. * @returns a float array containing vertex data
  22671. */
  22672. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22673. /**
  22674. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22675. * @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.
  22676. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22677. * @returns the indices array or an empty array if the mesh has no geometry
  22678. */
  22679. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22680. /**
  22681. * Set specific vertex data
  22682. * @param kind defines the data kind (Position, normal, etc...)
  22683. * @param data defines the vertex data to use
  22684. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22685. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22686. */
  22687. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22688. /**
  22689. * Update a specific associated vertex buffer
  22690. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22691. * - VertexBuffer.PositionKind
  22692. * - VertexBuffer.UVKind
  22693. * - VertexBuffer.UV2Kind
  22694. * - VertexBuffer.UV3Kind
  22695. * - VertexBuffer.UV4Kind
  22696. * - VertexBuffer.UV5Kind
  22697. * - VertexBuffer.UV6Kind
  22698. * - VertexBuffer.ColorKind
  22699. * - VertexBuffer.MatricesIndicesKind
  22700. * - VertexBuffer.MatricesIndicesExtraKind
  22701. * - VertexBuffer.MatricesWeightsKind
  22702. * - VertexBuffer.MatricesWeightsExtraKind
  22703. * @param data defines the data source
  22704. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22705. * @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)
  22706. */
  22707. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22708. /**
  22709. * Creates a new index buffer
  22710. * @param indices defines the indices to store in the index buffer
  22711. * @param totalVertices defines the total number of vertices (could be null)
  22712. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22713. */
  22714. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22715. }
  22716. /**
  22717. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22718. */
  22719. export class VertexData {
  22720. /**
  22721. * Mesh side orientation : usually the external or front surface
  22722. */
  22723. static readonly FRONTSIDE: number;
  22724. /**
  22725. * Mesh side orientation : usually the internal or back surface
  22726. */
  22727. static readonly BACKSIDE: number;
  22728. /**
  22729. * Mesh side orientation : both internal and external or front and back surfaces
  22730. */
  22731. static readonly DOUBLESIDE: number;
  22732. /**
  22733. * Mesh side orientation : by default, `FRONTSIDE`
  22734. */
  22735. static readonly DEFAULTSIDE: number;
  22736. /**
  22737. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22738. */
  22739. positions: Nullable<FloatArray>;
  22740. /**
  22741. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22742. */
  22743. normals: Nullable<FloatArray>;
  22744. /**
  22745. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22746. */
  22747. tangents: Nullable<FloatArray>;
  22748. /**
  22749. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22750. */
  22751. uvs: Nullable<FloatArray>;
  22752. /**
  22753. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22754. */
  22755. uvs2: Nullable<FloatArray>;
  22756. /**
  22757. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22758. */
  22759. uvs3: Nullable<FloatArray>;
  22760. /**
  22761. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22762. */
  22763. uvs4: Nullable<FloatArray>;
  22764. /**
  22765. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22766. */
  22767. uvs5: Nullable<FloatArray>;
  22768. /**
  22769. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22770. */
  22771. uvs6: Nullable<FloatArray>;
  22772. /**
  22773. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22774. */
  22775. colors: Nullable<FloatArray>;
  22776. /**
  22777. * 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).
  22778. */
  22779. matricesIndices: Nullable<FloatArray>;
  22780. /**
  22781. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22782. */
  22783. matricesWeights: Nullable<FloatArray>;
  22784. /**
  22785. * An array extending the number of possible indices
  22786. */
  22787. matricesIndicesExtra: Nullable<FloatArray>;
  22788. /**
  22789. * An array extending the number of possible weights when the number of indices is extended
  22790. */
  22791. matricesWeightsExtra: Nullable<FloatArray>;
  22792. /**
  22793. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22794. */
  22795. indices: Nullable<IndicesArray>;
  22796. /**
  22797. * Uses the passed data array to set the set the values for the specified kind of data
  22798. * @param data a linear array of floating numbers
  22799. * @param kind the type of data that is being set, eg positions, colors etc
  22800. */
  22801. set(data: FloatArray, kind: string): void;
  22802. /**
  22803. * Associates the vertexData to the passed Mesh.
  22804. * Sets it as updatable or not (default `false`)
  22805. * @param mesh the mesh the vertexData is applied to
  22806. * @param updatable when used and having the value true allows new data to update the vertexData
  22807. * @returns the VertexData
  22808. */
  22809. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22810. /**
  22811. * Associates the vertexData to the passed Geometry.
  22812. * Sets it as updatable or not (default `false`)
  22813. * @param geometry the geometry the vertexData is applied to
  22814. * @param updatable when used and having the value true allows new data to update the vertexData
  22815. * @returns VertexData
  22816. */
  22817. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22818. /**
  22819. * Updates the associated mesh
  22820. * @param mesh the mesh to be updated
  22821. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22822. * @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
  22823. * @returns VertexData
  22824. */
  22825. updateMesh(mesh: Mesh): VertexData;
  22826. /**
  22827. * Updates the associated geometry
  22828. * @param geometry the geometry to be updated
  22829. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22830. * @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
  22831. * @returns VertexData.
  22832. */
  22833. updateGeometry(geometry: Geometry): VertexData;
  22834. private _applyTo;
  22835. private _update;
  22836. /**
  22837. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22838. * @param matrix the transforming matrix
  22839. * @returns the VertexData
  22840. */
  22841. transform(matrix: Matrix): VertexData;
  22842. /**
  22843. * Merges the passed VertexData into the current one
  22844. * @param other the VertexData to be merged into the current one
  22845. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22846. * @returns the modified VertexData
  22847. */
  22848. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22849. private _mergeElement;
  22850. private _validate;
  22851. /**
  22852. * Serializes the VertexData
  22853. * @returns a serialized object
  22854. */
  22855. serialize(): any;
  22856. /**
  22857. * Extracts the vertexData from a mesh
  22858. * @param mesh the mesh from which to extract the VertexData
  22859. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22860. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22861. * @returns the object VertexData associated to the passed mesh
  22862. */
  22863. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22864. /**
  22865. * Extracts the vertexData from the geometry
  22866. * @param geometry the geometry from which to extract the VertexData
  22867. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22868. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22869. * @returns the object VertexData associated to the passed mesh
  22870. */
  22871. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22872. private static _ExtractFrom;
  22873. /**
  22874. * Creates the VertexData for a Ribbon
  22875. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22876. * * pathArray array of paths, each of which an array of successive Vector3
  22877. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22878. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22879. * * 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
  22880. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22881. * * 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)
  22882. * * 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)
  22883. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22884. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22885. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22886. * @returns the VertexData of the ribbon
  22887. */
  22888. static CreateRibbon(options: {
  22889. pathArray: Vector3[][];
  22890. closeArray?: boolean;
  22891. closePath?: boolean;
  22892. offset?: number;
  22893. sideOrientation?: number;
  22894. frontUVs?: Vector4;
  22895. backUVs?: Vector4;
  22896. invertUV?: boolean;
  22897. uvs?: Vector2[];
  22898. colors?: Color4[];
  22899. }): VertexData;
  22900. /**
  22901. * Creates the VertexData for a box
  22902. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22903. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22904. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22905. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22906. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22907. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22908. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22909. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22910. * * 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)
  22911. * * 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)
  22912. * @returns the VertexData of the box
  22913. */
  22914. static CreateBox(options: {
  22915. size?: number;
  22916. width?: number;
  22917. height?: number;
  22918. depth?: number;
  22919. faceUV?: Vector4[];
  22920. faceColors?: Color4[];
  22921. sideOrientation?: number;
  22922. frontUVs?: Vector4;
  22923. backUVs?: Vector4;
  22924. }): VertexData;
  22925. /**
  22926. * Creates the VertexData for a tiled box
  22927. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22928. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22929. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22930. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22931. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22932. * @returns the VertexData of the box
  22933. */
  22934. static CreateTiledBox(options: {
  22935. pattern?: number;
  22936. width?: number;
  22937. height?: number;
  22938. depth?: number;
  22939. tileSize?: number;
  22940. tileWidth?: number;
  22941. tileHeight?: number;
  22942. alignHorizontal?: number;
  22943. alignVertical?: number;
  22944. faceUV?: Vector4[];
  22945. faceColors?: Color4[];
  22946. sideOrientation?: number;
  22947. }): VertexData;
  22948. /**
  22949. * Creates the VertexData for a tiled plane
  22950. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22951. * * pattern a limited pattern arrangement depending on the number
  22952. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22953. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22954. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22955. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22956. * * 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)
  22957. * * 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)
  22958. * @returns the VertexData of the tiled plane
  22959. */
  22960. static CreateTiledPlane(options: {
  22961. pattern?: number;
  22962. tileSize?: number;
  22963. tileWidth?: number;
  22964. tileHeight?: number;
  22965. size?: number;
  22966. width?: number;
  22967. height?: number;
  22968. alignHorizontal?: number;
  22969. alignVertical?: number;
  22970. sideOrientation?: number;
  22971. frontUVs?: Vector4;
  22972. backUVs?: Vector4;
  22973. }): VertexData;
  22974. /**
  22975. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22976. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22977. * * segments sets the number of horizontal strips optional, default 32
  22978. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22979. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22980. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22981. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22982. * * 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
  22983. * * 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
  22984. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22985. * * 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)
  22986. * * 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)
  22987. * @returns the VertexData of the ellipsoid
  22988. */
  22989. static CreateSphere(options: {
  22990. segments?: number;
  22991. diameter?: number;
  22992. diameterX?: number;
  22993. diameterY?: number;
  22994. diameterZ?: number;
  22995. arc?: number;
  22996. slice?: number;
  22997. sideOrientation?: number;
  22998. frontUVs?: Vector4;
  22999. backUVs?: Vector4;
  23000. }): VertexData;
  23001. /**
  23002. * Creates the VertexData for a cylinder, cone or prism
  23003. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23004. * * height sets the height (y direction) of the cylinder, optional, default 2
  23005. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23006. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23007. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23008. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23009. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23010. * * 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
  23011. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23012. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23013. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23014. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23015. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23016. * * 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)
  23017. * * 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)
  23018. * @returns the VertexData of the cylinder, cone or prism
  23019. */
  23020. static CreateCylinder(options: {
  23021. height?: number;
  23022. diameterTop?: number;
  23023. diameterBottom?: number;
  23024. diameter?: number;
  23025. tessellation?: number;
  23026. subdivisions?: number;
  23027. arc?: number;
  23028. faceColors?: Color4[];
  23029. faceUV?: Vector4[];
  23030. hasRings?: boolean;
  23031. enclose?: boolean;
  23032. sideOrientation?: number;
  23033. frontUVs?: Vector4;
  23034. backUVs?: Vector4;
  23035. }): VertexData;
  23036. /**
  23037. * Creates the VertexData for a torus
  23038. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23039. * * diameter the diameter of the torus, optional default 1
  23040. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23041. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23042. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23043. * * 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)
  23044. * * 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)
  23045. * @returns the VertexData of the torus
  23046. */
  23047. static CreateTorus(options: {
  23048. diameter?: number;
  23049. thickness?: number;
  23050. tessellation?: number;
  23051. sideOrientation?: number;
  23052. frontUVs?: Vector4;
  23053. backUVs?: Vector4;
  23054. }): VertexData;
  23055. /**
  23056. * Creates the VertexData of the LineSystem
  23057. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23058. * - lines an array of lines, each line being an array of successive Vector3
  23059. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23060. * @returns the VertexData of the LineSystem
  23061. */
  23062. static CreateLineSystem(options: {
  23063. lines: Vector3[][];
  23064. colors?: Nullable<Color4[][]>;
  23065. }): VertexData;
  23066. /**
  23067. * Create the VertexData for a DashedLines
  23068. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23069. * - points an array successive Vector3
  23070. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23071. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23072. * - dashNb the intended total number of dashes, optional, default 200
  23073. * @returns the VertexData for the DashedLines
  23074. */
  23075. static CreateDashedLines(options: {
  23076. points: Vector3[];
  23077. dashSize?: number;
  23078. gapSize?: number;
  23079. dashNb?: number;
  23080. }): VertexData;
  23081. /**
  23082. * Creates the VertexData for a Ground
  23083. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23084. * - width the width (x direction) of the ground, optional, default 1
  23085. * - height the height (z direction) of the ground, optional, default 1
  23086. * - subdivisions the number of subdivisions per side, optional, default 1
  23087. * @returns the VertexData of the Ground
  23088. */
  23089. static CreateGround(options: {
  23090. width?: number;
  23091. height?: number;
  23092. subdivisions?: number;
  23093. subdivisionsX?: number;
  23094. subdivisionsY?: number;
  23095. }): VertexData;
  23096. /**
  23097. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23098. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23099. * * xmin the ground minimum X coordinate, optional, default -1
  23100. * * zmin the ground minimum Z coordinate, optional, default -1
  23101. * * xmax the ground maximum X coordinate, optional, default 1
  23102. * * zmax the ground maximum Z coordinate, optional, default 1
  23103. * * 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}
  23104. * * 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}
  23105. * @returns the VertexData of the TiledGround
  23106. */
  23107. static CreateTiledGround(options: {
  23108. xmin: number;
  23109. zmin: number;
  23110. xmax: number;
  23111. zmax: number;
  23112. subdivisions?: {
  23113. w: number;
  23114. h: number;
  23115. };
  23116. precision?: {
  23117. w: number;
  23118. h: number;
  23119. };
  23120. }): VertexData;
  23121. /**
  23122. * Creates the VertexData of the Ground designed from a heightmap
  23123. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23124. * * width the width (x direction) of the ground
  23125. * * height the height (z direction) of the ground
  23126. * * subdivisions the number of subdivisions per side
  23127. * * minHeight the minimum altitude on the ground, optional, default 0
  23128. * * maxHeight the maximum altitude on the ground, optional default 1
  23129. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23130. * * buffer the array holding the image color data
  23131. * * bufferWidth the width of image
  23132. * * bufferHeight the height of image
  23133. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23134. * @returns the VertexData of the Ground designed from a heightmap
  23135. */
  23136. static CreateGroundFromHeightMap(options: {
  23137. width: number;
  23138. height: number;
  23139. subdivisions: number;
  23140. minHeight: number;
  23141. maxHeight: number;
  23142. colorFilter: Color3;
  23143. buffer: Uint8Array;
  23144. bufferWidth: number;
  23145. bufferHeight: number;
  23146. alphaFilter: number;
  23147. }): VertexData;
  23148. /**
  23149. * Creates the VertexData for a Plane
  23150. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23151. * * size sets the width and height of the plane to the value of size, optional default 1
  23152. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23153. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23154. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23155. * * 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)
  23156. * * 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)
  23157. * @returns the VertexData of the box
  23158. */
  23159. static CreatePlane(options: {
  23160. size?: number;
  23161. width?: number;
  23162. height?: number;
  23163. sideOrientation?: number;
  23164. frontUVs?: Vector4;
  23165. backUVs?: Vector4;
  23166. }): VertexData;
  23167. /**
  23168. * Creates the VertexData of the Disc or regular Polygon
  23169. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23170. * * radius the radius of the disc, optional default 0.5
  23171. * * tessellation the number of polygon sides, optional, default 64
  23172. * * 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
  23173. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23174. * * 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)
  23175. * * 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)
  23176. * @returns the VertexData of the box
  23177. */
  23178. static CreateDisc(options: {
  23179. radius?: number;
  23180. tessellation?: number;
  23181. arc?: number;
  23182. sideOrientation?: number;
  23183. frontUVs?: Vector4;
  23184. backUVs?: Vector4;
  23185. }): VertexData;
  23186. /**
  23187. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23188. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23189. * @param polygon a mesh built from polygonTriangulation.build()
  23190. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23191. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23192. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23193. * @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)
  23194. * @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)
  23195. * @returns the VertexData of the Polygon
  23196. */
  23197. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23198. /**
  23199. * Creates the VertexData of the IcoSphere
  23200. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23201. * * radius the radius of the IcoSphere, optional default 1
  23202. * * radiusX allows stretching in the x direction, optional, default radius
  23203. * * radiusY allows stretching in the y direction, optional, default radius
  23204. * * radiusZ allows stretching in the z direction, optional, default radius
  23205. * * flat when true creates a flat shaded mesh, optional, default true
  23206. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23207. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23208. * * 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)
  23209. * * 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)
  23210. * @returns the VertexData of the IcoSphere
  23211. */
  23212. static CreateIcoSphere(options: {
  23213. radius?: number;
  23214. radiusX?: number;
  23215. radiusY?: number;
  23216. radiusZ?: number;
  23217. flat?: boolean;
  23218. subdivisions?: number;
  23219. sideOrientation?: number;
  23220. frontUVs?: Vector4;
  23221. backUVs?: Vector4;
  23222. }): VertexData;
  23223. /**
  23224. * Creates the VertexData for a Polyhedron
  23225. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23226. * * type provided types are:
  23227. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23228. * * 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)
  23229. * * size the size of the IcoSphere, optional default 1
  23230. * * sizeX allows stretching in the x direction, optional, default size
  23231. * * sizeY allows stretching in the y direction, optional, default size
  23232. * * sizeZ allows stretching in the z direction, optional, default size
  23233. * * 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
  23234. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23235. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23236. * * flat when true creates a flat shaded mesh, optional, default true
  23237. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23238. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23239. * * 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)
  23240. * * 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)
  23241. * @returns the VertexData of the Polyhedron
  23242. */
  23243. static CreatePolyhedron(options: {
  23244. type?: number;
  23245. size?: number;
  23246. sizeX?: number;
  23247. sizeY?: number;
  23248. sizeZ?: number;
  23249. custom?: any;
  23250. faceUV?: Vector4[];
  23251. faceColors?: Color4[];
  23252. flat?: boolean;
  23253. sideOrientation?: number;
  23254. frontUVs?: Vector4;
  23255. backUVs?: Vector4;
  23256. }): VertexData;
  23257. /**
  23258. * Creates the VertexData for a TorusKnot
  23259. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23260. * * radius the radius of the torus knot, optional, default 2
  23261. * * tube the thickness of the tube, optional, default 0.5
  23262. * * radialSegments the number of sides on each tube segments, optional, default 32
  23263. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23264. * * p the number of windings around the z axis, optional, default 2
  23265. * * q the number of windings around the x axis, optional, default 3
  23266. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23267. * * 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)
  23268. * * 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)
  23269. * @returns the VertexData of the Torus Knot
  23270. */
  23271. static CreateTorusKnot(options: {
  23272. radius?: number;
  23273. tube?: number;
  23274. radialSegments?: number;
  23275. tubularSegments?: number;
  23276. p?: number;
  23277. q?: number;
  23278. sideOrientation?: number;
  23279. frontUVs?: Vector4;
  23280. backUVs?: Vector4;
  23281. }): VertexData;
  23282. /**
  23283. * Compute normals for given positions and indices
  23284. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23285. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23286. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23287. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23288. * * facetNormals : optional array of facet normals (vector3)
  23289. * * facetPositions : optional array of facet positions (vector3)
  23290. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23291. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23292. * * bInfo : optional bounding info, required for facetPartitioning computation
  23293. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23294. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23295. * * useRightHandedSystem: optional boolean to for right handed system computation
  23296. * * depthSort : optional boolean to enable the facet depth sort computation
  23297. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23298. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23299. */
  23300. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23301. facetNormals?: any;
  23302. facetPositions?: any;
  23303. facetPartitioning?: any;
  23304. ratio?: number;
  23305. bInfo?: any;
  23306. bbSize?: Vector3;
  23307. subDiv?: any;
  23308. useRightHandedSystem?: boolean;
  23309. depthSort?: boolean;
  23310. distanceTo?: Vector3;
  23311. depthSortedFacets?: any;
  23312. }): void;
  23313. /** @hidden */
  23314. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23315. /**
  23316. * Applies VertexData created from the imported parameters to the geometry
  23317. * @param parsedVertexData the parsed data from an imported file
  23318. * @param geometry the geometry to apply the VertexData to
  23319. */
  23320. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23321. }
  23322. }
  23323. declare module "babylonjs/Morph/morphTarget" {
  23324. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23325. import { Observable } from "babylonjs/Misc/observable";
  23326. import { Nullable, FloatArray } from "babylonjs/types";
  23327. import { Scene } from "babylonjs/scene";
  23328. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23329. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  23330. /**
  23331. * Defines a target to use with MorphTargetManager
  23332. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23333. */
  23334. export class MorphTarget implements IAnimatable {
  23335. /** defines the name of the target */
  23336. name: string;
  23337. /**
  23338. * Gets or sets the list of animations
  23339. */
  23340. animations: import("babylonjs/Animations/animation").Animation[];
  23341. private _scene;
  23342. private _positions;
  23343. private _normals;
  23344. private _tangents;
  23345. private _uvs;
  23346. private _influence;
  23347. private _uniqueId;
  23348. /**
  23349. * Observable raised when the influence changes
  23350. */
  23351. onInfluenceChanged: Observable<boolean>;
  23352. /** @hidden */
  23353. _onDataLayoutChanged: Observable<void>;
  23354. /**
  23355. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  23356. */
  23357. get influence(): number;
  23358. set influence(influence: number);
  23359. /**
  23360. * Gets or sets the id of the morph Target
  23361. */
  23362. id: string;
  23363. private _animationPropertiesOverride;
  23364. /**
  23365. * Gets or sets the animation properties override
  23366. */
  23367. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  23368. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  23369. /**
  23370. * Creates a new MorphTarget
  23371. * @param name defines the name of the target
  23372. * @param influence defines the influence to use
  23373. * @param scene defines the scene the morphtarget belongs to
  23374. */
  23375. constructor(
  23376. /** defines the name of the target */
  23377. name: string, influence?: number, scene?: Nullable<Scene>);
  23378. /**
  23379. * Gets the unique ID of this manager
  23380. */
  23381. get uniqueId(): number;
  23382. /**
  23383. * Gets a boolean defining if the target contains position data
  23384. */
  23385. get hasPositions(): boolean;
  23386. /**
  23387. * Gets a boolean defining if the target contains normal data
  23388. */
  23389. get hasNormals(): boolean;
  23390. /**
  23391. * Gets a boolean defining if the target contains tangent data
  23392. */
  23393. get hasTangents(): boolean;
  23394. /**
  23395. * Gets a boolean defining if the target contains texture coordinates data
  23396. */
  23397. get hasUVs(): boolean;
  23398. /**
  23399. * Affects position data to this target
  23400. * @param data defines the position data to use
  23401. */
  23402. setPositions(data: Nullable<FloatArray>): void;
  23403. /**
  23404. * Gets the position data stored in this target
  23405. * @returns a FloatArray containing the position data (or null if not present)
  23406. */
  23407. getPositions(): Nullable<FloatArray>;
  23408. /**
  23409. * Affects normal data to this target
  23410. * @param data defines the normal data to use
  23411. */
  23412. setNormals(data: Nullable<FloatArray>): void;
  23413. /**
  23414. * Gets the normal data stored in this target
  23415. * @returns a FloatArray containing the normal data (or null if not present)
  23416. */
  23417. getNormals(): Nullable<FloatArray>;
  23418. /**
  23419. * Affects tangent data to this target
  23420. * @param data defines the tangent data to use
  23421. */
  23422. setTangents(data: Nullable<FloatArray>): void;
  23423. /**
  23424. * Gets the tangent data stored in this target
  23425. * @returns a FloatArray containing the tangent data (or null if not present)
  23426. */
  23427. getTangents(): Nullable<FloatArray>;
  23428. /**
  23429. * Affects texture coordinates data to this target
  23430. * @param data defines the texture coordinates data to use
  23431. */
  23432. setUVs(data: Nullable<FloatArray>): void;
  23433. /**
  23434. * Gets the texture coordinates data stored in this target
  23435. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23436. */
  23437. getUVs(): Nullable<FloatArray>;
  23438. /**
  23439. * Clone the current target
  23440. * @returns a new MorphTarget
  23441. */
  23442. clone(): MorphTarget;
  23443. /**
  23444. * Serializes the current target into a Serialization object
  23445. * @returns the serialized object
  23446. */
  23447. serialize(): any;
  23448. /**
  23449. * Returns the string "MorphTarget"
  23450. * @returns "MorphTarget"
  23451. */
  23452. getClassName(): string;
  23453. /**
  23454. * Creates a new target from serialized data
  23455. * @param serializationObject defines the serialized data to use
  23456. * @returns a new MorphTarget
  23457. */
  23458. static Parse(serializationObject: any): MorphTarget;
  23459. /**
  23460. * Creates a MorphTarget from mesh data
  23461. * @param mesh defines the source mesh
  23462. * @param name defines the name to use for the new target
  23463. * @param influence defines the influence to attach to the target
  23464. * @returns a new MorphTarget
  23465. */
  23466. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23467. }
  23468. }
  23469. declare module "babylonjs/Morph/morphTargetManager" {
  23470. import { Nullable } from "babylonjs/types";
  23471. import { Scene } from "babylonjs/scene";
  23472. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  23473. /**
  23474. * This class is used to deform meshes using morphing between different targets
  23475. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23476. */
  23477. export class MorphTargetManager {
  23478. private _targets;
  23479. private _targetInfluenceChangedObservers;
  23480. private _targetDataLayoutChangedObservers;
  23481. private _activeTargets;
  23482. private _scene;
  23483. private _influences;
  23484. private _supportsNormals;
  23485. private _supportsTangents;
  23486. private _supportsUVs;
  23487. private _vertexCount;
  23488. private _uniqueId;
  23489. private _tempInfluences;
  23490. /**
  23491. * Gets or sets a boolean indicating if normals must be morphed
  23492. */
  23493. enableNormalMorphing: boolean;
  23494. /**
  23495. * Gets or sets a boolean indicating if tangents must be morphed
  23496. */
  23497. enableTangentMorphing: boolean;
  23498. /**
  23499. * Gets or sets a boolean indicating if UV must be morphed
  23500. */
  23501. enableUVMorphing: boolean;
  23502. /**
  23503. * Creates a new MorphTargetManager
  23504. * @param scene defines the current scene
  23505. */
  23506. constructor(scene?: Nullable<Scene>);
  23507. /**
  23508. * Gets the unique ID of this manager
  23509. */
  23510. get uniqueId(): number;
  23511. /**
  23512. * Gets the number of vertices handled by this manager
  23513. */
  23514. get vertexCount(): number;
  23515. /**
  23516. * Gets a boolean indicating if this manager supports morphing of normals
  23517. */
  23518. get supportsNormals(): boolean;
  23519. /**
  23520. * Gets a boolean indicating if this manager supports morphing of tangents
  23521. */
  23522. get supportsTangents(): boolean;
  23523. /**
  23524. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23525. */
  23526. get supportsUVs(): boolean;
  23527. /**
  23528. * Gets the number of targets stored in this manager
  23529. */
  23530. get numTargets(): number;
  23531. /**
  23532. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23533. */
  23534. get numInfluencers(): number;
  23535. /**
  23536. * Gets the list of influences (one per target)
  23537. */
  23538. get influences(): Float32Array;
  23539. /**
  23540. * Gets the active target at specified index. An active target is a target with an influence > 0
  23541. * @param index defines the index to check
  23542. * @returns the requested target
  23543. */
  23544. getActiveTarget(index: number): MorphTarget;
  23545. /**
  23546. * Gets the target at specified index
  23547. * @param index defines the index to check
  23548. * @returns the requested target
  23549. */
  23550. getTarget(index: number): MorphTarget;
  23551. /**
  23552. * Add a new target to this manager
  23553. * @param target defines the target to add
  23554. */
  23555. addTarget(target: MorphTarget): void;
  23556. /**
  23557. * Removes a target from the manager
  23558. * @param target defines the target to remove
  23559. */
  23560. removeTarget(target: MorphTarget): void;
  23561. /**
  23562. * Clone the current manager
  23563. * @returns a new MorphTargetManager
  23564. */
  23565. clone(): MorphTargetManager;
  23566. /**
  23567. * Serializes the current manager into a Serialization object
  23568. * @returns the serialized object
  23569. */
  23570. serialize(): any;
  23571. private _syncActiveTargets;
  23572. /**
  23573. * Syncrhonize the targets with all the meshes using this morph target manager
  23574. */
  23575. synchronize(): void;
  23576. /**
  23577. * Creates a new MorphTargetManager from serialized data
  23578. * @param serializationObject defines the serialized data
  23579. * @param scene defines the hosting scene
  23580. * @returns the new MorphTargetManager
  23581. */
  23582. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23583. }
  23584. }
  23585. declare module "babylonjs/Meshes/meshLODLevel" {
  23586. import { Mesh } from "babylonjs/Meshes/mesh";
  23587. import { Nullable } from "babylonjs/types";
  23588. /**
  23589. * Class used to represent a specific level of detail of a mesh
  23590. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23591. */
  23592. export class MeshLODLevel {
  23593. /** Defines the distance where this level should start being displayed */
  23594. distance: number;
  23595. /** Defines the mesh to use to render this level */
  23596. mesh: Nullable<Mesh>;
  23597. /**
  23598. * Creates a new LOD level
  23599. * @param distance defines the distance where this level should star being displayed
  23600. * @param mesh defines the mesh to use to render this level
  23601. */
  23602. constructor(
  23603. /** Defines the distance where this level should start being displayed */
  23604. distance: number,
  23605. /** Defines the mesh to use to render this level */
  23606. mesh: Nullable<Mesh>);
  23607. }
  23608. }
  23609. declare module "babylonjs/Meshes/groundMesh" {
  23610. import { Scene } from "babylonjs/scene";
  23611. import { Vector3 } from "babylonjs/Maths/math.vector";
  23612. import { Mesh } from "babylonjs/Meshes/mesh";
  23613. /**
  23614. * Mesh representing the gorund
  23615. */
  23616. export class GroundMesh extends Mesh {
  23617. /** If octree should be generated */
  23618. generateOctree: boolean;
  23619. private _heightQuads;
  23620. /** @hidden */
  23621. _subdivisionsX: number;
  23622. /** @hidden */
  23623. _subdivisionsY: number;
  23624. /** @hidden */
  23625. _width: number;
  23626. /** @hidden */
  23627. _height: number;
  23628. /** @hidden */
  23629. _minX: number;
  23630. /** @hidden */
  23631. _maxX: number;
  23632. /** @hidden */
  23633. _minZ: number;
  23634. /** @hidden */
  23635. _maxZ: number;
  23636. constructor(name: string, scene: Scene);
  23637. /**
  23638. * "GroundMesh"
  23639. * @returns "GroundMesh"
  23640. */
  23641. getClassName(): string;
  23642. /**
  23643. * The minimum of x and y subdivisions
  23644. */
  23645. get subdivisions(): number;
  23646. /**
  23647. * X subdivisions
  23648. */
  23649. get subdivisionsX(): number;
  23650. /**
  23651. * Y subdivisions
  23652. */
  23653. get subdivisionsY(): number;
  23654. /**
  23655. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23656. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23657. * @param chunksCount the number of subdivisions for x and y
  23658. * @param octreeBlocksSize (Default: 32)
  23659. */
  23660. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23661. /**
  23662. * Returns a height (y) value in the Worl system :
  23663. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23664. * @param x x coordinate
  23665. * @param z z coordinate
  23666. * @returns the ground y position if (x, z) are outside the ground surface.
  23667. */
  23668. getHeightAtCoordinates(x: number, z: number): number;
  23669. /**
  23670. * Returns a normalized vector (Vector3) orthogonal to the ground
  23671. * at the ground coordinates (x, z) expressed in the World system.
  23672. * @param x x coordinate
  23673. * @param z z coordinate
  23674. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23675. */
  23676. getNormalAtCoordinates(x: number, z: number): Vector3;
  23677. /**
  23678. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23679. * at the ground coordinates (x, z) expressed in the World system.
  23680. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23681. * @param x x coordinate
  23682. * @param z z coordinate
  23683. * @param ref vector to store the result
  23684. * @returns the GroundMesh.
  23685. */
  23686. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23687. /**
  23688. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23689. * if the ground has been updated.
  23690. * This can be used in the render loop.
  23691. * @returns the GroundMesh.
  23692. */
  23693. updateCoordinateHeights(): GroundMesh;
  23694. private _getFacetAt;
  23695. private _initHeightQuads;
  23696. private _computeHeightQuads;
  23697. /**
  23698. * Serializes this ground mesh
  23699. * @param serializationObject object to write serialization to
  23700. */
  23701. serialize(serializationObject: any): void;
  23702. /**
  23703. * Parses a serialized ground mesh
  23704. * @param parsedMesh the serialized mesh
  23705. * @param scene the scene to create the ground mesh in
  23706. * @returns the created ground mesh
  23707. */
  23708. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23709. }
  23710. }
  23711. declare module "babylonjs/Physics/physicsJoint" {
  23712. import { Vector3 } from "babylonjs/Maths/math.vector";
  23713. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23714. /**
  23715. * Interface for Physics-Joint data
  23716. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23717. */
  23718. export interface PhysicsJointData {
  23719. /**
  23720. * The main pivot of the joint
  23721. */
  23722. mainPivot?: Vector3;
  23723. /**
  23724. * The connected pivot of the joint
  23725. */
  23726. connectedPivot?: Vector3;
  23727. /**
  23728. * The main axis of the joint
  23729. */
  23730. mainAxis?: Vector3;
  23731. /**
  23732. * The connected axis of the joint
  23733. */
  23734. connectedAxis?: Vector3;
  23735. /**
  23736. * The collision of the joint
  23737. */
  23738. collision?: boolean;
  23739. /**
  23740. * Native Oimo/Cannon/Energy data
  23741. */
  23742. nativeParams?: any;
  23743. }
  23744. /**
  23745. * This is a holder class for the physics joint created by the physics plugin
  23746. * It holds a set of functions to control the underlying joint
  23747. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23748. */
  23749. export class PhysicsJoint {
  23750. /**
  23751. * The type of the physics joint
  23752. */
  23753. type: number;
  23754. /**
  23755. * The data for the physics joint
  23756. */
  23757. jointData: PhysicsJointData;
  23758. private _physicsJoint;
  23759. protected _physicsPlugin: IPhysicsEnginePlugin;
  23760. /**
  23761. * Initializes the physics joint
  23762. * @param type The type of the physics joint
  23763. * @param jointData The data for the physics joint
  23764. */
  23765. constructor(
  23766. /**
  23767. * The type of the physics joint
  23768. */
  23769. type: number,
  23770. /**
  23771. * The data for the physics joint
  23772. */
  23773. jointData: PhysicsJointData);
  23774. /**
  23775. * Gets the physics joint
  23776. */
  23777. get physicsJoint(): any;
  23778. /**
  23779. * Sets the physics joint
  23780. */
  23781. set physicsJoint(newJoint: any);
  23782. /**
  23783. * Sets the physics plugin
  23784. */
  23785. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23786. /**
  23787. * Execute a function that is physics-plugin specific.
  23788. * @param {Function} func the function that will be executed.
  23789. * It accepts two parameters: the physics world and the physics joint
  23790. */
  23791. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23792. /**
  23793. * Distance-Joint type
  23794. */
  23795. static DistanceJoint: number;
  23796. /**
  23797. * Hinge-Joint type
  23798. */
  23799. static HingeJoint: number;
  23800. /**
  23801. * Ball-and-Socket joint type
  23802. */
  23803. static BallAndSocketJoint: number;
  23804. /**
  23805. * Wheel-Joint type
  23806. */
  23807. static WheelJoint: number;
  23808. /**
  23809. * Slider-Joint type
  23810. */
  23811. static SliderJoint: number;
  23812. /**
  23813. * Prismatic-Joint type
  23814. */
  23815. static PrismaticJoint: number;
  23816. /**
  23817. * Universal-Joint type
  23818. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23819. */
  23820. static UniversalJoint: number;
  23821. /**
  23822. * Hinge-Joint 2 type
  23823. */
  23824. static Hinge2Joint: number;
  23825. /**
  23826. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23827. */
  23828. static PointToPointJoint: number;
  23829. /**
  23830. * Spring-Joint type
  23831. */
  23832. static SpringJoint: number;
  23833. /**
  23834. * Lock-Joint type
  23835. */
  23836. static LockJoint: number;
  23837. }
  23838. /**
  23839. * A class representing a physics distance joint
  23840. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23841. */
  23842. export class DistanceJoint extends PhysicsJoint {
  23843. /**
  23844. *
  23845. * @param jointData The data for the Distance-Joint
  23846. */
  23847. constructor(jointData: DistanceJointData);
  23848. /**
  23849. * Update the predefined distance.
  23850. * @param maxDistance The maximum preferred distance
  23851. * @param minDistance The minimum preferred distance
  23852. */
  23853. updateDistance(maxDistance: number, minDistance?: number): void;
  23854. }
  23855. /**
  23856. * Represents a Motor-Enabled Joint
  23857. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23858. */
  23859. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23860. /**
  23861. * Initializes the Motor-Enabled Joint
  23862. * @param type The type of the joint
  23863. * @param jointData The physica joint data for the joint
  23864. */
  23865. constructor(type: number, jointData: PhysicsJointData);
  23866. /**
  23867. * Set the motor values.
  23868. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23869. * @param force the force to apply
  23870. * @param maxForce max force for this motor.
  23871. */
  23872. setMotor(force?: number, maxForce?: number): void;
  23873. /**
  23874. * Set the motor's limits.
  23875. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23876. * @param upperLimit The upper limit of the motor
  23877. * @param lowerLimit The lower limit of the motor
  23878. */
  23879. setLimit(upperLimit: number, lowerLimit?: number): void;
  23880. }
  23881. /**
  23882. * This class represents a single physics Hinge-Joint
  23883. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23884. */
  23885. export class HingeJoint extends MotorEnabledJoint {
  23886. /**
  23887. * Initializes the Hinge-Joint
  23888. * @param jointData The joint data for the Hinge-Joint
  23889. */
  23890. constructor(jointData: PhysicsJointData);
  23891. /**
  23892. * Set the motor values.
  23893. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23894. * @param {number} force the force to apply
  23895. * @param {number} maxForce max force for this motor.
  23896. */
  23897. setMotor(force?: number, maxForce?: number): void;
  23898. /**
  23899. * Set the motor's limits.
  23900. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23901. * @param upperLimit The upper limit of the motor
  23902. * @param lowerLimit The lower limit of the motor
  23903. */
  23904. setLimit(upperLimit: number, lowerLimit?: number): void;
  23905. }
  23906. /**
  23907. * This class represents a dual hinge physics joint (same as wheel joint)
  23908. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23909. */
  23910. export class Hinge2Joint extends MotorEnabledJoint {
  23911. /**
  23912. * Initializes the Hinge2-Joint
  23913. * @param jointData The joint data for the Hinge2-Joint
  23914. */
  23915. constructor(jointData: PhysicsJointData);
  23916. /**
  23917. * Set the motor values.
  23918. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23919. * @param {number} targetSpeed the speed the motor is to reach
  23920. * @param {number} maxForce max force for this motor.
  23921. * @param {motorIndex} the motor's index, 0 or 1.
  23922. */
  23923. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23924. /**
  23925. * Set the motor limits.
  23926. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23927. * @param {number} upperLimit the upper limit
  23928. * @param {number} lowerLimit lower limit
  23929. * @param {motorIndex} the motor's index, 0 or 1.
  23930. */
  23931. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23932. }
  23933. /**
  23934. * Interface for a motor enabled joint
  23935. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23936. */
  23937. export interface IMotorEnabledJoint {
  23938. /**
  23939. * Physics joint
  23940. */
  23941. physicsJoint: any;
  23942. /**
  23943. * Sets the motor of the motor-enabled joint
  23944. * @param force The force of the motor
  23945. * @param maxForce The maximum force of the motor
  23946. * @param motorIndex The index of the motor
  23947. */
  23948. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23949. /**
  23950. * Sets the limit of the motor
  23951. * @param upperLimit The upper limit of the motor
  23952. * @param lowerLimit The lower limit of the motor
  23953. * @param motorIndex The index of the motor
  23954. */
  23955. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23956. }
  23957. /**
  23958. * Joint data for a Distance-Joint
  23959. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23960. */
  23961. export interface DistanceJointData extends PhysicsJointData {
  23962. /**
  23963. * Max distance the 2 joint objects can be apart
  23964. */
  23965. maxDistance: number;
  23966. }
  23967. /**
  23968. * Joint data from a spring joint
  23969. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23970. */
  23971. export interface SpringJointData extends PhysicsJointData {
  23972. /**
  23973. * Length of the spring
  23974. */
  23975. length: number;
  23976. /**
  23977. * Stiffness of the spring
  23978. */
  23979. stiffness: number;
  23980. /**
  23981. * Damping of the spring
  23982. */
  23983. damping: number;
  23984. /** this callback will be called when applying the force to the impostors. */
  23985. forceApplicationCallback: () => void;
  23986. }
  23987. }
  23988. declare module "babylonjs/Physics/physicsRaycastResult" {
  23989. import { Vector3 } from "babylonjs/Maths/math.vector";
  23990. /**
  23991. * Holds the data for the raycast result
  23992. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23993. */
  23994. export class PhysicsRaycastResult {
  23995. private _hasHit;
  23996. private _hitDistance;
  23997. private _hitNormalWorld;
  23998. private _hitPointWorld;
  23999. private _rayFromWorld;
  24000. private _rayToWorld;
  24001. /**
  24002. * Gets if there was a hit
  24003. */
  24004. get hasHit(): boolean;
  24005. /**
  24006. * Gets the distance from the hit
  24007. */
  24008. get hitDistance(): number;
  24009. /**
  24010. * Gets the hit normal/direction in the world
  24011. */
  24012. get hitNormalWorld(): Vector3;
  24013. /**
  24014. * Gets the hit point in the world
  24015. */
  24016. get hitPointWorld(): Vector3;
  24017. /**
  24018. * Gets the ray "start point" of the ray in the world
  24019. */
  24020. get rayFromWorld(): Vector3;
  24021. /**
  24022. * Gets the ray "end point" of the ray in the world
  24023. */
  24024. get rayToWorld(): Vector3;
  24025. /**
  24026. * Sets the hit data (normal & point in world space)
  24027. * @param hitNormalWorld defines the normal in world space
  24028. * @param hitPointWorld defines the point in world space
  24029. */
  24030. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  24031. /**
  24032. * Sets the distance from the start point to the hit point
  24033. * @param distance
  24034. */
  24035. setHitDistance(distance: number): void;
  24036. /**
  24037. * Calculates the distance manually
  24038. */
  24039. calculateHitDistance(): void;
  24040. /**
  24041. * Resets all the values to default
  24042. * @param from The from point on world space
  24043. * @param to The to point on world space
  24044. */
  24045. reset(from?: Vector3, to?: Vector3): void;
  24046. }
  24047. /**
  24048. * Interface for the size containing width and height
  24049. */
  24050. interface IXYZ {
  24051. /**
  24052. * X
  24053. */
  24054. x: number;
  24055. /**
  24056. * Y
  24057. */
  24058. y: number;
  24059. /**
  24060. * Z
  24061. */
  24062. z: number;
  24063. }
  24064. }
  24065. declare module "babylonjs/Physics/IPhysicsEngine" {
  24066. import { Nullable } from "babylonjs/types";
  24067. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  24068. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24069. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24070. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  24071. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  24072. /**
  24073. * Interface used to describe a physics joint
  24074. */
  24075. export interface PhysicsImpostorJoint {
  24076. /** Defines the main impostor to which the joint is linked */
  24077. mainImpostor: PhysicsImpostor;
  24078. /** Defines the impostor that is connected to the main impostor using this joint */
  24079. connectedImpostor: PhysicsImpostor;
  24080. /** Defines the joint itself */
  24081. joint: PhysicsJoint;
  24082. }
  24083. /** @hidden */
  24084. export interface IPhysicsEnginePlugin {
  24085. world: any;
  24086. name: string;
  24087. setGravity(gravity: Vector3): void;
  24088. setTimeStep(timeStep: number): void;
  24089. getTimeStep(): number;
  24090. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  24091. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24092. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24093. generatePhysicsBody(impostor: PhysicsImpostor): void;
  24094. removePhysicsBody(impostor: PhysicsImpostor): void;
  24095. generateJoint(joint: PhysicsImpostorJoint): void;
  24096. removeJoint(joint: PhysicsImpostorJoint): void;
  24097. isSupported(): boolean;
  24098. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  24099. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  24100. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24101. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24102. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24103. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24104. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  24105. getBodyMass(impostor: PhysicsImpostor): number;
  24106. getBodyFriction(impostor: PhysicsImpostor): number;
  24107. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  24108. getBodyRestitution(impostor: PhysicsImpostor): number;
  24109. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  24110. getBodyPressure?(impostor: PhysicsImpostor): number;
  24111. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  24112. getBodyStiffness?(impostor: PhysicsImpostor): number;
  24113. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  24114. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  24115. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  24116. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  24117. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  24118. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24119. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24120. sleepBody(impostor: PhysicsImpostor): void;
  24121. wakeUpBody(impostor: PhysicsImpostor): void;
  24122. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24123. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  24124. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  24125. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24126. getRadius(impostor: PhysicsImpostor): number;
  24127. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  24128. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  24129. dispose(): void;
  24130. }
  24131. /**
  24132. * Interface used to define a physics engine
  24133. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  24134. */
  24135. export interface IPhysicsEngine {
  24136. /**
  24137. * Gets the gravity vector used by the simulation
  24138. */
  24139. gravity: Vector3;
  24140. /**
  24141. * Sets the gravity vector used by the simulation
  24142. * @param gravity defines the gravity vector to use
  24143. */
  24144. setGravity(gravity: Vector3): void;
  24145. /**
  24146. * Set the time step of the physics engine.
  24147. * Default is 1/60.
  24148. * To slow it down, enter 1/600 for example.
  24149. * To speed it up, 1/30
  24150. * @param newTimeStep the new timestep to apply to this world.
  24151. */
  24152. setTimeStep(newTimeStep: number): void;
  24153. /**
  24154. * Get the time step of the physics engine.
  24155. * @returns the current time step
  24156. */
  24157. getTimeStep(): number;
  24158. /**
  24159. * Set the sub time step of the physics engine.
  24160. * Default is 0 meaning there is no sub steps
  24161. * To increase physics resolution precision, set a small value (like 1 ms)
  24162. * @param subTimeStep defines the new sub timestep used for physics resolution.
  24163. */
  24164. setSubTimeStep(subTimeStep: number): void;
  24165. /**
  24166. * Get the sub time step of the physics engine.
  24167. * @returns the current sub time step
  24168. */
  24169. getSubTimeStep(): number;
  24170. /**
  24171. * Release all resources
  24172. */
  24173. dispose(): void;
  24174. /**
  24175. * Gets the name of the current physics plugin
  24176. * @returns the name of the plugin
  24177. */
  24178. getPhysicsPluginName(): string;
  24179. /**
  24180. * Adding a new impostor for the impostor tracking.
  24181. * This will be done by the impostor itself.
  24182. * @param impostor the impostor to add
  24183. */
  24184. addImpostor(impostor: PhysicsImpostor): void;
  24185. /**
  24186. * Remove an impostor from the engine.
  24187. * This impostor and its mesh will not longer be updated by the physics engine.
  24188. * @param impostor the impostor to remove
  24189. */
  24190. removeImpostor(impostor: PhysicsImpostor): void;
  24191. /**
  24192. * Add a joint to the physics engine
  24193. * @param mainImpostor defines the main impostor to which the joint is added.
  24194. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  24195. * @param joint defines the joint that will connect both impostors.
  24196. */
  24197. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24198. /**
  24199. * Removes a joint from the simulation
  24200. * @param mainImpostor defines the impostor used with the joint
  24201. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  24202. * @param joint defines the joint to remove
  24203. */
  24204. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24205. /**
  24206. * Gets the current plugin used to run the simulation
  24207. * @returns current plugin
  24208. */
  24209. getPhysicsPlugin(): IPhysicsEnginePlugin;
  24210. /**
  24211. * Gets the list of physic impostors
  24212. * @returns an array of PhysicsImpostor
  24213. */
  24214. getImpostors(): Array<PhysicsImpostor>;
  24215. /**
  24216. * Gets the impostor for a physics enabled object
  24217. * @param object defines the object impersonated by the impostor
  24218. * @returns the PhysicsImpostor or null if not found
  24219. */
  24220. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24221. /**
  24222. * Gets the impostor for a physics body object
  24223. * @param body defines physics body used by the impostor
  24224. * @returns the PhysicsImpostor or null if not found
  24225. */
  24226. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  24227. /**
  24228. * Does a raycast in the physics world
  24229. * @param from when should the ray start?
  24230. * @param to when should the ray end?
  24231. * @returns PhysicsRaycastResult
  24232. */
  24233. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24234. /**
  24235. * Called by the scene. No need to call it.
  24236. * @param delta defines the timespam between frames
  24237. */
  24238. _step(delta: number): void;
  24239. }
  24240. }
  24241. declare module "babylonjs/Physics/physicsImpostor" {
  24242. import { Nullable, IndicesArray } from "babylonjs/types";
  24243. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  24244. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24245. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24246. import { Scene } from "babylonjs/scene";
  24247. import { Bone } from "babylonjs/Bones/bone";
  24248. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24249. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  24250. import { Space } from "babylonjs/Maths/math.axis";
  24251. /**
  24252. * The interface for the physics imposter parameters
  24253. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24254. */
  24255. export interface PhysicsImpostorParameters {
  24256. /**
  24257. * The mass of the physics imposter
  24258. */
  24259. mass: number;
  24260. /**
  24261. * The friction of the physics imposter
  24262. */
  24263. friction?: number;
  24264. /**
  24265. * The coefficient of restitution of the physics imposter
  24266. */
  24267. restitution?: number;
  24268. /**
  24269. * The native options of the physics imposter
  24270. */
  24271. nativeOptions?: any;
  24272. /**
  24273. * Specifies if the parent should be ignored
  24274. */
  24275. ignoreParent?: boolean;
  24276. /**
  24277. * Specifies if bi-directional transformations should be disabled
  24278. */
  24279. disableBidirectionalTransformation?: boolean;
  24280. /**
  24281. * The pressure inside the physics imposter, soft object only
  24282. */
  24283. pressure?: number;
  24284. /**
  24285. * The stiffness the physics imposter, soft object only
  24286. */
  24287. stiffness?: number;
  24288. /**
  24289. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  24290. */
  24291. velocityIterations?: number;
  24292. /**
  24293. * The number of iterations used in maintaining consistent vertex positions, soft object only
  24294. */
  24295. positionIterations?: number;
  24296. /**
  24297. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  24298. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  24299. * Add to fix multiple points
  24300. */
  24301. fixedPoints?: number;
  24302. /**
  24303. * The collision margin around a soft object
  24304. */
  24305. margin?: number;
  24306. /**
  24307. * The collision margin around a soft object
  24308. */
  24309. damping?: number;
  24310. /**
  24311. * The path for a rope based on an extrusion
  24312. */
  24313. path?: any;
  24314. /**
  24315. * The shape of an extrusion used for a rope based on an extrusion
  24316. */
  24317. shape?: any;
  24318. }
  24319. /**
  24320. * Interface for a physics-enabled object
  24321. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24322. */
  24323. export interface IPhysicsEnabledObject {
  24324. /**
  24325. * The position of the physics-enabled object
  24326. */
  24327. position: Vector3;
  24328. /**
  24329. * The rotation of the physics-enabled object
  24330. */
  24331. rotationQuaternion: Nullable<Quaternion>;
  24332. /**
  24333. * The scale of the physics-enabled object
  24334. */
  24335. scaling: Vector3;
  24336. /**
  24337. * The rotation of the physics-enabled object
  24338. */
  24339. rotation?: Vector3;
  24340. /**
  24341. * The parent of the physics-enabled object
  24342. */
  24343. parent?: any;
  24344. /**
  24345. * The bounding info of the physics-enabled object
  24346. * @returns The bounding info of the physics-enabled object
  24347. */
  24348. getBoundingInfo(): BoundingInfo;
  24349. /**
  24350. * Computes the world matrix
  24351. * @param force Specifies if the world matrix should be computed by force
  24352. * @returns A world matrix
  24353. */
  24354. computeWorldMatrix(force: boolean): Matrix;
  24355. /**
  24356. * Gets the world matrix
  24357. * @returns A world matrix
  24358. */
  24359. getWorldMatrix?(): Matrix;
  24360. /**
  24361. * Gets the child meshes
  24362. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  24363. * @returns An array of abstract meshes
  24364. */
  24365. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24366. /**
  24367. * Gets the vertex data
  24368. * @param kind The type of vertex data
  24369. * @returns A nullable array of numbers, or a float32 array
  24370. */
  24371. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24372. /**
  24373. * Gets the indices from the mesh
  24374. * @returns A nullable array of index arrays
  24375. */
  24376. getIndices?(): Nullable<IndicesArray>;
  24377. /**
  24378. * Gets the scene from the mesh
  24379. * @returns the indices array or null
  24380. */
  24381. getScene?(): Scene;
  24382. /**
  24383. * Gets the absolute position from the mesh
  24384. * @returns the absolute position
  24385. */
  24386. getAbsolutePosition(): Vector3;
  24387. /**
  24388. * Gets the absolute pivot point from the mesh
  24389. * @returns the absolute pivot point
  24390. */
  24391. getAbsolutePivotPoint(): Vector3;
  24392. /**
  24393. * Rotates the mesh
  24394. * @param axis The axis of rotation
  24395. * @param amount The amount of rotation
  24396. * @param space The space of the rotation
  24397. * @returns The rotation transform node
  24398. */
  24399. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24400. /**
  24401. * Translates the mesh
  24402. * @param axis The axis of translation
  24403. * @param distance The distance of translation
  24404. * @param space The space of the translation
  24405. * @returns The transform node
  24406. */
  24407. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24408. /**
  24409. * Sets the absolute position of the mesh
  24410. * @param absolutePosition The absolute position of the mesh
  24411. * @returns The transform node
  24412. */
  24413. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24414. /**
  24415. * Gets the class name of the mesh
  24416. * @returns The class name
  24417. */
  24418. getClassName(): string;
  24419. }
  24420. /**
  24421. * Represents a physics imposter
  24422. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24423. */
  24424. export class PhysicsImpostor {
  24425. /**
  24426. * The physics-enabled object used as the physics imposter
  24427. */
  24428. object: IPhysicsEnabledObject;
  24429. /**
  24430. * The type of the physics imposter
  24431. */
  24432. type: number;
  24433. private _options;
  24434. private _scene?;
  24435. /**
  24436. * The default object size of the imposter
  24437. */
  24438. static DEFAULT_OBJECT_SIZE: Vector3;
  24439. /**
  24440. * The identity quaternion of the imposter
  24441. */
  24442. static IDENTITY_QUATERNION: Quaternion;
  24443. /** @hidden */
  24444. _pluginData: any;
  24445. private _physicsEngine;
  24446. private _physicsBody;
  24447. private _bodyUpdateRequired;
  24448. private _onBeforePhysicsStepCallbacks;
  24449. private _onAfterPhysicsStepCallbacks;
  24450. /** @hidden */
  24451. _onPhysicsCollideCallbacks: Array<{
  24452. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24453. otherImpostors: Array<PhysicsImpostor>;
  24454. }>;
  24455. private _deltaPosition;
  24456. private _deltaRotation;
  24457. private _deltaRotationConjugated;
  24458. /** @hidden */
  24459. _isFromLine: boolean;
  24460. private _parent;
  24461. private _isDisposed;
  24462. private static _tmpVecs;
  24463. private static _tmpQuat;
  24464. /**
  24465. * Specifies if the physics imposter is disposed
  24466. */
  24467. get isDisposed(): boolean;
  24468. /**
  24469. * Gets the mass of the physics imposter
  24470. */
  24471. get mass(): number;
  24472. set mass(value: number);
  24473. /**
  24474. * Gets the coefficient of friction
  24475. */
  24476. get friction(): number;
  24477. /**
  24478. * Sets the coefficient of friction
  24479. */
  24480. set friction(value: number);
  24481. /**
  24482. * Gets the coefficient of restitution
  24483. */
  24484. get restitution(): number;
  24485. /**
  24486. * Sets the coefficient of restitution
  24487. */
  24488. set restitution(value: number);
  24489. /**
  24490. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24491. */
  24492. get pressure(): number;
  24493. /**
  24494. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24495. */
  24496. set pressure(value: number);
  24497. /**
  24498. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24499. */
  24500. get stiffness(): number;
  24501. /**
  24502. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24503. */
  24504. set stiffness(value: number);
  24505. /**
  24506. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24507. */
  24508. get velocityIterations(): number;
  24509. /**
  24510. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24511. */
  24512. set velocityIterations(value: number);
  24513. /**
  24514. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24515. */
  24516. get positionIterations(): number;
  24517. /**
  24518. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24519. */
  24520. set positionIterations(value: number);
  24521. /**
  24522. * The unique id of the physics imposter
  24523. * set by the physics engine when adding this impostor to the array
  24524. */
  24525. uniqueId: number;
  24526. /**
  24527. * @hidden
  24528. */
  24529. soft: boolean;
  24530. /**
  24531. * @hidden
  24532. */
  24533. segments: number;
  24534. private _joints;
  24535. /**
  24536. * Initializes the physics imposter
  24537. * @param object The physics-enabled object used as the physics imposter
  24538. * @param type The type of the physics imposter
  24539. * @param _options The options for the physics imposter
  24540. * @param _scene The Babylon scene
  24541. */
  24542. constructor(
  24543. /**
  24544. * The physics-enabled object used as the physics imposter
  24545. */
  24546. object: IPhysicsEnabledObject,
  24547. /**
  24548. * The type of the physics imposter
  24549. */
  24550. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24551. /**
  24552. * This function will completly initialize this impostor.
  24553. * It will create a new body - but only if this mesh has no parent.
  24554. * If it has, this impostor will not be used other than to define the impostor
  24555. * of the child mesh.
  24556. * @hidden
  24557. */
  24558. _init(): void;
  24559. private _getPhysicsParent;
  24560. /**
  24561. * Should a new body be generated.
  24562. * @returns boolean specifying if body initialization is required
  24563. */
  24564. isBodyInitRequired(): boolean;
  24565. /**
  24566. * Sets the updated scaling
  24567. * @param updated Specifies if the scaling is updated
  24568. */
  24569. setScalingUpdated(): void;
  24570. /**
  24571. * Force a regeneration of this or the parent's impostor's body.
  24572. * Use under cautious - This will remove all joints already implemented.
  24573. */
  24574. forceUpdate(): void;
  24575. /**
  24576. * Gets the body that holds this impostor. Either its own, or its parent.
  24577. */
  24578. get physicsBody(): any;
  24579. /**
  24580. * Get the parent of the physics imposter
  24581. * @returns Physics imposter or null
  24582. */
  24583. get parent(): Nullable<PhysicsImpostor>;
  24584. /**
  24585. * Sets the parent of the physics imposter
  24586. */
  24587. set parent(value: Nullable<PhysicsImpostor>);
  24588. /**
  24589. * Set the physics body. Used mainly by the physics engine/plugin
  24590. */
  24591. set physicsBody(physicsBody: any);
  24592. /**
  24593. * Resets the update flags
  24594. */
  24595. resetUpdateFlags(): void;
  24596. /**
  24597. * Gets the object extend size
  24598. * @returns the object extend size
  24599. */
  24600. getObjectExtendSize(): Vector3;
  24601. /**
  24602. * Gets the object center
  24603. * @returns The object center
  24604. */
  24605. getObjectCenter(): Vector3;
  24606. /**
  24607. * Get a specific parameter from the options parameters
  24608. * @param paramName The object parameter name
  24609. * @returns The object parameter
  24610. */
  24611. getParam(paramName: string): any;
  24612. /**
  24613. * Sets a specific parameter in the options given to the physics plugin
  24614. * @param paramName The parameter name
  24615. * @param value The value of the parameter
  24616. */
  24617. setParam(paramName: string, value: number): void;
  24618. /**
  24619. * Specifically change the body's mass option. Won't recreate the physics body object
  24620. * @param mass The mass of the physics imposter
  24621. */
  24622. setMass(mass: number): void;
  24623. /**
  24624. * Gets the linear velocity
  24625. * @returns linear velocity or null
  24626. */
  24627. getLinearVelocity(): Nullable<Vector3>;
  24628. /**
  24629. * Sets the linear velocity
  24630. * @param velocity linear velocity or null
  24631. */
  24632. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24633. /**
  24634. * Gets the angular velocity
  24635. * @returns angular velocity or null
  24636. */
  24637. getAngularVelocity(): Nullable<Vector3>;
  24638. /**
  24639. * Sets the angular velocity
  24640. * @param velocity The velocity or null
  24641. */
  24642. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24643. /**
  24644. * Execute a function with the physics plugin native code
  24645. * Provide a function the will have two variables - the world object and the physics body object
  24646. * @param func The function to execute with the physics plugin native code
  24647. */
  24648. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24649. /**
  24650. * Register a function that will be executed before the physics world is stepping forward
  24651. * @param func The function to execute before the physics world is stepped forward
  24652. */
  24653. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24654. /**
  24655. * Unregister a function that will be executed before the physics world is stepping forward
  24656. * @param func The function to execute before the physics world is stepped forward
  24657. */
  24658. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24659. /**
  24660. * Register a function that will be executed after the physics step
  24661. * @param func The function to execute after physics step
  24662. */
  24663. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24664. /**
  24665. * Unregisters a function that will be executed after the physics step
  24666. * @param func The function to execute after physics step
  24667. */
  24668. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24669. /**
  24670. * register a function that will be executed when this impostor collides against a different body
  24671. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24672. * @param func Callback that is executed on collision
  24673. */
  24674. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24675. /**
  24676. * Unregisters the physics imposter on contact
  24677. * @param collideAgainst The physics object to collide against
  24678. * @param func Callback to execute on collision
  24679. */
  24680. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24681. private _tmpQuat;
  24682. private _tmpQuat2;
  24683. /**
  24684. * Get the parent rotation
  24685. * @returns The parent rotation
  24686. */
  24687. getParentsRotation(): Quaternion;
  24688. /**
  24689. * this function is executed by the physics engine.
  24690. */
  24691. beforeStep: () => void;
  24692. /**
  24693. * this function is executed by the physics engine
  24694. */
  24695. afterStep: () => void;
  24696. /**
  24697. * Legacy collision detection event support
  24698. */
  24699. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24700. /**
  24701. * event and body object due to cannon's event-based architecture.
  24702. */
  24703. onCollide: (e: {
  24704. body: any;
  24705. }) => void;
  24706. /**
  24707. * Apply a force
  24708. * @param force The force to apply
  24709. * @param contactPoint The contact point for the force
  24710. * @returns The physics imposter
  24711. */
  24712. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24713. /**
  24714. * Apply an impulse
  24715. * @param force The impulse force
  24716. * @param contactPoint The contact point for the impulse force
  24717. * @returns The physics imposter
  24718. */
  24719. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24720. /**
  24721. * A help function to create a joint
  24722. * @param otherImpostor A physics imposter used to create a joint
  24723. * @param jointType The type of joint
  24724. * @param jointData The data for the joint
  24725. * @returns The physics imposter
  24726. */
  24727. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24728. /**
  24729. * Add a joint to this impostor with a different impostor
  24730. * @param otherImpostor A physics imposter used to add a joint
  24731. * @param joint The joint to add
  24732. * @returns The physics imposter
  24733. */
  24734. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24735. /**
  24736. * Add an anchor to a cloth impostor
  24737. * @param otherImpostor rigid impostor to anchor to
  24738. * @param width ratio across width from 0 to 1
  24739. * @param height ratio up height from 0 to 1
  24740. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24741. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24742. * @returns impostor the soft imposter
  24743. */
  24744. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24745. /**
  24746. * Add a hook to a rope impostor
  24747. * @param otherImpostor rigid impostor to anchor to
  24748. * @param length ratio across rope from 0 to 1
  24749. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24750. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24751. * @returns impostor the rope imposter
  24752. */
  24753. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24754. /**
  24755. * Will keep this body still, in a sleep mode.
  24756. * @returns the physics imposter
  24757. */
  24758. sleep(): PhysicsImpostor;
  24759. /**
  24760. * Wake the body up.
  24761. * @returns The physics imposter
  24762. */
  24763. wakeUp(): PhysicsImpostor;
  24764. /**
  24765. * Clones the physics imposter
  24766. * @param newObject The physics imposter clones to this physics-enabled object
  24767. * @returns A nullable physics imposter
  24768. */
  24769. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24770. /**
  24771. * Disposes the physics imposter
  24772. */
  24773. dispose(): void;
  24774. /**
  24775. * Sets the delta position
  24776. * @param position The delta position amount
  24777. */
  24778. setDeltaPosition(position: Vector3): void;
  24779. /**
  24780. * Sets the delta rotation
  24781. * @param rotation The delta rotation amount
  24782. */
  24783. setDeltaRotation(rotation: Quaternion): void;
  24784. /**
  24785. * Gets the box size of the physics imposter and stores the result in the input parameter
  24786. * @param result Stores the box size
  24787. * @returns The physics imposter
  24788. */
  24789. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24790. /**
  24791. * Gets the radius of the physics imposter
  24792. * @returns Radius of the physics imposter
  24793. */
  24794. getRadius(): number;
  24795. /**
  24796. * Sync a bone with this impostor
  24797. * @param bone The bone to sync to the impostor.
  24798. * @param boneMesh The mesh that the bone is influencing.
  24799. * @param jointPivot The pivot of the joint / bone in local space.
  24800. * @param distToJoint Optional distance from the impostor to the joint.
  24801. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24802. */
  24803. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24804. /**
  24805. * Sync impostor to a bone
  24806. * @param bone The bone that the impostor will be synced to.
  24807. * @param boneMesh The mesh that the bone is influencing.
  24808. * @param jointPivot The pivot of the joint / bone in local space.
  24809. * @param distToJoint Optional distance from the impostor to the joint.
  24810. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24811. * @param boneAxis Optional vector3 axis the bone is aligned with
  24812. */
  24813. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24814. /**
  24815. * No-Imposter type
  24816. */
  24817. static NoImpostor: number;
  24818. /**
  24819. * Sphere-Imposter type
  24820. */
  24821. static SphereImpostor: number;
  24822. /**
  24823. * Box-Imposter type
  24824. */
  24825. static BoxImpostor: number;
  24826. /**
  24827. * Plane-Imposter type
  24828. */
  24829. static PlaneImpostor: number;
  24830. /**
  24831. * Mesh-imposter type
  24832. */
  24833. static MeshImpostor: number;
  24834. /**
  24835. * Capsule-Impostor type (Ammo.js plugin only)
  24836. */
  24837. static CapsuleImpostor: number;
  24838. /**
  24839. * Cylinder-Imposter type
  24840. */
  24841. static CylinderImpostor: number;
  24842. /**
  24843. * Particle-Imposter type
  24844. */
  24845. static ParticleImpostor: number;
  24846. /**
  24847. * Heightmap-Imposter type
  24848. */
  24849. static HeightmapImpostor: number;
  24850. /**
  24851. * ConvexHull-Impostor type (Ammo.js plugin only)
  24852. */
  24853. static ConvexHullImpostor: number;
  24854. /**
  24855. * Custom-Imposter type (Ammo.js plugin only)
  24856. */
  24857. static CustomImpostor: number;
  24858. /**
  24859. * Rope-Imposter type
  24860. */
  24861. static RopeImpostor: number;
  24862. /**
  24863. * Cloth-Imposter type
  24864. */
  24865. static ClothImpostor: number;
  24866. /**
  24867. * Softbody-Imposter type
  24868. */
  24869. static SoftbodyImpostor: number;
  24870. }
  24871. }
  24872. declare module "babylonjs/Meshes/mesh" {
  24873. import { Observable } from "babylonjs/Misc/observable";
  24874. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24875. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24876. import { Camera } from "babylonjs/Cameras/camera";
  24877. import { Scene } from "babylonjs/scene";
  24878. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24879. import { Color4 } from "babylonjs/Maths/math.color";
  24880. import { Engine } from "babylonjs/Engines/engine";
  24881. import { Node } from "babylonjs/node";
  24882. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24883. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24884. import { Buffer } from "babylonjs/Meshes/buffer";
  24885. import { Geometry } from "babylonjs/Meshes/geometry";
  24886. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24887. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24888. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24889. import { Effect } from "babylonjs/Materials/effect";
  24890. import { Material } from "babylonjs/Materials/material";
  24891. import { Skeleton } from "babylonjs/Bones/skeleton";
  24892. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24893. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24894. import { Path3D } from "babylonjs/Maths/math.path";
  24895. import { Plane } from "babylonjs/Maths/math.plane";
  24896. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24897. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24898. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24899. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24900. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24901. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24902. /**
  24903. * @hidden
  24904. **/
  24905. export class _CreationDataStorage {
  24906. closePath?: boolean;
  24907. closeArray?: boolean;
  24908. idx: number[];
  24909. dashSize: number;
  24910. gapSize: number;
  24911. path3D: Path3D;
  24912. pathArray: Vector3[][];
  24913. arc: number;
  24914. radius: number;
  24915. cap: number;
  24916. tessellation: number;
  24917. }
  24918. /**
  24919. * @hidden
  24920. **/
  24921. class _InstanceDataStorage {
  24922. visibleInstances: any;
  24923. batchCache: _InstancesBatch;
  24924. instancesBufferSize: number;
  24925. instancesBuffer: Nullable<Buffer>;
  24926. instancesData: Float32Array;
  24927. overridenInstanceCount: number;
  24928. isFrozen: boolean;
  24929. previousBatch: Nullable<_InstancesBatch>;
  24930. hardwareInstancedRendering: boolean;
  24931. sideOrientation: number;
  24932. manualUpdate: boolean;
  24933. }
  24934. /**
  24935. * @hidden
  24936. **/
  24937. export class _InstancesBatch {
  24938. mustReturn: boolean;
  24939. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24940. renderSelf: boolean[];
  24941. hardwareInstancedRendering: boolean[];
  24942. }
  24943. /**
  24944. * Class used to represent renderable models
  24945. */
  24946. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24947. /**
  24948. * Mesh side orientation : usually the external or front surface
  24949. */
  24950. static readonly FRONTSIDE: number;
  24951. /**
  24952. * Mesh side orientation : usually the internal or back surface
  24953. */
  24954. static readonly BACKSIDE: number;
  24955. /**
  24956. * Mesh side orientation : both internal and external or front and back surfaces
  24957. */
  24958. static readonly DOUBLESIDE: number;
  24959. /**
  24960. * Mesh side orientation : by default, `FRONTSIDE`
  24961. */
  24962. static readonly DEFAULTSIDE: number;
  24963. /**
  24964. * Mesh cap setting : no cap
  24965. */
  24966. static readonly NO_CAP: number;
  24967. /**
  24968. * Mesh cap setting : one cap at the beginning of the mesh
  24969. */
  24970. static readonly CAP_START: number;
  24971. /**
  24972. * Mesh cap setting : one cap at the end of the mesh
  24973. */
  24974. static readonly CAP_END: number;
  24975. /**
  24976. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24977. */
  24978. static readonly CAP_ALL: number;
  24979. /**
  24980. * Mesh pattern setting : no flip or rotate
  24981. */
  24982. static readonly NO_FLIP: number;
  24983. /**
  24984. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24985. */
  24986. static readonly FLIP_TILE: number;
  24987. /**
  24988. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24989. */
  24990. static readonly ROTATE_TILE: number;
  24991. /**
  24992. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24993. */
  24994. static readonly FLIP_ROW: number;
  24995. /**
  24996. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24997. */
  24998. static readonly ROTATE_ROW: number;
  24999. /**
  25000. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  25001. */
  25002. static readonly FLIP_N_ROTATE_TILE: number;
  25003. /**
  25004. * Mesh pattern setting : rotate pattern and rotate
  25005. */
  25006. static readonly FLIP_N_ROTATE_ROW: number;
  25007. /**
  25008. * Mesh tile positioning : part tiles same on left/right or top/bottom
  25009. */
  25010. static readonly CENTER: number;
  25011. /**
  25012. * Mesh tile positioning : part tiles on left
  25013. */
  25014. static readonly LEFT: number;
  25015. /**
  25016. * Mesh tile positioning : part tiles on right
  25017. */
  25018. static readonly RIGHT: number;
  25019. /**
  25020. * Mesh tile positioning : part tiles on top
  25021. */
  25022. static readonly TOP: number;
  25023. /**
  25024. * Mesh tile positioning : part tiles on bottom
  25025. */
  25026. static readonly BOTTOM: number;
  25027. /**
  25028. * Gets the default side orientation.
  25029. * @param orientation the orientation to value to attempt to get
  25030. * @returns the default orientation
  25031. * @hidden
  25032. */
  25033. static _GetDefaultSideOrientation(orientation?: number): number;
  25034. private _internalMeshDataInfo;
  25035. /**
  25036. * An event triggered before rendering the mesh
  25037. */
  25038. get onBeforeRenderObservable(): Observable<Mesh>;
  25039. /**
  25040. * An event triggered before binding the mesh
  25041. */
  25042. get onBeforeBindObservable(): Observable<Mesh>;
  25043. /**
  25044. * An event triggered after rendering the mesh
  25045. */
  25046. get onAfterRenderObservable(): Observable<Mesh>;
  25047. /**
  25048. * An event triggered before drawing the mesh
  25049. */
  25050. get onBeforeDrawObservable(): Observable<Mesh>;
  25051. private _onBeforeDrawObserver;
  25052. /**
  25053. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  25054. */
  25055. set onBeforeDraw(callback: () => void);
  25056. get hasInstances(): boolean;
  25057. /**
  25058. * Gets the delay loading state of the mesh (when delay loading is turned on)
  25059. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  25060. */
  25061. delayLoadState: number;
  25062. /**
  25063. * Gets the list of instances created from this mesh
  25064. * it is not supposed to be modified manually.
  25065. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  25066. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25067. */
  25068. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  25069. /**
  25070. * Gets the file containing delay loading data for this mesh
  25071. */
  25072. delayLoadingFile: string;
  25073. /** @hidden */
  25074. _binaryInfo: any;
  25075. /**
  25076. * User defined function used to change how LOD level selection is done
  25077. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  25078. */
  25079. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  25080. /**
  25081. * Gets or sets the morph target manager
  25082. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25083. */
  25084. get morphTargetManager(): Nullable<MorphTargetManager>;
  25085. set morphTargetManager(value: Nullable<MorphTargetManager>);
  25086. /** @hidden */
  25087. _creationDataStorage: Nullable<_CreationDataStorage>;
  25088. /** @hidden */
  25089. _geometry: Nullable<Geometry>;
  25090. /** @hidden */
  25091. _delayInfo: Array<string>;
  25092. /** @hidden */
  25093. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  25094. /** @hidden */
  25095. _instanceDataStorage: _InstanceDataStorage;
  25096. private _effectiveMaterial;
  25097. /** @hidden */
  25098. _shouldGenerateFlatShading: boolean;
  25099. /** @hidden */
  25100. _originalBuilderSideOrientation: number;
  25101. /**
  25102. * Use this property to change the original side orientation defined at construction time
  25103. */
  25104. overrideMaterialSideOrientation: Nullable<number>;
  25105. /**
  25106. * Gets the source mesh (the one used to clone this one from)
  25107. */
  25108. get source(): Nullable<Mesh>;
  25109. /**
  25110. * Gets or sets a boolean indicating that this mesh does not use index buffer
  25111. */
  25112. get isUnIndexed(): boolean;
  25113. set isUnIndexed(value: boolean);
  25114. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  25115. get worldMatrixInstancedBuffer(): Float32Array;
  25116. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  25117. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  25118. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  25119. /**
  25120. * @constructor
  25121. * @param name The value used by scene.getMeshByName() to do a lookup.
  25122. * @param scene The scene to add this mesh to.
  25123. * @param parent The parent of this mesh, if it has one
  25124. * @param source An optional Mesh from which geometry is shared, cloned.
  25125. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  25126. * When false, achieved by calling a clone(), also passing False.
  25127. * This will make creation of children, recursive.
  25128. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  25129. */
  25130. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  25131. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  25132. doNotInstantiate: boolean;
  25133. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  25134. /**
  25135. * Gets the class name
  25136. * @returns the string "Mesh".
  25137. */
  25138. getClassName(): string;
  25139. /** @hidden */
  25140. get _isMesh(): boolean;
  25141. /**
  25142. * Returns a description of this mesh
  25143. * @param fullDetails define if full details about this mesh must be used
  25144. * @returns a descriptive string representing this mesh
  25145. */
  25146. toString(fullDetails?: boolean): string;
  25147. /** @hidden */
  25148. _unBindEffect(): void;
  25149. /**
  25150. * Gets a boolean indicating if this mesh has LOD
  25151. */
  25152. get hasLODLevels(): boolean;
  25153. /**
  25154. * Gets the list of MeshLODLevel associated with the current mesh
  25155. * @returns an array of MeshLODLevel
  25156. */
  25157. getLODLevels(): MeshLODLevel[];
  25158. private _sortLODLevels;
  25159. /**
  25160. * Add a mesh as LOD level triggered at the given distance.
  25161. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25162. * @param distance The distance from the center of the object to show this level
  25163. * @param mesh The mesh to be added as LOD level (can be null)
  25164. * @return This mesh (for chaining)
  25165. */
  25166. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  25167. /**
  25168. * Returns the LOD level mesh at the passed distance or null if not found.
  25169. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25170. * @param distance The distance from the center of the object to show this level
  25171. * @returns a Mesh or `null`
  25172. */
  25173. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  25174. /**
  25175. * Remove a mesh from the LOD array
  25176. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25177. * @param mesh defines the mesh to be removed
  25178. * @return This mesh (for chaining)
  25179. */
  25180. removeLODLevel(mesh: Mesh): Mesh;
  25181. /**
  25182. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  25183. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25184. * @param camera defines the camera to use to compute distance
  25185. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  25186. * @return This mesh (for chaining)
  25187. */
  25188. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  25189. /**
  25190. * Gets the mesh internal Geometry object
  25191. */
  25192. get geometry(): Nullable<Geometry>;
  25193. /**
  25194. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  25195. * @returns the total number of vertices
  25196. */
  25197. getTotalVertices(): number;
  25198. /**
  25199. * Returns the content of an associated vertex buffer
  25200. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25201. * - VertexBuffer.PositionKind
  25202. * - VertexBuffer.UVKind
  25203. * - VertexBuffer.UV2Kind
  25204. * - VertexBuffer.UV3Kind
  25205. * - VertexBuffer.UV4Kind
  25206. * - VertexBuffer.UV5Kind
  25207. * - VertexBuffer.UV6Kind
  25208. * - VertexBuffer.ColorKind
  25209. * - VertexBuffer.MatricesIndicesKind
  25210. * - VertexBuffer.MatricesIndicesExtraKind
  25211. * - VertexBuffer.MatricesWeightsKind
  25212. * - VertexBuffer.MatricesWeightsExtraKind
  25213. * @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
  25214. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  25215. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  25216. */
  25217. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25218. /**
  25219. * Returns the mesh VertexBuffer object from the requested `kind`
  25220. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25221. * - VertexBuffer.PositionKind
  25222. * - VertexBuffer.NormalKind
  25223. * - VertexBuffer.UVKind
  25224. * - VertexBuffer.UV2Kind
  25225. * - VertexBuffer.UV3Kind
  25226. * - VertexBuffer.UV4Kind
  25227. * - VertexBuffer.UV5Kind
  25228. * - VertexBuffer.UV6Kind
  25229. * - VertexBuffer.ColorKind
  25230. * - VertexBuffer.MatricesIndicesKind
  25231. * - VertexBuffer.MatricesIndicesExtraKind
  25232. * - VertexBuffer.MatricesWeightsKind
  25233. * - VertexBuffer.MatricesWeightsExtraKind
  25234. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  25235. */
  25236. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25237. /**
  25238. * Tests if a specific vertex buffer is associated with this mesh
  25239. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25240. * - VertexBuffer.PositionKind
  25241. * - VertexBuffer.NormalKind
  25242. * - VertexBuffer.UVKind
  25243. * - VertexBuffer.UV2Kind
  25244. * - VertexBuffer.UV3Kind
  25245. * - VertexBuffer.UV4Kind
  25246. * - VertexBuffer.UV5Kind
  25247. * - VertexBuffer.UV6Kind
  25248. * - VertexBuffer.ColorKind
  25249. * - VertexBuffer.MatricesIndicesKind
  25250. * - VertexBuffer.MatricesIndicesExtraKind
  25251. * - VertexBuffer.MatricesWeightsKind
  25252. * - VertexBuffer.MatricesWeightsExtraKind
  25253. * @returns a boolean
  25254. */
  25255. isVerticesDataPresent(kind: string): boolean;
  25256. /**
  25257. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  25258. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25259. * - VertexBuffer.PositionKind
  25260. * - VertexBuffer.UVKind
  25261. * - VertexBuffer.UV2Kind
  25262. * - VertexBuffer.UV3Kind
  25263. * - VertexBuffer.UV4Kind
  25264. * - VertexBuffer.UV5Kind
  25265. * - VertexBuffer.UV6Kind
  25266. * - VertexBuffer.ColorKind
  25267. * - VertexBuffer.MatricesIndicesKind
  25268. * - VertexBuffer.MatricesIndicesExtraKind
  25269. * - VertexBuffer.MatricesWeightsKind
  25270. * - VertexBuffer.MatricesWeightsExtraKind
  25271. * @returns a boolean
  25272. */
  25273. isVertexBufferUpdatable(kind: string): boolean;
  25274. /**
  25275. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  25276. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25277. * - VertexBuffer.PositionKind
  25278. * - VertexBuffer.NormalKind
  25279. * - VertexBuffer.UVKind
  25280. * - VertexBuffer.UV2Kind
  25281. * - VertexBuffer.UV3Kind
  25282. * - VertexBuffer.UV4Kind
  25283. * - VertexBuffer.UV5Kind
  25284. * - VertexBuffer.UV6Kind
  25285. * - VertexBuffer.ColorKind
  25286. * - VertexBuffer.MatricesIndicesKind
  25287. * - VertexBuffer.MatricesIndicesExtraKind
  25288. * - VertexBuffer.MatricesWeightsKind
  25289. * - VertexBuffer.MatricesWeightsExtraKind
  25290. * @returns an array of strings
  25291. */
  25292. getVerticesDataKinds(): string[];
  25293. /**
  25294. * Returns a positive integer : the total number of indices in this mesh geometry.
  25295. * @returns the numner of indices or zero if the mesh has no geometry.
  25296. */
  25297. getTotalIndices(): number;
  25298. /**
  25299. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25300. * @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.
  25301. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25302. * @returns the indices array or an empty array if the mesh has no geometry
  25303. */
  25304. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25305. get isBlocked(): boolean;
  25306. /**
  25307. * Determine if the current mesh is ready to be rendered
  25308. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25309. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  25310. * @returns true if all associated assets are ready (material, textures, shaders)
  25311. */
  25312. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  25313. /**
  25314. * 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.
  25315. */
  25316. get areNormalsFrozen(): boolean;
  25317. /**
  25318. * 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.
  25319. * @returns the current mesh
  25320. */
  25321. freezeNormals(): Mesh;
  25322. /**
  25323. * 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
  25324. * @returns the current mesh
  25325. */
  25326. unfreezeNormals(): Mesh;
  25327. /**
  25328. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  25329. */
  25330. set overridenInstanceCount(count: number);
  25331. /** @hidden */
  25332. _preActivate(): Mesh;
  25333. /** @hidden */
  25334. _preActivateForIntermediateRendering(renderId: number): Mesh;
  25335. /** @hidden */
  25336. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  25337. /**
  25338. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25339. * This means the mesh underlying bounding box and sphere are recomputed.
  25340. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25341. * @returns the current mesh
  25342. */
  25343. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  25344. /** @hidden */
  25345. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  25346. /**
  25347. * This function will subdivide the mesh into multiple submeshes
  25348. * @param count defines the expected number of submeshes
  25349. */
  25350. subdivide(count: number): void;
  25351. /**
  25352. * Copy a FloatArray into a specific associated vertex buffer
  25353. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25354. * - VertexBuffer.PositionKind
  25355. * - VertexBuffer.UVKind
  25356. * - VertexBuffer.UV2Kind
  25357. * - VertexBuffer.UV3Kind
  25358. * - VertexBuffer.UV4Kind
  25359. * - VertexBuffer.UV5Kind
  25360. * - VertexBuffer.UV6Kind
  25361. * - VertexBuffer.ColorKind
  25362. * - VertexBuffer.MatricesIndicesKind
  25363. * - VertexBuffer.MatricesIndicesExtraKind
  25364. * - VertexBuffer.MatricesWeightsKind
  25365. * - VertexBuffer.MatricesWeightsExtraKind
  25366. * @param data defines the data source
  25367. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25368. * @param stride defines the data stride size (can be null)
  25369. * @returns the current mesh
  25370. */
  25371. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25372. /**
  25373. * Delete a vertex buffer associated with this mesh
  25374. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  25375. * - VertexBuffer.PositionKind
  25376. * - VertexBuffer.UVKind
  25377. * - VertexBuffer.UV2Kind
  25378. * - VertexBuffer.UV3Kind
  25379. * - VertexBuffer.UV4Kind
  25380. * - VertexBuffer.UV5Kind
  25381. * - VertexBuffer.UV6Kind
  25382. * - VertexBuffer.ColorKind
  25383. * - VertexBuffer.MatricesIndicesKind
  25384. * - VertexBuffer.MatricesIndicesExtraKind
  25385. * - VertexBuffer.MatricesWeightsKind
  25386. * - VertexBuffer.MatricesWeightsExtraKind
  25387. */
  25388. removeVerticesData(kind: string): void;
  25389. /**
  25390. * Flags an associated vertex buffer as updatable
  25391. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  25392. * - VertexBuffer.PositionKind
  25393. * - VertexBuffer.UVKind
  25394. * - VertexBuffer.UV2Kind
  25395. * - VertexBuffer.UV3Kind
  25396. * - VertexBuffer.UV4Kind
  25397. * - VertexBuffer.UV5Kind
  25398. * - VertexBuffer.UV6Kind
  25399. * - VertexBuffer.ColorKind
  25400. * - VertexBuffer.MatricesIndicesKind
  25401. * - VertexBuffer.MatricesIndicesExtraKind
  25402. * - VertexBuffer.MatricesWeightsKind
  25403. * - VertexBuffer.MatricesWeightsExtraKind
  25404. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25405. */
  25406. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  25407. /**
  25408. * Sets the mesh global Vertex Buffer
  25409. * @param buffer defines the buffer to use
  25410. * @returns the current mesh
  25411. */
  25412. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  25413. /**
  25414. * Update a specific associated vertex buffer
  25415. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25416. * - VertexBuffer.PositionKind
  25417. * - VertexBuffer.UVKind
  25418. * - VertexBuffer.UV2Kind
  25419. * - VertexBuffer.UV3Kind
  25420. * - VertexBuffer.UV4Kind
  25421. * - VertexBuffer.UV5Kind
  25422. * - VertexBuffer.UV6Kind
  25423. * - VertexBuffer.ColorKind
  25424. * - VertexBuffer.MatricesIndicesKind
  25425. * - VertexBuffer.MatricesIndicesExtraKind
  25426. * - VertexBuffer.MatricesWeightsKind
  25427. * - VertexBuffer.MatricesWeightsExtraKind
  25428. * @param data defines the data source
  25429. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25430. * @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)
  25431. * @returns the current mesh
  25432. */
  25433. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25434. /**
  25435. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  25436. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25437. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25438. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25439. * @returns the current mesh
  25440. */
  25441. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25442. /**
  25443. * Creates a un-shared specific occurence of the geometry for the mesh.
  25444. * @returns the current mesh
  25445. */
  25446. makeGeometryUnique(): Mesh;
  25447. /**
  25448. * Set the index buffer of this mesh
  25449. * @param indices defines the source data
  25450. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25451. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25452. * @returns the current mesh
  25453. */
  25454. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25455. /**
  25456. * Update the current index buffer
  25457. * @param indices defines the source data
  25458. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25459. * @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)
  25460. * @returns the current mesh
  25461. */
  25462. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25463. /**
  25464. * Invert the geometry to move from a right handed system to a left handed one.
  25465. * @returns the current mesh
  25466. */
  25467. toLeftHanded(): Mesh;
  25468. /** @hidden */
  25469. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25470. /** @hidden */
  25471. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25472. /**
  25473. * Registers for this mesh a javascript function called just before the rendering process
  25474. * @param func defines the function to call before rendering this mesh
  25475. * @returns the current mesh
  25476. */
  25477. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25478. /**
  25479. * Disposes a previously registered javascript function called before the rendering
  25480. * @param func defines the function to remove
  25481. * @returns the current mesh
  25482. */
  25483. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25484. /**
  25485. * Registers for this mesh a javascript function called just after the rendering is complete
  25486. * @param func defines the function to call after rendering this mesh
  25487. * @returns the current mesh
  25488. */
  25489. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25490. /**
  25491. * Disposes a previously registered javascript function called after the rendering.
  25492. * @param func defines the function to remove
  25493. * @returns the current mesh
  25494. */
  25495. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25496. /** @hidden */
  25497. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25498. /** @hidden */
  25499. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25500. /** @hidden */
  25501. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25502. /** @hidden */
  25503. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25504. /** @hidden */
  25505. _rebuild(): void;
  25506. /** @hidden */
  25507. _freeze(): void;
  25508. /** @hidden */
  25509. _unFreeze(): void;
  25510. /**
  25511. * 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
  25512. * @param subMesh defines the subMesh to render
  25513. * @param enableAlphaMode defines if alpha mode can be changed
  25514. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25515. * @returns the current mesh
  25516. */
  25517. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25518. private _onBeforeDraw;
  25519. /**
  25520. * Renormalize the mesh and patch it up if there are no weights
  25521. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25522. * However in the case of zero weights then we set just a single influence to 1.
  25523. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25524. */
  25525. cleanMatrixWeights(): void;
  25526. private normalizeSkinFourWeights;
  25527. private normalizeSkinWeightsAndExtra;
  25528. /**
  25529. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25530. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25531. * the user know there was an issue with importing the mesh
  25532. * @returns a validation object with skinned, valid and report string
  25533. */
  25534. validateSkinning(): {
  25535. skinned: boolean;
  25536. valid: boolean;
  25537. report: string;
  25538. };
  25539. /** @hidden */
  25540. _checkDelayState(): Mesh;
  25541. private _queueLoad;
  25542. /**
  25543. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25544. * A mesh is in the frustum if its bounding box intersects the frustum
  25545. * @param frustumPlanes defines the frustum to test
  25546. * @returns true if the mesh is in the frustum planes
  25547. */
  25548. isInFrustum(frustumPlanes: Plane[]): boolean;
  25549. /**
  25550. * Sets the mesh material by the material or multiMaterial `id` property
  25551. * @param id is a string identifying the material or the multiMaterial
  25552. * @returns the current mesh
  25553. */
  25554. setMaterialByID(id: string): Mesh;
  25555. /**
  25556. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25557. * @returns an array of IAnimatable
  25558. */
  25559. getAnimatables(): IAnimatable[];
  25560. /**
  25561. * Modifies the mesh geometry according to the passed transformation matrix.
  25562. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25563. * The mesh normals are modified using the same transformation.
  25564. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25565. * @param transform defines the transform matrix to use
  25566. * @see http://doc.babylonjs.com/resources/baking_transformations
  25567. * @returns the current mesh
  25568. */
  25569. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25570. /**
  25571. * Modifies the mesh geometry according to its own current World Matrix.
  25572. * The mesh World Matrix is then reset.
  25573. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25574. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25575. * @see http://doc.babylonjs.com/resources/baking_transformations
  25576. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  25577. * @returns the current mesh
  25578. */
  25579. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  25580. /** @hidden */
  25581. get _positions(): Nullable<Vector3[]>;
  25582. /** @hidden */
  25583. _resetPointsArrayCache(): Mesh;
  25584. /** @hidden */
  25585. _generatePointsArray(): boolean;
  25586. /**
  25587. * Returns a new Mesh object generated from the current mesh properties.
  25588. * This method must not get confused with createInstance()
  25589. * @param name is a string, the name given to the new mesh
  25590. * @param newParent can be any Node object (default `null`)
  25591. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25592. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25593. * @returns a new mesh
  25594. */
  25595. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  25596. /**
  25597. * Releases resources associated with this mesh.
  25598. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25599. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25600. */
  25601. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25602. /** @hidden */
  25603. _disposeInstanceSpecificData(): void;
  25604. /**
  25605. * Modifies the mesh geometry according to a displacement map.
  25606. * 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.
  25607. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25608. * @param url is a string, the URL from the image file is to be downloaded.
  25609. * @param minHeight is the lower limit of the displacement.
  25610. * @param maxHeight is the upper limit of the displacement.
  25611. * @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.
  25612. * @param uvOffset is an optional vector2 used to offset UV.
  25613. * @param uvScale is an optional vector2 used to scale UV.
  25614. * @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.
  25615. * @returns the Mesh.
  25616. */
  25617. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25618. /**
  25619. * Modifies the mesh geometry according to a displacementMap buffer.
  25620. * 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.
  25621. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25622. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25623. * @param heightMapWidth is the width of the buffer image.
  25624. * @param heightMapHeight is the height of the buffer image.
  25625. * @param minHeight is the lower limit of the displacement.
  25626. * @param maxHeight is the upper limit of the displacement.
  25627. * @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.
  25628. * @param uvOffset is an optional vector2 used to offset UV.
  25629. * @param uvScale is an optional vector2 used to scale UV.
  25630. * @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.
  25631. * @returns the Mesh.
  25632. */
  25633. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25634. /**
  25635. * Modify the mesh to get a flat shading rendering.
  25636. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25637. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25638. * @returns current mesh
  25639. */
  25640. convertToFlatShadedMesh(): Mesh;
  25641. /**
  25642. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25643. * In other words, more vertices, no more indices and a single bigger VBO.
  25644. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25645. * @returns current mesh
  25646. */
  25647. convertToUnIndexedMesh(): Mesh;
  25648. /**
  25649. * Inverses facet orientations.
  25650. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25651. * @param flipNormals will also inverts the normals
  25652. * @returns current mesh
  25653. */
  25654. flipFaces(flipNormals?: boolean): Mesh;
  25655. /**
  25656. * Increase the number of facets and hence vertices in a mesh
  25657. * Vertex normals are interpolated from existing vertex normals
  25658. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25659. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25660. */
  25661. increaseVertices(numberPerEdge: number): void;
  25662. /**
  25663. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25664. * This will undo any application of covertToFlatShadedMesh
  25665. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25666. */
  25667. forceSharedVertices(): void;
  25668. /** @hidden */
  25669. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25670. /** @hidden */
  25671. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25672. /**
  25673. * Creates a new InstancedMesh object from the mesh model.
  25674. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25675. * @param name defines the name of the new instance
  25676. * @returns a new InstancedMesh
  25677. */
  25678. createInstance(name: string): InstancedMesh;
  25679. /**
  25680. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25681. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25682. * @returns the current mesh
  25683. */
  25684. synchronizeInstances(): Mesh;
  25685. /**
  25686. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25687. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25688. * This should be used together with the simplification to avoid disappearing triangles.
  25689. * @param successCallback an optional success callback to be called after the optimization finished.
  25690. * @returns the current mesh
  25691. */
  25692. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25693. /**
  25694. * Serialize current mesh
  25695. * @param serializationObject defines the object which will receive the serialization data
  25696. */
  25697. serialize(serializationObject: any): void;
  25698. /** @hidden */
  25699. _syncGeometryWithMorphTargetManager(): void;
  25700. /** @hidden */
  25701. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25702. /**
  25703. * Returns a new Mesh object parsed from the source provided.
  25704. * @param parsedMesh is the source
  25705. * @param scene defines the hosting scene
  25706. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25707. * @returns a new Mesh
  25708. */
  25709. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25710. /**
  25711. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25712. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25713. * @param name defines the name of the mesh to create
  25714. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25715. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25716. * @param closePath creates a seam between the first and the last points of each path of the path array
  25717. * @param offset is taken in account only if the `pathArray` is containing a single path
  25718. * @param scene defines the hosting scene
  25719. * @param updatable defines if the mesh must be flagged as updatable
  25720. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25721. * @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)
  25722. * @returns a new Mesh
  25723. */
  25724. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25725. /**
  25726. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25727. * @param name defines the name of the mesh to create
  25728. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25729. * @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
  25730. * @param scene defines the hosting scene
  25731. * @param updatable defines if the mesh must be flagged as updatable
  25732. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25733. * @returns a new Mesh
  25734. */
  25735. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25736. /**
  25737. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25738. * @param name defines the name of the mesh to create
  25739. * @param size sets the size (float) of each box side (default 1)
  25740. * @param scene defines the hosting scene
  25741. * @param updatable defines if the mesh must be flagged as updatable
  25742. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25743. * @returns a new Mesh
  25744. */
  25745. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25746. /**
  25747. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25748. * @param name defines the name of the mesh to create
  25749. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25750. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25751. * @param scene defines the hosting scene
  25752. * @param updatable defines if the mesh must be flagged as updatable
  25753. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25754. * @returns a new Mesh
  25755. */
  25756. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25757. /**
  25758. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25759. * @param name defines the name of the mesh to create
  25760. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25761. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25762. * @param scene defines the hosting scene
  25763. * @returns a new Mesh
  25764. */
  25765. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25766. /**
  25767. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25768. * @param name defines the name of the mesh to create
  25769. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25770. * @param diameterTop set the top cap diameter (floats, default 1)
  25771. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25772. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25773. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25774. * @param scene defines the hosting scene
  25775. * @param updatable defines if the mesh must be flagged as updatable
  25776. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25777. * @returns a new Mesh
  25778. */
  25779. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25780. /**
  25781. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25782. * @param name defines the name of the mesh to create
  25783. * @param diameter sets the diameter size (float) of the torus (default 1)
  25784. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25785. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25786. * @param scene defines the hosting scene
  25787. * @param updatable defines if the mesh must be flagged as updatable
  25788. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25789. * @returns a new Mesh
  25790. */
  25791. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25792. /**
  25793. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25794. * @param name defines the name of the mesh to create
  25795. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25796. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25797. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25798. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25799. * @param p the number of windings on X axis (positive integers, default 2)
  25800. * @param q the number of windings on Y axis (positive integers, default 3)
  25801. * @param scene defines the hosting scene
  25802. * @param updatable defines if the mesh must be flagged as updatable
  25803. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25804. * @returns a new Mesh
  25805. */
  25806. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25807. /**
  25808. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25809. * @param name defines the name of the mesh to create
  25810. * @param points is an array successive Vector3
  25811. * @param scene defines the hosting scene
  25812. * @param updatable defines if the mesh must be flagged as updatable
  25813. * @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).
  25814. * @returns a new Mesh
  25815. */
  25816. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25817. /**
  25818. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25819. * @param name defines the name of the mesh to create
  25820. * @param points is an array successive Vector3
  25821. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25822. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25823. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25824. * @param scene defines the hosting scene
  25825. * @param updatable defines if the mesh must be flagged as updatable
  25826. * @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)
  25827. * @returns a new Mesh
  25828. */
  25829. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25830. /**
  25831. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25832. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25833. * 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.
  25834. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25835. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25836. * Remember you can only change the shape positions, not their number when updating a polygon.
  25837. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25838. * @param name defines the name of the mesh to create
  25839. * @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
  25840. * @param scene defines the hosting scene
  25841. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25842. * @param updatable defines if the mesh must be flagged as updatable
  25843. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25844. * @param earcutInjection can be used to inject your own earcut reference
  25845. * @returns a new Mesh
  25846. */
  25847. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25848. /**
  25849. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25850. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25851. * @param name defines the name of the mesh to create
  25852. * @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
  25853. * @param depth defines the height of extrusion
  25854. * @param scene defines the hosting scene
  25855. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25856. * @param updatable defines if the mesh must be flagged as updatable
  25857. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25858. * @param earcutInjection can be used to inject your own earcut reference
  25859. * @returns a new Mesh
  25860. */
  25861. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25862. /**
  25863. * Creates an extruded shape mesh.
  25864. * 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
  25865. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25866. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25867. * @param name defines the name of the mesh to create
  25868. * @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
  25869. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25870. * @param scale is the value to scale the shape
  25871. * @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
  25872. * @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
  25873. * @param scene defines the hosting scene
  25874. * @param updatable defines if the mesh must be flagged as updatable
  25875. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25876. * @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)
  25877. * @returns a new Mesh
  25878. */
  25879. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25880. /**
  25881. * Creates an custom extruded shape mesh.
  25882. * The custom extrusion is a parametric shape.
  25883. * It has no predefined shape. Its final shape will depend on the input parameters.
  25884. * Please consider using the same method from the MeshBuilder class instead
  25885. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25886. * @param name defines the name of the mesh to create
  25887. * @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
  25888. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25889. * @param scaleFunction is a custom Javascript function called on each path point
  25890. * @param rotationFunction is a custom Javascript function called on each path point
  25891. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25892. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25893. * @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
  25894. * @param scene defines the hosting scene
  25895. * @param updatable defines if the mesh must be flagged as updatable
  25896. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25897. * @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)
  25898. * @returns a new Mesh
  25899. */
  25900. 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;
  25901. /**
  25902. * Creates lathe mesh.
  25903. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25904. * Please consider using the same method from the MeshBuilder class instead
  25905. * @param name defines the name of the mesh to create
  25906. * @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
  25907. * @param radius is the radius value of the lathe
  25908. * @param tessellation is the side number of the lathe.
  25909. * @param scene defines the hosting scene
  25910. * @param updatable defines if the mesh must be flagged as updatable
  25911. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25912. * @returns a new Mesh
  25913. */
  25914. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25915. /**
  25916. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25917. * @param name defines the name of the mesh to create
  25918. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25919. * @param scene defines the hosting scene
  25920. * @param updatable defines if the mesh must be flagged as updatable
  25921. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25922. * @returns a new Mesh
  25923. */
  25924. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25925. /**
  25926. * Creates a ground mesh.
  25927. * Please consider using the same method from the MeshBuilder class instead
  25928. * @param name defines the name of the mesh to create
  25929. * @param width set the width of the ground
  25930. * @param height set the height of the ground
  25931. * @param subdivisions sets the number of subdivisions per side
  25932. * @param scene defines the hosting scene
  25933. * @param updatable defines if the mesh must be flagged as updatable
  25934. * @returns a new Mesh
  25935. */
  25936. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25937. /**
  25938. * Creates a tiled ground mesh.
  25939. * Please consider using the same method from the MeshBuilder class instead
  25940. * @param name defines the name of the mesh to create
  25941. * @param xmin set the ground minimum X coordinate
  25942. * @param zmin set the ground minimum Y coordinate
  25943. * @param xmax set the ground maximum X coordinate
  25944. * @param zmax set the ground maximum Z coordinate
  25945. * @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
  25946. * @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
  25947. * @param scene defines the hosting scene
  25948. * @param updatable defines if the mesh must be flagged as updatable
  25949. * @returns a new Mesh
  25950. */
  25951. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25952. w: number;
  25953. h: number;
  25954. }, precision: {
  25955. w: number;
  25956. h: number;
  25957. }, scene: Scene, updatable?: boolean): Mesh;
  25958. /**
  25959. * Creates a ground mesh from a height map.
  25960. * Please consider using the same method from the MeshBuilder class instead
  25961. * @see http://doc.babylonjs.com/babylon101/height_map
  25962. * @param name defines the name of the mesh to create
  25963. * @param url sets the URL of the height map image resource
  25964. * @param width set the ground width size
  25965. * @param height set the ground height size
  25966. * @param subdivisions sets the number of subdivision per side
  25967. * @param minHeight is the minimum altitude on the ground
  25968. * @param maxHeight is the maximum altitude on the ground
  25969. * @param scene defines the hosting scene
  25970. * @param updatable defines if the mesh must be flagged as updatable
  25971. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25972. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25973. * @returns a new Mesh
  25974. */
  25975. 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;
  25976. /**
  25977. * Creates a tube mesh.
  25978. * The tube is a parametric shape.
  25979. * It has no predefined shape. Its final shape will depend on the input parameters.
  25980. * Please consider using the same method from the MeshBuilder class instead
  25981. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25982. * @param name defines the name of the mesh to create
  25983. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25984. * @param radius sets the tube radius size
  25985. * @param tessellation is the number of sides on the tubular surface
  25986. * @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
  25987. * @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
  25988. * @param scene defines the hosting scene
  25989. * @param updatable defines if the mesh must be flagged as updatable
  25990. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25991. * @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)
  25992. * @returns a new Mesh
  25993. */
  25994. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25995. (i: number, distance: number): number;
  25996. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25997. /**
  25998. * Creates a polyhedron mesh.
  25999. * Please consider using the same method from the MeshBuilder class instead.
  26000. * * 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
  26001. * * The parameter `size` (positive float, default 1) sets the polygon size
  26002. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  26003. * * 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`
  26004. * * 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
  26005. * * 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)`)
  26006. * * 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
  26007. * * 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
  26008. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26009. * * If you create a double-sided mesh, you can choose what parts of 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
  26010. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26011. * @param name defines the name of the mesh to create
  26012. * @param options defines the options used to create the mesh
  26013. * @param scene defines the hosting scene
  26014. * @returns a new Mesh
  26015. */
  26016. static CreatePolyhedron(name: string, options: {
  26017. type?: number;
  26018. size?: number;
  26019. sizeX?: number;
  26020. sizeY?: number;
  26021. sizeZ?: number;
  26022. custom?: any;
  26023. faceUV?: Vector4[];
  26024. faceColors?: Color4[];
  26025. updatable?: boolean;
  26026. sideOrientation?: number;
  26027. }, scene: Scene): Mesh;
  26028. /**
  26029. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  26030. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  26031. * * 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`)
  26032. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  26033. * * 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
  26034. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26035. * * If you create a double-sided mesh, you can choose what parts of 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
  26036. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26037. * @param name defines the name of the mesh
  26038. * @param options defines the options used to create the mesh
  26039. * @param scene defines the hosting scene
  26040. * @returns a new Mesh
  26041. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  26042. */
  26043. static CreateIcoSphere(name: string, options: {
  26044. radius?: number;
  26045. flat?: boolean;
  26046. subdivisions?: number;
  26047. sideOrientation?: number;
  26048. updatable?: boolean;
  26049. }, scene: Scene): Mesh;
  26050. /**
  26051. * Creates a decal mesh.
  26052. * Please consider using the same method from the MeshBuilder class instead.
  26053. * A decal is a mesh usually applied as a model onto the surface of another mesh
  26054. * @param name defines the name of the mesh
  26055. * @param sourceMesh defines the mesh receiving the decal
  26056. * @param position sets the position of the decal in world coordinates
  26057. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  26058. * @param size sets the decal scaling
  26059. * @param angle sets the angle to rotate the decal
  26060. * @returns a new Mesh
  26061. */
  26062. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  26063. /**
  26064. * Prepare internal position array for software CPU skinning
  26065. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  26066. */
  26067. setPositionsForCPUSkinning(): Float32Array;
  26068. /**
  26069. * Prepare internal normal array for software CPU skinning
  26070. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  26071. */
  26072. setNormalsForCPUSkinning(): Float32Array;
  26073. /**
  26074. * Updates the vertex buffer by applying transformation from the bones
  26075. * @param skeleton defines the skeleton to apply to current mesh
  26076. * @returns the current mesh
  26077. */
  26078. applySkeleton(skeleton: Skeleton): Mesh;
  26079. /**
  26080. * 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
  26081. * @param meshes defines the list of meshes to scan
  26082. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  26083. */
  26084. static MinMax(meshes: AbstractMesh[]): {
  26085. min: Vector3;
  26086. max: Vector3;
  26087. };
  26088. /**
  26089. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  26090. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  26091. * @returns a vector3
  26092. */
  26093. static Center(meshesOrMinMaxVector: {
  26094. min: Vector3;
  26095. max: Vector3;
  26096. } | AbstractMesh[]): Vector3;
  26097. /**
  26098. * Merge the array of meshes into a single mesh for performance reasons.
  26099. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  26100. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  26101. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  26102. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  26103. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  26104. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  26105. * @returns a new mesh
  26106. */
  26107. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  26108. /** @hidden */
  26109. addInstance(instance: InstancedMesh): void;
  26110. /** @hidden */
  26111. removeInstance(instance: InstancedMesh): void;
  26112. }
  26113. }
  26114. declare module "babylonjs/Cameras/camera" {
  26115. import { SmartArray } from "babylonjs/Misc/smartArray";
  26116. import { Observable } from "babylonjs/Misc/observable";
  26117. import { Nullable } from "babylonjs/types";
  26118. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  26119. import { Scene } from "babylonjs/scene";
  26120. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  26121. import { Node } from "babylonjs/node";
  26122. import { Mesh } from "babylonjs/Meshes/mesh";
  26123. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26124. import { ICullable } from "babylonjs/Culling/boundingInfo";
  26125. import { Viewport } from "babylonjs/Maths/math.viewport";
  26126. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  26127. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26128. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  26129. import { Ray } from "babylonjs/Culling/ray";
  26130. /**
  26131. * This is the base class of all the camera used in the application.
  26132. * @see http://doc.babylonjs.com/features/cameras
  26133. */
  26134. export class Camera extends Node {
  26135. /** @hidden */
  26136. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  26137. /**
  26138. * This is the default projection mode used by the cameras.
  26139. * It helps recreating a feeling of perspective and better appreciate depth.
  26140. * This is the best way to simulate real life cameras.
  26141. */
  26142. static readonly PERSPECTIVE_CAMERA: number;
  26143. /**
  26144. * This helps creating camera with an orthographic mode.
  26145. * 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.
  26146. */
  26147. static readonly ORTHOGRAPHIC_CAMERA: number;
  26148. /**
  26149. * This is the default FOV mode for perspective cameras.
  26150. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  26151. */
  26152. static readonly FOVMODE_VERTICAL_FIXED: number;
  26153. /**
  26154. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  26155. */
  26156. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  26157. /**
  26158. * This specifies ther is no need for a camera rig.
  26159. * Basically only one eye is rendered corresponding to the camera.
  26160. */
  26161. static readonly RIG_MODE_NONE: number;
  26162. /**
  26163. * Simulates a camera Rig with one blue eye and one red eye.
  26164. * This can be use with 3d blue and red glasses.
  26165. */
  26166. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  26167. /**
  26168. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  26169. */
  26170. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  26171. /**
  26172. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  26173. */
  26174. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  26175. /**
  26176. * Defines that both eyes of the camera will be rendered over under each other.
  26177. */
  26178. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  26179. /**
  26180. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  26181. */
  26182. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  26183. /**
  26184. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  26185. */
  26186. static readonly RIG_MODE_VR: number;
  26187. /**
  26188. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  26189. */
  26190. static readonly RIG_MODE_WEBVR: number;
  26191. /**
  26192. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  26193. */
  26194. static readonly RIG_MODE_CUSTOM: number;
  26195. /**
  26196. * Defines if by default attaching controls should prevent the default javascript event to continue.
  26197. */
  26198. static ForceAttachControlToAlwaysPreventDefault: boolean;
  26199. /**
  26200. * Define the input manager associated with the camera.
  26201. */
  26202. inputs: CameraInputsManager<Camera>;
  26203. /** @hidden */
  26204. _position: Vector3;
  26205. /**
  26206. * Define the current local position of the camera in the scene
  26207. */
  26208. get position(): Vector3;
  26209. set position(newPosition: Vector3);
  26210. /**
  26211. * The vector the camera should consider as up.
  26212. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  26213. */
  26214. upVector: Vector3;
  26215. /**
  26216. * Define the current limit on the left side for an orthographic camera
  26217. * In scene unit
  26218. */
  26219. orthoLeft: Nullable<number>;
  26220. /**
  26221. * Define the current limit on the right side for an orthographic camera
  26222. * In scene unit
  26223. */
  26224. orthoRight: Nullable<number>;
  26225. /**
  26226. * Define the current limit on the bottom side for an orthographic camera
  26227. * In scene unit
  26228. */
  26229. orthoBottom: Nullable<number>;
  26230. /**
  26231. * Define the current limit on the top side for an orthographic camera
  26232. * In scene unit
  26233. */
  26234. orthoTop: Nullable<number>;
  26235. /**
  26236. * Field Of View is set in Radians. (default is 0.8)
  26237. */
  26238. fov: number;
  26239. /**
  26240. * Define the minimum distance the camera can see from.
  26241. * This is important to note that the depth buffer are not infinite and the closer it starts
  26242. * the more your scene might encounter depth fighting issue.
  26243. */
  26244. minZ: number;
  26245. /**
  26246. * Define the maximum distance the camera can see to.
  26247. * This is important to note that the depth buffer are not infinite and the further it end
  26248. * the more your scene might encounter depth fighting issue.
  26249. */
  26250. maxZ: number;
  26251. /**
  26252. * Define the default inertia of the camera.
  26253. * This helps giving a smooth feeling to the camera movement.
  26254. */
  26255. inertia: number;
  26256. /**
  26257. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  26258. */
  26259. mode: number;
  26260. /**
  26261. * Define whether the camera is intermediate.
  26262. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  26263. */
  26264. isIntermediate: boolean;
  26265. /**
  26266. * Define the viewport of the camera.
  26267. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  26268. */
  26269. viewport: Viewport;
  26270. /**
  26271. * Restricts the camera to viewing objects with the same layerMask.
  26272. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  26273. */
  26274. layerMask: number;
  26275. /**
  26276. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  26277. */
  26278. fovMode: number;
  26279. /**
  26280. * Rig mode of the camera.
  26281. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  26282. * This is normally controlled byt the camera themselves as internal use.
  26283. */
  26284. cameraRigMode: number;
  26285. /**
  26286. * Defines the distance between both "eyes" in case of a RIG
  26287. */
  26288. interaxialDistance: number;
  26289. /**
  26290. * Defines if stereoscopic rendering is done side by side or over under.
  26291. */
  26292. isStereoscopicSideBySide: boolean;
  26293. /**
  26294. * 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
  26295. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  26296. * else in the scene. (Eg. security camera)
  26297. *
  26298. * 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)
  26299. */
  26300. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  26301. /**
  26302. * When set, the camera will render to this render target instead of the default canvas
  26303. *
  26304. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  26305. */
  26306. outputRenderTarget: Nullable<RenderTargetTexture>;
  26307. /**
  26308. * Observable triggered when the camera view matrix has changed.
  26309. */
  26310. onViewMatrixChangedObservable: Observable<Camera>;
  26311. /**
  26312. * Observable triggered when the camera Projection matrix has changed.
  26313. */
  26314. onProjectionMatrixChangedObservable: Observable<Camera>;
  26315. /**
  26316. * Observable triggered when the inputs have been processed.
  26317. */
  26318. onAfterCheckInputsObservable: Observable<Camera>;
  26319. /**
  26320. * Observable triggered when reset has been called and applied to the camera.
  26321. */
  26322. onRestoreStateObservable: Observable<Camera>;
  26323. /**
  26324. * Is this camera a part of a rig system?
  26325. */
  26326. isRigCamera: boolean;
  26327. /**
  26328. * If isRigCamera set to true this will be set with the parent camera.
  26329. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  26330. */
  26331. rigParent?: Camera;
  26332. /** @hidden */
  26333. _cameraRigParams: any;
  26334. /** @hidden */
  26335. _rigCameras: Camera[];
  26336. /** @hidden */
  26337. _rigPostProcess: Nullable<PostProcess>;
  26338. protected _webvrViewMatrix: Matrix;
  26339. /** @hidden */
  26340. _skipRendering: boolean;
  26341. /** @hidden */
  26342. _projectionMatrix: Matrix;
  26343. /** @hidden */
  26344. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  26345. /** @hidden */
  26346. _activeMeshes: SmartArray<AbstractMesh>;
  26347. protected _globalPosition: Vector3;
  26348. /** @hidden */
  26349. _computedViewMatrix: Matrix;
  26350. private _doNotComputeProjectionMatrix;
  26351. private _transformMatrix;
  26352. private _frustumPlanes;
  26353. private _refreshFrustumPlanes;
  26354. private _storedFov;
  26355. private _stateStored;
  26356. /**
  26357. * Instantiates a new camera object.
  26358. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  26359. * @see http://doc.babylonjs.com/features/cameras
  26360. * @param name Defines the name of the camera in the scene
  26361. * @param position Defines the position of the camera
  26362. * @param scene Defines the scene the camera belongs too
  26363. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  26364. */
  26365. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  26366. /**
  26367. * Store current camera state (fov, position, etc..)
  26368. * @returns the camera
  26369. */
  26370. storeState(): Camera;
  26371. /**
  26372. * Restores the camera state values if it has been stored. You must call storeState() first
  26373. */
  26374. protected _restoreStateValues(): boolean;
  26375. /**
  26376. * Restored camera state. You must call storeState() first.
  26377. * @returns true if restored and false otherwise
  26378. */
  26379. restoreState(): boolean;
  26380. /**
  26381. * Gets the class name of the camera.
  26382. * @returns the class name
  26383. */
  26384. getClassName(): string;
  26385. /** @hidden */
  26386. readonly _isCamera: boolean;
  26387. /**
  26388. * Gets a string representation of the camera useful for debug purpose.
  26389. * @param fullDetails Defines that a more verboe level of logging is required
  26390. * @returns the string representation
  26391. */
  26392. toString(fullDetails?: boolean): string;
  26393. /**
  26394. * Gets the current world space position of the camera.
  26395. */
  26396. get globalPosition(): Vector3;
  26397. /**
  26398. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  26399. * @returns the active meshe list
  26400. */
  26401. getActiveMeshes(): SmartArray<AbstractMesh>;
  26402. /**
  26403. * Check whether a mesh is part of the current active mesh list of the camera
  26404. * @param mesh Defines the mesh to check
  26405. * @returns true if active, false otherwise
  26406. */
  26407. isActiveMesh(mesh: Mesh): boolean;
  26408. /**
  26409. * Is this camera ready to be used/rendered
  26410. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  26411. * @return true if the camera is ready
  26412. */
  26413. isReady(completeCheck?: boolean): boolean;
  26414. /** @hidden */
  26415. _initCache(): void;
  26416. /** @hidden */
  26417. _updateCache(ignoreParentClass?: boolean): void;
  26418. /** @hidden */
  26419. _isSynchronized(): boolean;
  26420. /** @hidden */
  26421. _isSynchronizedViewMatrix(): boolean;
  26422. /** @hidden */
  26423. _isSynchronizedProjectionMatrix(): boolean;
  26424. /**
  26425. * Attach the input controls to a specific dom element to get the input from.
  26426. * @param element Defines the element the controls should be listened from
  26427. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26428. */
  26429. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  26430. /**
  26431. * Detach the current controls from the specified dom element.
  26432. * @param element Defines the element to stop listening the inputs from
  26433. */
  26434. detachControl(element: HTMLElement): void;
  26435. /**
  26436. * Update the camera state according to the different inputs gathered during the frame.
  26437. */
  26438. update(): void;
  26439. /** @hidden */
  26440. _checkInputs(): void;
  26441. /** @hidden */
  26442. get rigCameras(): Camera[];
  26443. /**
  26444. * Gets the post process used by the rig cameras
  26445. */
  26446. get rigPostProcess(): Nullable<PostProcess>;
  26447. /**
  26448. * Internal, gets the first post proces.
  26449. * @returns the first post process to be run on this camera.
  26450. */
  26451. _getFirstPostProcess(): Nullable<PostProcess>;
  26452. private _cascadePostProcessesToRigCams;
  26453. /**
  26454. * Attach a post process to the camera.
  26455. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26456. * @param postProcess The post process to attach to the camera
  26457. * @param insertAt The position of the post process in case several of them are in use in the scene
  26458. * @returns the position the post process has been inserted at
  26459. */
  26460. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26461. /**
  26462. * Detach a post process to the camera.
  26463. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26464. * @param postProcess The post process to detach from the camera
  26465. */
  26466. detachPostProcess(postProcess: PostProcess): void;
  26467. /**
  26468. * Gets the current world matrix of the camera
  26469. */
  26470. getWorldMatrix(): Matrix;
  26471. /** @hidden */
  26472. _getViewMatrix(): Matrix;
  26473. /**
  26474. * Gets the current view matrix of the camera.
  26475. * @param force forces the camera to recompute the matrix without looking at the cached state
  26476. * @returns the view matrix
  26477. */
  26478. getViewMatrix(force?: boolean): Matrix;
  26479. /**
  26480. * Freeze the projection matrix.
  26481. * It will prevent the cache check of the camera projection compute and can speed up perf
  26482. * if no parameter of the camera are meant to change
  26483. * @param projection Defines manually a projection if necessary
  26484. */
  26485. freezeProjectionMatrix(projection?: Matrix): void;
  26486. /**
  26487. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26488. */
  26489. unfreezeProjectionMatrix(): void;
  26490. /**
  26491. * Gets the current projection matrix of the camera.
  26492. * @param force forces the camera to recompute the matrix without looking at the cached state
  26493. * @returns the projection matrix
  26494. */
  26495. getProjectionMatrix(force?: boolean): Matrix;
  26496. /**
  26497. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26498. * @returns a Matrix
  26499. */
  26500. getTransformationMatrix(): Matrix;
  26501. private _updateFrustumPlanes;
  26502. /**
  26503. * Checks if a cullable object (mesh...) is in the camera frustum
  26504. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26505. * @param target The object to check
  26506. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26507. * @returns true if the object is in frustum otherwise false
  26508. */
  26509. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26510. /**
  26511. * Checks if a cullable object (mesh...) is in the camera frustum
  26512. * Unlike isInFrustum this cheks the full bounding box
  26513. * @param target The object to check
  26514. * @returns true if the object is in frustum otherwise false
  26515. */
  26516. isCompletelyInFrustum(target: ICullable): boolean;
  26517. /**
  26518. * Gets a ray in the forward direction from the camera.
  26519. * @param length Defines the length of the ray to create
  26520. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26521. * @param origin Defines the start point of the ray which defaults to the camera position
  26522. * @returns the forward ray
  26523. */
  26524. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26525. /**
  26526. * Releases resources associated with this node.
  26527. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26528. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26529. */
  26530. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26531. /** @hidden */
  26532. _isLeftCamera: boolean;
  26533. /**
  26534. * Gets the left camera of a rig setup in case of Rigged Camera
  26535. */
  26536. get isLeftCamera(): boolean;
  26537. /** @hidden */
  26538. _isRightCamera: boolean;
  26539. /**
  26540. * Gets the right camera of a rig setup in case of Rigged Camera
  26541. */
  26542. get isRightCamera(): boolean;
  26543. /**
  26544. * Gets the left camera of a rig setup in case of Rigged Camera
  26545. */
  26546. get leftCamera(): Nullable<FreeCamera>;
  26547. /**
  26548. * Gets the right camera of a rig setup in case of Rigged Camera
  26549. */
  26550. get rightCamera(): Nullable<FreeCamera>;
  26551. /**
  26552. * Gets the left camera target of a rig setup in case of Rigged Camera
  26553. * @returns the target position
  26554. */
  26555. getLeftTarget(): Nullable<Vector3>;
  26556. /**
  26557. * Gets the right camera target of a rig setup in case of Rigged Camera
  26558. * @returns the target position
  26559. */
  26560. getRightTarget(): Nullable<Vector3>;
  26561. /**
  26562. * @hidden
  26563. */
  26564. setCameraRigMode(mode: number, rigParams: any): void;
  26565. /** @hidden */
  26566. static _setStereoscopicRigMode(camera: Camera): void;
  26567. /** @hidden */
  26568. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26569. /** @hidden */
  26570. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26571. /** @hidden */
  26572. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26573. /** @hidden */
  26574. _getVRProjectionMatrix(): Matrix;
  26575. protected _updateCameraRotationMatrix(): void;
  26576. protected _updateWebVRCameraRotationMatrix(): void;
  26577. /**
  26578. * This function MUST be overwritten by the different WebVR cameras available.
  26579. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26580. * @hidden
  26581. */
  26582. _getWebVRProjectionMatrix(): Matrix;
  26583. /**
  26584. * This function MUST be overwritten by the different WebVR cameras available.
  26585. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26586. * @hidden
  26587. */
  26588. _getWebVRViewMatrix(): Matrix;
  26589. /** @hidden */
  26590. setCameraRigParameter(name: string, value: any): void;
  26591. /**
  26592. * needs to be overridden by children so sub has required properties to be copied
  26593. * @hidden
  26594. */
  26595. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26596. /**
  26597. * May need to be overridden by children
  26598. * @hidden
  26599. */
  26600. _updateRigCameras(): void;
  26601. /** @hidden */
  26602. _setupInputs(): void;
  26603. /**
  26604. * Serialiaze the camera setup to a json represention
  26605. * @returns the JSON representation
  26606. */
  26607. serialize(): any;
  26608. /**
  26609. * Clones the current camera.
  26610. * @param name The cloned camera name
  26611. * @returns the cloned camera
  26612. */
  26613. clone(name: string): Camera;
  26614. /**
  26615. * Gets the direction of the camera relative to a given local axis.
  26616. * @param localAxis Defines the reference axis to provide a relative direction.
  26617. * @return the direction
  26618. */
  26619. getDirection(localAxis: Vector3): Vector3;
  26620. /**
  26621. * Returns the current camera absolute rotation
  26622. */
  26623. get absoluteRotation(): Quaternion;
  26624. /**
  26625. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26626. * @param localAxis Defines the reference axis to provide a relative direction.
  26627. * @param result Defines the vector to store the result in
  26628. */
  26629. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26630. /**
  26631. * Gets a camera constructor for a given camera type
  26632. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26633. * @param name The name of the camera the result will be able to instantiate
  26634. * @param scene The scene the result will construct the camera in
  26635. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26636. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26637. * @returns a factory method to construc the camera
  26638. */
  26639. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26640. /**
  26641. * Compute the world matrix of the camera.
  26642. * @returns the camera world matrix
  26643. */
  26644. computeWorldMatrix(): Matrix;
  26645. /**
  26646. * Parse a JSON and creates the camera from the parsed information
  26647. * @param parsedCamera The JSON to parse
  26648. * @param scene The scene to instantiate the camera in
  26649. * @returns the newly constructed camera
  26650. */
  26651. static Parse(parsedCamera: any, scene: Scene): Camera;
  26652. }
  26653. }
  26654. declare module "babylonjs/Meshes/Builders/discBuilder" {
  26655. import { Nullable } from "babylonjs/types";
  26656. import { Scene } from "babylonjs/scene";
  26657. import { Vector4 } from "babylonjs/Maths/math.vector";
  26658. import { Mesh } from "babylonjs/Meshes/mesh";
  26659. /**
  26660. * Class containing static functions to help procedurally build meshes
  26661. */
  26662. export class DiscBuilder {
  26663. /**
  26664. * Creates a plane polygonal mesh. By default, this is a disc
  26665. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26666. * * 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
  26667. * * 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
  26668. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26669. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26670. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26671. * @param name defines the name of the mesh
  26672. * @param options defines the options used to create the mesh
  26673. * @param scene defines the hosting scene
  26674. * @returns the plane polygonal mesh
  26675. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26676. */
  26677. static CreateDisc(name: string, options: {
  26678. radius?: number;
  26679. tessellation?: number;
  26680. arc?: number;
  26681. updatable?: boolean;
  26682. sideOrientation?: number;
  26683. frontUVs?: Vector4;
  26684. backUVs?: Vector4;
  26685. }, scene?: Nullable<Scene>): Mesh;
  26686. }
  26687. }
  26688. declare module "babylonjs/Materials/fresnelParameters" {
  26689. import { Color3 } from "babylonjs/Maths/math.color";
  26690. /**
  26691. * This represents all the required information to add a fresnel effect on a material:
  26692. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26693. */
  26694. export class FresnelParameters {
  26695. private _isEnabled;
  26696. /**
  26697. * Define if the fresnel effect is enable or not.
  26698. */
  26699. get isEnabled(): boolean;
  26700. set isEnabled(value: boolean);
  26701. /**
  26702. * Define the color used on edges (grazing angle)
  26703. */
  26704. leftColor: Color3;
  26705. /**
  26706. * Define the color used on center
  26707. */
  26708. rightColor: Color3;
  26709. /**
  26710. * Define bias applied to computed fresnel term
  26711. */
  26712. bias: number;
  26713. /**
  26714. * Defined the power exponent applied to fresnel term
  26715. */
  26716. power: number;
  26717. /**
  26718. * Clones the current fresnel and its valuues
  26719. * @returns a clone fresnel configuration
  26720. */
  26721. clone(): FresnelParameters;
  26722. /**
  26723. * Serializes the current fresnel parameters to a JSON representation.
  26724. * @return the JSON serialization
  26725. */
  26726. serialize(): any;
  26727. /**
  26728. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26729. * @param parsedFresnelParameters Define the JSON representation
  26730. * @returns the parsed parameters
  26731. */
  26732. static Parse(parsedFresnelParameters: any): FresnelParameters;
  26733. }
  26734. }
  26735. declare module "babylonjs/Materials/pushMaterial" {
  26736. import { Nullable } from "babylonjs/types";
  26737. import { Scene } from "babylonjs/scene";
  26738. import { Matrix } from "babylonjs/Maths/math.vector";
  26739. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26740. import { Mesh } from "babylonjs/Meshes/mesh";
  26741. import { Material } from "babylonjs/Materials/material";
  26742. import { Effect } from "babylonjs/Materials/effect";
  26743. /**
  26744. * Base class of materials working in push mode in babylon JS
  26745. * @hidden
  26746. */
  26747. export class PushMaterial extends Material {
  26748. protected _activeEffect: Effect;
  26749. protected _normalMatrix: Matrix;
  26750. /**
  26751. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26752. * This means that the material can keep using a previous shader while a new one is being compiled.
  26753. * This is mostly used when shader parallel compilation is supported (true by default)
  26754. */
  26755. allowShaderHotSwapping: boolean;
  26756. constructor(name: string, scene: Scene);
  26757. getEffect(): Effect;
  26758. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26759. /**
  26760. * Binds the given world matrix to the active effect
  26761. *
  26762. * @param world the matrix to bind
  26763. */
  26764. bindOnlyWorldMatrix(world: Matrix): void;
  26765. /**
  26766. * Binds the given normal matrix to the active effect
  26767. *
  26768. * @param normalMatrix the matrix to bind
  26769. */
  26770. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26771. bind(world: Matrix, mesh?: Mesh): void;
  26772. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26773. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26774. }
  26775. }
  26776. declare module "babylonjs/Materials/materialFlags" {
  26777. /**
  26778. * This groups all the flags used to control the materials channel.
  26779. */
  26780. export class MaterialFlags {
  26781. private static _DiffuseTextureEnabled;
  26782. /**
  26783. * Are diffuse textures enabled in the application.
  26784. */
  26785. static get DiffuseTextureEnabled(): boolean;
  26786. static set DiffuseTextureEnabled(value: boolean);
  26787. private static _AmbientTextureEnabled;
  26788. /**
  26789. * Are ambient textures enabled in the application.
  26790. */
  26791. static get AmbientTextureEnabled(): boolean;
  26792. static set AmbientTextureEnabled(value: boolean);
  26793. private static _OpacityTextureEnabled;
  26794. /**
  26795. * Are opacity textures enabled in the application.
  26796. */
  26797. static get OpacityTextureEnabled(): boolean;
  26798. static set OpacityTextureEnabled(value: boolean);
  26799. private static _ReflectionTextureEnabled;
  26800. /**
  26801. * Are reflection textures enabled in the application.
  26802. */
  26803. static get ReflectionTextureEnabled(): boolean;
  26804. static set ReflectionTextureEnabled(value: boolean);
  26805. private static _EmissiveTextureEnabled;
  26806. /**
  26807. * Are emissive textures enabled in the application.
  26808. */
  26809. static get EmissiveTextureEnabled(): boolean;
  26810. static set EmissiveTextureEnabled(value: boolean);
  26811. private static _SpecularTextureEnabled;
  26812. /**
  26813. * Are specular textures enabled in the application.
  26814. */
  26815. static get SpecularTextureEnabled(): boolean;
  26816. static set SpecularTextureEnabled(value: boolean);
  26817. private static _BumpTextureEnabled;
  26818. /**
  26819. * Are bump textures enabled in the application.
  26820. */
  26821. static get BumpTextureEnabled(): boolean;
  26822. static set BumpTextureEnabled(value: boolean);
  26823. private static _LightmapTextureEnabled;
  26824. /**
  26825. * Are lightmap textures enabled in the application.
  26826. */
  26827. static get LightmapTextureEnabled(): boolean;
  26828. static set LightmapTextureEnabled(value: boolean);
  26829. private static _RefractionTextureEnabled;
  26830. /**
  26831. * Are refraction textures enabled in the application.
  26832. */
  26833. static get RefractionTextureEnabled(): boolean;
  26834. static set RefractionTextureEnabled(value: boolean);
  26835. private static _ColorGradingTextureEnabled;
  26836. /**
  26837. * Are color grading textures enabled in the application.
  26838. */
  26839. static get ColorGradingTextureEnabled(): boolean;
  26840. static set ColorGradingTextureEnabled(value: boolean);
  26841. private static _FresnelEnabled;
  26842. /**
  26843. * Are fresnels enabled in the application.
  26844. */
  26845. static get FresnelEnabled(): boolean;
  26846. static set FresnelEnabled(value: boolean);
  26847. private static _ClearCoatTextureEnabled;
  26848. /**
  26849. * Are clear coat textures enabled in the application.
  26850. */
  26851. static get ClearCoatTextureEnabled(): boolean;
  26852. static set ClearCoatTextureEnabled(value: boolean);
  26853. private static _ClearCoatBumpTextureEnabled;
  26854. /**
  26855. * Are clear coat bump textures enabled in the application.
  26856. */
  26857. static get ClearCoatBumpTextureEnabled(): boolean;
  26858. static set ClearCoatBumpTextureEnabled(value: boolean);
  26859. private static _ClearCoatTintTextureEnabled;
  26860. /**
  26861. * Are clear coat tint textures enabled in the application.
  26862. */
  26863. static get ClearCoatTintTextureEnabled(): boolean;
  26864. static set ClearCoatTintTextureEnabled(value: boolean);
  26865. private static _SheenTextureEnabled;
  26866. /**
  26867. * Are sheen textures enabled in the application.
  26868. */
  26869. static get SheenTextureEnabled(): boolean;
  26870. static set SheenTextureEnabled(value: boolean);
  26871. private static _AnisotropicTextureEnabled;
  26872. /**
  26873. * Are anisotropic textures enabled in the application.
  26874. */
  26875. static get AnisotropicTextureEnabled(): boolean;
  26876. static set AnisotropicTextureEnabled(value: boolean);
  26877. private static _ThicknessTextureEnabled;
  26878. /**
  26879. * Are thickness textures enabled in the application.
  26880. */
  26881. static get ThicknessTextureEnabled(): boolean;
  26882. static set ThicknessTextureEnabled(value: boolean);
  26883. }
  26884. }
  26885. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  26886. /** @hidden */
  26887. export var defaultFragmentDeclaration: {
  26888. name: string;
  26889. shader: string;
  26890. };
  26891. }
  26892. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  26893. /** @hidden */
  26894. export var defaultUboDeclaration: {
  26895. name: string;
  26896. shader: string;
  26897. };
  26898. }
  26899. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  26900. /** @hidden */
  26901. export var lightFragmentDeclaration: {
  26902. name: string;
  26903. shader: string;
  26904. };
  26905. }
  26906. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  26907. /** @hidden */
  26908. export var lightUboDeclaration: {
  26909. name: string;
  26910. shader: string;
  26911. };
  26912. }
  26913. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  26914. /** @hidden */
  26915. export var lightsFragmentFunctions: {
  26916. name: string;
  26917. shader: string;
  26918. };
  26919. }
  26920. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  26921. /** @hidden */
  26922. export var shadowsFragmentFunctions: {
  26923. name: string;
  26924. shader: string;
  26925. };
  26926. }
  26927. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  26928. /** @hidden */
  26929. export var fresnelFunction: {
  26930. name: string;
  26931. shader: string;
  26932. };
  26933. }
  26934. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  26935. /** @hidden */
  26936. export var reflectionFunction: {
  26937. name: string;
  26938. shader: string;
  26939. };
  26940. }
  26941. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  26942. /** @hidden */
  26943. export var bumpFragmentFunctions: {
  26944. name: string;
  26945. shader: string;
  26946. };
  26947. }
  26948. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  26949. /** @hidden */
  26950. export var logDepthDeclaration: {
  26951. name: string;
  26952. shader: string;
  26953. };
  26954. }
  26955. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  26956. /** @hidden */
  26957. export var bumpFragment: {
  26958. name: string;
  26959. shader: string;
  26960. };
  26961. }
  26962. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  26963. /** @hidden */
  26964. export var depthPrePass: {
  26965. name: string;
  26966. shader: string;
  26967. };
  26968. }
  26969. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  26970. /** @hidden */
  26971. export var lightFragment: {
  26972. name: string;
  26973. shader: string;
  26974. };
  26975. }
  26976. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  26977. /** @hidden */
  26978. export var logDepthFragment: {
  26979. name: string;
  26980. shader: string;
  26981. };
  26982. }
  26983. declare module "babylonjs/Shaders/default.fragment" {
  26984. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  26985. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  26986. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26987. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26988. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26989. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  26990. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  26991. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  26992. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  26993. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  26994. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  26995. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  26996. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  26997. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26998. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  26999. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  27000. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  27001. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  27002. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  27003. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  27004. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  27005. /** @hidden */
  27006. export var defaultPixelShader: {
  27007. name: string;
  27008. shader: string;
  27009. };
  27010. }
  27011. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  27012. /** @hidden */
  27013. export var defaultVertexDeclaration: {
  27014. name: string;
  27015. shader: string;
  27016. };
  27017. }
  27018. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  27019. /** @hidden */
  27020. export var bumpVertexDeclaration: {
  27021. name: string;
  27022. shader: string;
  27023. };
  27024. }
  27025. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  27026. /** @hidden */
  27027. export var bumpVertex: {
  27028. name: string;
  27029. shader: string;
  27030. };
  27031. }
  27032. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  27033. /** @hidden */
  27034. export var fogVertex: {
  27035. name: string;
  27036. shader: string;
  27037. };
  27038. }
  27039. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  27040. /** @hidden */
  27041. export var shadowsVertex: {
  27042. name: string;
  27043. shader: string;
  27044. };
  27045. }
  27046. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  27047. /** @hidden */
  27048. export var pointCloudVertex: {
  27049. name: string;
  27050. shader: string;
  27051. };
  27052. }
  27053. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  27054. /** @hidden */
  27055. export var logDepthVertex: {
  27056. name: string;
  27057. shader: string;
  27058. };
  27059. }
  27060. declare module "babylonjs/Shaders/default.vertex" {
  27061. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  27062. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  27063. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  27064. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  27065. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  27066. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  27067. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  27068. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  27069. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  27070. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  27071. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  27072. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  27073. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  27074. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  27075. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  27076. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  27077. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  27078. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  27079. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  27080. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  27081. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  27082. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  27083. /** @hidden */
  27084. export var defaultVertexShader: {
  27085. name: string;
  27086. shader: string;
  27087. };
  27088. }
  27089. declare module "babylonjs/Materials/standardMaterial" {
  27090. import { SmartArray } from "babylonjs/Misc/smartArray";
  27091. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27092. import { Nullable } from "babylonjs/types";
  27093. import { Scene } from "babylonjs/scene";
  27094. import { Matrix } from "babylonjs/Maths/math.vector";
  27095. import { Color3 } from "babylonjs/Maths/math.color";
  27096. import { SubMesh } from "babylonjs/Meshes/subMesh";
  27097. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27098. import { Mesh } from "babylonjs/Meshes/mesh";
  27099. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  27100. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  27101. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  27102. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  27103. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  27104. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27105. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27106. import "babylonjs/Shaders/default.fragment";
  27107. import "babylonjs/Shaders/default.vertex";
  27108. /** @hidden */
  27109. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  27110. MAINUV1: boolean;
  27111. MAINUV2: boolean;
  27112. DIFFUSE: boolean;
  27113. DIFFUSEDIRECTUV: number;
  27114. AMBIENT: boolean;
  27115. AMBIENTDIRECTUV: number;
  27116. OPACITY: boolean;
  27117. OPACITYDIRECTUV: number;
  27118. OPACITYRGB: boolean;
  27119. REFLECTION: boolean;
  27120. EMISSIVE: boolean;
  27121. EMISSIVEDIRECTUV: number;
  27122. SPECULAR: boolean;
  27123. SPECULARDIRECTUV: number;
  27124. BUMP: boolean;
  27125. BUMPDIRECTUV: number;
  27126. PARALLAX: boolean;
  27127. PARALLAXOCCLUSION: boolean;
  27128. SPECULAROVERALPHA: boolean;
  27129. CLIPPLANE: boolean;
  27130. CLIPPLANE2: boolean;
  27131. CLIPPLANE3: boolean;
  27132. CLIPPLANE4: boolean;
  27133. CLIPPLANE5: boolean;
  27134. CLIPPLANE6: boolean;
  27135. ALPHATEST: boolean;
  27136. DEPTHPREPASS: boolean;
  27137. ALPHAFROMDIFFUSE: boolean;
  27138. POINTSIZE: boolean;
  27139. FOG: boolean;
  27140. SPECULARTERM: boolean;
  27141. DIFFUSEFRESNEL: boolean;
  27142. OPACITYFRESNEL: boolean;
  27143. REFLECTIONFRESNEL: boolean;
  27144. REFRACTIONFRESNEL: boolean;
  27145. EMISSIVEFRESNEL: boolean;
  27146. FRESNEL: boolean;
  27147. NORMAL: boolean;
  27148. UV1: boolean;
  27149. UV2: boolean;
  27150. VERTEXCOLOR: boolean;
  27151. VERTEXALPHA: boolean;
  27152. NUM_BONE_INFLUENCERS: number;
  27153. BonesPerMesh: number;
  27154. BONETEXTURE: boolean;
  27155. INSTANCES: boolean;
  27156. GLOSSINESS: boolean;
  27157. ROUGHNESS: boolean;
  27158. EMISSIVEASILLUMINATION: boolean;
  27159. LINKEMISSIVEWITHDIFFUSE: boolean;
  27160. REFLECTIONFRESNELFROMSPECULAR: boolean;
  27161. LIGHTMAP: boolean;
  27162. LIGHTMAPDIRECTUV: number;
  27163. OBJECTSPACE_NORMALMAP: boolean;
  27164. USELIGHTMAPASSHADOWMAP: boolean;
  27165. REFLECTIONMAP_3D: boolean;
  27166. REFLECTIONMAP_SPHERICAL: boolean;
  27167. REFLECTIONMAP_PLANAR: boolean;
  27168. REFLECTIONMAP_CUBIC: boolean;
  27169. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  27170. REFLECTIONMAP_PROJECTION: boolean;
  27171. REFLECTIONMAP_SKYBOX: boolean;
  27172. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  27173. REFLECTIONMAP_EXPLICIT: boolean;
  27174. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  27175. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  27176. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  27177. INVERTCUBICMAP: boolean;
  27178. LOGARITHMICDEPTH: boolean;
  27179. REFRACTION: boolean;
  27180. REFRACTIONMAP_3D: boolean;
  27181. REFLECTIONOVERALPHA: boolean;
  27182. TWOSIDEDLIGHTING: boolean;
  27183. SHADOWFLOAT: boolean;
  27184. MORPHTARGETS: boolean;
  27185. MORPHTARGETS_NORMAL: boolean;
  27186. MORPHTARGETS_TANGENT: boolean;
  27187. MORPHTARGETS_UV: boolean;
  27188. NUM_MORPH_INFLUENCERS: number;
  27189. NONUNIFORMSCALING: boolean;
  27190. PREMULTIPLYALPHA: boolean;
  27191. IMAGEPROCESSING: boolean;
  27192. VIGNETTE: boolean;
  27193. VIGNETTEBLENDMODEMULTIPLY: boolean;
  27194. VIGNETTEBLENDMODEOPAQUE: boolean;
  27195. TONEMAPPING: boolean;
  27196. TONEMAPPING_ACES: boolean;
  27197. CONTRAST: boolean;
  27198. COLORCURVES: boolean;
  27199. COLORGRADING: boolean;
  27200. COLORGRADING3D: boolean;
  27201. SAMPLER3DGREENDEPTH: boolean;
  27202. SAMPLER3DBGRMAP: boolean;
  27203. IMAGEPROCESSINGPOSTPROCESS: boolean;
  27204. MULTIVIEW: boolean;
  27205. /**
  27206. * If the reflection texture on this material is in linear color space
  27207. * @hidden
  27208. */
  27209. IS_REFLECTION_LINEAR: boolean;
  27210. /**
  27211. * If the refraction texture on this material is in linear color space
  27212. * @hidden
  27213. */
  27214. IS_REFRACTION_LINEAR: boolean;
  27215. EXPOSURE: boolean;
  27216. constructor();
  27217. setReflectionMode(modeToEnable: string): void;
  27218. }
  27219. /**
  27220. * This is the default material used in Babylon. It is the best trade off between quality
  27221. * and performances.
  27222. * @see http://doc.babylonjs.com/babylon101/materials
  27223. */
  27224. export class StandardMaterial extends PushMaterial {
  27225. private _diffuseTexture;
  27226. /**
  27227. * The basic texture of the material as viewed under a light.
  27228. */
  27229. diffuseTexture: Nullable<BaseTexture>;
  27230. private _ambientTexture;
  27231. /**
  27232. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  27233. */
  27234. ambientTexture: Nullable<BaseTexture>;
  27235. private _opacityTexture;
  27236. /**
  27237. * Define the transparency of the material from a texture.
  27238. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  27239. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  27240. */
  27241. opacityTexture: Nullable<BaseTexture>;
  27242. private _reflectionTexture;
  27243. /**
  27244. * Define the texture used to display the reflection.
  27245. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27246. */
  27247. reflectionTexture: Nullable<BaseTexture>;
  27248. private _emissiveTexture;
  27249. /**
  27250. * Define texture of the material as if self lit.
  27251. * This will be mixed in the final result even in the absence of light.
  27252. */
  27253. emissiveTexture: Nullable<BaseTexture>;
  27254. private _specularTexture;
  27255. /**
  27256. * Define how the color and intensity of the highlight given by the light in the material.
  27257. */
  27258. specularTexture: Nullable<BaseTexture>;
  27259. private _bumpTexture;
  27260. /**
  27261. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  27262. * 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.
  27263. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  27264. */
  27265. bumpTexture: Nullable<BaseTexture>;
  27266. private _lightmapTexture;
  27267. /**
  27268. * Complex lighting can be computationally expensive to compute at runtime.
  27269. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  27270. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  27271. */
  27272. lightmapTexture: Nullable<BaseTexture>;
  27273. private _refractionTexture;
  27274. /**
  27275. * Define the texture used to display the refraction.
  27276. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27277. */
  27278. refractionTexture: Nullable<BaseTexture>;
  27279. /**
  27280. * The color of the material lit by the environmental background lighting.
  27281. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  27282. */
  27283. ambientColor: Color3;
  27284. /**
  27285. * The basic color of the material as viewed under a light.
  27286. */
  27287. diffuseColor: Color3;
  27288. /**
  27289. * Define how the color and intensity of the highlight given by the light in the material.
  27290. */
  27291. specularColor: Color3;
  27292. /**
  27293. * Define the color of the material as if self lit.
  27294. * This will be mixed in the final result even in the absence of light.
  27295. */
  27296. emissiveColor: Color3;
  27297. /**
  27298. * Defines how sharp are the highlights in the material.
  27299. * The bigger the value the sharper giving a more glossy feeling to the result.
  27300. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  27301. */
  27302. specularPower: number;
  27303. private _useAlphaFromDiffuseTexture;
  27304. /**
  27305. * Does the transparency come from the diffuse texture alpha channel.
  27306. */
  27307. useAlphaFromDiffuseTexture: boolean;
  27308. private _useEmissiveAsIllumination;
  27309. /**
  27310. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  27311. */
  27312. useEmissiveAsIllumination: boolean;
  27313. private _linkEmissiveWithDiffuse;
  27314. /**
  27315. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  27316. * the emissive level when the final color is close to one.
  27317. */
  27318. linkEmissiveWithDiffuse: boolean;
  27319. private _useSpecularOverAlpha;
  27320. /**
  27321. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27322. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27323. */
  27324. useSpecularOverAlpha: boolean;
  27325. private _useReflectionOverAlpha;
  27326. /**
  27327. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27328. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27329. */
  27330. useReflectionOverAlpha: boolean;
  27331. private _disableLighting;
  27332. /**
  27333. * Does lights from the scene impacts this material.
  27334. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  27335. */
  27336. disableLighting: boolean;
  27337. private _useObjectSpaceNormalMap;
  27338. /**
  27339. * Allows using an object space normal map (instead of tangent space).
  27340. */
  27341. useObjectSpaceNormalMap: boolean;
  27342. private _useParallax;
  27343. /**
  27344. * Is parallax enabled or not.
  27345. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27346. */
  27347. useParallax: boolean;
  27348. private _useParallaxOcclusion;
  27349. /**
  27350. * Is parallax occlusion enabled or not.
  27351. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  27352. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27353. */
  27354. useParallaxOcclusion: boolean;
  27355. /**
  27356. * 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.
  27357. */
  27358. parallaxScaleBias: number;
  27359. private _roughness;
  27360. /**
  27361. * Helps to define how blurry the reflections should appears in the material.
  27362. */
  27363. roughness: number;
  27364. /**
  27365. * In case of refraction, define the value of the index of refraction.
  27366. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27367. */
  27368. indexOfRefraction: number;
  27369. /**
  27370. * Invert the refraction texture alongside the y axis.
  27371. * It can be useful with procedural textures or probe for instance.
  27372. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27373. */
  27374. invertRefractionY: boolean;
  27375. /**
  27376. * Defines the alpha limits in alpha test mode.
  27377. */
  27378. alphaCutOff: number;
  27379. private _useLightmapAsShadowmap;
  27380. /**
  27381. * In case of light mapping, define whether the map contains light or shadow informations.
  27382. */
  27383. useLightmapAsShadowmap: boolean;
  27384. private _diffuseFresnelParameters;
  27385. /**
  27386. * Define the diffuse fresnel parameters of the material.
  27387. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27388. */
  27389. diffuseFresnelParameters: FresnelParameters;
  27390. private _opacityFresnelParameters;
  27391. /**
  27392. * Define the opacity fresnel parameters of the material.
  27393. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27394. */
  27395. opacityFresnelParameters: FresnelParameters;
  27396. private _reflectionFresnelParameters;
  27397. /**
  27398. * Define the reflection fresnel parameters of the material.
  27399. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27400. */
  27401. reflectionFresnelParameters: FresnelParameters;
  27402. private _refractionFresnelParameters;
  27403. /**
  27404. * Define the refraction fresnel parameters of the material.
  27405. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27406. */
  27407. refractionFresnelParameters: FresnelParameters;
  27408. private _emissiveFresnelParameters;
  27409. /**
  27410. * Define the emissive fresnel parameters of the material.
  27411. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27412. */
  27413. emissiveFresnelParameters: FresnelParameters;
  27414. private _useReflectionFresnelFromSpecular;
  27415. /**
  27416. * If true automatically deducts the fresnels values from the material specularity.
  27417. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27418. */
  27419. useReflectionFresnelFromSpecular: boolean;
  27420. private _useGlossinessFromSpecularMapAlpha;
  27421. /**
  27422. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  27423. */
  27424. useGlossinessFromSpecularMapAlpha: boolean;
  27425. private _maxSimultaneousLights;
  27426. /**
  27427. * Defines the maximum number of lights that can be used in the material
  27428. */
  27429. maxSimultaneousLights: number;
  27430. private _invertNormalMapX;
  27431. /**
  27432. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27433. */
  27434. invertNormalMapX: boolean;
  27435. private _invertNormalMapY;
  27436. /**
  27437. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27438. */
  27439. invertNormalMapY: boolean;
  27440. private _twoSidedLighting;
  27441. /**
  27442. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27443. */
  27444. twoSidedLighting: boolean;
  27445. /**
  27446. * Default configuration related to image processing available in the standard Material.
  27447. */
  27448. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27449. /**
  27450. * Gets the image processing configuration used either in this material.
  27451. */
  27452. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27453. /**
  27454. * Sets the Default image processing configuration used either in the this material.
  27455. *
  27456. * If sets to null, the scene one is in use.
  27457. */
  27458. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27459. /**
  27460. * Keep track of the image processing observer to allow dispose and replace.
  27461. */
  27462. private _imageProcessingObserver;
  27463. /**
  27464. * Attaches a new image processing configuration to the Standard Material.
  27465. * @param configuration
  27466. */
  27467. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27468. /**
  27469. * Gets wether the color curves effect is enabled.
  27470. */
  27471. get cameraColorCurvesEnabled(): boolean;
  27472. /**
  27473. * Sets wether the color curves effect is enabled.
  27474. */
  27475. set cameraColorCurvesEnabled(value: boolean);
  27476. /**
  27477. * Gets wether the color grading effect is enabled.
  27478. */
  27479. get cameraColorGradingEnabled(): boolean;
  27480. /**
  27481. * Gets wether the color grading effect is enabled.
  27482. */
  27483. set cameraColorGradingEnabled(value: boolean);
  27484. /**
  27485. * Gets wether tonemapping is enabled or not.
  27486. */
  27487. get cameraToneMappingEnabled(): boolean;
  27488. /**
  27489. * Sets wether tonemapping is enabled or not
  27490. */
  27491. set cameraToneMappingEnabled(value: boolean);
  27492. /**
  27493. * The camera exposure used on this material.
  27494. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27495. * This corresponds to a photographic exposure.
  27496. */
  27497. get cameraExposure(): number;
  27498. /**
  27499. * The camera exposure used on this material.
  27500. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27501. * This corresponds to a photographic exposure.
  27502. */
  27503. set cameraExposure(value: number);
  27504. /**
  27505. * Gets The camera contrast used on this material.
  27506. */
  27507. get cameraContrast(): number;
  27508. /**
  27509. * Sets The camera contrast used on this material.
  27510. */
  27511. set cameraContrast(value: number);
  27512. /**
  27513. * Gets the Color Grading 2D Lookup Texture.
  27514. */
  27515. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27516. /**
  27517. * Sets the Color Grading 2D Lookup Texture.
  27518. */
  27519. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27520. /**
  27521. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27522. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27523. * 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;
  27524. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27525. */
  27526. get cameraColorCurves(): Nullable<ColorCurves>;
  27527. /**
  27528. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27529. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27530. * 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;
  27531. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27532. */
  27533. set cameraColorCurves(value: Nullable<ColorCurves>);
  27534. /**
  27535. * Custom callback helping to override the default shader used in the material.
  27536. */
  27537. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  27538. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27539. protected _worldViewProjectionMatrix: Matrix;
  27540. protected _globalAmbientColor: Color3;
  27541. protected _useLogarithmicDepth: boolean;
  27542. protected _rebuildInParallel: boolean;
  27543. /**
  27544. * Instantiates a new standard material.
  27545. * This is the default material used in Babylon. It is the best trade off between quality
  27546. * and performances.
  27547. * @see http://doc.babylonjs.com/babylon101/materials
  27548. * @param name Define the name of the material in the scene
  27549. * @param scene Define the scene the material belong to
  27550. */
  27551. constructor(name: string, scene: Scene);
  27552. /**
  27553. * Gets a boolean indicating that current material needs to register RTT
  27554. */
  27555. get hasRenderTargetTextures(): boolean;
  27556. /**
  27557. * Gets the current class name of the material e.g. "StandardMaterial"
  27558. * Mainly use in serialization.
  27559. * @returns the class name
  27560. */
  27561. getClassName(): string;
  27562. /**
  27563. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27564. * You can try switching to logarithmic depth.
  27565. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27566. */
  27567. get useLogarithmicDepth(): boolean;
  27568. set useLogarithmicDepth(value: boolean);
  27569. /**
  27570. * Specifies if the material will require alpha blending
  27571. * @returns a boolean specifying if alpha blending is needed
  27572. */
  27573. needAlphaBlending(): boolean;
  27574. /**
  27575. * Specifies if this material should be rendered in alpha test mode
  27576. * @returns a boolean specifying if an alpha test is needed.
  27577. */
  27578. needAlphaTesting(): boolean;
  27579. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27580. /**
  27581. * Get the texture used for alpha test purpose.
  27582. * @returns the diffuse texture in case of the standard material.
  27583. */
  27584. getAlphaTestTexture(): Nullable<BaseTexture>;
  27585. /**
  27586. * Get if the submesh is ready to be used and all its information available.
  27587. * Child classes can use it to update shaders
  27588. * @param mesh defines the mesh to check
  27589. * @param subMesh defines which submesh to check
  27590. * @param useInstances specifies that instances should be used
  27591. * @returns a boolean indicating that the submesh is ready or not
  27592. */
  27593. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27594. /**
  27595. * Builds the material UBO layouts.
  27596. * Used internally during the effect preparation.
  27597. */
  27598. buildUniformLayout(): void;
  27599. /**
  27600. * Unbinds the material from the mesh
  27601. */
  27602. unbind(): void;
  27603. /**
  27604. * Binds the submesh to this material by preparing the effect and shader to draw
  27605. * @param world defines the world transformation matrix
  27606. * @param mesh defines the mesh containing the submesh
  27607. * @param subMesh defines the submesh to bind the material to
  27608. */
  27609. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27610. /**
  27611. * Get the list of animatables in the material.
  27612. * @returns the list of animatables object used in the material
  27613. */
  27614. getAnimatables(): IAnimatable[];
  27615. /**
  27616. * Gets the active textures from the material
  27617. * @returns an array of textures
  27618. */
  27619. getActiveTextures(): BaseTexture[];
  27620. /**
  27621. * Specifies if the material uses a texture
  27622. * @param texture defines the texture to check against the material
  27623. * @returns a boolean specifying if the material uses the texture
  27624. */
  27625. hasTexture(texture: BaseTexture): boolean;
  27626. /**
  27627. * Disposes the material
  27628. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27629. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27630. */
  27631. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27632. /**
  27633. * Makes a duplicate of the material, and gives it a new name
  27634. * @param name defines the new name for the duplicated material
  27635. * @returns the cloned material
  27636. */
  27637. clone(name: string): StandardMaterial;
  27638. /**
  27639. * Serializes this material in a JSON representation
  27640. * @returns the serialized material object
  27641. */
  27642. serialize(): any;
  27643. /**
  27644. * Creates a standard material from parsed material data
  27645. * @param source defines the JSON representation of the material
  27646. * @param scene defines the hosting scene
  27647. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27648. * @returns a new standard material
  27649. */
  27650. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27651. /**
  27652. * Are diffuse textures enabled in the application.
  27653. */
  27654. static get DiffuseTextureEnabled(): boolean;
  27655. static set DiffuseTextureEnabled(value: boolean);
  27656. /**
  27657. * Are ambient textures enabled in the application.
  27658. */
  27659. static get AmbientTextureEnabled(): boolean;
  27660. static set AmbientTextureEnabled(value: boolean);
  27661. /**
  27662. * Are opacity textures enabled in the application.
  27663. */
  27664. static get OpacityTextureEnabled(): boolean;
  27665. static set OpacityTextureEnabled(value: boolean);
  27666. /**
  27667. * Are reflection textures enabled in the application.
  27668. */
  27669. static get ReflectionTextureEnabled(): boolean;
  27670. static set ReflectionTextureEnabled(value: boolean);
  27671. /**
  27672. * Are emissive textures enabled in the application.
  27673. */
  27674. static get EmissiveTextureEnabled(): boolean;
  27675. static set EmissiveTextureEnabled(value: boolean);
  27676. /**
  27677. * Are specular textures enabled in the application.
  27678. */
  27679. static get SpecularTextureEnabled(): boolean;
  27680. static set SpecularTextureEnabled(value: boolean);
  27681. /**
  27682. * Are bump textures enabled in the application.
  27683. */
  27684. static get BumpTextureEnabled(): boolean;
  27685. static set BumpTextureEnabled(value: boolean);
  27686. /**
  27687. * Are lightmap textures enabled in the application.
  27688. */
  27689. static get LightmapTextureEnabled(): boolean;
  27690. static set LightmapTextureEnabled(value: boolean);
  27691. /**
  27692. * Are refraction textures enabled in the application.
  27693. */
  27694. static get RefractionTextureEnabled(): boolean;
  27695. static set RefractionTextureEnabled(value: boolean);
  27696. /**
  27697. * Are color grading textures enabled in the application.
  27698. */
  27699. static get ColorGradingTextureEnabled(): boolean;
  27700. static set ColorGradingTextureEnabled(value: boolean);
  27701. /**
  27702. * Are fresnels enabled in the application.
  27703. */
  27704. static get FresnelEnabled(): boolean;
  27705. static set FresnelEnabled(value: boolean);
  27706. }
  27707. }
  27708. declare module "babylonjs/Particles/solidParticleSystem" {
  27709. import { Nullable } from "babylonjs/types";
  27710. import { Vector3 } from "babylonjs/Maths/math.vector";
  27711. import { Mesh } from "babylonjs/Meshes/mesh";
  27712. import { Scene, IDisposable } from "babylonjs/scene";
  27713. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  27714. import { Material } from "babylonjs/Materials/material";
  27715. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  27716. /**
  27717. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27718. *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.
  27719. * The SPS is also a particle system. It provides some methods to manage the particles.
  27720. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27721. *
  27722. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27723. */
  27724. export class SolidParticleSystem implements IDisposable {
  27725. /**
  27726. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27727. * Example : var p = SPS.particles[i];
  27728. */
  27729. particles: SolidParticle[];
  27730. /**
  27731. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27732. */
  27733. nbParticles: number;
  27734. /**
  27735. * If the particles must ever face the camera (default false). Useful for planar particles.
  27736. */
  27737. billboard: boolean;
  27738. /**
  27739. * Recompute normals when adding a shape
  27740. */
  27741. recomputeNormals: boolean;
  27742. /**
  27743. * This a counter ofr your own usage. It's not set by any SPS functions.
  27744. */
  27745. counter: number;
  27746. /**
  27747. * The SPS name. This name is also given to the underlying mesh.
  27748. */
  27749. name: string;
  27750. /**
  27751. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27752. */
  27753. mesh: Mesh;
  27754. /**
  27755. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27756. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27757. */
  27758. vars: any;
  27759. /**
  27760. * This array is populated when the SPS is set as 'pickable'.
  27761. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27762. * Each element of this array is an object `{idx: int, faceId: int}`.
  27763. * `idx` is the picked particle index in the `SPS.particles` array
  27764. * `faceId` is the picked face index counted within this particle.
  27765. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27766. */
  27767. pickedParticles: {
  27768. idx: number;
  27769. faceId: number;
  27770. }[];
  27771. /**
  27772. * This array is populated when `enableDepthSort` is set to true.
  27773. * Each element of this array is an instance of the class DepthSortedParticle.
  27774. */
  27775. depthSortedParticles: DepthSortedParticle[];
  27776. /**
  27777. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27778. * @hidden
  27779. */
  27780. _bSphereOnly: boolean;
  27781. /**
  27782. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27783. * @hidden
  27784. */
  27785. _bSphereRadiusFactor: number;
  27786. private _scene;
  27787. private _positions;
  27788. private _indices;
  27789. private _normals;
  27790. private _colors;
  27791. private _uvs;
  27792. private _indices32;
  27793. private _positions32;
  27794. private _normals32;
  27795. private _fixedNormal32;
  27796. private _colors32;
  27797. private _uvs32;
  27798. private _index;
  27799. private _updatable;
  27800. private _pickable;
  27801. private _isVisibilityBoxLocked;
  27802. private _alwaysVisible;
  27803. private _depthSort;
  27804. private _expandable;
  27805. private _shapeCounter;
  27806. private _copy;
  27807. private _color;
  27808. private _computeParticleColor;
  27809. private _computeParticleTexture;
  27810. private _computeParticleRotation;
  27811. private _computeParticleVertex;
  27812. private _computeBoundingBox;
  27813. private _depthSortParticles;
  27814. private _camera;
  27815. private _mustUnrotateFixedNormals;
  27816. private _particlesIntersect;
  27817. private _needs32Bits;
  27818. private _isNotBuilt;
  27819. private _lastParticleId;
  27820. private _idxOfId;
  27821. private _multimaterialEnabled;
  27822. private _useModelMaterial;
  27823. private _indicesByMaterial;
  27824. private _materialIndexes;
  27825. private _depthSortFunction;
  27826. private _materialSortFunction;
  27827. private _materials;
  27828. private _multimaterial;
  27829. private _materialIndexesById;
  27830. private _defaultMaterial;
  27831. private _autoUpdateSubMeshes;
  27832. /**
  27833. * Creates a SPS (Solid Particle System) object.
  27834. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27835. * @param scene (Scene) is the scene in which the SPS is added.
  27836. * @param options defines the options of the sps e.g.
  27837. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27838. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27839. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27840. * * 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.
  27841. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27842. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27843. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27844. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27845. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27846. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27847. */
  27848. constructor(name: string, scene: Scene, options?: {
  27849. updatable?: boolean;
  27850. isPickable?: boolean;
  27851. enableDepthSort?: boolean;
  27852. particleIntersection?: boolean;
  27853. boundingSphereOnly?: boolean;
  27854. bSphereRadiusFactor?: number;
  27855. expandable?: boolean;
  27856. useModelMaterial?: boolean;
  27857. enableMultiMaterial?: boolean;
  27858. });
  27859. /**
  27860. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27861. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27862. * @returns the created mesh
  27863. */
  27864. buildMesh(): Mesh;
  27865. /**
  27866. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27867. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27868. * Thus the particles generated from `digest()` have their property `position` set yet.
  27869. * @param mesh ( Mesh ) is the mesh to be digested
  27870. * @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
  27871. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27872. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27873. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27874. * @returns the current SPS
  27875. */
  27876. digest(mesh: Mesh, options?: {
  27877. facetNb?: number;
  27878. number?: number;
  27879. delta?: number;
  27880. storage?: [];
  27881. }): SolidParticleSystem;
  27882. /**
  27883. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27884. * @hidden
  27885. */
  27886. private _unrotateFixedNormals;
  27887. /**
  27888. * Resets the temporary working copy particle
  27889. * @hidden
  27890. */
  27891. private _resetCopy;
  27892. /**
  27893. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27894. * @param p the current index in the positions array to be updated
  27895. * @param ind the current index in the indices array
  27896. * @param shape a Vector3 array, the shape geometry
  27897. * @param positions the positions array to be updated
  27898. * @param meshInd the shape indices array
  27899. * @param indices the indices array to be updated
  27900. * @param meshUV the shape uv array
  27901. * @param uvs the uv array to be updated
  27902. * @param meshCol the shape color array
  27903. * @param colors the color array to be updated
  27904. * @param meshNor the shape normals array
  27905. * @param normals the normals array to be updated
  27906. * @param idx the particle index
  27907. * @param idxInShape the particle index in its shape
  27908. * @param options the addShape() method passed options
  27909. * @model the particle model
  27910. * @hidden
  27911. */
  27912. private _meshBuilder;
  27913. /**
  27914. * Returns a shape Vector3 array from positions float array
  27915. * @param positions float array
  27916. * @returns a vector3 array
  27917. * @hidden
  27918. */
  27919. private _posToShape;
  27920. /**
  27921. * Returns a shapeUV array from a float uvs (array deep copy)
  27922. * @param uvs as a float array
  27923. * @returns a shapeUV array
  27924. * @hidden
  27925. */
  27926. private _uvsToShapeUV;
  27927. /**
  27928. * Adds a new particle object in the particles array
  27929. * @param idx particle index in particles array
  27930. * @param id particle id
  27931. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27932. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27933. * @param model particle ModelShape object
  27934. * @param shapeId model shape identifier
  27935. * @param idxInShape index of the particle in the current model
  27936. * @param bInfo model bounding info object
  27937. * @param storage target storage array, if any
  27938. * @hidden
  27939. */
  27940. private _addParticle;
  27941. /**
  27942. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27943. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27944. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27945. * @param nb (positive integer) the number of particles to be created from this model
  27946. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27947. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27948. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27949. * @returns the number of shapes in the system
  27950. */
  27951. addShape(mesh: Mesh, nb: number, options?: {
  27952. positionFunction?: any;
  27953. vertexFunction?: any;
  27954. storage?: [];
  27955. }): number;
  27956. /**
  27957. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27958. * @hidden
  27959. */
  27960. private _rebuildParticle;
  27961. /**
  27962. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27963. * @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.
  27964. * @returns the SPS.
  27965. */
  27966. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27967. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27968. * Returns an array with the removed particles.
  27969. * 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.
  27970. * The SPS can't be empty so at least one particle needs to remain in place.
  27971. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27972. * @param start index of the first particle to remove
  27973. * @param end index of the last particle to remove (included)
  27974. * @returns an array populated with the removed particles
  27975. */
  27976. removeParticles(start: number, end: number): SolidParticle[];
  27977. /**
  27978. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27979. * @param solidParticleArray an array populated with Solid Particles objects
  27980. * @returns the SPS
  27981. */
  27982. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27983. /**
  27984. * Creates a new particle and modifies the SPS mesh geometry :
  27985. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27986. * - calls _addParticle() to populate the particle array
  27987. * factorized code from addShape() and insertParticlesFromArray()
  27988. * @param idx particle index in the particles array
  27989. * @param i particle index in its shape
  27990. * @param modelShape particle ModelShape object
  27991. * @param shape shape vertex array
  27992. * @param meshInd shape indices array
  27993. * @param meshUV shape uv array
  27994. * @param meshCol shape color array
  27995. * @param meshNor shape normals array
  27996. * @param bbInfo shape bounding info
  27997. * @param storage target particle storage
  27998. * @options addShape() passed options
  27999. * @hidden
  28000. */
  28001. private _insertNewParticle;
  28002. /**
  28003. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  28004. * This method calls `updateParticle()` for each particle of the SPS.
  28005. * For an animated SPS, it is usually called within the render loop.
  28006. * 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.
  28007. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  28008. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  28009. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  28010. * @returns the SPS.
  28011. */
  28012. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  28013. /**
  28014. * Disposes the SPS.
  28015. */
  28016. dispose(): void;
  28017. /**
  28018. * Returns a SolidParticle object from its identifier : particle.id
  28019. * @param id (integer) the particle Id
  28020. * @returns the searched particle or null if not found in the SPS.
  28021. */
  28022. getParticleById(id: number): Nullable<SolidParticle>;
  28023. /**
  28024. * Returns a new array populated with the particles having the passed shapeId.
  28025. * @param shapeId (integer) the shape identifier
  28026. * @returns a new solid particle array
  28027. */
  28028. getParticlesByShapeId(shapeId: number): SolidParticle[];
  28029. /**
  28030. * Populates the passed array "ref" with the particles having the passed shapeId.
  28031. * @param shapeId the shape identifier
  28032. * @returns the SPS
  28033. * @param ref
  28034. */
  28035. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  28036. /**
  28037. * Computes the required SubMeshes according the materials assigned to the particles.
  28038. * @returns the solid particle system.
  28039. * Does nothing if called before the SPS mesh is built.
  28040. */
  28041. computeSubMeshes(): SolidParticleSystem;
  28042. /**
  28043. * Sorts the solid particles by material when MultiMaterial is enabled.
  28044. * Updates the indices32 array.
  28045. * Updates the indicesByMaterial array.
  28046. * Updates the mesh indices array.
  28047. * @returns the SPS
  28048. * @hidden
  28049. */
  28050. private _sortParticlesByMaterial;
  28051. /**
  28052. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  28053. * @hidden
  28054. */
  28055. private _setMaterialIndexesById;
  28056. /**
  28057. * Returns an array with unique values of Materials from the passed array
  28058. * @param array the material array to be checked and filtered
  28059. * @hidden
  28060. */
  28061. private _filterUniqueMaterialId;
  28062. /**
  28063. * Sets a new Standard Material as _defaultMaterial if not already set.
  28064. * @hidden
  28065. */
  28066. private _setDefaultMaterial;
  28067. /**
  28068. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  28069. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28070. * @returns the SPS.
  28071. */
  28072. refreshVisibleSize(): SolidParticleSystem;
  28073. /**
  28074. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  28075. * @param size the size (float) of the visibility box
  28076. * note : this doesn't lock the SPS mesh bounding box.
  28077. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28078. */
  28079. setVisibilityBox(size: number): void;
  28080. /**
  28081. * Gets whether the SPS as always visible or not
  28082. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28083. */
  28084. get isAlwaysVisible(): boolean;
  28085. /**
  28086. * Sets the SPS as always visible or not
  28087. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28088. */
  28089. set isAlwaysVisible(val: boolean);
  28090. /**
  28091. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28092. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28093. */
  28094. set isVisibilityBoxLocked(val: boolean);
  28095. /**
  28096. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28097. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28098. */
  28099. get isVisibilityBoxLocked(): boolean;
  28100. /**
  28101. * Tells to `setParticles()` to compute the particle rotations or not.
  28102. * Default value : true. The SPS is faster when it's set to false.
  28103. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28104. */
  28105. set computeParticleRotation(val: boolean);
  28106. /**
  28107. * Tells to `setParticles()` to compute the particle colors or not.
  28108. * Default value : true. The SPS is faster when it's set to false.
  28109. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28110. */
  28111. set computeParticleColor(val: boolean);
  28112. set computeParticleTexture(val: boolean);
  28113. /**
  28114. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  28115. * Default value : false. The SPS is faster when it's set to false.
  28116. * Note : the particle custom vertex positions aren't stored values.
  28117. */
  28118. set computeParticleVertex(val: boolean);
  28119. /**
  28120. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  28121. */
  28122. set computeBoundingBox(val: boolean);
  28123. /**
  28124. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  28125. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28126. * Default : `true`
  28127. */
  28128. set depthSortParticles(val: boolean);
  28129. /**
  28130. * Gets if `setParticles()` computes the particle rotations or not.
  28131. * Default value : true. The SPS is faster when it's set to false.
  28132. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28133. */
  28134. get computeParticleRotation(): boolean;
  28135. /**
  28136. * Gets if `setParticles()` computes the particle colors or not.
  28137. * Default value : true. The SPS is faster when it's set to false.
  28138. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28139. */
  28140. get computeParticleColor(): boolean;
  28141. /**
  28142. * Gets if `setParticles()` computes the particle textures or not.
  28143. * Default value : true. The SPS is faster when it's set to false.
  28144. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  28145. */
  28146. get computeParticleTexture(): boolean;
  28147. /**
  28148. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  28149. * Default value : false. The SPS is faster when it's set to false.
  28150. * Note : the particle custom vertex positions aren't stored values.
  28151. */
  28152. get computeParticleVertex(): boolean;
  28153. /**
  28154. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  28155. */
  28156. get computeBoundingBox(): boolean;
  28157. /**
  28158. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  28159. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28160. * Default : `true`
  28161. */
  28162. get depthSortParticles(): boolean;
  28163. /**
  28164. * Gets if the SPS is created as expandable at construction time.
  28165. * Default : `false`
  28166. */
  28167. get expandable(): boolean;
  28168. /**
  28169. * Gets if the SPS supports the Multi Materials
  28170. */
  28171. get multimaterialEnabled(): boolean;
  28172. /**
  28173. * Gets if the SPS uses the model materials for its own multimaterial.
  28174. */
  28175. get useModelMaterial(): boolean;
  28176. /**
  28177. * The SPS used material array.
  28178. */
  28179. get materials(): Material[];
  28180. /**
  28181. * Sets the SPS MultiMaterial from the passed materials.
  28182. * Note : the passed array is internally copied and not used then by reference.
  28183. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  28184. */
  28185. setMultiMaterial(materials: Material[]): void;
  28186. /**
  28187. * The SPS computed multimaterial object
  28188. */
  28189. get multimaterial(): MultiMaterial;
  28190. set multimaterial(mm: MultiMaterial);
  28191. /**
  28192. * If the subMeshes must be updated on the next call to setParticles()
  28193. */
  28194. get autoUpdateSubMeshes(): boolean;
  28195. set autoUpdateSubMeshes(val: boolean);
  28196. /**
  28197. * This function does nothing. It may be overwritten to set all the particle first values.
  28198. * The SPS doesn't call this function, you may have to call it by your own.
  28199. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28200. */
  28201. initParticles(): void;
  28202. /**
  28203. * This function does nothing. It may be overwritten to recycle a particle.
  28204. * The SPS doesn't call this function, you may have to call it by your own.
  28205. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28206. * @param particle The particle to recycle
  28207. * @returns the recycled particle
  28208. */
  28209. recycleParticle(particle: SolidParticle): SolidParticle;
  28210. /**
  28211. * Updates a particle : this function should be overwritten by the user.
  28212. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  28213. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28214. * @example : just set a particle position or velocity and recycle conditions
  28215. * @param particle The particle to update
  28216. * @returns the updated particle
  28217. */
  28218. updateParticle(particle: SolidParticle): SolidParticle;
  28219. /**
  28220. * Updates a vertex of a particle : it can be overwritten by the user.
  28221. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  28222. * @param particle the current particle
  28223. * @param vertex the current index of the current particle
  28224. * @param pt the index of the current vertex in the particle shape
  28225. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  28226. * @example : just set a vertex particle position
  28227. * @returns the updated vertex
  28228. */
  28229. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  28230. /**
  28231. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  28232. * This does nothing and may be overwritten by the user.
  28233. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28234. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28235. * @param update the boolean update value actually passed to setParticles()
  28236. */
  28237. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28238. /**
  28239. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  28240. * This will be passed three parameters.
  28241. * This does nothing and may be overwritten by the user.
  28242. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28243. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28244. * @param update the boolean update value actually passed to setParticles()
  28245. */
  28246. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28247. }
  28248. }
  28249. declare module "babylonjs/Particles/solidParticle" {
  28250. import { Nullable } from "babylonjs/types";
  28251. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  28252. import { Color4 } from "babylonjs/Maths/math.color";
  28253. import { Mesh } from "babylonjs/Meshes/mesh";
  28254. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28255. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  28256. import { Plane } from "babylonjs/Maths/math.plane";
  28257. import { Material } from "babylonjs/Materials/material";
  28258. /**
  28259. * Represents one particle of a solid particle system.
  28260. */
  28261. export class SolidParticle {
  28262. /**
  28263. * particle global index
  28264. */
  28265. idx: number;
  28266. /**
  28267. * particle identifier
  28268. */
  28269. id: number;
  28270. /**
  28271. * The color of the particle
  28272. */
  28273. color: Nullable<Color4>;
  28274. /**
  28275. * The world space position of the particle.
  28276. */
  28277. position: Vector3;
  28278. /**
  28279. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  28280. */
  28281. rotation: Vector3;
  28282. /**
  28283. * The world space rotation quaternion of the particle.
  28284. */
  28285. rotationQuaternion: Nullable<Quaternion>;
  28286. /**
  28287. * The scaling of the particle.
  28288. */
  28289. scaling: Vector3;
  28290. /**
  28291. * The uvs of the particle.
  28292. */
  28293. uvs: Vector4;
  28294. /**
  28295. * The current speed of the particle.
  28296. */
  28297. velocity: Vector3;
  28298. /**
  28299. * The pivot point in the particle local space.
  28300. */
  28301. pivot: Vector3;
  28302. /**
  28303. * Must the particle be translated from its pivot point in its local space ?
  28304. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  28305. * Default : false
  28306. */
  28307. translateFromPivot: boolean;
  28308. /**
  28309. * Is the particle active or not ?
  28310. */
  28311. alive: boolean;
  28312. /**
  28313. * Is the particle visible or not ?
  28314. */
  28315. isVisible: boolean;
  28316. /**
  28317. * Index of this particle in the global "positions" array (Internal use)
  28318. * @hidden
  28319. */
  28320. _pos: number;
  28321. /**
  28322. * @hidden Index of this particle in the global "indices" array (Internal use)
  28323. */
  28324. _ind: number;
  28325. /**
  28326. * @hidden ModelShape of this particle (Internal use)
  28327. */
  28328. _model: ModelShape;
  28329. /**
  28330. * ModelShape id of this particle
  28331. */
  28332. shapeId: number;
  28333. /**
  28334. * Index of the particle in its shape id
  28335. */
  28336. idxInShape: number;
  28337. /**
  28338. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  28339. */
  28340. _modelBoundingInfo: BoundingInfo;
  28341. /**
  28342. * @hidden Particle BoundingInfo object (Internal use)
  28343. */
  28344. _boundingInfo: BoundingInfo;
  28345. /**
  28346. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  28347. */
  28348. _sps: SolidParticleSystem;
  28349. /**
  28350. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  28351. */
  28352. _stillInvisible: boolean;
  28353. /**
  28354. * @hidden Last computed particle rotation matrix
  28355. */
  28356. _rotationMatrix: number[];
  28357. /**
  28358. * Parent particle Id, if any.
  28359. * Default null.
  28360. */
  28361. parentId: Nullable<number>;
  28362. /**
  28363. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  28364. */
  28365. materialIndex: Nullable<number>;
  28366. /**
  28367. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  28368. * The possible values are :
  28369. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28370. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28371. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28372. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28373. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28374. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  28375. * */
  28376. cullingStrategy: number;
  28377. /**
  28378. * @hidden Internal global position in the SPS.
  28379. */
  28380. _globalPosition: Vector3;
  28381. /**
  28382. * Creates a Solid Particle object.
  28383. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  28384. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  28385. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  28386. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  28387. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  28388. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  28389. * @param shapeId (integer) is the model shape identifier in the SPS.
  28390. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  28391. * @param sps defines the sps it is associated to
  28392. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  28393. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  28394. */
  28395. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  28396. /**
  28397. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  28398. * @param target the particle target
  28399. * @returns the current particle
  28400. */
  28401. copyToRef(target: SolidParticle): SolidParticle;
  28402. /**
  28403. * Legacy support, changed scale to scaling
  28404. */
  28405. get scale(): Vector3;
  28406. /**
  28407. * Legacy support, changed scale to scaling
  28408. */
  28409. set scale(scale: Vector3);
  28410. /**
  28411. * Legacy support, changed quaternion to rotationQuaternion
  28412. */
  28413. get quaternion(): Nullable<Quaternion>;
  28414. /**
  28415. * Legacy support, changed quaternion to rotationQuaternion
  28416. */
  28417. set quaternion(q: Nullable<Quaternion>);
  28418. /**
  28419. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  28420. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  28421. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  28422. * @returns true if it intersects
  28423. */
  28424. intersectsMesh(target: Mesh | SolidParticle): boolean;
  28425. /**
  28426. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  28427. * A particle is in the frustum if its bounding box intersects the frustum
  28428. * @param frustumPlanes defines the frustum to test
  28429. * @returns true if the particle is in the frustum planes
  28430. */
  28431. isInFrustum(frustumPlanes: Plane[]): boolean;
  28432. /**
  28433. * get the rotation matrix of the particle
  28434. * @hidden
  28435. */
  28436. getRotationMatrix(m: Matrix): void;
  28437. }
  28438. /**
  28439. * Represents the shape of the model used by one particle of a solid particle system.
  28440. * SPS internal tool, don't use it manually.
  28441. */
  28442. export class ModelShape {
  28443. /**
  28444. * The shape id
  28445. * @hidden
  28446. */
  28447. shapeID: number;
  28448. /**
  28449. * flat array of model positions (internal use)
  28450. * @hidden
  28451. */
  28452. _shape: Vector3[];
  28453. /**
  28454. * flat array of model UVs (internal use)
  28455. * @hidden
  28456. */
  28457. _shapeUV: number[];
  28458. /**
  28459. * color array of the model
  28460. * @hidden
  28461. */
  28462. _shapeColors: number[];
  28463. /**
  28464. * indices array of the model
  28465. * @hidden
  28466. */
  28467. _indices: number[];
  28468. /**
  28469. * normals array of the model
  28470. * @hidden
  28471. */
  28472. _normals: number[];
  28473. /**
  28474. * length of the shape in the model indices array (internal use)
  28475. * @hidden
  28476. */
  28477. _indicesLength: number;
  28478. /**
  28479. * Custom position function (internal use)
  28480. * @hidden
  28481. */
  28482. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  28483. /**
  28484. * Custom vertex function (internal use)
  28485. * @hidden
  28486. */
  28487. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  28488. /**
  28489. * Model material (internal use)
  28490. * @hidden
  28491. */
  28492. _material: Nullable<Material>;
  28493. /**
  28494. * 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.
  28495. * SPS internal tool, don't use it manually.
  28496. * @hidden
  28497. */
  28498. 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>);
  28499. }
  28500. /**
  28501. * Represents a Depth Sorted Particle in the solid particle system.
  28502. * @hidden
  28503. */
  28504. export class DepthSortedParticle {
  28505. /**
  28506. * Index of the particle in the "indices" array
  28507. */
  28508. ind: number;
  28509. /**
  28510. * Length of the particle shape in the "indices" array
  28511. */
  28512. indicesLength: number;
  28513. /**
  28514. * Squared distance from the particle to the camera
  28515. */
  28516. sqDistance: number;
  28517. /**
  28518. * Material index when used with MultiMaterials
  28519. */
  28520. materialIndex: number;
  28521. /**
  28522. * Creates a new sorted particle
  28523. * @param materialIndex
  28524. */
  28525. constructor(ind: number, indLength: number, materialIndex: number);
  28526. }
  28527. }
  28528. declare module "babylonjs/Collisions/meshCollisionData" {
  28529. import { Collider } from "babylonjs/Collisions/collider";
  28530. import { Vector3 } from "babylonjs/Maths/math.vector";
  28531. import { Nullable } from "babylonjs/types";
  28532. import { Observer } from "babylonjs/Misc/observable";
  28533. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28534. /**
  28535. * @hidden
  28536. */
  28537. export class _MeshCollisionData {
  28538. _checkCollisions: boolean;
  28539. _collisionMask: number;
  28540. _collisionGroup: number;
  28541. _collider: Nullable<Collider>;
  28542. _oldPositionForCollisions: Vector3;
  28543. _diffPositionForCollisions: Vector3;
  28544. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28545. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28546. }
  28547. }
  28548. declare module "babylonjs/Meshes/abstractMesh" {
  28549. import { Observable } from "babylonjs/Misc/observable";
  28550. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  28551. import { Camera } from "babylonjs/Cameras/camera";
  28552. import { Scene, IDisposable } from "babylonjs/scene";
  28553. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  28554. import { Node } from "babylonjs/node";
  28555. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28556. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28557. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28558. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  28559. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28560. import { Material } from "babylonjs/Materials/material";
  28561. import { Light } from "babylonjs/Lights/light";
  28562. import { Skeleton } from "babylonjs/Bones/skeleton";
  28563. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  28564. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  28565. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  28566. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  28567. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28568. import { Plane } from "babylonjs/Maths/math.plane";
  28569. import { Ray } from "babylonjs/Culling/ray";
  28570. import { Collider } from "babylonjs/Collisions/collider";
  28571. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  28572. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  28573. /** @hidden */
  28574. class _FacetDataStorage {
  28575. facetPositions: Vector3[];
  28576. facetNormals: Vector3[];
  28577. facetPartitioning: number[][];
  28578. facetNb: number;
  28579. partitioningSubdivisions: number;
  28580. partitioningBBoxRatio: number;
  28581. facetDataEnabled: boolean;
  28582. facetParameters: any;
  28583. bbSize: Vector3;
  28584. subDiv: {
  28585. max: number;
  28586. X: number;
  28587. Y: number;
  28588. Z: number;
  28589. };
  28590. facetDepthSort: boolean;
  28591. facetDepthSortEnabled: boolean;
  28592. depthSortedIndices: IndicesArray;
  28593. depthSortedFacets: {
  28594. ind: number;
  28595. sqDistance: number;
  28596. }[];
  28597. facetDepthSortFunction: (f1: {
  28598. ind: number;
  28599. sqDistance: number;
  28600. }, f2: {
  28601. ind: number;
  28602. sqDistance: number;
  28603. }) => number;
  28604. facetDepthSortFrom: Vector3;
  28605. facetDepthSortOrigin: Vector3;
  28606. invertedMatrix: Matrix;
  28607. }
  28608. /**
  28609. * @hidden
  28610. **/
  28611. class _InternalAbstractMeshDataInfo {
  28612. _hasVertexAlpha: boolean;
  28613. _useVertexColors: boolean;
  28614. _numBoneInfluencers: number;
  28615. _applyFog: boolean;
  28616. _receiveShadows: boolean;
  28617. _facetData: _FacetDataStorage;
  28618. _visibility: number;
  28619. _skeleton: Nullable<Skeleton>;
  28620. _layerMask: number;
  28621. _computeBonesUsingShaders: boolean;
  28622. _isActive: boolean;
  28623. _onlyForInstances: boolean;
  28624. _isActiveIntermediate: boolean;
  28625. _onlyForInstancesIntermediate: boolean;
  28626. _actAsRegularMesh: boolean;
  28627. }
  28628. /**
  28629. * Class used to store all common mesh properties
  28630. */
  28631. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28632. /** No occlusion */
  28633. static OCCLUSION_TYPE_NONE: number;
  28634. /** Occlusion set to optimisitic */
  28635. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28636. /** Occlusion set to strict */
  28637. static OCCLUSION_TYPE_STRICT: number;
  28638. /** Use an accurante occlusion algorithm */
  28639. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28640. /** Use a conservative occlusion algorithm */
  28641. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28642. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28643. * Test order :
  28644. * Is the bounding sphere outside the frustum ?
  28645. * If not, are the bounding box vertices outside the frustum ?
  28646. * It not, then the cullable object is in the frustum.
  28647. */
  28648. static readonly CULLINGSTRATEGY_STANDARD: number;
  28649. /** Culling strategy : Bounding Sphere Only.
  28650. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28651. * It's also less accurate than the standard because some not visible objects can still be selected.
  28652. * Test : is the bounding sphere outside the frustum ?
  28653. * If not, then the cullable object is in the frustum.
  28654. */
  28655. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28656. /** Culling strategy : Optimistic Inclusion.
  28657. * This in an inclusion test first, then the standard exclusion test.
  28658. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28659. * 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.
  28660. * Anyway, it's as accurate as the standard strategy.
  28661. * Test :
  28662. * Is the cullable object bounding sphere center in the frustum ?
  28663. * If not, apply the default culling strategy.
  28664. */
  28665. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28666. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28667. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28668. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28669. * 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.
  28670. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28671. * Test :
  28672. * Is the cullable object bounding sphere center in the frustum ?
  28673. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28674. */
  28675. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  28676. /**
  28677. * No billboard
  28678. */
  28679. static get BILLBOARDMODE_NONE(): number;
  28680. /** Billboard on X axis */
  28681. static get BILLBOARDMODE_X(): number;
  28682. /** Billboard on Y axis */
  28683. static get BILLBOARDMODE_Y(): number;
  28684. /** Billboard on Z axis */
  28685. static get BILLBOARDMODE_Z(): number;
  28686. /** Billboard on all axes */
  28687. static get BILLBOARDMODE_ALL(): number;
  28688. /** Billboard on using position instead of orientation */
  28689. static get BILLBOARDMODE_USE_POSITION(): number;
  28690. /** @hidden */
  28691. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  28692. /**
  28693. * The culling strategy to use to check whether the mesh must be rendered or not.
  28694. * This value can be changed at any time and will be used on the next render mesh selection.
  28695. * The possible values are :
  28696. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28697. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28698. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28699. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28700. * Please read each static variable documentation to get details about the culling process.
  28701. * */
  28702. cullingStrategy: number;
  28703. /**
  28704. * Gets the number of facets in the mesh
  28705. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28706. */
  28707. get facetNb(): number;
  28708. /**
  28709. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  28710. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28711. */
  28712. get partitioningSubdivisions(): number;
  28713. set partitioningSubdivisions(nb: number);
  28714. /**
  28715. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  28716. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  28717. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28718. */
  28719. get partitioningBBoxRatio(): number;
  28720. set partitioningBBoxRatio(ratio: number);
  28721. /**
  28722. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28723. * Works only for updatable meshes.
  28724. * Doesn't work with multi-materials
  28725. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28726. */
  28727. get mustDepthSortFacets(): boolean;
  28728. set mustDepthSortFacets(sort: boolean);
  28729. /**
  28730. * The location (Vector3) where the facet depth sort must be computed from.
  28731. * By default, the active camera position.
  28732. * Used only when facet depth sort is enabled
  28733. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28734. */
  28735. get facetDepthSortFrom(): Vector3;
  28736. set facetDepthSortFrom(location: Vector3);
  28737. /**
  28738. * gets a boolean indicating if facetData is enabled
  28739. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28740. */
  28741. get isFacetDataEnabled(): boolean;
  28742. /** @hidden */
  28743. _updateNonUniformScalingState(value: boolean): boolean;
  28744. /**
  28745. * An event triggered when this mesh collides with another one
  28746. */
  28747. onCollideObservable: Observable<AbstractMesh>;
  28748. /** Set a function to call when this mesh collides with another one */
  28749. set onCollide(callback: () => void);
  28750. /**
  28751. * An event triggered when the collision's position changes
  28752. */
  28753. onCollisionPositionChangeObservable: Observable<Vector3>;
  28754. /** Set a function to call when the collision's position changes */
  28755. set onCollisionPositionChange(callback: () => void);
  28756. /**
  28757. * An event triggered when material is changed
  28758. */
  28759. onMaterialChangedObservable: Observable<AbstractMesh>;
  28760. /**
  28761. * Gets or sets the orientation for POV movement & rotation
  28762. */
  28763. definedFacingForward: boolean;
  28764. /** @hidden */
  28765. _occlusionQuery: Nullable<WebGLQuery>;
  28766. /** @hidden */
  28767. _renderingGroup: Nullable<RenderingGroup>;
  28768. /**
  28769. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28770. */
  28771. get visibility(): number;
  28772. /**
  28773. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28774. */
  28775. set visibility(value: number);
  28776. /** Gets or sets the alpha index used to sort transparent meshes
  28777. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28778. */
  28779. alphaIndex: number;
  28780. /**
  28781. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28782. */
  28783. isVisible: boolean;
  28784. /**
  28785. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28786. */
  28787. isPickable: boolean;
  28788. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28789. showSubMeshesBoundingBox: boolean;
  28790. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28791. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28792. */
  28793. isBlocker: boolean;
  28794. /**
  28795. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28796. */
  28797. enablePointerMoveEvents: boolean;
  28798. /**
  28799. * Specifies the rendering group id for this mesh (0 by default)
  28800. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28801. */
  28802. renderingGroupId: number;
  28803. private _material;
  28804. /** Gets or sets current material */
  28805. get material(): Nullable<Material>;
  28806. set material(value: Nullable<Material>);
  28807. /**
  28808. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28809. * @see http://doc.babylonjs.com/babylon101/shadows
  28810. */
  28811. get receiveShadows(): boolean;
  28812. set receiveShadows(value: boolean);
  28813. /** Defines color to use when rendering outline */
  28814. outlineColor: Color3;
  28815. /** Define width to use when rendering outline */
  28816. outlineWidth: number;
  28817. /** Defines color to use when rendering overlay */
  28818. overlayColor: Color3;
  28819. /** Defines alpha to use when rendering overlay */
  28820. overlayAlpha: number;
  28821. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28822. get hasVertexAlpha(): boolean;
  28823. set hasVertexAlpha(value: boolean);
  28824. /** 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) */
  28825. get useVertexColors(): boolean;
  28826. set useVertexColors(value: boolean);
  28827. /**
  28828. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28829. */
  28830. get computeBonesUsingShaders(): boolean;
  28831. set computeBonesUsingShaders(value: boolean);
  28832. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28833. get numBoneInfluencers(): number;
  28834. set numBoneInfluencers(value: number);
  28835. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28836. get applyFog(): boolean;
  28837. set applyFog(value: boolean);
  28838. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  28839. useOctreeForRenderingSelection: boolean;
  28840. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  28841. useOctreeForPicking: boolean;
  28842. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  28843. useOctreeForCollisions: boolean;
  28844. /**
  28845. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28846. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28847. */
  28848. get layerMask(): number;
  28849. set layerMask(value: number);
  28850. /**
  28851. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28852. */
  28853. alwaysSelectAsActiveMesh: boolean;
  28854. /**
  28855. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28856. */
  28857. doNotSyncBoundingInfo: boolean;
  28858. /**
  28859. * Gets or sets the current action manager
  28860. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28861. */
  28862. actionManager: Nullable<AbstractActionManager>;
  28863. private _meshCollisionData;
  28864. /**
  28865. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28866. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28867. */
  28868. ellipsoid: Vector3;
  28869. /**
  28870. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28871. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28872. */
  28873. ellipsoidOffset: Vector3;
  28874. /**
  28875. * Gets or sets a collision mask used to mask collisions (default is -1).
  28876. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28877. */
  28878. get collisionMask(): number;
  28879. set collisionMask(mask: number);
  28880. /**
  28881. * Gets or sets the current collision group mask (-1 by default).
  28882. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28883. */
  28884. get collisionGroup(): number;
  28885. set collisionGroup(mask: number);
  28886. /**
  28887. * Defines edge width used when edgesRenderer is enabled
  28888. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28889. */
  28890. edgesWidth: number;
  28891. /**
  28892. * Defines edge color used when edgesRenderer is enabled
  28893. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28894. */
  28895. edgesColor: Color4;
  28896. /** @hidden */
  28897. _edgesRenderer: Nullable<IEdgesRenderer>;
  28898. /** @hidden */
  28899. _masterMesh: Nullable<AbstractMesh>;
  28900. /** @hidden */
  28901. _boundingInfo: Nullable<BoundingInfo>;
  28902. /** @hidden */
  28903. _renderId: number;
  28904. /**
  28905. * Gets or sets the list of subMeshes
  28906. * @see http://doc.babylonjs.com/how_to/multi_materials
  28907. */
  28908. subMeshes: SubMesh[];
  28909. /** @hidden */
  28910. _intersectionsInProgress: AbstractMesh[];
  28911. /** @hidden */
  28912. _unIndexed: boolean;
  28913. /** @hidden */
  28914. _lightSources: Light[];
  28915. /** Gets the list of lights affecting that mesh */
  28916. get lightSources(): Light[];
  28917. /** @hidden */
  28918. get _positions(): Nullable<Vector3[]>;
  28919. /** @hidden */
  28920. _waitingData: {
  28921. lods: Nullable<any>;
  28922. actions: Nullable<any>;
  28923. freezeWorldMatrix: Nullable<boolean>;
  28924. };
  28925. /** @hidden */
  28926. _bonesTransformMatrices: Nullable<Float32Array>;
  28927. /** @hidden */
  28928. _transformMatrixTexture: Nullable<RawTexture>;
  28929. /**
  28930. * Gets or sets a skeleton to apply skining transformations
  28931. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28932. */
  28933. set skeleton(value: Nullable<Skeleton>);
  28934. get skeleton(): Nullable<Skeleton>;
  28935. /**
  28936. * An event triggered when the mesh is rebuilt.
  28937. */
  28938. onRebuildObservable: Observable<AbstractMesh>;
  28939. /**
  28940. * Creates a new AbstractMesh
  28941. * @param name defines the name of the mesh
  28942. * @param scene defines the hosting scene
  28943. */
  28944. constructor(name: string, scene?: Nullable<Scene>);
  28945. /**
  28946. * Returns the string "AbstractMesh"
  28947. * @returns "AbstractMesh"
  28948. */
  28949. getClassName(): string;
  28950. /**
  28951. * Gets a string representation of the current mesh
  28952. * @param fullDetails defines a boolean indicating if full details must be included
  28953. * @returns a string representation of the current mesh
  28954. */
  28955. toString(fullDetails?: boolean): string;
  28956. /**
  28957. * @hidden
  28958. */
  28959. protected _getEffectiveParent(): Nullable<Node>;
  28960. /** @hidden */
  28961. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28962. /** @hidden */
  28963. _rebuild(): void;
  28964. /** @hidden */
  28965. _resyncLightSources(): void;
  28966. /** @hidden */
  28967. _resyncLightSource(light: Light): void;
  28968. /** @hidden */
  28969. _unBindEffect(): void;
  28970. /** @hidden */
  28971. _removeLightSource(light: Light, dispose: boolean): void;
  28972. private _markSubMeshesAsDirty;
  28973. /** @hidden */
  28974. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28975. /** @hidden */
  28976. _markSubMeshesAsAttributesDirty(): void;
  28977. /** @hidden */
  28978. _markSubMeshesAsMiscDirty(): void;
  28979. /**
  28980. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28981. */
  28982. get scaling(): Vector3;
  28983. set scaling(newScaling: Vector3);
  28984. /**
  28985. * Returns true if the mesh is blocked. Implemented by child classes
  28986. */
  28987. get isBlocked(): boolean;
  28988. /**
  28989. * Returns the mesh itself by default. Implemented by child classes
  28990. * @param camera defines the camera to use to pick the right LOD level
  28991. * @returns the currentAbstractMesh
  28992. */
  28993. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28994. /**
  28995. * Returns 0 by default. Implemented by child classes
  28996. * @returns an integer
  28997. */
  28998. getTotalVertices(): number;
  28999. /**
  29000. * Returns a positive integer : the total number of indices in this mesh geometry.
  29001. * @returns the numner of indices or zero if the mesh has no geometry.
  29002. */
  29003. getTotalIndices(): number;
  29004. /**
  29005. * Returns null by default. Implemented by child classes
  29006. * @returns null
  29007. */
  29008. getIndices(): Nullable<IndicesArray>;
  29009. /**
  29010. * Returns the array of the requested vertex data kind. Implemented by child classes
  29011. * @param kind defines the vertex data kind to use
  29012. * @returns null
  29013. */
  29014. getVerticesData(kind: string): Nullable<FloatArray>;
  29015. /**
  29016. * Sets the vertex data of the mesh geometry for the requested `kind`.
  29017. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  29018. * Note that a new underlying VertexBuffer object is created each call.
  29019. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  29020. * @param kind defines vertex data kind:
  29021. * * VertexBuffer.PositionKind
  29022. * * VertexBuffer.UVKind
  29023. * * VertexBuffer.UV2Kind
  29024. * * VertexBuffer.UV3Kind
  29025. * * VertexBuffer.UV4Kind
  29026. * * VertexBuffer.UV5Kind
  29027. * * VertexBuffer.UV6Kind
  29028. * * VertexBuffer.ColorKind
  29029. * * VertexBuffer.MatricesIndicesKind
  29030. * * VertexBuffer.MatricesIndicesExtraKind
  29031. * * VertexBuffer.MatricesWeightsKind
  29032. * * VertexBuffer.MatricesWeightsExtraKind
  29033. * @param data defines the data source
  29034. * @param updatable defines if the data must be flagged as updatable (or static)
  29035. * @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
  29036. * @returns the current mesh
  29037. */
  29038. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  29039. /**
  29040. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  29041. * If the mesh has no geometry, it is simply returned as it is.
  29042. * @param kind defines vertex data kind:
  29043. * * VertexBuffer.PositionKind
  29044. * * VertexBuffer.UVKind
  29045. * * VertexBuffer.UV2Kind
  29046. * * VertexBuffer.UV3Kind
  29047. * * VertexBuffer.UV4Kind
  29048. * * VertexBuffer.UV5Kind
  29049. * * VertexBuffer.UV6Kind
  29050. * * VertexBuffer.ColorKind
  29051. * * VertexBuffer.MatricesIndicesKind
  29052. * * VertexBuffer.MatricesIndicesExtraKind
  29053. * * VertexBuffer.MatricesWeightsKind
  29054. * * VertexBuffer.MatricesWeightsExtraKind
  29055. * @param data defines the data source
  29056. * @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
  29057. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  29058. * @returns the current mesh
  29059. */
  29060. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  29061. /**
  29062. * Sets the mesh indices,
  29063. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  29064. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  29065. * @param totalVertices Defines the total number of vertices
  29066. * @returns the current mesh
  29067. */
  29068. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  29069. /**
  29070. * Gets a boolean indicating if specific vertex data is present
  29071. * @param kind defines the vertex data kind to use
  29072. * @returns true is data kind is present
  29073. */
  29074. isVerticesDataPresent(kind: string): boolean;
  29075. /**
  29076. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  29077. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  29078. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  29079. * @returns a BoundingInfo
  29080. */
  29081. getBoundingInfo(): BoundingInfo;
  29082. /**
  29083. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  29084. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  29085. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  29086. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  29087. * @returns the current mesh
  29088. */
  29089. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  29090. /**
  29091. * Overwrite the current bounding info
  29092. * @param boundingInfo defines the new bounding info
  29093. * @returns the current mesh
  29094. */
  29095. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  29096. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  29097. get useBones(): boolean;
  29098. /** @hidden */
  29099. _preActivate(): void;
  29100. /** @hidden */
  29101. _preActivateForIntermediateRendering(renderId: number): void;
  29102. /** @hidden */
  29103. _activate(renderId: number, intermediateRendering: boolean): boolean;
  29104. /** @hidden */
  29105. _postActivate(): void;
  29106. /** @hidden */
  29107. _freeze(): void;
  29108. /** @hidden */
  29109. _unFreeze(): void;
  29110. /**
  29111. * Gets the current world matrix
  29112. * @returns a Matrix
  29113. */
  29114. getWorldMatrix(): Matrix;
  29115. /** @hidden */
  29116. _getWorldMatrixDeterminant(): number;
  29117. /**
  29118. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  29119. */
  29120. get isAnInstance(): boolean;
  29121. /**
  29122. * Gets a boolean indicating if this mesh has instances
  29123. */
  29124. get hasInstances(): boolean;
  29125. /**
  29126. * Perform relative position change from the point of view of behind the front of the mesh.
  29127. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29128. * Supports definition of mesh facing forward or backward
  29129. * @param amountRight defines the distance on the right axis
  29130. * @param amountUp defines the distance on the up axis
  29131. * @param amountForward defines the distance on the forward axis
  29132. * @returns the current mesh
  29133. */
  29134. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  29135. /**
  29136. * Calculate relative position change from the point of view of behind the front of the mesh.
  29137. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29138. * Supports definition of mesh facing forward or backward
  29139. * @param amountRight defines the distance on the right axis
  29140. * @param amountUp defines the distance on the up axis
  29141. * @param amountForward defines the distance on the forward axis
  29142. * @returns the new displacement vector
  29143. */
  29144. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  29145. /**
  29146. * Perform relative rotation change from the point of view of behind the front of the mesh.
  29147. * Supports definition of mesh facing forward or backward
  29148. * @param flipBack defines the flip
  29149. * @param twirlClockwise defines the twirl
  29150. * @param tiltRight defines the tilt
  29151. * @returns the current mesh
  29152. */
  29153. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  29154. /**
  29155. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  29156. * Supports definition of mesh facing forward or backward.
  29157. * @param flipBack defines the flip
  29158. * @param twirlClockwise defines the twirl
  29159. * @param tiltRight defines the tilt
  29160. * @returns the new rotation vector
  29161. */
  29162. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  29163. /**
  29164. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29165. * This means the mesh underlying bounding box and sphere are recomputed.
  29166. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29167. * @returns the current mesh
  29168. */
  29169. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  29170. /** @hidden */
  29171. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  29172. /** @hidden */
  29173. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  29174. /** @hidden */
  29175. _updateBoundingInfo(): AbstractMesh;
  29176. /** @hidden */
  29177. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  29178. /** @hidden */
  29179. protected _afterComputeWorldMatrix(): void;
  29180. /** @hidden */
  29181. get _effectiveMesh(): AbstractMesh;
  29182. /**
  29183. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  29184. * A mesh is in the frustum if its bounding box intersects the frustum
  29185. * @param frustumPlanes defines the frustum to test
  29186. * @returns true if the mesh is in the frustum planes
  29187. */
  29188. isInFrustum(frustumPlanes: Plane[]): boolean;
  29189. /**
  29190. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  29191. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  29192. * @param frustumPlanes defines the frustum to test
  29193. * @returns true if the mesh is completely in the frustum planes
  29194. */
  29195. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  29196. /**
  29197. * True if the mesh intersects another mesh or a SolidParticle object
  29198. * @param mesh defines a target mesh or SolidParticle to test
  29199. * @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)
  29200. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  29201. * @returns true if there is an intersection
  29202. */
  29203. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  29204. /**
  29205. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  29206. * @param point defines the point to test
  29207. * @returns true if there is an intersection
  29208. */
  29209. intersectsPoint(point: Vector3): boolean;
  29210. /**
  29211. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  29212. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29213. */
  29214. get checkCollisions(): boolean;
  29215. set checkCollisions(collisionEnabled: boolean);
  29216. /**
  29217. * Gets Collider object used to compute collisions (not physics)
  29218. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29219. */
  29220. get collider(): Nullable<Collider>;
  29221. /**
  29222. * Move the mesh using collision engine
  29223. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29224. * @param displacement defines the requested displacement vector
  29225. * @returns the current mesh
  29226. */
  29227. moveWithCollisions(displacement: Vector3): AbstractMesh;
  29228. private _onCollisionPositionChange;
  29229. /** @hidden */
  29230. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  29231. /** @hidden */
  29232. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  29233. /** @hidden */
  29234. _checkCollision(collider: Collider): AbstractMesh;
  29235. /** @hidden */
  29236. _generatePointsArray(): boolean;
  29237. /**
  29238. * Checks if the passed Ray intersects with the mesh
  29239. * @param ray defines the ray to use
  29240. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  29241. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  29242. * @returns the picking info
  29243. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  29244. */
  29245. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  29246. /**
  29247. * Clones the current mesh
  29248. * @param name defines the mesh name
  29249. * @param newParent defines the new mesh parent
  29250. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  29251. * @returns the new mesh
  29252. */
  29253. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  29254. /**
  29255. * Disposes all the submeshes of the current meshnp
  29256. * @returns the current mesh
  29257. */
  29258. releaseSubMeshes(): AbstractMesh;
  29259. /**
  29260. * Releases resources associated with this abstract mesh.
  29261. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29262. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29263. */
  29264. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29265. /**
  29266. * Adds the passed mesh as a child to the current mesh
  29267. * @param mesh defines the child mesh
  29268. * @returns the current mesh
  29269. */
  29270. addChild(mesh: AbstractMesh): AbstractMesh;
  29271. /**
  29272. * Removes the passed mesh from the current mesh children list
  29273. * @param mesh defines the child mesh
  29274. * @returns the current mesh
  29275. */
  29276. removeChild(mesh: AbstractMesh): AbstractMesh;
  29277. /** @hidden */
  29278. private _initFacetData;
  29279. /**
  29280. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  29281. * This method can be called within the render loop.
  29282. * 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
  29283. * @returns the current mesh
  29284. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29285. */
  29286. updateFacetData(): AbstractMesh;
  29287. /**
  29288. * Returns the facetLocalNormals array.
  29289. * The normals are expressed in the mesh local spac
  29290. * @returns an array of Vector3
  29291. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29292. */
  29293. getFacetLocalNormals(): Vector3[];
  29294. /**
  29295. * Returns the facetLocalPositions array.
  29296. * The facet positions are expressed in the mesh local space
  29297. * @returns an array of Vector3
  29298. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29299. */
  29300. getFacetLocalPositions(): Vector3[];
  29301. /**
  29302. * Returns the facetLocalPartioning array
  29303. * @returns an array of array of numbers
  29304. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29305. */
  29306. getFacetLocalPartitioning(): number[][];
  29307. /**
  29308. * Returns the i-th facet position in the world system.
  29309. * This method allocates a new Vector3 per call
  29310. * @param i defines the facet index
  29311. * @returns a new Vector3
  29312. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29313. */
  29314. getFacetPosition(i: number): Vector3;
  29315. /**
  29316. * Sets the reference Vector3 with the i-th facet position in the world system
  29317. * @param i defines the facet index
  29318. * @param ref defines the target vector
  29319. * @returns the current mesh
  29320. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29321. */
  29322. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  29323. /**
  29324. * Returns the i-th facet normal in the world system.
  29325. * This method allocates a new Vector3 per call
  29326. * @param i defines the facet index
  29327. * @returns a new Vector3
  29328. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29329. */
  29330. getFacetNormal(i: number): Vector3;
  29331. /**
  29332. * Sets the reference Vector3 with the i-th facet normal in the world system
  29333. * @param i defines the facet index
  29334. * @param ref defines the target vector
  29335. * @returns the current mesh
  29336. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29337. */
  29338. getFacetNormalToRef(i: number, ref: Vector3): this;
  29339. /**
  29340. * 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)
  29341. * @param x defines x coordinate
  29342. * @param y defines y coordinate
  29343. * @param z defines z coordinate
  29344. * @returns the array of facet indexes
  29345. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29346. */
  29347. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  29348. /**
  29349. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  29350. * @param projected sets as the (x,y,z) world projection on the facet
  29351. * @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
  29352. * @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
  29353. * @param x defines x coordinate
  29354. * @param y defines y coordinate
  29355. * @param z defines z coordinate
  29356. * @returns the face index if found (or null instead)
  29357. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29358. */
  29359. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29360. /**
  29361. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  29362. * @param projected sets as the (x,y,z) local projection on the facet
  29363. * @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
  29364. * @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
  29365. * @param x defines x coordinate
  29366. * @param y defines y coordinate
  29367. * @param z defines z coordinate
  29368. * @returns the face index if found (or null instead)
  29369. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29370. */
  29371. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29372. /**
  29373. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  29374. * @returns the parameters
  29375. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29376. */
  29377. getFacetDataParameters(): any;
  29378. /**
  29379. * Disables the feature FacetData and frees the related memory
  29380. * @returns the current mesh
  29381. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29382. */
  29383. disableFacetData(): AbstractMesh;
  29384. /**
  29385. * Updates the AbstractMesh indices array
  29386. * @param indices defines the data source
  29387. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29388. * @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)
  29389. * @returns the current mesh
  29390. */
  29391. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29392. /**
  29393. * Creates new normals data for the mesh
  29394. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  29395. * @returns the current mesh
  29396. */
  29397. createNormals(updatable: boolean): AbstractMesh;
  29398. /**
  29399. * Align the mesh with a normal
  29400. * @param normal defines the normal to use
  29401. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  29402. * @returns the current mesh
  29403. */
  29404. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  29405. /** @hidden */
  29406. _checkOcclusionQuery(): boolean;
  29407. /**
  29408. * Disables the mesh edge rendering mode
  29409. * @returns the currentAbstractMesh
  29410. */
  29411. disableEdgesRendering(): AbstractMesh;
  29412. /**
  29413. * Enables the edge rendering mode on the mesh.
  29414. * This mode makes the mesh edges visible
  29415. * @param epsilon defines the maximal distance between two angles to detect a face
  29416. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29417. * @returns the currentAbstractMesh
  29418. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29419. */
  29420. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29421. }
  29422. }
  29423. declare module "babylonjs/Actions/actionEvent" {
  29424. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29425. import { Nullable } from "babylonjs/types";
  29426. import { Sprite } from "babylonjs/Sprites/sprite";
  29427. import { Scene } from "babylonjs/scene";
  29428. import { Vector2 } from "babylonjs/Maths/math.vector";
  29429. /**
  29430. * Interface used to define ActionEvent
  29431. */
  29432. export interface IActionEvent {
  29433. /** The mesh or sprite that triggered the action */
  29434. source: any;
  29435. /** The X mouse cursor position at the time of the event */
  29436. pointerX: number;
  29437. /** The Y mouse cursor position at the time of the event */
  29438. pointerY: number;
  29439. /** The mesh that is currently pointed at (can be null) */
  29440. meshUnderPointer: Nullable<AbstractMesh>;
  29441. /** the original (browser) event that triggered the ActionEvent */
  29442. sourceEvent?: any;
  29443. /** additional data for the event */
  29444. additionalData?: any;
  29445. }
  29446. /**
  29447. * ActionEvent is the event being sent when an action is triggered.
  29448. */
  29449. export class ActionEvent implements IActionEvent {
  29450. /** The mesh or sprite that triggered the action */
  29451. source: any;
  29452. /** The X mouse cursor position at the time of the event */
  29453. pointerX: number;
  29454. /** The Y mouse cursor position at the time of the event */
  29455. pointerY: number;
  29456. /** The mesh that is currently pointed at (can be null) */
  29457. meshUnderPointer: Nullable<AbstractMesh>;
  29458. /** the original (browser) event that triggered the ActionEvent */
  29459. sourceEvent?: any;
  29460. /** additional data for the event */
  29461. additionalData?: any;
  29462. /**
  29463. * Creates a new ActionEvent
  29464. * @param source The mesh or sprite that triggered the action
  29465. * @param pointerX The X mouse cursor position at the time of the event
  29466. * @param pointerY The Y mouse cursor position at the time of the event
  29467. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  29468. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  29469. * @param additionalData additional data for the event
  29470. */
  29471. constructor(
  29472. /** The mesh or sprite that triggered the action */
  29473. source: any,
  29474. /** The X mouse cursor position at the time of the event */
  29475. pointerX: number,
  29476. /** The Y mouse cursor position at the time of the event */
  29477. pointerY: number,
  29478. /** The mesh that is currently pointed at (can be null) */
  29479. meshUnderPointer: Nullable<AbstractMesh>,
  29480. /** the original (browser) event that triggered the ActionEvent */
  29481. sourceEvent?: any,
  29482. /** additional data for the event */
  29483. additionalData?: any);
  29484. /**
  29485. * Helper function to auto-create an ActionEvent from a source mesh.
  29486. * @param source The source mesh that triggered the event
  29487. * @param evt The original (browser) event
  29488. * @param additionalData additional data for the event
  29489. * @returns the new ActionEvent
  29490. */
  29491. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  29492. /**
  29493. * Helper function to auto-create an ActionEvent from a source sprite
  29494. * @param source The source sprite that triggered the event
  29495. * @param scene Scene associated with the sprite
  29496. * @param evt The original (browser) event
  29497. * @param additionalData additional data for the event
  29498. * @returns the new ActionEvent
  29499. */
  29500. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  29501. /**
  29502. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  29503. * @param scene the scene where the event occurred
  29504. * @param evt The original (browser) event
  29505. * @returns the new ActionEvent
  29506. */
  29507. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  29508. /**
  29509. * Helper function to auto-create an ActionEvent from a primitive
  29510. * @param prim defines the target primitive
  29511. * @param pointerPos defines the pointer position
  29512. * @param evt The original (browser) event
  29513. * @param additionalData additional data for the event
  29514. * @returns the new ActionEvent
  29515. */
  29516. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  29517. }
  29518. }
  29519. declare module "babylonjs/Actions/abstractActionManager" {
  29520. import { IDisposable } from "babylonjs/scene";
  29521. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  29522. import { IAction } from "babylonjs/Actions/action";
  29523. import { Nullable } from "babylonjs/types";
  29524. /**
  29525. * Abstract class used to decouple action Manager from scene and meshes.
  29526. * Do not instantiate.
  29527. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29528. */
  29529. export abstract class AbstractActionManager implements IDisposable {
  29530. /** Gets the list of active triggers */
  29531. static Triggers: {
  29532. [key: string]: number;
  29533. };
  29534. /** Gets the cursor to use when hovering items */
  29535. hoverCursor: string;
  29536. /** Gets the list of actions */
  29537. actions: IAction[];
  29538. /**
  29539. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29540. */
  29541. isRecursive: boolean;
  29542. /**
  29543. * Releases all associated resources
  29544. */
  29545. abstract dispose(): void;
  29546. /**
  29547. * Does this action manager has pointer triggers
  29548. */
  29549. abstract get hasPointerTriggers(): boolean;
  29550. /**
  29551. * Does this action manager has pick triggers
  29552. */
  29553. abstract get hasPickTriggers(): boolean;
  29554. /**
  29555. * Process a specific trigger
  29556. * @param trigger defines the trigger to process
  29557. * @param evt defines the event details to be processed
  29558. */
  29559. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29560. /**
  29561. * Does this action manager handles actions of any of the given triggers
  29562. * @param triggers defines the triggers to be tested
  29563. * @return a boolean indicating whether one (or more) of the triggers is handled
  29564. */
  29565. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29566. /**
  29567. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29568. * speed.
  29569. * @param triggerA defines the trigger to be tested
  29570. * @param triggerB defines the trigger to be tested
  29571. * @return a boolean indicating whether one (or more) of the triggers is handled
  29572. */
  29573. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29574. /**
  29575. * Does this action manager handles actions of a given trigger
  29576. * @param trigger defines the trigger to be tested
  29577. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29578. * @return whether the trigger is handled
  29579. */
  29580. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29581. /**
  29582. * Serialize this manager to a JSON object
  29583. * @param name defines the property name to store this manager
  29584. * @returns a JSON representation of this manager
  29585. */
  29586. abstract serialize(name: string): any;
  29587. /**
  29588. * Registers an action to this action manager
  29589. * @param action defines the action to be registered
  29590. * @return the action amended (prepared) after registration
  29591. */
  29592. abstract registerAction(action: IAction): Nullable<IAction>;
  29593. /**
  29594. * Unregisters an action to this action manager
  29595. * @param action defines the action to be unregistered
  29596. * @return a boolean indicating whether the action has been unregistered
  29597. */
  29598. abstract unregisterAction(action: IAction): Boolean;
  29599. /**
  29600. * Does exist one action manager with at least one trigger
  29601. **/
  29602. static get HasTriggers(): boolean;
  29603. /**
  29604. * Does exist one action manager with at least one pick trigger
  29605. **/
  29606. static get HasPickTriggers(): boolean;
  29607. /**
  29608. * Does exist one action manager that handles actions of a given trigger
  29609. * @param trigger defines the trigger to be tested
  29610. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29611. **/
  29612. static HasSpecificTrigger(trigger: number): boolean;
  29613. }
  29614. }
  29615. declare module "babylonjs/node" {
  29616. import { Scene } from "babylonjs/scene";
  29617. import { Nullable } from "babylonjs/types";
  29618. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29619. import { Engine } from "babylonjs/Engines/engine";
  29620. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  29621. import { Observable } from "babylonjs/Misc/observable";
  29622. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  29623. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29624. import { Animatable } from "babylonjs/Animations/animatable";
  29625. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  29626. import { Animation } from "babylonjs/Animations/animation";
  29627. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29628. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29629. /**
  29630. * Defines how a node can be built from a string name.
  29631. */
  29632. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29633. /**
  29634. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29635. */
  29636. export class Node implements IBehaviorAware<Node> {
  29637. /** @hidden */
  29638. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  29639. private static _NodeConstructors;
  29640. /**
  29641. * Add a new node constructor
  29642. * @param type defines the type name of the node to construct
  29643. * @param constructorFunc defines the constructor function
  29644. */
  29645. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  29646. /**
  29647. * Returns a node constructor based on type name
  29648. * @param type defines the type name
  29649. * @param name defines the new node name
  29650. * @param scene defines the hosting scene
  29651. * @param options defines optional options to transmit to constructors
  29652. * @returns the new constructor or null
  29653. */
  29654. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  29655. /**
  29656. * Gets or sets the name of the node
  29657. */
  29658. name: string;
  29659. /**
  29660. * Gets or sets the id of the node
  29661. */
  29662. id: string;
  29663. /**
  29664. * Gets or sets the unique id of the node
  29665. */
  29666. uniqueId: number;
  29667. /**
  29668. * Gets or sets a string used to store user defined state for the node
  29669. */
  29670. state: string;
  29671. /**
  29672. * Gets or sets an object used to store user defined information for the node
  29673. */
  29674. metadata: any;
  29675. /**
  29676. * For internal use only. Please do not use.
  29677. */
  29678. reservedDataStore: any;
  29679. /**
  29680. * List of inspectable custom properties (used by the Inspector)
  29681. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29682. */
  29683. inspectableCustomProperties: IInspectable[];
  29684. private _doNotSerialize;
  29685. /**
  29686. * Gets or sets a boolean used to define if the node must be serialized
  29687. */
  29688. get doNotSerialize(): boolean;
  29689. set doNotSerialize(value: boolean);
  29690. /** @hidden */
  29691. _isDisposed: boolean;
  29692. /**
  29693. * Gets a list of Animations associated with the node
  29694. */
  29695. animations: import("babylonjs/Animations/animation").Animation[];
  29696. protected _ranges: {
  29697. [name: string]: Nullable<AnimationRange>;
  29698. };
  29699. /**
  29700. * Callback raised when the node is ready to be used
  29701. */
  29702. onReady: Nullable<(node: Node) => void>;
  29703. private _isEnabled;
  29704. private _isParentEnabled;
  29705. private _isReady;
  29706. /** @hidden */
  29707. _currentRenderId: number;
  29708. private _parentUpdateId;
  29709. /** @hidden */
  29710. _childUpdateId: number;
  29711. /** @hidden */
  29712. _waitingParentId: Nullable<string>;
  29713. /** @hidden */
  29714. _scene: Scene;
  29715. /** @hidden */
  29716. _cache: any;
  29717. private _parentNode;
  29718. private _children;
  29719. /** @hidden */
  29720. _worldMatrix: Matrix;
  29721. /** @hidden */
  29722. _worldMatrixDeterminant: number;
  29723. /** @hidden */
  29724. _worldMatrixDeterminantIsDirty: boolean;
  29725. /** @hidden */
  29726. private _sceneRootNodesIndex;
  29727. /**
  29728. * Gets a boolean indicating if the node has been disposed
  29729. * @returns true if the node was disposed
  29730. */
  29731. isDisposed(): boolean;
  29732. /**
  29733. * Gets or sets the parent of the node (without keeping the current position in the scene)
  29734. * @see https://doc.babylonjs.com/how_to/parenting
  29735. */
  29736. set parent(parent: Nullable<Node>);
  29737. get parent(): Nullable<Node>;
  29738. /** @hidden */
  29739. _addToSceneRootNodes(): void;
  29740. /** @hidden */
  29741. _removeFromSceneRootNodes(): void;
  29742. private _animationPropertiesOverride;
  29743. /**
  29744. * Gets or sets the animation properties override
  29745. */
  29746. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  29747. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  29748. /**
  29749. * Gets a string idenfifying the name of the class
  29750. * @returns "Node" string
  29751. */
  29752. getClassName(): string;
  29753. /** @hidden */
  29754. readonly _isNode: boolean;
  29755. /**
  29756. * An event triggered when the mesh is disposed
  29757. */
  29758. onDisposeObservable: Observable<Node>;
  29759. private _onDisposeObserver;
  29760. /**
  29761. * Sets a callback that will be raised when the node will be disposed
  29762. */
  29763. set onDispose(callback: () => void);
  29764. /**
  29765. * Creates a new Node
  29766. * @param name the name and id to be given to this node
  29767. * @param scene the scene this node will be added to
  29768. */
  29769. constructor(name: string, scene?: Nullable<Scene>);
  29770. /**
  29771. * Gets the scene of the node
  29772. * @returns a scene
  29773. */
  29774. getScene(): Scene;
  29775. /**
  29776. * Gets the engine of the node
  29777. * @returns a Engine
  29778. */
  29779. getEngine(): Engine;
  29780. private _behaviors;
  29781. /**
  29782. * Attach a behavior to the node
  29783. * @see http://doc.babylonjs.com/features/behaviour
  29784. * @param behavior defines the behavior to attach
  29785. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29786. * @returns the current Node
  29787. */
  29788. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29789. /**
  29790. * Remove an attached behavior
  29791. * @see http://doc.babylonjs.com/features/behaviour
  29792. * @param behavior defines the behavior to attach
  29793. * @returns the current Node
  29794. */
  29795. removeBehavior(behavior: Behavior<Node>): Node;
  29796. /**
  29797. * Gets the list of attached behaviors
  29798. * @see http://doc.babylonjs.com/features/behaviour
  29799. */
  29800. get behaviors(): Behavior<Node>[];
  29801. /**
  29802. * Gets an attached behavior by name
  29803. * @param name defines the name of the behavior to look for
  29804. * @see http://doc.babylonjs.com/features/behaviour
  29805. * @returns null if behavior was not found else the requested behavior
  29806. */
  29807. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29808. /**
  29809. * Returns the latest update of the World matrix
  29810. * @returns a Matrix
  29811. */
  29812. getWorldMatrix(): Matrix;
  29813. /** @hidden */
  29814. _getWorldMatrixDeterminant(): number;
  29815. /**
  29816. * Returns directly the latest state of the mesh World matrix.
  29817. * A Matrix is returned.
  29818. */
  29819. get worldMatrixFromCache(): Matrix;
  29820. /** @hidden */
  29821. _initCache(): void;
  29822. /** @hidden */
  29823. updateCache(force?: boolean): void;
  29824. /** @hidden */
  29825. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29826. /** @hidden */
  29827. _updateCache(ignoreParentClass?: boolean): void;
  29828. /** @hidden */
  29829. _isSynchronized(): boolean;
  29830. /** @hidden */
  29831. _markSyncedWithParent(): void;
  29832. /** @hidden */
  29833. isSynchronizedWithParent(): boolean;
  29834. /** @hidden */
  29835. isSynchronized(): boolean;
  29836. /**
  29837. * Is this node ready to be used/rendered
  29838. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29839. * @return true if the node is ready
  29840. */
  29841. isReady(completeCheck?: boolean): boolean;
  29842. /**
  29843. * Is this node enabled?
  29844. * 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
  29845. * @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
  29846. * @return whether this node (and its parent) is enabled
  29847. */
  29848. isEnabled(checkAncestors?: boolean): boolean;
  29849. /** @hidden */
  29850. protected _syncParentEnabledState(): void;
  29851. /**
  29852. * Set the enabled state of this node
  29853. * @param value defines the new enabled state
  29854. */
  29855. setEnabled(value: boolean): void;
  29856. /**
  29857. * Is this node a descendant of the given node?
  29858. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  29859. * @param ancestor defines the parent node to inspect
  29860. * @returns a boolean indicating if this node is a descendant of the given node
  29861. */
  29862. isDescendantOf(ancestor: Node): boolean;
  29863. /** @hidden */
  29864. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  29865. /**
  29866. * Will return all nodes that have this node as ascendant
  29867. * @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
  29868. * @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
  29869. * @return all children nodes of all types
  29870. */
  29871. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29872. /**
  29873. * Get all child-meshes of this node
  29874. * @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)
  29875. * @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
  29876. * @returns an array of AbstractMesh
  29877. */
  29878. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29879. /**
  29880. * Get all direct children of this node
  29881. * @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
  29882. * @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)
  29883. * @returns an array of Node
  29884. */
  29885. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29886. /** @hidden */
  29887. _setReady(state: boolean): void;
  29888. /**
  29889. * Get an animation by name
  29890. * @param name defines the name of the animation to look for
  29891. * @returns null if not found else the requested animation
  29892. */
  29893. getAnimationByName(name: string): Nullable<Animation>;
  29894. /**
  29895. * Creates an animation range for this node
  29896. * @param name defines the name of the range
  29897. * @param from defines the starting key
  29898. * @param to defines the end key
  29899. */
  29900. createAnimationRange(name: string, from: number, to: number): void;
  29901. /**
  29902. * Delete a specific animation range
  29903. * @param name defines the name of the range to delete
  29904. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29905. */
  29906. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29907. /**
  29908. * Get an animation range by name
  29909. * @param name defines the name of the animation range to look for
  29910. * @returns null if not found else the requested animation range
  29911. */
  29912. getAnimationRange(name: string): Nullable<AnimationRange>;
  29913. /**
  29914. * Gets the list of all animation ranges defined on this node
  29915. * @returns an array
  29916. */
  29917. getAnimationRanges(): Nullable<AnimationRange>[];
  29918. /**
  29919. * Will start the animation sequence
  29920. * @param name defines the range frames for animation sequence
  29921. * @param loop defines if the animation should loop (false by default)
  29922. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29923. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29924. * @returns the object created for this animation. If range does not exist, it will return null
  29925. */
  29926. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29927. /**
  29928. * Serialize animation ranges into a JSON compatible object
  29929. * @returns serialization object
  29930. */
  29931. serializeAnimationRanges(): any;
  29932. /**
  29933. * Computes the world matrix of the node
  29934. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29935. * @returns the world matrix
  29936. */
  29937. computeWorldMatrix(force?: boolean): Matrix;
  29938. /**
  29939. * Releases resources associated with this node.
  29940. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29941. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29942. */
  29943. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29944. /**
  29945. * Parse animation range data from a serialization object and store them into a given node
  29946. * @param node defines where to store the animation ranges
  29947. * @param parsedNode defines the serialization object to read data from
  29948. * @param scene defines the hosting scene
  29949. */
  29950. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29951. /**
  29952. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29953. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29954. * @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
  29955. * @returns the new bounding vectors
  29956. */
  29957. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29958. min: Vector3;
  29959. max: Vector3;
  29960. };
  29961. }
  29962. }
  29963. declare module "babylonjs/Animations/animation" {
  29964. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  29965. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  29966. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  29967. import { Nullable } from "babylonjs/types";
  29968. import { Scene } from "babylonjs/scene";
  29969. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  29970. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29971. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  29972. import { Node } from "babylonjs/node";
  29973. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29974. import { Size } from "babylonjs/Maths/math.size";
  29975. import { Animatable } from "babylonjs/Animations/animatable";
  29976. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  29977. /**
  29978. * @hidden
  29979. */
  29980. export class _IAnimationState {
  29981. key: number;
  29982. repeatCount: number;
  29983. workValue?: any;
  29984. loopMode?: number;
  29985. offsetValue?: any;
  29986. highLimitValue?: any;
  29987. }
  29988. /**
  29989. * Class used to store any kind of animation
  29990. */
  29991. export class Animation {
  29992. /**Name of the animation */
  29993. name: string;
  29994. /**Property to animate */
  29995. targetProperty: string;
  29996. /**The frames per second of the animation */
  29997. framePerSecond: number;
  29998. /**The data type of the animation */
  29999. dataType: number;
  30000. /**The loop mode of the animation */
  30001. loopMode?: number | undefined;
  30002. /**Specifies if blending should be enabled */
  30003. enableBlending?: boolean | undefined;
  30004. /**
  30005. * Use matrix interpolation instead of using direct key value when animating matrices
  30006. */
  30007. static AllowMatricesInterpolation: boolean;
  30008. /**
  30009. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  30010. */
  30011. static AllowMatrixDecomposeForInterpolation: boolean;
  30012. /**
  30013. * Stores the key frames of the animation
  30014. */
  30015. private _keys;
  30016. /**
  30017. * Stores the easing function of the animation
  30018. */
  30019. private _easingFunction;
  30020. /**
  30021. * @hidden Internal use only
  30022. */
  30023. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  30024. /**
  30025. * The set of event that will be linked to this animation
  30026. */
  30027. private _events;
  30028. /**
  30029. * Stores an array of target property paths
  30030. */
  30031. targetPropertyPath: string[];
  30032. /**
  30033. * Stores the blending speed of the animation
  30034. */
  30035. blendingSpeed: number;
  30036. /**
  30037. * Stores the animation ranges for the animation
  30038. */
  30039. private _ranges;
  30040. /**
  30041. * @hidden Internal use
  30042. */
  30043. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  30044. /**
  30045. * Sets up an animation
  30046. * @param property The property to animate
  30047. * @param animationType The animation type to apply
  30048. * @param framePerSecond The frames per second of the animation
  30049. * @param easingFunction The easing function used in the animation
  30050. * @returns The created animation
  30051. */
  30052. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  30053. /**
  30054. * Create and start an animation on a node
  30055. * @param name defines the name of the global animation that will be run on all nodes
  30056. * @param node defines the root node where the animation will take place
  30057. * @param targetProperty defines property to animate
  30058. * @param framePerSecond defines the number of frame per second yo use
  30059. * @param totalFrame defines the number of frames in total
  30060. * @param from defines the initial value
  30061. * @param to defines the final value
  30062. * @param loopMode defines which loop mode you want to use (off by default)
  30063. * @param easingFunction defines the easing function to use (linear by default)
  30064. * @param onAnimationEnd defines the callback to call when animation end
  30065. * @returns the animatable created for this animation
  30066. */
  30067. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30068. /**
  30069. * Create and start an animation on a node and its descendants
  30070. * @param name defines the name of the global animation that will be run on all nodes
  30071. * @param node defines the root node where the animation will take place
  30072. * @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
  30073. * @param targetProperty defines property to animate
  30074. * @param framePerSecond defines the number of frame per second to use
  30075. * @param totalFrame defines the number of frames in total
  30076. * @param from defines the initial value
  30077. * @param to defines the final value
  30078. * @param loopMode defines which loop mode you want to use (off by default)
  30079. * @param easingFunction defines the easing function to use (linear by default)
  30080. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  30081. * @returns the list of animatables created for all nodes
  30082. * @example https://www.babylonjs-playground.com/#MH0VLI
  30083. */
  30084. 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[]>;
  30085. /**
  30086. * Creates a new animation, merges it with the existing animations and starts it
  30087. * @param name Name of the animation
  30088. * @param node Node which contains the scene that begins the animations
  30089. * @param targetProperty Specifies which property to animate
  30090. * @param framePerSecond The frames per second of the animation
  30091. * @param totalFrame The total number of frames
  30092. * @param from The frame at the beginning of the animation
  30093. * @param to The frame at the end of the animation
  30094. * @param loopMode Specifies the loop mode of the animation
  30095. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  30096. * @param onAnimationEnd Callback to run once the animation is complete
  30097. * @returns Nullable animation
  30098. */
  30099. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30100. /**
  30101. * Transition property of an host to the target Value
  30102. * @param property The property to transition
  30103. * @param targetValue The target Value of the property
  30104. * @param host The object where the property to animate belongs
  30105. * @param scene Scene used to run the animation
  30106. * @param frameRate Framerate (in frame/s) to use
  30107. * @param transition The transition type we want to use
  30108. * @param duration The duration of the animation, in milliseconds
  30109. * @param onAnimationEnd Callback trigger at the end of the animation
  30110. * @returns Nullable animation
  30111. */
  30112. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  30113. /**
  30114. * Return the array of runtime animations currently using this animation
  30115. */
  30116. get runtimeAnimations(): RuntimeAnimation[];
  30117. /**
  30118. * Specifies if any of the runtime animations are currently running
  30119. */
  30120. get hasRunningRuntimeAnimations(): boolean;
  30121. /**
  30122. * Initializes the animation
  30123. * @param name Name of the animation
  30124. * @param targetProperty Property to animate
  30125. * @param framePerSecond The frames per second of the animation
  30126. * @param dataType The data type of the animation
  30127. * @param loopMode The loop mode of the animation
  30128. * @param enableBlending Specifies if blending should be enabled
  30129. */
  30130. constructor(
  30131. /**Name of the animation */
  30132. name: string,
  30133. /**Property to animate */
  30134. targetProperty: string,
  30135. /**The frames per second of the animation */
  30136. framePerSecond: number,
  30137. /**The data type of the animation */
  30138. dataType: number,
  30139. /**The loop mode of the animation */
  30140. loopMode?: number | undefined,
  30141. /**Specifies if blending should be enabled */
  30142. enableBlending?: boolean | undefined);
  30143. /**
  30144. * Converts the animation to a string
  30145. * @param fullDetails support for multiple levels of logging within scene loading
  30146. * @returns String form of the animation
  30147. */
  30148. toString(fullDetails?: boolean): string;
  30149. /**
  30150. * Add an event to this animation
  30151. * @param event Event to add
  30152. */
  30153. addEvent(event: AnimationEvent): void;
  30154. /**
  30155. * Remove all events found at the given frame
  30156. * @param frame The frame to remove events from
  30157. */
  30158. removeEvents(frame: number): void;
  30159. /**
  30160. * Retrieves all the events from the animation
  30161. * @returns Events from the animation
  30162. */
  30163. getEvents(): AnimationEvent[];
  30164. /**
  30165. * Creates an animation range
  30166. * @param name Name of the animation range
  30167. * @param from Starting frame of the animation range
  30168. * @param to Ending frame of the animation
  30169. */
  30170. createRange(name: string, from: number, to: number): void;
  30171. /**
  30172. * Deletes an animation range by name
  30173. * @param name Name of the animation range to delete
  30174. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  30175. */
  30176. deleteRange(name: string, deleteFrames?: boolean): void;
  30177. /**
  30178. * Gets the animation range by name, or null if not defined
  30179. * @param name Name of the animation range
  30180. * @returns Nullable animation range
  30181. */
  30182. getRange(name: string): Nullable<AnimationRange>;
  30183. /**
  30184. * Gets the key frames from the animation
  30185. * @returns The key frames of the animation
  30186. */
  30187. getKeys(): Array<IAnimationKey>;
  30188. /**
  30189. * Gets the highest frame rate of the animation
  30190. * @returns Highest frame rate of the animation
  30191. */
  30192. getHighestFrame(): number;
  30193. /**
  30194. * Gets the easing function of the animation
  30195. * @returns Easing function of the animation
  30196. */
  30197. getEasingFunction(): IEasingFunction;
  30198. /**
  30199. * Sets the easing function of the animation
  30200. * @param easingFunction A custom mathematical formula for animation
  30201. */
  30202. setEasingFunction(easingFunction: EasingFunction): void;
  30203. /**
  30204. * Interpolates a scalar linearly
  30205. * @param startValue Start value of the animation curve
  30206. * @param endValue End value of the animation curve
  30207. * @param gradient Scalar amount to interpolate
  30208. * @returns Interpolated scalar value
  30209. */
  30210. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  30211. /**
  30212. * Interpolates a scalar cubically
  30213. * @param startValue Start value of the animation curve
  30214. * @param outTangent End tangent of the animation
  30215. * @param endValue End value of the animation curve
  30216. * @param inTangent Start tangent of the animation curve
  30217. * @param gradient Scalar amount to interpolate
  30218. * @returns Interpolated scalar value
  30219. */
  30220. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  30221. /**
  30222. * Interpolates a quaternion using a spherical linear interpolation
  30223. * @param startValue Start value of the animation curve
  30224. * @param endValue End value of the animation curve
  30225. * @param gradient Scalar amount to interpolate
  30226. * @returns Interpolated quaternion value
  30227. */
  30228. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  30229. /**
  30230. * Interpolates a quaternion cubically
  30231. * @param startValue Start value of the animation curve
  30232. * @param outTangent End tangent of the animation curve
  30233. * @param endValue End value of the animation curve
  30234. * @param inTangent Start tangent of the animation curve
  30235. * @param gradient Scalar amount to interpolate
  30236. * @returns Interpolated quaternion value
  30237. */
  30238. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  30239. /**
  30240. * Interpolates a Vector3 linearl
  30241. * @param startValue Start value of the animation curve
  30242. * @param endValue End value of the animation curve
  30243. * @param gradient Scalar amount to interpolate
  30244. * @returns Interpolated scalar value
  30245. */
  30246. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  30247. /**
  30248. * Interpolates a Vector3 cubically
  30249. * @param startValue Start value of the animation curve
  30250. * @param outTangent End tangent of the animation
  30251. * @param endValue End value of the animation curve
  30252. * @param inTangent Start tangent of the animation curve
  30253. * @param gradient Scalar amount to interpolate
  30254. * @returns InterpolatedVector3 value
  30255. */
  30256. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  30257. /**
  30258. * Interpolates a Vector2 linearly
  30259. * @param startValue Start value of the animation curve
  30260. * @param endValue End value of the animation curve
  30261. * @param gradient Scalar amount to interpolate
  30262. * @returns Interpolated Vector2 value
  30263. */
  30264. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  30265. /**
  30266. * Interpolates a Vector2 cubically
  30267. * @param startValue Start value of the animation curve
  30268. * @param outTangent End tangent of the animation
  30269. * @param endValue End value of the animation curve
  30270. * @param inTangent Start tangent of the animation curve
  30271. * @param gradient Scalar amount to interpolate
  30272. * @returns Interpolated Vector2 value
  30273. */
  30274. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  30275. /**
  30276. * Interpolates a size linearly
  30277. * @param startValue Start value of the animation curve
  30278. * @param endValue End value of the animation curve
  30279. * @param gradient Scalar amount to interpolate
  30280. * @returns Interpolated Size value
  30281. */
  30282. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  30283. /**
  30284. * Interpolates a Color3 linearly
  30285. * @param startValue Start value of the animation curve
  30286. * @param endValue End value of the animation curve
  30287. * @param gradient Scalar amount to interpolate
  30288. * @returns Interpolated Color3 value
  30289. */
  30290. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  30291. /**
  30292. * Interpolates a Color4 linearly
  30293. * @param startValue Start value of the animation curve
  30294. * @param endValue End value of the animation curve
  30295. * @param gradient Scalar amount to interpolate
  30296. * @returns Interpolated Color3 value
  30297. */
  30298. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  30299. /**
  30300. * @hidden Internal use only
  30301. */
  30302. _getKeyValue(value: any): any;
  30303. /**
  30304. * @hidden Internal use only
  30305. */
  30306. _interpolate(currentFrame: number, state: _IAnimationState): any;
  30307. /**
  30308. * Defines the function to use to interpolate matrices
  30309. * @param startValue defines the start matrix
  30310. * @param endValue defines the end matrix
  30311. * @param gradient defines the gradient between both matrices
  30312. * @param result defines an optional target matrix where to store the interpolation
  30313. * @returns the interpolated matrix
  30314. */
  30315. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  30316. /**
  30317. * Makes a copy of the animation
  30318. * @returns Cloned animation
  30319. */
  30320. clone(): Animation;
  30321. /**
  30322. * Sets the key frames of the animation
  30323. * @param values The animation key frames to set
  30324. */
  30325. setKeys(values: Array<IAnimationKey>): void;
  30326. /**
  30327. * Serializes the animation to an object
  30328. * @returns Serialized object
  30329. */
  30330. serialize(): any;
  30331. /**
  30332. * Float animation type
  30333. */
  30334. static readonly ANIMATIONTYPE_FLOAT: number;
  30335. /**
  30336. * Vector3 animation type
  30337. */
  30338. static readonly ANIMATIONTYPE_VECTOR3: number;
  30339. /**
  30340. * Quaternion animation type
  30341. */
  30342. static readonly ANIMATIONTYPE_QUATERNION: number;
  30343. /**
  30344. * Matrix animation type
  30345. */
  30346. static readonly ANIMATIONTYPE_MATRIX: number;
  30347. /**
  30348. * Color3 animation type
  30349. */
  30350. static readonly ANIMATIONTYPE_COLOR3: number;
  30351. /**
  30352. * Color3 animation type
  30353. */
  30354. static readonly ANIMATIONTYPE_COLOR4: number;
  30355. /**
  30356. * Vector2 animation type
  30357. */
  30358. static readonly ANIMATIONTYPE_VECTOR2: number;
  30359. /**
  30360. * Size animation type
  30361. */
  30362. static readonly ANIMATIONTYPE_SIZE: number;
  30363. /**
  30364. * Relative Loop Mode
  30365. */
  30366. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  30367. /**
  30368. * Cycle Loop Mode
  30369. */
  30370. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  30371. /**
  30372. * Constant Loop Mode
  30373. */
  30374. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  30375. /** @hidden */
  30376. static _UniversalLerp(left: any, right: any, amount: number): any;
  30377. /**
  30378. * Parses an animation object and creates an animation
  30379. * @param parsedAnimation Parsed animation object
  30380. * @returns Animation object
  30381. */
  30382. static Parse(parsedAnimation: any): Animation;
  30383. /**
  30384. * Appends the serialized animations from the source animations
  30385. * @param source Source containing the animations
  30386. * @param destination Target to store the animations
  30387. */
  30388. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30389. }
  30390. }
  30391. declare module "babylonjs/Animations/animatable.interface" {
  30392. import { Nullable } from "babylonjs/types";
  30393. import { Animation } from "babylonjs/Animations/animation";
  30394. /**
  30395. * Interface containing an array of animations
  30396. */
  30397. export interface IAnimatable {
  30398. /**
  30399. * Array of animations
  30400. */
  30401. animations: Nullable<Array<Animation>>;
  30402. }
  30403. }
  30404. declare module "babylonjs/Misc/decorators" {
  30405. import { Nullable } from "babylonjs/types";
  30406. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30407. import { Scene } from "babylonjs/scene";
  30408. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30409. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30410. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30411. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30412. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30413. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30414. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30415. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30416. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30417. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30418. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30419. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30420. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30421. /**
  30422. * Decorator used to define property that can be serialized as reference to a camera
  30423. * @param sourceName defines the name of the property to decorate
  30424. */
  30425. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30426. /**
  30427. * Class used to help serialization objects
  30428. */
  30429. export class SerializationHelper {
  30430. /** @hidden */
  30431. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30432. /** @hidden */
  30433. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30434. /** @hidden */
  30435. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30436. /** @hidden */
  30437. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30438. /**
  30439. * Appends the serialized animations from the source animations
  30440. * @param source Source containing the animations
  30441. * @param destination Target to store the animations
  30442. */
  30443. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30444. /**
  30445. * Static function used to serialized a specific entity
  30446. * @param entity defines the entity to serialize
  30447. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30448. * @returns a JSON compatible object representing the serialization of the entity
  30449. */
  30450. static Serialize<T>(entity: T, serializationObject?: any): any;
  30451. /**
  30452. * Creates a new entity from a serialization data object
  30453. * @param creationFunction defines a function used to instanciated the new entity
  30454. * @param source defines the source serialization data
  30455. * @param scene defines the hosting scene
  30456. * @param rootUrl defines the root url for resources
  30457. * @returns a new entity
  30458. */
  30459. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30460. /**
  30461. * Clones an object
  30462. * @param creationFunction defines the function used to instanciate the new object
  30463. * @param source defines the source object
  30464. * @returns the cloned object
  30465. */
  30466. static Clone<T>(creationFunction: () => T, source: T): T;
  30467. /**
  30468. * Instanciates a new object based on a source one (some data will be shared between both object)
  30469. * @param creationFunction defines the function used to instanciate the new object
  30470. * @param source defines the source object
  30471. * @returns the new object
  30472. */
  30473. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30474. }
  30475. }
  30476. declare module "babylonjs/Misc/guid" {
  30477. /**
  30478. * Class used to manipulate GUIDs
  30479. */
  30480. export class GUID {
  30481. /**
  30482. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30483. * Be aware Math.random() could cause collisions, but:
  30484. * "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"
  30485. * @returns a pseudo random id
  30486. */
  30487. static RandomId(): string;
  30488. }
  30489. }
  30490. declare module "babylonjs/Materials/Textures/baseTexture" {
  30491. import { Observable } from "babylonjs/Misc/observable";
  30492. import { Nullable } from "babylonjs/types";
  30493. import { Scene } from "babylonjs/scene";
  30494. import { Matrix } from "babylonjs/Maths/math.vector";
  30495. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30496. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30497. import { ISize } from "babylonjs/Maths/math.size";
  30498. import "babylonjs/Misc/fileTools";
  30499. /**
  30500. * Base class of all the textures in babylon.
  30501. * It groups all the common properties the materials, post process, lights... might need
  30502. * in order to make a correct use of the texture.
  30503. */
  30504. export class BaseTexture implements IAnimatable {
  30505. /**
  30506. * Default anisotropic filtering level for the application.
  30507. * It is set to 4 as a good tradeoff between perf and quality.
  30508. */
  30509. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  30510. /**
  30511. * Gets or sets the unique id of the texture
  30512. */
  30513. uniqueId: number;
  30514. /**
  30515. * Define the name of the texture.
  30516. */
  30517. name: string;
  30518. /**
  30519. * Gets or sets an object used to store user defined information.
  30520. */
  30521. metadata: any;
  30522. /**
  30523. * For internal use only. Please do not use.
  30524. */
  30525. reservedDataStore: any;
  30526. private _hasAlpha;
  30527. /**
  30528. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  30529. */
  30530. set hasAlpha(value: boolean);
  30531. get hasAlpha(): boolean;
  30532. /**
  30533. * Defines if the alpha value should be determined via the rgb values.
  30534. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  30535. */
  30536. getAlphaFromRGB: boolean;
  30537. /**
  30538. * Intensity or strength of the texture.
  30539. * It is commonly used by materials to fine tune the intensity of the texture
  30540. */
  30541. level: number;
  30542. /**
  30543. * Define the UV chanel to use starting from 0 and defaulting to 0.
  30544. * This is part of the texture as textures usually maps to one uv set.
  30545. */
  30546. coordinatesIndex: number;
  30547. private _coordinatesMode;
  30548. /**
  30549. * How a texture is mapped.
  30550. *
  30551. * | Value | Type | Description |
  30552. * | ----- | ----------------------------------- | ----------- |
  30553. * | 0 | EXPLICIT_MODE | |
  30554. * | 1 | SPHERICAL_MODE | |
  30555. * | 2 | PLANAR_MODE | |
  30556. * | 3 | CUBIC_MODE | |
  30557. * | 4 | PROJECTION_MODE | |
  30558. * | 5 | SKYBOX_MODE | |
  30559. * | 6 | INVCUBIC_MODE | |
  30560. * | 7 | EQUIRECTANGULAR_MODE | |
  30561. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  30562. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  30563. */
  30564. set coordinatesMode(value: number);
  30565. get coordinatesMode(): number;
  30566. /**
  30567. * | Value | Type | Description |
  30568. * | ----- | ------------------ | ----------- |
  30569. * | 0 | CLAMP_ADDRESSMODE | |
  30570. * | 1 | WRAP_ADDRESSMODE | |
  30571. * | 2 | MIRROR_ADDRESSMODE | |
  30572. */
  30573. wrapU: number;
  30574. /**
  30575. * | Value | Type | Description |
  30576. * | ----- | ------------------ | ----------- |
  30577. * | 0 | CLAMP_ADDRESSMODE | |
  30578. * | 1 | WRAP_ADDRESSMODE | |
  30579. * | 2 | MIRROR_ADDRESSMODE | |
  30580. */
  30581. wrapV: number;
  30582. /**
  30583. * | Value | Type | Description |
  30584. * | ----- | ------------------ | ----------- |
  30585. * | 0 | CLAMP_ADDRESSMODE | |
  30586. * | 1 | WRAP_ADDRESSMODE | |
  30587. * | 2 | MIRROR_ADDRESSMODE | |
  30588. */
  30589. wrapR: number;
  30590. /**
  30591. * With compliant hardware and browser (supporting anisotropic filtering)
  30592. * this defines the level of anisotropic filtering in the texture.
  30593. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30594. */
  30595. anisotropicFilteringLevel: number;
  30596. /**
  30597. * Define if the texture is a cube texture or if false a 2d texture.
  30598. */
  30599. get isCube(): boolean;
  30600. set isCube(value: boolean);
  30601. /**
  30602. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30603. */
  30604. get is3D(): boolean;
  30605. set is3D(value: boolean);
  30606. /**
  30607. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30608. */
  30609. get is2DArray(): boolean;
  30610. set is2DArray(value: boolean);
  30611. /**
  30612. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30613. * HDR texture are usually stored in linear space.
  30614. * This only impacts the PBR and Background materials
  30615. */
  30616. gammaSpace: boolean;
  30617. /**
  30618. * Gets or sets whether or not the texture contains RGBD data.
  30619. */
  30620. get isRGBD(): boolean;
  30621. set isRGBD(value: boolean);
  30622. /**
  30623. * Is Z inverted in the texture (useful in a cube texture).
  30624. */
  30625. invertZ: boolean;
  30626. /**
  30627. * Are mip maps generated for this texture or not.
  30628. */
  30629. get noMipmap(): boolean;
  30630. /**
  30631. * @hidden
  30632. */
  30633. lodLevelInAlpha: boolean;
  30634. /**
  30635. * With prefiltered texture, defined the offset used during the prefiltering steps.
  30636. */
  30637. get lodGenerationOffset(): number;
  30638. set lodGenerationOffset(value: number);
  30639. /**
  30640. * With prefiltered texture, defined the scale used during the prefiltering steps.
  30641. */
  30642. get lodGenerationScale(): number;
  30643. set lodGenerationScale(value: number);
  30644. /**
  30645. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  30646. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  30647. * average roughness values.
  30648. */
  30649. get linearSpecularLOD(): boolean;
  30650. set linearSpecularLOD(value: boolean);
  30651. /**
  30652. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  30653. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  30654. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  30655. */
  30656. get irradianceTexture(): Nullable<BaseTexture>;
  30657. set irradianceTexture(value: Nullable<BaseTexture>);
  30658. /**
  30659. * Define if the texture is a render target.
  30660. */
  30661. isRenderTarget: boolean;
  30662. /**
  30663. * Define the unique id of the texture in the scene.
  30664. */
  30665. get uid(): string;
  30666. /**
  30667. * Return a string representation of the texture.
  30668. * @returns the texture as a string
  30669. */
  30670. toString(): string;
  30671. /**
  30672. * Get the class name of the texture.
  30673. * @returns "BaseTexture"
  30674. */
  30675. getClassName(): string;
  30676. /**
  30677. * Define the list of animation attached to the texture.
  30678. */
  30679. animations: import("babylonjs/Animations/animation").Animation[];
  30680. /**
  30681. * An event triggered when the texture is disposed.
  30682. */
  30683. onDisposeObservable: Observable<BaseTexture>;
  30684. private _onDisposeObserver;
  30685. /**
  30686. * Callback triggered when the texture has been disposed.
  30687. * Kept for back compatibility, you can use the onDisposeObservable instead.
  30688. */
  30689. set onDispose(callback: () => void);
  30690. /**
  30691. * Define the current state of the loading sequence when in delayed load mode.
  30692. */
  30693. delayLoadState: number;
  30694. private _scene;
  30695. /** @hidden */
  30696. _texture: Nullable<InternalTexture>;
  30697. private _uid;
  30698. /**
  30699. * Define if the texture is preventinga material to render or not.
  30700. * If not and the texture is not ready, the engine will use a default black texture instead.
  30701. */
  30702. get isBlocking(): boolean;
  30703. /**
  30704. * Instantiates a new BaseTexture.
  30705. * Base class of all the textures in babylon.
  30706. * It groups all the common properties the materials, post process, lights... might need
  30707. * in order to make a correct use of the texture.
  30708. * @param scene Define the scene the texture blongs to
  30709. */
  30710. constructor(scene: Nullable<Scene>);
  30711. /**
  30712. * Get the scene the texture belongs to.
  30713. * @returns the scene or null if undefined
  30714. */
  30715. getScene(): Nullable<Scene>;
  30716. /**
  30717. * Get the texture transform matrix used to offset tile the texture for istance.
  30718. * @returns the transformation matrix
  30719. */
  30720. getTextureMatrix(): Matrix;
  30721. /**
  30722. * Get the texture reflection matrix used to rotate/transform the reflection.
  30723. * @returns the reflection matrix
  30724. */
  30725. getReflectionTextureMatrix(): Matrix;
  30726. /**
  30727. * Get the underlying lower level texture from Babylon.
  30728. * @returns the insternal texture
  30729. */
  30730. getInternalTexture(): Nullable<InternalTexture>;
  30731. /**
  30732. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  30733. * @returns true if ready or not blocking
  30734. */
  30735. isReadyOrNotBlocking(): boolean;
  30736. /**
  30737. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  30738. * @returns true if fully ready
  30739. */
  30740. isReady(): boolean;
  30741. private _cachedSize;
  30742. /**
  30743. * Get the size of the texture.
  30744. * @returns the texture size.
  30745. */
  30746. getSize(): ISize;
  30747. /**
  30748. * Get the base size of the texture.
  30749. * It can be different from the size if the texture has been resized for POT for instance
  30750. * @returns the base size
  30751. */
  30752. getBaseSize(): ISize;
  30753. /**
  30754. * Update the sampling mode of the texture.
  30755. * Default is Trilinear mode.
  30756. *
  30757. * | Value | Type | Description |
  30758. * | ----- | ------------------ | ----------- |
  30759. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  30760. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  30761. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  30762. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  30763. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  30764. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  30765. * | 7 | NEAREST_LINEAR | |
  30766. * | 8 | NEAREST_NEAREST | |
  30767. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30768. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30769. * | 11 | LINEAR_LINEAR | |
  30770. * | 12 | LINEAR_NEAREST | |
  30771. *
  30772. * > _mag_: magnification filter (close to the viewer)
  30773. * > _min_: minification filter (far from the viewer)
  30774. * > _mip_: filter used between mip map levels
  30775. *@param samplingMode Define the new sampling mode of the texture
  30776. */
  30777. updateSamplingMode(samplingMode: number): void;
  30778. /**
  30779. * Scales the texture if is `canRescale()`
  30780. * @param ratio the resize factor we want to use to rescale
  30781. */
  30782. scale(ratio: number): void;
  30783. /**
  30784. * Get if the texture can rescale.
  30785. */
  30786. get canRescale(): boolean;
  30787. /** @hidden */
  30788. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30789. /** @hidden */
  30790. _rebuild(): void;
  30791. /**
  30792. * Triggers the load sequence in delayed load mode.
  30793. */
  30794. delayLoad(): void;
  30795. /**
  30796. * Clones the texture.
  30797. * @returns the cloned texture
  30798. */
  30799. clone(): Nullable<BaseTexture>;
  30800. /**
  30801. * Get the texture underlying type (INT, FLOAT...)
  30802. */
  30803. get textureType(): number;
  30804. /**
  30805. * Get the texture underlying format (RGB, RGBA...)
  30806. */
  30807. get textureFormat(): number;
  30808. /**
  30809. * Indicates that textures need to be re-calculated for all materials
  30810. */
  30811. protected _markAllSubMeshesAsTexturesDirty(): void;
  30812. /**
  30813. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30814. * This will returns an RGBA array buffer containing either in values (0-255) or
  30815. * float values (0-1) depending of the underlying buffer type.
  30816. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30817. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30818. * @param buffer defines a user defined buffer to fill with data (can be null)
  30819. * @returns The Array buffer containing the pixels data.
  30820. */
  30821. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30822. /**
  30823. * Release and destroy the underlying lower level texture aka internalTexture.
  30824. */
  30825. releaseInternalTexture(): void;
  30826. /** @hidden */
  30827. get _lodTextureHigh(): Nullable<BaseTexture>;
  30828. /** @hidden */
  30829. get _lodTextureMid(): Nullable<BaseTexture>;
  30830. /** @hidden */
  30831. get _lodTextureLow(): Nullable<BaseTexture>;
  30832. /**
  30833. * Dispose the texture and release its associated resources.
  30834. */
  30835. dispose(): void;
  30836. /**
  30837. * Serialize the texture into a JSON representation that can be parsed later on.
  30838. * @returns the JSON representation of the texture
  30839. */
  30840. serialize(): any;
  30841. /**
  30842. * Helper function to be called back once a list of texture contains only ready textures.
  30843. * @param textures Define the list of textures to wait for
  30844. * @param callback Define the callback triggered once the entire list will be ready
  30845. */
  30846. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  30847. }
  30848. }
  30849. declare module "babylonjs/Materials/effect" {
  30850. import { Observable } from "babylonjs/Misc/observable";
  30851. import { Nullable } from "babylonjs/types";
  30852. import { IDisposable } from "babylonjs/scene";
  30853. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30854. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30855. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  30856. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  30857. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  30858. import { Engine } from "babylonjs/Engines/engine";
  30859. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30860. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30861. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30862. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30863. /**
  30864. * Options to be used when creating an effect.
  30865. */
  30866. export interface IEffectCreationOptions {
  30867. /**
  30868. * Atrributes that will be used in the shader.
  30869. */
  30870. attributes: string[];
  30871. /**
  30872. * Uniform varible names that will be set in the shader.
  30873. */
  30874. uniformsNames: string[];
  30875. /**
  30876. * Uniform buffer variable names that will be set in the shader.
  30877. */
  30878. uniformBuffersNames: string[];
  30879. /**
  30880. * Sampler texture variable names that will be set in the shader.
  30881. */
  30882. samplers: string[];
  30883. /**
  30884. * Define statements that will be set in the shader.
  30885. */
  30886. defines: any;
  30887. /**
  30888. * Possible fallbacks for this effect to improve performance when needed.
  30889. */
  30890. fallbacks: Nullable<IEffectFallbacks>;
  30891. /**
  30892. * Callback that will be called when the shader is compiled.
  30893. */
  30894. onCompiled: Nullable<(effect: Effect) => void>;
  30895. /**
  30896. * Callback that will be called if an error occurs during shader compilation.
  30897. */
  30898. onError: Nullable<(effect: Effect, errors: string) => void>;
  30899. /**
  30900. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30901. */
  30902. indexParameters?: any;
  30903. /**
  30904. * Max number of lights that can be used in the shader.
  30905. */
  30906. maxSimultaneousLights?: number;
  30907. /**
  30908. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30909. */
  30910. transformFeedbackVaryings?: Nullable<string[]>;
  30911. }
  30912. /**
  30913. * Effect containing vertex and fragment shader that can be executed on an object.
  30914. */
  30915. export class Effect implements IDisposable {
  30916. /**
  30917. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30918. */
  30919. static ShadersRepository: string;
  30920. /**
  30921. * Name of the effect.
  30922. */
  30923. name: any;
  30924. /**
  30925. * String container all the define statements that should be set on the shader.
  30926. */
  30927. defines: string;
  30928. /**
  30929. * Callback that will be called when the shader is compiled.
  30930. */
  30931. onCompiled: Nullable<(effect: Effect) => void>;
  30932. /**
  30933. * Callback that will be called if an error occurs during shader compilation.
  30934. */
  30935. onError: Nullable<(effect: Effect, errors: string) => void>;
  30936. /**
  30937. * Callback that will be called when effect is bound.
  30938. */
  30939. onBind: Nullable<(effect: Effect) => void>;
  30940. /**
  30941. * Unique ID of the effect.
  30942. */
  30943. uniqueId: number;
  30944. /**
  30945. * Observable that will be called when the shader is compiled.
  30946. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30947. */
  30948. onCompileObservable: Observable<Effect>;
  30949. /**
  30950. * Observable that will be called if an error occurs during shader compilation.
  30951. */
  30952. onErrorObservable: Observable<Effect>;
  30953. /** @hidden */
  30954. _onBindObservable: Nullable<Observable<Effect>>;
  30955. /**
  30956. * @hidden
  30957. * Specifies if the effect was previously ready
  30958. */
  30959. _wasPreviouslyReady: boolean;
  30960. /**
  30961. * Observable that will be called when effect is bound.
  30962. */
  30963. get onBindObservable(): Observable<Effect>;
  30964. /** @hidden */
  30965. _bonesComputationForcedToCPU: boolean;
  30966. private static _uniqueIdSeed;
  30967. private _engine;
  30968. private _uniformBuffersNames;
  30969. private _uniformsNames;
  30970. private _samplerList;
  30971. private _samplers;
  30972. private _isReady;
  30973. private _compilationError;
  30974. private _allFallbacksProcessed;
  30975. private _attributesNames;
  30976. private _attributes;
  30977. private _attributeLocationByName;
  30978. private _uniforms;
  30979. /**
  30980. * Key for the effect.
  30981. * @hidden
  30982. */
  30983. _key: string;
  30984. private _indexParameters;
  30985. private _fallbacks;
  30986. private _vertexSourceCode;
  30987. private _fragmentSourceCode;
  30988. private _vertexSourceCodeOverride;
  30989. private _fragmentSourceCodeOverride;
  30990. private _transformFeedbackVaryings;
  30991. /**
  30992. * Compiled shader to webGL program.
  30993. * @hidden
  30994. */
  30995. _pipelineContext: Nullable<IPipelineContext>;
  30996. private _valueCache;
  30997. private static _baseCache;
  30998. /**
  30999. * Instantiates an effect.
  31000. * An effect can be used to create/manage/execute vertex and fragment shaders.
  31001. * @param baseName Name of the effect.
  31002. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  31003. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  31004. * @param samplers List of sampler variables that will be passed to the shader.
  31005. * @param engine Engine to be used to render the effect
  31006. * @param defines Define statements to be added to the shader.
  31007. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  31008. * @param onCompiled Callback that will be called when the shader is compiled.
  31009. * @param onError Callback that will be called if an error occurs during shader compilation.
  31010. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  31011. */
  31012. 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);
  31013. private _useFinalCode;
  31014. /**
  31015. * Unique key for this effect
  31016. */
  31017. get key(): string;
  31018. /**
  31019. * If the effect has been compiled and prepared.
  31020. * @returns if the effect is compiled and prepared.
  31021. */
  31022. isReady(): boolean;
  31023. private _isReadyInternal;
  31024. /**
  31025. * The engine the effect was initialized with.
  31026. * @returns the engine.
  31027. */
  31028. getEngine(): Engine;
  31029. /**
  31030. * The pipeline context for this effect
  31031. * @returns the associated pipeline context
  31032. */
  31033. getPipelineContext(): Nullable<IPipelineContext>;
  31034. /**
  31035. * The set of names of attribute variables for the shader.
  31036. * @returns An array of attribute names.
  31037. */
  31038. getAttributesNames(): string[];
  31039. /**
  31040. * Returns the attribute at the given index.
  31041. * @param index The index of the attribute.
  31042. * @returns The location of the attribute.
  31043. */
  31044. getAttributeLocation(index: number): number;
  31045. /**
  31046. * Returns the attribute based on the name of the variable.
  31047. * @param name of the attribute to look up.
  31048. * @returns the attribute location.
  31049. */
  31050. getAttributeLocationByName(name: string): number;
  31051. /**
  31052. * The number of attributes.
  31053. * @returns the numnber of attributes.
  31054. */
  31055. getAttributesCount(): number;
  31056. /**
  31057. * Gets the index of a uniform variable.
  31058. * @param uniformName of the uniform to look up.
  31059. * @returns the index.
  31060. */
  31061. getUniformIndex(uniformName: string): number;
  31062. /**
  31063. * Returns the attribute based on the name of the variable.
  31064. * @param uniformName of the uniform to look up.
  31065. * @returns the location of the uniform.
  31066. */
  31067. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  31068. /**
  31069. * Returns an array of sampler variable names
  31070. * @returns The array of sampler variable neames.
  31071. */
  31072. getSamplers(): string[];
  31073. /**
  31074. * The error from the last compilation.
  31075. * @returns the error string.
  31076. */
  31077. getCompilationError(): string;
  31078. /**
  31079. * Gets a boolean indicating that all fallbacks were used during compilation
  31080. * @returns true if all fallbacks were used
  31081. */
  31082. allFallbacksProcessed(): boolean;
  31083. /**
  31084. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  31085. * @param func The callback to be used.
  31086. */
  31087. executeWhenCompiled(func: (effect: Effect) => void): void;
  31088. private _checkIsReady;
  31089. private _loadShader;
  31090. /**
  31091. * Recompiles the webGL program
  31092. * @param vertexSourceCode The source code for the vertex shader.
  31093. * @param fragmentSourceCode The source code for the fragment shader.
  31094. * @param onCompiled Callback called when completed.
  31095. * @param onError Callback called on error.
  31096. * @hidden
  31097. */
  31098. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  31099. /**
  31100. * Prepares the effect
  31101. * @hidden
  31102. */
  31103. _prepareEffect(): void;
  31104. private _processCompilationErrors;
  31105. /**
  31106. * Checks if the effect is supported. (Must be called after compilation)
  31107. */
  31108. get isSupported(): boolean;
  31109. /**
  31110. * Binds a texture to the engine to be used as output of the shader.
  31111. * @param channel Name of the output variable.
  31112. * @param texture Texture to bind.
  31113. * @hidden
  31114. */
  31115. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  31116. /**
  31117. * Sets a texture on the engine to be used in the shader.
  31118. * @param channel Name of the sampler variable.
  31119. * @param texture Texture to set.
  31120. */
  31121. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  31122. /**
  31123. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  31124. * @param channel Name of the sampler variable.
  31125. * @param texture Texture to set.
  31126. */
  31127. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  31128. /**
  31129. * Sets an array of textures on the engine to be used in the shader.
  31130. * @param channel Name of the variable.
  31131. * @param textures Textures to set.
  31132. */
  31133. setTextureArray(channel: string, textures: BaseTexture[]): void;
  31134. /**
  31135. * 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)
  31136. * @param channel Name of the sampler variable.
  31137. * @param postProcess Post process to get the input texture from.
  31138. */
  31139. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  31140. /**
  31141. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  31142. * 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)
  31143. * @param channel Name of the sampler variable.
  31144. * @param postProcess Post process to get the output texture from.
  31145. */
  31146. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  31147. /** @hidden */
  31148. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  31149. /** @hidden */
  31150. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  31151. /** @hidden */
  31152. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  31153. /** @hidden */
  31154. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  31155. /**
  31156. * Binds a buffer to a uniform.
  31157. * @param buffer Buffer to bind.
  31158. * @param name Name of the uniform variable to bind to.
  31159. */
  31160. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  31161. /**
  31162. * Binds block to a uniform.
  31163. * @param blockName Name of the block to bind.
  31164. * @param index Index to bind.
  31165. */
  31166. bindUniformBlock(blockName: string, index: number): void;
  31167. /**
  31168. * Sets an interger value on a uniform variable.
  31169. * @param uniformName Name of the variable.
  31170. * @param value Value to be set.
  31171. * @returns this effect.
  31172. */
  31173. setInt(uniformName: string, value: number): Effect;
  31174. /**
  31175. * Sets an int array on a uniform variable.
  31176. * @param uniformName Name of the variable.
  31177. * @param array array to be set.
  31178. * @returns this effect.
  31179. */
  31180. setIntArray(uniformName: string, array: Int32Array): Effect;
  31181. /**
  31182. * 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)
  31183. * @param uniformName Name of the variable.
  31184. * @param array array to be set.
  31185. * @returns this effect.
  31186. */
  31187. setIntArray2(uniformName: string, array: Int32Array): Effect;
  31188. /**
  31189. * 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)
  31190. * @param uniformName Name of the variable.
  31191. * @param array array to be set.
  31192. * @returns this effect.
  31193. */
  31194. setIntArray3(uniformName: string, array: Int32Array): Effect;
  31195. /**
  31196. * 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)
  31197. * @param uniformName Name of the variable.
  31198. * @param array array to be set.
  31199. * @returns this effect.
  31200. */
  31201. setIntArray4(uniformName: string, array: Int32Array): Effect;
  31202. /**
  31203. * Sets an float array on a uniform variable.
  31204. * @param uniformName Name of the variable.
  31205. * @param array array to be set.
  31206. * @returns this effect.
  31207. */
  31208. setFloatArray(uniformName: string, array: Float32Array): Effect;
  31209. /**
  31210. * 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)
  31211. * @param uniformName Name of the variable.
  31212. * @param array array to be set.
  31213. * @returns this effect.
  31214. */
  31215. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  31216. /**
  31217. * 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)
  31218. * @param uniformName Name of the variable.
  31219. * @param array array to be set.
  31220. * @returns this effect.
  31221. */
  31222. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  31223. /**
  31224. * 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)
  31225. * @param uniformName Name of the variable.
  31226. * @param array array to be set.
  31227. * @returns this effect.
  31228. */
  31229. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  31230. /**
  31231. * Sets an array on a uniform variable.
  31232. * @param uniformName Name of the variable.
  31233. * @param array array to be set.
  31234. * @returns this effect.
  31235. */
  31236. setArray(uniformName: string, array: number[]): Effect;
  31237. /**
  31238. * 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)
  31239. * @param uniformName Name of the variable.
  31240. * @param array array to be set.
  31241. * @returns this effect.
  31242. */
  31243. setArray2(uniformName: string, array: number[]): Effect;
  31244. /**
  31245. * 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)
  31246. * @param uniformName Name of the variable.
  31247. * @param array array to be set.
  31248. * @returns this effect.
  31249. */
  31250. setArray3(uniformName: string, array: number[]): Effect;
  31251. /**
  31252. * 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)
  31253. * @param uniformName Name of the variable.
  31254. * @param array array to be set.
  31255. * @returns this effect.
  31256. */
  31257. setArray4(uniformName: string, array: number[]): Effect;
  31258. /**
  31259. * Sets matrices on a uniform variable.
  31260. * @param uniformName Name of the variable.
  31261. * @param matrices matrices to be set.
  31262. * @returns this effect.
  31263. */
  31264. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  31265. /**
  31266. * Sets matrix on a uniform variable.
  31267. * @param uniformName Name of the variable.
  31268. * @param matrix matrix to be set.
  31269. * @returns this effect.
  31270. */
  31271. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  31272. /**
  31273. * 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)
  31274. * @param uniformName Name of the variable.
  31275. * @param matrix matrix to be set.
  31276. * @returns this effect.
  31277. */
  31278. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  31279. /**
  31280. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  31281. * @param uniformName Name of the variable.
  31282. * @param matrix matrix to be set.
  31283. * @returns this effect.
  31284. */
  31285. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  31286. /**
  31287. * Sets a float on a uniform variable.
  31288. * @param uniformName Name of the variable.
  31289. * @param value value to be set.
  31290. * @returns this effect.
  31291. */
  31292. setFloat(uniformName: string, value: number): Effect;
  31293. /**
  31294. * Sets a boolean on a uniform variable.
  31295. * @param uniformName Name of the variable.
  31296. * @param bool value to be set.
  31297. * @returns this effect.
  31298. */
  31299. setBool(uniformName: string, bool: boolean): Effect;
  31300. /**
  31301. * Sets a Vector2 on a uniform variable.
  31302. * @param uniformName Name of the variable.
  31303. * @param vector2 vector2 to be set.
  31304. * @returns this effect.
  31305. */
  31306. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  31307. /**
  31308. * Sets a float2 on a uniform variable.
  31309. * @param uniformName Name of the variable.
  31310. * @param x First float in float2.
  31311. * @param y Second float in float2.
  31312. * @returns this effect.
  31313. */
  31314. setFloat2(uniformName: string, x: number, y: number): Effect;
  31315. /**
  31316. * Sets a Vector3 on a uniform variable.
  31317. * @param uniformName Name of the variable.
  31318. * @param vector3 Value to be set.
  31319. * @returns this effect.
  31320. */
  31321. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  31322. /**
  31323. * Sets a float3 on a uniform variable.
  31324. * @param uniformName Name of the variable.
  31325. * @param x First float in float3.
  31326. * @param y Second float in float3.
  31327. * @param z Third float in float3.
  31328. * @returns this effect.
  31329. */
  31330. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  31331. /**
  31332. * Sets a Vector4 on a uniform variable.
  31333. * @param uniformName Name of the variable.
  31334. * @param vector4 Value to be set.
  31335. * @returns this effect.
  31336. */
  31337. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  31338. /**
  31339. * Sets a float4 on a uniform variable.
  31340. * @param uniformName Name of the variable.
  31341. * @param x First float in float4.
  31342. * @param y Second float in float4.
  31343. * @param z Third float in float4.
  31344. * @param w Fourth float in float4.
  31345. * @returns this effect.
  31346. */
  31347. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  31348. /**
  31349. * Sets a Color3 on a uniform variable.
  31350. * @param uniformName Name of the variable.
  31351. * @param color3 Value to be set.
  31352. * @returns this effect.
  31353. */
  31354. setColor3(uniformName: string, color3: IColor3Like): Effect;
  31355. /**
  31356. * Sets a Color4 on a uniform variable.
  31357. * @param uniformName Name of the variable.
  31358. * @param color3 Value to be set.
  31359. * @param alpha Alpha value to be set.
  31360. * @returns this effect.
  31361. */
  31362. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  31363. /**
  31364. * Sets a Color4 on a uniform variable
  31365. * @param uniformName defines the name of the variable
  31366. * @param color4 defines the value to be set
  31367. * @returns this effect.
  31368. */
  31369. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  31370. /** Release all associated resources */
  31371. dispose(): void;
  31372. /**
  31373. * This function will add a new shader to the shader store
  31374. * @param name the name of the shader
  31375. * @param pixelShader optional pixel shader content
  31376. * @param vertexShader optional vertex shader content
  31377. */
  31378. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  31379. /**
  31380. * Store of each shader (The can be looked up using effect.key)
  31381. */
  31382. static ShadersStore: {
  31383. [key: string]: string;
  31384. };
  31385. /**
  31386. * Store of each included file for a shader (The can be looked up using effect.key)
  31387. */
  31388. static IncludesShadersStore: {
  31389. [key: string]: string;
  31390. };
  31391. /**
  31392. * Resets the cache of effects.
  31393. */
  31394. static ResetCache(): void;
  31395. }
  31396. }
  31397. declare module "babylonjs/Engines/engineCapabilities" {
  31398. /**
  31399. * Interface used to describe the capabilities of the engine relatively to the current browser
  31400. */
  31401. export interface EngineCapabilities {
  31402. /** Maximum textures units per fragment shader */
  31403. maxTexturesImageUnits: number;
  31404. /** Maximum texture units per vertex shader */
  31405. maxVertexTextureImageUnits: number;
  31406. /** Maximum textures units in the entire pipeline */
  31407. maxCombinedTexturesImageUnits: number;
  31408. /** Maximum texture size */
  31409. maxTextureSize: number;
  31410. /** Maximum texture samples */
  31411. maxSamples?: number;
  31412. /** Maximum cube texture size */
  31413. maxCubemapTextureSize: number;
  31414. /** Maximum render texture size */
  31415. maxRenderTextureSize: number;
  31416. /** Maximum number of vertex attributes */
  31417. maxVertexAttribs: number;
  31418. /** Maximum number of varyings */
  31419. maxVaryingVectors: number;
  31420. /** Maximum number of uniforms per vertex shader */
  31421. maxVertexUniformVectors: number;
  31422. /** Maximum number of uniforms per fragment shader */
  31423. maxFragmentUniformVectors: number;
  31424. /** Defines if standard derivates (dx/dy) are supported */
  31425. standardDerivatives: boolean;
  31426. /** Defines if s3tc texture compression is supported */
  31427. s3tc?: WEBGL_compressed_texture_s3tc;
  31428. /** Defines if pvrtc texture compression is supported */
  31429. pvrtc: any;
  31430. /** Defines if etc1 texture compression is supported */
  31431. etc1: any;
  31432. /** Defines if etc2 texture compression is supported */
  31433. etc2: any;
  31434. /** Defines if astc texture compression is supported */
  31435. astc: any;
  31436. /** Defines if float textures are supported */
  31437. textureFloat: boolean;
  31438. /** Defines if vertex array objects are supported */
  31439. vertexArrayObject: boolean;
  31440. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  31441. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  31442. /** Gets the maximum level of anisotropy supported */
  31443. maxAnisotropy: number;
  31444. /** Defines if instancing is supported */
  31445. instancedArrays: boolean;
  31446. /** Defines if 32 bits indices are supported */
  31447. uintIndices: boolean;
  31448. /** Defines if high precision shaders are supported */
  31449. highPrecisionShaderSupported: boolean;
  31450. /** Defines if depth reading in the fragment shader is supported */
  31451. fragmentDepthSupported: boolean;
  31452. /** Defines if float texture linear filtering is supported*/
  31453. textureFloatLinearFiltering: boolean;
  31454. /** Defines if rendering to float textures is supported */
  31455. textureFloatRender: boolean;
  31456. /** Defines if half float textures are supported*/
  31457. textureHalfFloat: boolean;
  31458. /** Defines if half float texture linear filtering is supported*/
  31459. textureHalfFloatLinearFiltering: boolean;
  31460. /** Defines if rendering to half float textures is supported */
  31461. textureHalfFloatRender: boolean;
  31462. /** Defines if textureLOD shader command is supported */
  31463. textureLOD: boolean;
  31464. /** Defines if draw buffers extension is supported */
  31465. drawBuffersExtension: boolean;
  31466. /** Defines if depth textures are supported */
  31467. depthTextureExtension: boolean;
  31468. /** Defines if float color buffer are supported */
  31469. colorBufferFloat: boolean;
  31470. /** Gets disjoint timer query extension (null if not supported) */
  31471. timerQuery?: EXT_disjoint_timer_query;
  31472. /** Defines if timestamp can be used with timer query */
  31473. canUseTimestampForTimerQuery: boolean;
  31474. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  31475. multiview?: any;
  31476. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  31477. oculusMultiview?: any;
  31478. /** Function used to let the system compiles shaders in background */
  31479. parallelShaderCompile?: {
  31480. COMPLETION_STATUS_KHR: number;
  31481. };
  31482. /** Max number of texture samples for MSAA */
  31483. maxMSAASamples: number;
  31484. /** Defines if the blend min max extension is supported */
  31485. blendMinMax: boolean;
  31486. }
  31487. }
  31488. declare module "babylonjs/States/depthCullingState" {
  31489. import { Nullable } from "babylonjs/types";
  31490. /**
  31491. * @hidden
  31492. **/
  31493. export class DepthCullingState {
  31494. private _isDepthTestDirty;
  31495. private _isDepthMaskDirty;
  31496. private _isDepthFuncDirty;
  31497. private _isCullFaceDirty;
  31498. private _isCullDirty;
  31499. private _isZOffsetDirty;
  31500. private _isFrontFaceDirty;
  31501. private _depthTest;
  31502. private _depthMask;
  31503. private _depthFunc;
  31504. private _cull;
  31505. private _cullFace;
  31506. private _zOffset;
  31507. private _frontFace;
  31508. /**
  31509. * Initializes the state.
  31510. */
  31511. constructor();
  31512. get isDirty(): boolean;
  31513. get zOffset(): number;
  31514. set zOffset(value: number);
  31515. get cullFace(): Nullable<number>;
  31516. set cullFace(value: Nullable<number>);
  31517. get cull(): Nullable<boolean>;
  31518. set cull(value: Nullable<boolean>);
  31519. get depthFunc(): Nullable<number>;
  31520. set depthFunc(value: Nullable<number>);
  31521. get depthMask(): boolean;
  31522. set depthMask(value: boolean);
  31523. get depthTest(): boolean;
  31524. set depthTest(value: boolean);
  31525. get frontFace(): Nullable<number>;
  31526. set frontFace(value: Nullable<number>);
  31527. reset(): void;
  31528. apply(gl: WebGLRenderingContext): void;
  31529. }
  31530. }
  31531. declare module "babylonjs/States/stencilState" {
  31532. /**
  31533. * @hidden
  31534. **/
  31535. export class StencilState {
  31536. /** 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 */
  31537. static readonly ALWAYS: number;
  31538. /** Passed to stencilOperation to specify that stencil value must be kept */
  31539. static readonly KEEP: number;
  31540. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31541. static readonly REPLACE: number;
  31542. private _isStencilTestDirty;
  31543. private _isStencilMaskDirty;
  31544. private _isStencilFuncDirty;
  31545. private _isStencilOpDirty;
  31546. private _stencilTest;
  31547. private _stencilMask;
  31548. private _stencilFunc;
  31549. private _stencilFuncRef;
  31550. private _stencilFuncMask;
  31551. private _stencilOpStencilFail;
  31552. private _stencilOpDepthFail;
  31553. private _stencilOpStencilDepthPass;
  31554. get isDirty(): boolean;
  31555. get stencilFunc(): number;
  31556. set stencilFunc(value: number);
  31557. get stencilFuncRef(): number;
  31558. set stencilFuncRef(value: number);
  31559. get stencilFuncMask(): number;
  31560. set stencilFuncMask(value: number);
  31561. get stencilOpStencilFail(): number;
  31562. set stencilOpStencilFail(value: number);
  31563. get stencilOpDepthFail(): number;
  31564. set stencilOpDepthFail(value: number);
  31565. get stencilOpStencilDepthPass(): number;
  31566. set stencilOpStencilDepthPass(value: number);
  31567. get stencilMask(): number;
  31568. set stencilMask(value: number);
  31569. get stencilTest(): boolean;
  31570. set stencilTest(value: boolean);
  31571. constructor();
  31572. reset(): void;
  31573. apply(gl: WebGLRenderingContext): void;
  31574. }
  31575. }
  31576. declare module "babylonjs/States/alphaCullingState" {
  31577. /**
  31578. * @hidden
  31579. **/
  31580. export class AlphaState {
  31581. private _isAlphaBlendDirty;
  31582. private _isBlendFunctionParametersDirty;
  31583. private _isBlendEquationParametersDirty;
  31584. private _isBlendConstantsDirty;
  31585. private _alphaBlend;
  31586. private _blendFunctionParameters;
  31587. private _blendEquationParameters;
  31588. private _blendConstants;
  31589. /**
  31590. * Initializes the state.
  31591. */
  31592. constructor();
  31593. get isDirty(): boolean;
  31594. get alphaBlend(): boolean;
  31595. set alphaBlend(value: boolean);
  31596. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31597. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31598. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31599. reset(): void;
  31600. apply(gl: WebGLRenderingContext): void;
  31601. }
  31602. }
  31603. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  31604. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31605. /** @hidden */
  31606. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31607. attributeProcessor(attribute: string): string;
  31608. varyingProcessor(varying: string, isFragment: boolean): string;
  31609. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31610. }
  31611. }
  31612. declare module "babylonjs/Engines/instancingAttributeInfo" {
  31613. /**
  31614. * Interface for attribute information associated with buffer instanciation
  31615. */
  31616. export interface InstancingAttributeInfo {
  31617. /**
  31618. * Name of the GLSL attribute
  31619. * if attribute index is not specified, this is used to retrieve the index from the effect
  31620. */
  31621. attributeName: string;
  31622. /**
  31623. * Index/offset of the attribute in the vertex shader
  31624. * if not specified, this will be computes from the name.
  31625. */
  31626. index?: number;
  31627. /**
  31628. * size of the attribute, 1, 2, 3 or 4
  31629. */
  31630. attributeSize: number;
  31631. /**
  31632. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  31633. */
  31634. offset: number;
  31635. /**
  31636. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  31637. * default to 1
  31638. */
  31639. divisor?: number;
  31640. /**
  31641. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  31642. * default is FLOAT
  31643. */
  31644. attributeType?: number;
  31645. /**
  31646. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  31647. */
  31648. normalized?: boolean;
  31649. }
  31650. }
  31651. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  31652. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31653. import { Nullable } from "babylonjs/types";
  31654. module "babylonjs/Engines/thinEngine" {
  31655. interface ThinEngine {
  31656. /**
  31657. * Update a video texture
  31658. * @param texture defines the texture to update
  31659. * @param video defines the video element to use
  31660. * @param invertY defines if data must be stored with Y axis inverted
  31661. */
  31662. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31663. }
  31664. }
  31665. }
  31666. declare module "babylonjs/Materials/Textures/videoTexture" {
  31667. import { Observable } from "babylonjs/Misc/observable";
  31668. import { Nullable } from "babylonjs/types";
  31669. import { Scene } from "babylonjs/scene";
  31670. import { Texture } from "babylonjs/Materials/Textures/texture";
  31671. import "babylonjs/Engines/Extensions/engine.videoTexture";
  31672. /**
  31673. * Settings for finer control over video usage
  31674. */
  31675. export interface VideoTextureSettings {
  31676. /**
  31677. * Applies `autoplay` to video, if specified
  31678. */
  31679. autoPlay?: boolean;
  31680. /**
  31681. * Applies `loop` to video, if specified
  31682. */
  31683. loop?: boolean;
  31684. /**
  31685. * Automatically updates internal texture from video at every frame in the render loop
  31686. */
  31687. autoUpdateTexture: boolean;
  31688. /**
  31689. * Image src displayed during the video loading or until the user interacts with the video.
  31690. */
  31691. poster?: string;
  31692. }
  31693. /**
  31694. * If you want to display a video in your scene, this is the special texture for that.
  31695. * This special texture works similar to other textures, with the exception of a few parameters.
  31696. * @see https://doc.babylonjs.com/how_to/video_texture
  31697. */
  31698. export class VideoTexture extends Texture {
  31699. /**
  31700. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  31701. */
  31702. readonly autoUpdateTexture: boolean;
  31703. /**
  31704. * The video instance used by the texture internally
  31705. */
  31706. readonly video: HTMLVideoElement;
  31707. private _onUserActionRequestedObservable;
  31708. /**
  31709. * Event triggerd when a dom action is required by the user to play the video.
  31710. * This happens due to recent changes in browser policies preventing video to auto start.
  31711. */
  31712. get onUserActionRequestedObservable(): Observable<Texture>;
  31713. private _generateMipMaps;
  31714. private _engine;
  31715. private _stillImageCaptured;
  31716. private _displayingPosterTexture;
  31717. private _settings;
  31718. private _createInternalTextureOnEvent;
  31719. private _frameId;
  31720. private _currentSrc;
  31721. /**
  31722. * Creates a video texture.
  31723. * If you want to display a video in your scene, this is the special texture for that.
  31724. * This special texture works similar to other textures, with the exception of a few parameters.
  31725. * @see https://doc.babylonjs.com/how_to/video_texture
  31726. * @param name optional name, will detect from video source, if not defined
  31727. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31728. * @param scene is obviously the current scene.
  31729. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31730. * @param invertY is false by default but can be used to invert video on Y axis
  31731. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31732. * @param settings allows finer control over video usage
  31733. */
  31734. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31735. private _getName;
  31736. private _getVideo;
  31737. private _createInternalTexture;
  31738. private reset;
  31739. /**
  31740. * @hidden Internal method to initiate `update`.
  31741. */
  31742. _rebuild(): void;
  31743. /**
  31744. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31745. */
  31746. update(): void;
  31747. /**
  31748. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31749. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31750. */
  31751. updateTexture(isVisible: boolean): void;
  31752. protected _updateInternalTexture: () => void;
  31753. /**
  31754. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31755. * @param url New url.
  31756. */
  31757. updateURL(url: string): void;
  31758. /**
  31759. * Clones the texture.
  31760. * @returns the cloned texture
  31761. */
  31762. clone(): VideoTexture;
  31763. /**
  31764. * Dispose the texture and release its associated resources.
  31765. */
  31766. dispose(): void;
  31767. /**
  31768. * Creates a video texture straight from a stream.
  31769. * @param scene Define the scene the texture should be created in
  31770. * @param stream Define the stream the texture should be created from
  31771. * @returns The created video texture as a promise
  31772. */
  31773. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  31774. /**
  31775. * Creates a video texture straight from your WebCam video feed.
  31776. * @param scene Define the scene the texture should be created in
  31777. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31778. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31779. * @returns The created video texture as a promise
  31780. */
  31781. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31782. minWidth: number;
  31783. maxWidth: number;
  31784. minHeight: number;
  31785. maxHeight: number;
  31786. deviceId: string;
  31787. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31788. /**
  31789. * Creates a video texture straight from your WebCam video feed.
  31790. * @param scene Define the scene the texture should be created in
  31791. * @param onReady Define a callback to triggered once the texture will be ready
  31792. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31793. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31794. */
  31795. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31796. minWidth: number;
  31797. maxWidth: number;
  31798. minHeight: number;
  31799. maxHeight: number;
  31800. deviceId: string;
  31801. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31802. }
  31803. }
  31804. declare module "babylonjs/Engines/thinEngine" {
  31805. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  31806. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  31807. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31808. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31809. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  31810. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  31811. import { Observable } from "babylonjs/Misc/observable";
  31812. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  31813. import { StencilState } from "babylonjs/States/stencilState";
  31814. import { AlphaState } from "babylonjs/States/alphaCullingState";
  31815. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31816. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31817. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31818. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  31819. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31820. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31821. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  31822. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  31823. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31824. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31825. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  31826. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  31827. import { WebRequest } from "babylonjs/Misc/webRequest";
  31828. import { LoadFileError } from "babylonjs/Misc/fileTools";
  31829. /**
  31830. * Defines the interface used by objects working like Scene
  31831. * @hidden
  31832. */
  31833. interface ISceneLike {
  31834. _addPendingData(data: any): void;
  31835. _removePendingData(data: any): void;
  31836. offlineProvider: IOfflineProvider;
  31837. }
  31838. /** Interface defining initialization parameters for Engine class */
  31839. export interface EngineOptions extends WebGLContextAttributes {
  31840. /**
  31841. * Defines if the engine should no exceed a specified device ratio
  31842. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  31843. */
  31844. limitDeviceRatio?: number;
  31845. /**
  31846. * Defines if webvr should be enabled automatically
  31847. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31848. */
  31849. autoEnableWebVR?: boolean;
  31850. /**
  31851. * Defines if webgl2 should be turned off even if supported
  31852. * @see http://doc.babylonjs.com/features/webgl2
  31853. */
  31854. disableWebGL2Support?: boolean;
  31855. /**
  31856. * Defines if webaudio should be initialized as well
  31857. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31858. */
  31859. audioEngine?: boolean;
  31860. /**
  31861. * Defines if animations should run using a deterministic lock step
  31862. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31863. */
  31864. deterministicLockstep?: boolean;
  31865. /** Defines the maximum steps to use with deterministic lock step mode */
  31866. lockstepMaxSteps?: number;
  31867. /** Defines the seconds between each deterministic lock step */
  31868. timeStep?: number;
  31869. /**
  31870. * Defines that engine should ignore context lost events
  31871. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  31872. */
  31873. doNotHandleContextLost?: boolean;
  31874. /**
  31875. * Defines that engine should ignore modifying touch action attribute and style
  31876. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  31877. */
  31878. doNotHandleTouchAction?: boolean;
  31879. /**
  31880. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  31881. */
  31882. useHighPrecisionFloats?: boolean;
  31883. }
  31884. /**
  31885. * The base engine class (root of all engines)
  31886. */
  31887. export class ThinEngine {
  31888. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  31889. static ExceptionList: ({
  31890. key: string;
  31891. capture: string;
  31892. captureConstraint: number;
  31893. targets: string[];
  31894. } | {
  31895. key: string;
  31896. capture: null;
  31897. captureConstraint: null;
  31898. targets: string[];
  31899. })[];
  31900. /** @hidden */
  31901. static _TextureLoaders: IInternalTextureLoader[];
  31902. /**
  31903. * Returns the current npm package of the sdk
  31904. */
  31905. static get NpmPackage(): string;
  31906. /**
  31907. * Returns the current version of the framework
  31908. */
  31909. static get Version(): string;
  31910. /**
  31911. * Returns a string describing the current engine
  31912. */
  31913. get description(): string;
  31914. /**
  31915. * Gets or sets the epsilon value used by collision engine
  31916. */
  31917. static CollisionsEpsilon: number;
  31918. /**
  31919. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31920. */
  31921. static get ShadersRepository(): string;
  31922. static set ShadersRepository(value: string);
  31923. /**
  31924. * Gets or sets the textures that the engine should not attempt to load as compressed
  31925. */
  31926. protected _excludedCompressedTextures: string[];
  31927. /**
  31928. * Filters the compressed texture formats to only include
  31929. * files that are not included in the skippable list
  31930. *
  31931. * @param url the current extension
  31932. * @param textureFormatInUse the current compressed texture format
  31933. * @returns "format" string
  31934. */
  31935. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  31936. /** @hidden */
  31937. _shaderProcessor: IShaderProcessor;
  31938. /**
  31939. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31940. */
  31941. forcePOTTextures: boolean;
  31942. /**
  31943. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31944. */
  31945. isFullscreen: boolean;
  31946. /**
  31947. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31948. */
  31949. cullBackFaces: boolean;
  31950. /**
  31951. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31952. */
  31953. renderEvenInBackground: boolean;
  31954. /**
  31955. * Gets or sets a boolean indicating that cache can be kept between frames
  31956. */
  31957. preventCacheWipeBetweenFrames: boolean;
  31958. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31959. validateShaderPrograms: boolean;
  31960. /**
  31961. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31962. * This can provide greater z depth for distant objects.
  31963. */
  31964. useReverseDepthBuffer: boolean;
  31965. /**
  31966. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31967. */
  31968. disableUniformBuffers: boolean;
  31969. /** @hidden */
  31970. _uniformBuffers: UniformBuffer[];
  31971. /**
  31972. * Gets a boolean indicating that the engine supports uniform buffers
  31973. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31974. */
  31975. get supportsUniformBuffers(): boolean;
  31976. /** @hidden */
  31977. _gl: WebGLRenderingContext;
  31978. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31979. protected _windowIsBackground: boolean;
  31980. protected _webGLVersion: number;
  31981. protected _creationOptions: EngineOptions;
  31982. protected _highPrecisionShadersAllowed: boolean;
  31983. /** @hidden */
  31984. get _shouldUseHighPrecisionShader(): boolean;
  31985. /**
  31986. * Gets a boolean indicating that only power of 2 textures are supported
  31987. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31988. */
  31989. get needPOTTextures(): boolean;
  31990. /** @hidden */
  31991. _badOS: boolean;
  31992. /** @hidden */
  31993. _badDesktopOS: boolean;
  31994. private _hardwareScalingLevel;
  31995. /** @hidden */
  31996. _caps: EngineCapabilities;
  31997. private _isStencilEnable;
  31998. private _glVersion;
  31999. private _glRenderer;
  32000. private _glVendor;
  32001. /** @hidden */
  32002. _videoTextureSupported: boolean;
  32003. protected _renderingQueueLaunched: boolean;
  32004. protected _activeRenderLoops: (() => void)[];
  32005. /**
  32006. * Observable signaled when a context lost event is raised
  32007. */
  32008. onContextLostObservable: Observable<ThinEngine>;
  32009. /**
  32010. * Observable signaled when a context restored event is raised
  32011. */
  32012. onContextRestoredObservable: Observable<ThinEngine>;
  32013. private _onContextLost;
  32014. private _onContextRestored;
  32015. protected _contextWasLost: boolean;
  32016. /** @hidden */
  32017. _doNotHandleContextLost: boolean;
  32018. /**
  32019. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  32020. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  32021. */
  32022. get doNotHandleContextLost(): boolean;
  32023. set doNotHandleContextLost(value: boolean);
  32024. /**
  32025. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  32026. */
  32027. disableVertexArrayObjects: boolean;
  32028. /** @hidden */
  32029. protected _colorWrite: boolean;
  32030. /** @hidden */
  32031. protected _colorWriteChanged: boolean;
  32032. /** @hidden */
  32033. protected _depthCullingState: DepthCullingState;
  32034. /** @hidden */
  32035. protected _stencilState: StencilState;
  32036. /** @hidden */
  32037. _alphaState: AlphaState;
  32038. /** @hidden */
  32039. _alphaMode: number;
  32040. /** @hidden */
  32041. _alphaEquation: number;
  32042. /** @hidden */
  32043. _internalTexturesCache: InternalTexture[];
  32044. /** @hidden */
  32045. protected _activeChannel: number;
  32046. private _currentTextureChannel;
  32047. /** @hidden */
  32048. protected _boundTexturesCache: {
  32049. [key: string]: Nullable<InternalTexture>;
  32050. };
  32051. /** @hidden */
  32052. protected _currentEffect: Nullable<Effect>;
  32053. /** @hidden */
  32054. protected _currentProgram: Nullable<WebGLProgram>;
  32055. private _compiledEffects;
  32056. private _vertexAttribArraysEnabled;
  32057. /** @hidden */
  32058. protected _cachedViewport: Nullable<IViewportLike>;
  32059. private _cachedVertexArrayObject;
  32060. /** @hidden */
  32061. protected _cachedVertexBuffers: any;
  32062. /** @hidden */
  32063. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  32064. /** @hidden */
  32065. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  32066. /** @hidden */
  32067. _currentRenderTarget: Nullable<InternalTexture>;
  32068. private _uintIndicesCurrentlySet;
  32069. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  32070. /** @hidden */
  32071. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  32072. private _currentBufferPointers;
  32073. private _currentInstanceLocations;
  32074. private _currentInstanceBuffers;
  32075. private _textureUnits;
  32076. /** @hidden */
  32077. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32078. /** @hidden */
  32079. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32080. /** @hidden */
  32081. _boundRenderFunction: any;
  32082. private _vaoRecordInProgress;
  32083. private _mustWipeVertexAttributes;
  32084. private _emptyTexture;
  32085. private _emptyCubeTexture;
  32086. private _emptyTexture3D;
  32087. private _emptyTexture2DArray;
  32088. /** @hidden */
  32089. _frameHandler: number;
  32090. private _nextFreeTextureSlots;
  32091. private _maxSimultaneousTextures;
  32092. private _activeRequests;
  32093. protected _texturesSupported: string[];
  32094. /** @hidden */
  32095. _textureFormatInUse: Nullable<string>;
  32096. protected get _supportsHardwareTextureRescaling(): boolean;
  32097. /**
  32098. * Gets the list of texture formats supported
  32099. */
  32100. get texturesSupported(): Array<string>;
  32101. /**
  32102. * Gets the list of texture formats in use
  32103. */
  32104. get textureFormatInUse(): Nullable<string>;
  32105. /**
  32106. * Gets the current viewport
  32107. */
  32108. get currentViewport(): Nullable<IViewportLike>;
  32109. /**
  32110. * Gets the default empty texture
  32111. */
  32112. get emptyTexture(): InternalTexture;
  32113. /**
  32114. * Gets the default empty 3D texture
  32115. */
  32116. get emptyTexture3D(): InternalTexture;
  32117. /**
  32118. * Gets the default empty 2D array texture
  32119. */
  32120. get emptyTexture2DArray(): InternalTexture;
  32121. /**
  32122. * Gets the default empty cube texture
  32123. */
  32124. get emptyCubeTexture(): InternalTexture;
  32125. /**
  32126. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  32127. */
  32128. readonly premultipliedAlpha: boolean;
  32129. /**
  32130. * Observable event triggered before each texture is initialized
  32131. */
  32132. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  32133. /**
  32134. * Creates a new engine
  32135. * @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
  32136. * @param antialias defines enable antialiasing (default: false)
  32137. * @param options defines further options to be sent to the getContext() function
  32138. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32139. */
  32140. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32141. private _rebuildInternalTextures;
  32142. private _rebuildEffects;
  32143. /**
  32144. * Gets a boolean indicating if all created effects are ready
  32145. * @returns true if all effects are ready
  32146. */
  32147. areAllEffectsReady(): boolean;
  32148. protected _rebuildBuffers(): void;
  32149. private _initGLContext;
  32150. /**
  32151. * Gets version of the current webGL context
  32152. */
  32153. get webGLVersion(): number;
  32154. /**
  32155. * Gets a string idenfifying the name of the class
  32156. * @returns "Engine" string
  32157. */
  32158. getClassName(): string;
  32159. /**
  32160. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  32161. */
  32162. get isStencilEnable(): boolean;
  32163. /** @hidden */
  32164. _prepareWorkingCanvas(): void;
  32165. /**
  32166. * Reset the texture cache to empty state
  32167. */
  32168. resetTextureCache(): void;
  32169. /**
  32170. * Gets an object containing information about the current webGL context
  32171. * @returns an object containing the vender, the renderer and the version of the current webGL context
  32172. */
  32173. getGlInfo(): {
  32174. vendor: string;
  32175. renderer: string;
  32176. version: string;
  32177. };
  32178. /**
  32179. * Defines the hardware scaling level.
  32180. * By default the hardware scaling level is computed from the window device ratio.
  32181. * 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.
  32182. * @param level defines the level to use
  32183. */
  32184. setHardwareScalingLevel(level: number): void;
  32185. /**
  32186. * Gets the current hardware scaling level.
  32187. * By default the hardware scaling level is computed from the window device ratio.
  32188. * 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.
  32189. * @returns a number indicating the current hardware scaling level
  32190. */
  32191. getHardwareScalingLevel(): number;
  32192. /**
  32193. * Gets the list of loaded textures
  32194. * @returns an array containing all loaded textures
  32195. */
  32196. getLoadedTexturesCache(): InternalTexture[];
  32197. /**
  32198. * Gets the object containing all engine capabilities
  32199. * @returns the EngineCapabilities object
  32200. */
  32201. getCaps(): EngineCapabilities;
  32202. /**
  32203. * stop executing a render loop function and remove it from the execution array
  32204. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  32205. */
  32206. stopRenderLoop(renderFunction?: () => void): void;
  32207. /** @hidden */
  32208. _renderLoop(): void;
  32209. /**
  32210. * Gets the HTML canvas attached with the current webGL context
  32211. * @returns a HTML canvas
  32212. */
  32213. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  32214. /**
  32215. * Gets host window
  32216. * @returns the host window object
  32217. */
  32218. getHostWindow(): Nullable<Window>;
  32219. /**
  32220. * Gets the current render width
  32221. * @param useScreen defines if screen size must be used (or the current render target if any)
  32222. * @returns a number defining the current render width
  32223. */
  32224. getRenderWidth(useScreen?: boolean): number;
  32225. /**
  32226. * Gets the current render height
  32227. * @param useScreen defines if screen size must be used (or the current render target if any)
  32228. * @returns a number defining the current render height
  32229. */
  32230. getRenderHeight(useScreen?: boolean): number;
  32231. /**
  32232. * Can be used to override the current requestAnimationFrame requester.
  32233. * @hidden
  32234. */
  32235. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  32236. /**
  32237. * Register and execute a render loop. The engine can have more than one render function
  32238. * @param renderFunction defines the function to continuously execute
  32239. */
  32240. runRenderLoop(renderFunction: () => void): void;
  32241. /**
  32242. * Clear the current render buffer or the current render target (if any is set up)
  32243. * @param color defines the color to use
  32244. * @param backBuffer defines if the back buffer must be cleared
  32245. * @param depth defines if the depth buffer must be cleared
  32246. * @param stencil defines if the stencil buffer must be cleared
  32247. */
  32248. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  32249. private _viewportCached;
  32250. /** @hidden */
  32251. _viewport(x: number, y: number, width: number, height: number): void;
  32252. /**
  32253. * Set the WebGL's viewport
  32254. * @param viewport defines the viewport element to be used
  32255. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  32256. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  32257. */
  32258. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  32259. /**
  32260. * Begin a new frame
  32261. */
  32262. beginFrame(): void;
  32263. /**
  32264. * Enf the current frame
  32265. */
  32266. endFrame(): void;
  32267. /**
  32268. * Resize the view according to the canvas' size
  32269. */
  32270. resize(): void;
  32271. /**
  32272. * Force a specific size of the canvas
  32273. * @param width defines the new canvas' width
  32274. * @param height defines the new canvas' height
  32275. */
  32276. setSize(width: number, height: number): void;
  32277. /**
  32278. * Binds the frame buffer to the specified texture.
  32279. * @param texture The texture to render to or null for the default canvas
  32280. * @param faceIndex The face of the texture to render to in case of cube texture
  32281. * @param requiredWidth The width of the target to render to
  32282. * @param requiredHeight The height of the target to render to
  32283. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  32284. * @param lodLevel defines the lod level to bind to the frame buffer
  32285. * @param layer defines the 2d array index to bind to frame buffer to
  32286. */
  32287. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  32288. /** @hidden */
  32289. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  32290. /**
  32291. * Unbind the current render target texture from the webGL context
  32292. * @param texture defines the render target texture to unbind
  32293. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  32294. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  32295. */
  32296. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  32297. /**
  32298. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  32299. */
  32300. flushFramebuffer(): void;
  32301. /**
  32302. * Unbind the current render target and bind the default framebuffer
  32303. */
  32304. restoreDefaultFramebuffer(): void;
  32305. /** @hidden */
  32306. protected _resetVertexBufferBinding(): void;
  32307. /**
  32308. * Creates a vertex buffer
  32309. * @param data the data for the vertex buffer
  32310. * @returns the new WebGL static buffer
  32311. */
  32312. createVertexBuffer(data: DataArray): DataBuffer;
  32313. private _createVertexBuffer;
  32314. /**
  32315. * Creates a dynamic vertex buffer
  32316. * @param data the data for the dynamic vertex buffer
  32317. * @returns the new WebGL dynamic buffer
  32318. */
  32319. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  32320. protected _resetIndexBufferBinding(): void;
  32321. /**
  32322. * Creates a new index buffer
  32323. * @param indices defines the content of the index buffer
  32324. * @param updatable defines if the index buffer must be updatable
  32325. * @returns a new webGL buffer
  32326. */
  32327. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  32328. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  32329. /**
  32330. * Bind a webGL buffer to the webGL context
  32331. * @param buffer defines the buffer to bind
  32332. */
  32333. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  32334. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  32335. private bindBuffer;
  32336. /**
  32337. * update the bound buffer with the given data
  32338. * @param data defines the data to update
  32339. */
  32340. updateArrayBuffer(data: Float32Array): void;
  32341. private _vertexAttribPointer;
  32342. /** @hidden */
  32343. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  32344. private _bindVertexBuffersAttributes;
  32345. /**
  32346. * Records a vertex array object
  32347. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32348. * @param vertexBuffers defines the list of vertex buffers to store
  32349. * @param indexBuffer defines the index buffer to store
  32350. * @param effect defines the effect to store
  32351. * @returns the new vertex array object
  32352. */
  32353. recordVertexArrayObject(vertexBuffers: {
  32354. [key: string]: VertexBuffer;
  32355. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  32356. /**
  32357. * Bind a specific vertex array object
  32358. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32359. * @param vertexArrayObject defines the vertex array object to bind
  32360. * @param indexBuffer defines the index buffer to bind
  32361. */
  32362. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  32363. /**
  32364. * Bind webGl buffers directly to the webGL context
  32365. * @param vertexBuffer defines the vertex buffer to bind
  32366. * @param indexBuffer defines the index buffer to bind
  32367. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  32368. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  32369. * @param effect defines the effect associated with the vertex buffer
  32370. */
  32371. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  32372. private _unbindVertexArrayObject;
  32373. /**
  32374. * Bind a list of vertex buffers to the webGL context
  32375. * @param vertexBuffers defines the list of vertex buffers to bind
  32376. * @param indexBuffer defines the index buffer to bind
  32377. * @param effect defines the effect associated with the vertex buffers
  32378. */
  32379. bindBuffers(vertexBuffers: {
  32380. [key: string]: Nullable<VertexBuffer>;
  32381. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  32382. /**
  32383. * Unbind all instance attributes
  32384. */
  32385. unbindInstanceAttributes(): void;
  32386. /**
  32387. * Release and free the memory of a vertex array object
  32388. * @param vao defines the vertex array object to delete
  32389. */
  32390. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  32391. /** @hidden */
  32392. _releaseBuffer(buffer: DataBuffer): boolean;
  32393. protected _deleteBuffer(buffer: DataBuffer): void;
  32394. /**
  32395. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  32396. * @param instancesBuffer defines the webGL buffer to update and bind
  32397. * @param data defines the data to store in the buffer
  32398. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  32399. */
  32400. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  32401. /**
  32402. * Bind the content of a webGL buffer used with instantiation
  32403. * @param instancesBuffer defines the webGL buffer to bind
  32404. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  32405. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  32406. */
  32407. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  32408. /**
  32409. * Disable the instance attribute corresponding to the name in parameter
  32410. * @param name defines the name of the attribute to disable
  32411. */
  32412. disableInstanceAttributeByName(name: string): void;
  32413. /**
  32414. * Disable the instance attribute corresponding to the location in parameter
  32415. * @param attributeLocation defines the attribute location of the attribute to disable
  32416. */
  32417. disableInstanceAttribute(attributeLocation: number): void;
  32418. /**
  32419. * Disable the attribute corresponding to the location in parameter
  32420. * @param attributeLocation defines the attribute location of the attribute to disable
  32421. */
  32422. disableAttributeByIndex(attributeLocation: number): void;
  32423. /**
  32424. * Send a draw order
  32425. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32426. * @param indexStart defines the starting index
  32427. * @param indexCount defines the number of index to draw
  32428. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32429. */
  32430. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  32431. /**
  32432. * Draw a list of points
  32433. * @param verticesStart defines the index of first vertex to draw
  32434. * @param verticesCount defines the count of vertices to draw
  32435. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32436. */
  32437. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32438. /**
  32439. * Draw a list of unindexed primitives
  32440. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32441. * @param verticesStart defines the index of first vertex to draw
  32442. * @param verticesCount defines the count of vertices to draw
  32443. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32444. */
  32445. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32446. /**
  32447. * Draw a list of indexed primitives
  32448. * @param fillMode defines the primitive to use
  32449. * @param indexStart defines the starting index
  32450. * @param indexCount defines the number of index to draw
  32451. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32452. */
  32453. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  32454. /**
  32455. * Draw a list of unindexed primitives
  32456. * @param fillMode defines the primitive to use
  32457. * @param verticesStart defines the index of first vertex to draw
  32458. * @param verticesCount defines the count of vertices to draw
  32459. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32460. */
  32461. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32462. private _drawMode;
  32463. /** @hidden */
  32464. protected _reportDrawCall(): void;
  32465. /** @hidden */
  32466. _releaseEffect(effect: Effect): void;
  32467. /** @hidden */
  32468. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32469. /**
  32470. * Create a new effect (used to store vertex/fragment shaders)
  32471. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  32472. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  32473. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  32474. * @param samplers defines an array of string used to represent textures
  32475. * @param defines defines the string containing the defines to use to compile the shaders
  32476. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32477. * @param onCompiled defines a function to call when the effect creation is successful
  32478. * @param onError defines a function to call when the effect creation has failed
  32479. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  32480. * @returns the new Effect
  32481. */
  32482. 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;
  32483. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  32484. private _compileShader;
  32485. private _compileRawShader;
  32486. /**
  32487. * Directly creates a webGL program
  32488. * @param pipelineContext defines the pipeline context to attach to
  32489. * @param vertexCode defines the vertex shader code to use
  32490. * @param fragmentCode defines the fragment shader code to use
  32491. * @param context defines the webGL context to use (if not set, the current one will be used)
  32492. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32493. * @returns the new webGL program
  32494. */
  32495. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32496. /**
  32497. * Creates a webGL program
  32498. * @param pipelineContext defines the pipeline context to attach to
  32499. * @param vertexCode defines the vertex shader code to use
  32500. * @param fragmentCode defines the fragment shader code to use
  32501. * @param defines defines the string containing the defines to use to compile the shaders
  32502. * @param context defines the webGL context to use (if not set, the current one will be used)
  32503. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32504. * @returns the new webGL program
  32505. */
  32506. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32507. /**
  32508. * Creates a new pipeline context
  32509. * @returns the new pipeline
  32510. */
  32511. createPipelineContext(): IPipelineContext;
  32512. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32513. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  32514. /** @hidden */
  32515. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  32516. /** @hidden */
  32517. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  32518. /** @hidden */
  32519. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  32520. /**
  32521. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  32522. * @param pipelineContext defines the pipeline context to use
  32523. * @param uniformsNames defines the list of uniform names
  32524. * @returns an array of webGL uniform locations
  32525. */
  32526. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  32527. /**
  32528. * Gets the lsit of active attributes for a given webGL program
  32529. * @param pipelineContext defines the pipeline context to use
  32530. * @param attributesNames defines the list of attribute names to get
  32531. * @returns an array of indices indicating the offset of each attribute
  32532. */
  32533. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  32534. /**
  32535. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  32536. * @param effect defines the effect to activate
  32537. */
  32538. enableEffect(effect: Nullable<Effect>): void;
  32539. /**
  32540. * Set the value of an uniform to a number (int)
  32541. * @param uniform defines the webGL uniform location where to store the value
  32542. * @param value defines the int number to store
  32543. */
  32544. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32545. /**
  32546. * Set the value of an uniform to an array of int32
  32547. * @param uniform defines the webGL uniform location where to store the value
  32548. * @param array defines the array of int32 to store
  32549. */
  32550. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32551. /**
  32552. * Set the value of an uniform to an array of int32 (stored as vec2)
  32553. * @param uniform defines the webGL uniform location where to store the value
  32554. * @param array defines the array of int32 to store
  32555. */
  32556. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32557. /**
  32558. * Set the value of an uniform to an array of int32 (stored as vec3)
  32559. * @param uniform defines the webGL uniform location where to store the value
  32560. * @param array defines the array of int32 to store
  32561. */
  32562. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32563. /**
  32564. * Set the value of an uniform to an array of int32 (stored as vec4)
  32565. * @param uniform defines the webGL uniform location where to store the value
  32566. * @param array defines the array of int32 to store
  32567. */
  32568. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32569. /**
  32570. * Set the value of an uniform to an array of number
  32571. * @param uniform defines the webGL uniform location where to store the value
  32572. * @param array defines the array of number to store
  32573. */
  32574. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32575. /**
  32576. * Set the value of an uniform to an array of number (stored as vec2)
  32577. * @param uniform defines the webGL uniform location where to store the value
  32578. * @param array defines the array of number to store
  32579. */
  32580. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32581. /**
  32582. * Set the value of an uniform to an array of number (stored as vec3)
  32583. * @param uniform defines the webGL uniform location where to store the value
  32584. * @param array defines the array of number to store
  32585. */
  32586. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32587. /**
  32588. * Set the value of an uniform to an array of number (stored as vec4)
  32589. * @param uniform defines the webGL uniform location where to store the value
  32590. * @param array defines the array of number to store
  32591. */
  32592. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32593. /**
  32594. * Set the value of an uniform to an array of float32 (stored as matrices)
  32595. * @param uniform defines the webGL uniform location where to store the value
  32596. * @param matrices defines the array of float32 to store
  32597. */
  32598. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32599. /**
  32600. * Set the value of an uniform to a matrix (3x3)
  32601. * @param uniform defines the webGL uniform location where to store the value
  32602. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32603. */
  32604. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32605. /**
  32606. * Set the value of an uniform to a matrix (2x2)
  32607. * @param uniform defines the webGL uniform location where to store the value
  32608. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32609. */
  32610. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32611. /**
  32612. * Set the value of an uniform to a number (float)
  32613. * @param uniform defines the webGL uniform location where to store the value
  32614. * @param value defines the float number to store
  32615. */
  32616. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32617. /**
  32618. * Set the value of an uniform to a vec2
  32619. * @param uniform defines the webGL uniform location where to store the value
  32620. * @param x defines the 1st component of the value
  32621. * @param y defines the 2nd component of the value
  32622. */
  32623. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32624. /**
  32625. * Set the value of an uniform to a vec3
  32626. * @param uniform defines the webGL uniform location where to store the value
  32627. * @param x defines the 1st component of the value
  32628. * @param y defines the 2nd component of the value
  32629. * @param z defines the 3rd component of the value
  32630. */
  32631. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32632. /**
  32633. * Set the value of an uniform to a vec4
  32634. * @param uniform defines the webGL uniform location where to store the value
  32635. * @param x defines the 1st component of the value
  32636. * @param y defines the 2nd component of the value
  32637. * @param z defines the 3rd component of the value
  32638. * @param w defines the 4th component of the value
  32639. */
  32640. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32641. /**
  32642. * Apply all cached states (depth, culling, stencil and alpha)
  32643. */
  32644. applyStates(): void;
  32645. /**
  32646. * Enable or disable color writing
  32647. * @param enable defines the state to set
  32648. */
  32649. setColorWrite(enable: boolean): void;
  32650. /**
  32651. * Gets a boolean indicating if color writing is enabled
  32652. * @returns the current color writing state
  32653. */
  32654. getColorWrite(): boolean;
  32655. /**
  32656. * Gets the depth culling state manager
  32657. */
  32658. get depthCullingState(): DepthCullingState;
  32659. /**
  32660. * Gets the alpha state manager
  32661. */
  32662. get alphaState(): AlphaState;
  32663. /**
  32664. * Gets the stencil state manager
  32665. */
  32666. get stencilState(): StencilState;
  32667. /**
  32668. * Clears the list of texture accessible through engine.
  32669. * This can help preventing texture load conflict due to name collision.
  32670. */
  32671. clearInternalTexturesCache(): void;
  32672. /**
  32673. * Force the entire cache to be cleared
  32674. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32675. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32676. */
  32677. wipeCaches(bruteForce?: boolean): void;
  32678. /** @hidden */
  32679. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32680. min: number;
  32681. mag: number;
  32682. };
  32683. /** @hidden */
  32684. _createTexture(): WebGLTexture;
  32685. /**
  32686. * Usually called from Texture.ts.
  32687. * Passed information to create a WebGLTexture
  32688. * @param urlArg defines a value which contains one of the following:
  32689. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32690. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32691. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32692. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32693. * @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)
  32694. * @param scene needed for loading to the correct scene
  32695. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32696. * @param onLoad optional callback to be called upon successful completion
  32697. * @param onError optional callback to be called upon failure
  32698. * @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
  32699. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32700. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32701. * @param forcedExtension defines the extension to use to pick the right loader
  32702. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  32703. * @param mimeType defines an optional mime type
  32704. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32705. */
  32706. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  32707. /**
  32708. * Loads an image as an HTMLImageElement.
  32709. * @param input url string, ArrayBuffer, or Blob to load
  32710. * @param onLoad callback called when the image successfully loads
  32711. * @param onError callback called when the image fails to load
  32712. * @param offlineProvider offline provider for caching
  32713. * @param mimeType optional mime type
  32714. * @returns the HTMLImageElement of the loaded image
  32715. * @hidden
  32716. */
  32717. 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>;
  32718. /**
  32719. * @hidden
  32720. */
  32721. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32722. /**
  32723. * Creates a raw texture
  32724. * @param data defines the data to store in the texture
  32725. * @param width defines the width of the texture
  32726. * @param height defines the height of the texture
  32727. * @param format defines the format of the data
  32728. * @param generateMipMaps defines if the engine should generate the mip levels
  32729. * @param invertY defines if data must be stored with Y axis inverted
  32730. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32731. * @param compression defines the compression used (null by default)
  32732. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32733. * @returns the raw texture inside an InternalTexture
  32734. */
  32735. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  32736. /**
  32737. * Creates a new raw cube texture
  32738. * @param data defines the array of data to use to create each face
  32739. * @param size defines the size of the textures
  32740. * @param format defines the format of the data
  32741. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32742. * @param generateMipMaps defines if the engine should generate the mip levels
  32743. * @param invertY defines if data must be stored with Y axis inverted
  32744. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32745. * @param compression defines the compression used (null by default)
  32746. * @returns the cube texture as an InternalTexture
  32747. */
  32748. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  32749. /**
  32750. * Creates a new raw 3D texture
  32751. * @param data defines the data used to create the texture
  32752. * @param width defines the width of the texture
  32753. * @param height defines the height of the texture
  32754. * @param depth defines the depth of the texture
  32755. * @param format defines the format of the texture
  32756. * @param generateMipMaps defines if the engine must generate mip levels
  32757. * @param invertY defines if data must be stored with Y axis inverted
  32758. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32759. * @param compression defines the compressed used (can be null)
  32760. * @param textureType defines the compressed used (can be null)
  32761. * @returns a new raw 3D texture (stored in an InternalTexture)
  32762. */
  32763. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32764. /**
  32765. * Creates a new raw 2D array texture
  32766. * @param data defines the data used to create the texture
  32767. * @param width defines the width of the texture
  32768. * @param height defines the height of the texture
  32769. * @param depth defines the number of layers of the texture
  32770. * @param format defines the format of the texture
  32771. * @param generateMipMaps defines if the engine must generate mip levels
  32772. * @param invertY defines if data must be stored with Y axis inverted
  32773. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32774. * @param compression defines the compressed used (can be null)
  32775. * @param textureType defines the compressed used (can be null)
  32776. * @returns a new raw 2D array texture (stored in an InternalTexture)
  32777. */
  32778. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32779. private _unpackFlipYCached;
  32780. /**
  32781. * In case you are sharing the context with other applications, it might
  32782. * be interested to not cache the unpack flip y state to ensure a consistent
  32783. * value would be set.
  32784. */
  32785. enableUnpackFlipYCached: boolean;
  32786. /** @hidden */
  32787. _unpackFlipY(value: boolean): void;
  32788. /** @hidden */
  32789. _getUnpackAlignement(): number;
  32790. private _getTextureTarget;
  32791. /**
  32792. * Update the sampling mode of a given texture
  32793. * @param samplingMode defines the required sampling mode
  32794. * @param texture defines the texture to update
  32795. * @param generateMipMaps defines whether to generate mipmaps for the texture
  32796. */
  32797. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  32798. /**
  32799. * Update the sampling mode of a given texture
  32800. * @param texture defines the texture to update
  32801. * @param wrapU defines the texture wrap mode of the u coordinates
  32802. * @param wrapV defines the texture wrap mode of the v coordinates
  32803. * @param wrapR defines the texture wrap mode of the r coordinates
  32804. */
  32805. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  32806. /** @hidden */
  32807. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32808. width: number;
  32809. height: number;
  32810. layers?: number;
  32811. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32812. /** @hidden */
  32813. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32814. /** @hidden */
  32815. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32816. /**
  32817. * Update a portion of an internal texture
  32818. * @param texture defines the texture to update
  32819. * @param imageData defines the data to store into the texture
  32820. * @param xOffset defines the x coordinates of the update rectangle
  32821. * @param yOffset defines the y coordinates of the update rectangle
  32822. * @param width defines the width of the update rectangle
  32823. * @param height defines the height of the update rectangle
  32824. * @param faceIndex defines the face index if texture is a cube (0 by default)
  32825. * @param lod defines the lod level to update (0 by default)
  32826. */
  32827. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  32828. /** @hidden */
  32829. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32830. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32831. private _prepareWebGLTexture;
  32832. /** @hidden */
  32833. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32834. private _getDepthStencilBuffer;
  32835. /** @hidden */
  32836. _releaseFramebufferObjects(texture: InternalTexture): void;
  32837. /** @hidden */
  32838. _releaseTexture(texture: InternalTexture): void;
  32839. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32840. protected _setProgram(program: WebGLProgram): void;
  32841. protected _boundUniforms: {
  32842. [key: number]: WebGLUniformLocation;
  32843. };
  32844. /**
  32845. * Binds an effect to the webGL context
  32846. * @param effect defines the effect to bind
  32847. */
  32848. bindSamplers(effect: Effect): void;
  32849. private _activateCurrentTexture;
  32850. /** @hidden */
  32851. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32852. /** @hidden */
  32853. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32854. /**
  32855. * Unbind all textures from the webGL context
  32856. */
  32857. unbindAllTextures(): void;
  32858. /**
  32859. * Sets a texture to the according uniform.
  32860. * @param channel The texture channel
  32861. * @param uniform The uniform to set
  32862. * @param texture The texture to apply
  32863. */
  32864. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32865. private _bindSamplerUniformToChannel;
  32866. private _getTextureWrapMode;
  32867. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32868. /**
  32869. * Sets an array of texture to the webGL context
  32870. * @param channel defines the channel where the texture array must be set
  32871. * @param uniform defines the associated uniform location
  32872. * @param textures defines the array of textures to bind
  32873. */
  32874. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32875. /** @hidden */
  32876. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  32877. private _setTextureParameterFloat;
  32878. private _setTextureParameterInteger;
  32879. /**
  32880. * Unbind all vertex attributes from the webGL context
  32881. */
  32882. unbindAllAttributes(): void;
  32883. /**
  32884. * 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
  32885. */
  32886. releaseEffects(): void;
  32887. /**
  32888. * Dispose and release all associated resources
  32889. */
  32890. dispose(): void;
  32891. /**
  32892. * Attach a new callback raised when context lost event is fired
  32893. * @param callback defines the callback to call
  32894. */
  32895. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32896. /**
  32897. * Attach a new callback raised when context restored event is fired
  32898. * @param callback defines the callback to call
  32899. */
  32900. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32901. /**
  32902. * Get the current error code of the webGL context
  32903. * @returns the error code
  32904. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32905. */
  32906. getError(): number;
  32907. private _canRenderToFloatFramebuffer;
  32908. private _canRenderToHalfFloatFramebuffer;
  32909. private _canRenderToFramebuffer;
  32910. /** @hidden */
  32911. _getWebGLTextureType(type: number): number;
  32912. /** @hidden */
  32913. _getInternalFormat(format: number): number;
  32914. /** @hidden */
  32915. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32916. /** @hidden */
  32917. _getRGBAMultiSampleBufferFormat(type: number): number;
  32918. /** @hidden */
  32919. _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;
  32920. /**
  32921. * Loads a file from a url
  32922. * @param url url to load
  32923. * @param onSuccess callback called when the file successfully loads
  32924. * @param onProgress callback called while file is loading (if the server supports this mode)
  32925. * @param offlineProvider defines the offline provider for caching
  32926. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32927. * @param onError callback called when the file fails to load
  32928. * @returns a file request object
  32929. * @hidden
  32930. */
  32931. 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;
  32932. /**
  32933. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32934. * @param x defines the x coordinate of the rectangle where pixels must be read
  32935. * @param y defines the y coordinate of the rectangle where pixels must be read
  32936. * @param width defines the width of the rectangle where pixels must be read
  32937. * @param height defines the height of the rectangle where pixels must be read
  32938. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  32939. * @returns a Uint8Array containing RGBA colors
  32940. */
  32941. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  32942. private static _isSupported;
  32943. /**
  32944. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32945. * @returns true if the engine can be created
  32946. * @ignorenaming
  32947. */
  32948. static isSupported(): boolean;
  32949. /**
  32950. * Find the next highest power of two.
  32951. * @param x Number to start search from.
  32952. * @return Next highest power of two.
  32953. */
  32954. static CeilingPOT(x: number): number;
  32955. /**
  32956. * Find the next lowest power of two.
  32957. * @param x Number to start search from.
  32958. * @return Next lowest power of two.
  32959. */
  32960. static FloorPOT(x: number): number;
  32961. /**
  32962. * Find the nearest power of two.
  32963. * @param x Number to start search from.
  32964. * @return Next nearest power of two.
  32965. */
  32966. static NearestPOT(x: number): number;
  32967. /**
  32968. * Get the closest exponent of two
  32969. * @param value defines the value to approximate
  32970. * @param max defines the maximum value to return
  32971. * @param mode defines how to define the closest value
  32972. * @returns closest exponent of two of the given value
  32973. */
  32974. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32975. /**
  32976. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32977. * @param func - the function to be called
  32978. * @param requester - the object that will request the next frame. Falls back to window.
  32979. * @returns frame number
  32980. */
  32981. static QueueNewFrame(func: () => void, requester?: any): number;
  32982. /**
  32983. * Gets host document
  32984. * @returns the host document object
  32985. */
  32986. getHostDocument(): Nullable<Document>;
  32987. }
  32988. }
  32989. declare module "babylonjs/Maths/sphericalPolynomial" {
  32990. import { Vector3 } from "babylonjs/Maths/math.vector";
  32991. import { Color3 } from "babylonjs/Maths/math.color";
  32992. /**
  32993. * Class representing spherical harmonics coefficients to the 3rd degree
  32994. */
  32995. export class SphericalHarmonics {
  32996. /**
  32997. * Defines whether or not the harmonics have been prescaled for rendering.
  32998. */
  32999. preScaled: boolean;
  33000. /**
  33001. * The l0,0 coefficients of the spherical harmonics
  33002. */
  33003. l00: Vector3;
  33004. /**
  33005. * The l1,-1 coefficients of the spherical harmonics
  33006. */
  33007. l1_1: Vector3;
  33008. /**
  33009. * The l1,0 coefficients of the spherical harmonics
  33010. */
  33011. l10: Vector3;
  33012. /**
  33013. * The l1,1 coefficients of the spherical harmonics
  33014. */
  33015. l11: Vector3;
  33016. /**
  33017. * The l2,-2 coefficients of the spherical harmonics
  33018. */
  33019. l2_2: Vector3;
  33020. /**
  33021. * The l2,-1 coefficients of the spherical harmonics
  33022. */
  33023. l2_1: Vector3;
  33024. /**
  33025. * The l2,0 coefficients of the spherical harmonics
  33026. */
  33027. l20: Vector3;
  33028. /**
  33029. * The l2,1 coefficients of the spherical harmonics
  33030. */
  33031. l21: Vector3;
  33032. /**
  33033. * The l2,2 coefficients of the spherical harmonics
  33034. */
  33035. l22: Vector3;
  33036. /**
  33037. * Adds a light to the spherical harmonics
  33038. * @param direction the direction of the light
  33039. * @param color the color of the light
  33040. * @param deltaSolidAngle the delta solid angle of the light
  33041. */
  33042. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  33043. /**
  33044. * Scales the spherical harmonics by the given amount
  33045. * @param scale the amount to scale
  33046. */
  33047. scaleInPlace(scale: number): void;
  33048. /**
  33049. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  33050. *
  33051. * ```
  33052. * E_lm = A_l * L_lm
  33053. * ```
  33054. *
  33055. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  33056. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  33057. * the scaling factors are given in equation 9.
  33058. */
  33059. convertIncidentRadianceToIrradiance(): void;
  33060. /**
  33061. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  33062. *
  33063. * ```
  33064. * L = (1/pi) * E * rho
  33065. * ```
  33066. *
  33067. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  33068. */
  33069. convertIrradianceToLambertianRadiance(): void;
  33070. /**
  33071. * Integrates the reconstruction coefficients directly in to the SH preventing further
  33072. * required operations at run time.
  33073. *
  33074. * This is simply done by scaling back the SH with Ylm constants parameter.
  33075. * The trigonometric part being applied by the shader at run time.
  33076. */
  33077. preScaleForRendering(): void;
  33078. /**
  33079. * Constructs a spherical harmonics from an array.
  33080. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  33081. * @returns the spherical harmonics
  33082. */
  33083. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  33084. /**
  33085. * Gets the spherical harmonics from polynomial
  33086. * @param polynomial the spherical polynomial
  33087. * @returns the spherical harmonics
  33088. */
  33089. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  33090. }
  33091. /**
  33092. * Class representing spherical polynomial coefficients to the 3rd degree
  33093. */
  33094. export class SphericalPolynomial {
  33095. private _harmonics;
  33096. /**
  33097. * The spherical harmonics used to create the polynomials.
  33098. */
  33099. get preScaledHarmonics(): SphericalHarmonics;
  33100. /**
  33101. * The x coefficients of the spherical polynomial
  33102. */
  33103. x: Vector3;
  33104. /**
  33105. * The y coefficients of the spherical polynomial
  33106. */
  33107. y: Vector3;
  33108. /**
  33109. * The z coefficients of the spherical polynomial
  33110. */
  33111. z: Vector3;
  33112. /**
  33113. * The xx coefficients of the spherical polynomial
  33114. */
  33115. xx: Vector3;
  33116. /**
  33117. * The yy coefficients of the spherical polynomial
  33118. */
  33119. yy: Vector3;
  33120. /**
  33121. * The zz coefficients of the spherical polynomial
  33122. */
  33123. zz: Vector3;
  33124. /**
  33125. * The xy coefficients of the spherical polynomial
  33126. */
  33127. xy: Vector3;
  33128. /**
  33129. * The yz coefficients of the spherical polynomial
  33130. */
  33131. yz: Vector3;
  33132. /**
  33133. * The zx coefficients of the spherical polynomial
  33134. */
  33135. zx: Vector3;
  33136. /**
  33137. * Adds an ambient color to the spherical polynomial
  33138. * @param color the color to add
  33139. */
  33140. addAmbient(color: Color3): void;
  33141. /**
  33142. * Scales the spherical polynomial by the given amount
  33143. * @param scale the amount to scale
  33144. */
  33145. scaleInPlace(scale: number): void;
  33146. /**
  33147. * Gets the spherical polynomial from harmonics
  33148. * @param harmonics the spherical harmonics
  33149. * @returns the spherical polynomial
  33150. */
  33151. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  33152. /**
  33153. * Constructs a spherical polynomial from an array.
  33154. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  33155. * @returns the spherical polynomial
  33156. */
  33157. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  33158. }
  33159. }
  33160. declare module "babylonjs/Materials/Textures/internalTexture" {
  33161. import { Observable } from "babylonjs/Misc/observable";
  33162. import { Nullable, int } from "babylonjs/types";
  33163. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  33164. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33165. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  33166. /**
  33167. * Defines the source of the internal texture
  33168. */
  33169. export enum InternalTextureSource {
  33170. /**
  33171. * The source of the texture data is unknown
  33172. */
  33173. Unknown = 0,
  33174. /**
  33175. * Texture data comes from an URL
  33176. */
  33177. Url = 1,
  33178. /**
  33179. * Texture data is only used for temporary storage
  33180. */
  33181. Temp = 2,
  33182. /**
  33183. * Texture data comes from raw data (ArrayBuffer)
  33184. */
  33185. Raw = 3,
  33186. /**
  33187. * Texture content is dynamic (video or dynamic texture)
  33188. */
  33189. Dynamic = 4,
  33190. /**
  33191. * Texture content is generated by rendering to it
  33192. */
  33193. RenderTarget = 5,
  33194. /**
  33195. * Texture content is part of a multi render target process
  33196. */
  33197. MultiRenderTarget = 6,
  33198. /**
  33199. * Texture data comes from a cube data file
  33200. */
  33201. Cube = 7,
  33202. /**
  33203. * Texture data comes from a raw cube data
  33204. */
  33205. CubeRaw = 8,
  33206. /**
  33207. * Texture data come from a prefiltered cube data file
  33208. */
  33209. CubePrefiltered = 9,
  33210. /**
  33211. * Texture content is raw 3D data
  33212. */
  33213. Raw3D = 10,
  33214. /**
  33215. * Texture content is raw 2D array data
  33216. */
  33217. Raw2DArray = 11,
  33218. /**
  33219. * Texture content is a depth texture
  33220. */
  33221. Depth = 12,
  33222. /**
  33223. * Texture data comes from a raw cube data encoded with RGBD
  33224. */
  33225. CubeRawRGBD = 13
  33226. }
  33227. /**
  33228. * Class used to store data associated with WebGL texture data for the engine
  33229. * This class should not be used directly
  33230. */
  33231. export class InternalTexture {
  33232. /** @hidden */
  33233. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  33234. /**
  33235. * Defines if the texture is ready
  33236. */
  33237. isReady: boolean;
  33238. /**
  33239. * Defines if the texture is a cube texture
  33240. */
  33241. isCube: boolean;
  33242. /**
  33243. * Defines if the texture contains 3D data
  33244. */
  33245. is3D: boolean;
  33246. /**
  33247. * Defines if the texture contains 2D array data
  33248. */
  33249. is2DArray: boolean;
  33250. /**
  33251. * Defines if the texture contains multiview data
  33252. */
  33253. isMultiview: boolean;
  33254. /**
  33255. * Gets the URL used to load this texture
  33256. */
  33257. url: string;
  33258. /**
  33259. * Gets the sampling mode of the texture
  33260. */
  33261. samplingMode: number;
  33262. /**
  33263. * Gets a boolean indicating if the texture needs mipmaps generation
  33264. */
  33265. generateMipMaps: boolean;
  33266. /**
  33267. * Gets the number of samples used by the texture (WebGL2+ only)
  33268. */
  33269. samples: number;
  33270. /**
  33271. * Gets the type of the texture (int, float...)
  33272. */
  33273. type: number;
  33274. /**
  33275. * Gets the format of the texture (RGB, RGBA...)
  33276. */
  33277. format: number;
  33278. /**
  33279. * Observable called when the texture is loaded
  33280. */
  33281. onLoadedObservable: Observable<InternalTexture>;
  33282. /**
  33283. * Gets the width of the texture
  33284. */
  33285. width: number;
  33286. /**
  33287. * Gets the height of the texture
  33288. */
  33289. height: number;
  33290. /**
  33291. * Gets the depth of the texture
  33292. */
  33293. depth: number;
  33294. /**
  33295. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  33296. */
  33297. baseWidth: number;
  33298. /**
  33299. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  33300. */
  33301. baseHeight: number;
  33302. /**
  33303. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  33304. */
  33305. baseDepth: number;
  33306. /**
  33307. * Gets a boolean indicating if the texture is inverted on Y axis
  33308. */
  33309. invertY: boolean;
  33310. /** @hidden */
  33311. _invertVScale: boolean;
  33312. /** @hidden */
  33313. _associatedChannel: number;
  33314. /** @hidden */
  33315. _source: InternalTextureSource;
  33316. /** @hidden */
  33317. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  33318. /** @hidden */
  33319. _bufferView: Nullable<ArrayBufferView>;
  33320. /** @hidden */
  33321. _bufferViewArray: Nullable<ArrayBufferView[]>;
  33322. /** @hidden */
  33323. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  33324. /** @hidden */
  33325. _size: number;
  33326. /** @hidden */
  33327. _extension: string;
  33328. /** @hidden */
  33329. _files: Nullable<string[]>;
  33330. /** @hidden */
  33331. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  33332. /** @hidden */
  33333. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  33334. /** @hidden */
  33335. _framebuffer: Nullable<WebGLFramebuffer>;
  33336. /** @hidden */
  33337. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  33338. /** @hidden */
  33339. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  33340. /** @hidden */
  33341. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  33342. /** @hidden */
  33343. _attachments: Nullable<number[]>;
  33344. /** @hidden */
  33345. _cachedCoordinatesMode: Nullable<number>;
  33346. /** @hidden */
  33347. _cachedWrapU: Nullable<number>;
  33348. /** @hidden */
  33349. _cachedWrapV: Nullable<number>;
  33350. /** @hidden */
  33351. _cachedWrapR: Nullable<number>;
  33352. /** @hidden */
  33353. _cachedAnisotropicFilteringLevel: Nullable<number>;
  33354. /** @hidden */
  33355. _isDisabled: boolean;
  33356. /** @hidden */
  33357. _compression: Nullable<string>;
  33358. /** @hidden */
  33359. _generateStencilBuffer: boolean;
  33360. /** @hidden */
  33361. _generateDepthBuffer: boolean;
  33362. /** @hidden */
  33363. _comparisonFunction: number;
  33364. /** @hidden */
  33365. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  33366. /** @hidden */
  33367. _lodGenerationScale: number;
  33368. /** @hidden */
  33369. _lodGenerationOffset: number;
  33370. /** @hidden */
  33371. _depthStencilTexture: Nullable<InternalTexture>;
  33372. /** @hidden */
  33373. _colorTextureArray: Nullable<WebGLTexture>;
  33374. /** @hidden */
  33375. _depthStencilTextureArray: Nullable<WebGLTexture>;
  33376. /** @hidden */
  33377. _lodTextureHigh: Nullable<BaseTexture>;
  33378. /** @hidden */
  33379. _lodTextureMid: Nullable<BaseTexture>;
  33380. /** @hidden */
  33381. _lodTextureLow: Nullable<BaseTexture>;
  33382. /** @hidden */
  33383. _isRGBD: boolean;
  33384. /** @hidden */
  33385. _linearSpecularLOD: boolean;
  33386. /** @hidden */
  33387. _irradianceTexture: Nullable<BaseTexture>;
  33388. /** @hidden */
  33389. _webGLTexture: Nullable<WebGLTexture>;
  33390. /** @hidden */
  33391. _references: number;
  33392. private _engine;
  33393. /**
  33394. * Gets the Engine the texture belongs to.
  33395. * @returns The babylon engine
  33396. */
  33397. getEngine(): ThinEngine;
  33398. /**
  33399. * Gets the data source type of the texture
  33400. */
  33401. get source(): InternalTextureSource;
  33402. /**
  33403. * Creates a new InternalTexture
  33404. * @param engine defines the engine to use
  33405. * @param source defines the type of data that will be used
  33406. * @param delayAllocation if the texture allocation should be delayed (default: false)
  33407. */
  33408. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  33409. /**
  33410. * Increments the number of references (ie. the number of Texture that point to it)
  33411. */
  33412. incrementReferences(): void;
  33413. /**
  33414. * Change the size of the texture (not the size of the content)
  33415. * @param width defines the new width
  33416. * @param height defines the new height
  33417. * @param depth defines the new depth (1 by default)
  33418. */
  33419. updateSize(width: int, height: int, depth?: int): void;
  33420. /** @hidden */
  33421. _rebuild(): void;
  33422. /** @hidden */
  33423. _swapAndDie(target: InternalTexture): void;
  33424. /**
  33425. * Dispose the current allocated resources
  33426. */
  33427. dispose(): void;
  33428. }
  33429. }
  33430. declare module "babylonjs/Audio/analyser" {
  33431. import { Scene } from "babylonjs/scene";
  33432. /**
  33433. * Class used to work with sound analyzer using fast fourier transform (FFT)
  33434. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33435. */
  33436. export class Analyser {
  33437. /**
  33438. * Gets or sets the smoothing
  33439. * @ignorenaming
  33440. */
  33441. SMOOTHING: number;
  33442. /**
  33443. * Gets or sets the FFT table size
  33444. * @ignorenaming
  33445. */
  33446. FFT_SIZE: number;
  33447. /**
  33448. * Gets or sets the bar graph amplitude
  33449. * @ignorenaming
  33450. */
  33451. BARGRAPHAMPLITUDE: number;
  33452. /**
  33453. * Gets or sets the position of the debug canvas
  33454. * @ignorenaming
  33455. */
  33456. DEBUGCANVASPOS: {
  33457. x: number;
  33458. y: number;
  33459. };
  33460. /**
  33461. * Gets or sets the debug canvas size
  33462. * @ignorenaming
  33463. */
  33464. DEBUGCANVASSIZE: {
  33465. width: number;
  33466. height: number;
  33467. };
  33468. private _byteFreqs;
  33469. private _byteTime;
  33470. private _floatFreqs;
  33471. private _webAudioAnalyser;
  33472. private _debugCanvas;
  33473. private _debugCanvasContext;
  33474. private _scene;
  33475. private _registerFunc;
  33476. private _audioEngine;
  33477. /**
  33478. * Creates a new analyser
  33479. * @param scene defines hosting scene
  33480. */
  33481. constructor(scene: Scene);
  33482. /**
  33483. * Get the number of data values you will have to play with for the visualization
  33484. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  33485. * @returns a number
  33486. */
  33487. getFrequencyBinCount(): number;
  33488. /**
  33489. * Gets the current frequency data as a byte array
  33490. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33491. * @returns a Uint8Array
  33492. */
  33493. getByteFrequencyData(): Uint8Array;
  33494. /**
  33495. * Gets the current waveform as a byte array
  33496. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  33497. * @returns a Uint8Array
  33498. */
  33499. getByteTimeDomainData(): Uint8Array;
  33500. /**
  33501. * Gets the current frequency data as a float array
  33502. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33503. * @returns a Float32Array
  33504. */
  33505. getFloatFrequencyData(): Float32Array;
  33506. /**
  33507. * Renders the debug canvas
  33508. */
  33509. drawDebugCanvas(): void;
  33510. /**
  33511. * Stops rendering the debug canvas and removes it
  33512. */
  33513. stopDebugCanvas(): void;
  33514. /**
  33515. * Connects two audio nodes
  33516. * @param inputAudioNode defines first node to connect
  33517. * @param outputAudioNode defines second node to connect
  33518. */
  33519. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  33520. /**
  33521. * Releases all associated resources
  33522. */
  33523. dispose(): void;
  33524. }
  33525. }
  33526. declare module "babylonjs/Audio/audioEngine" {
  33527. import { IDisposable } from "babylonjs/scene";
  33528. import { Analyser } from "babylonjs/Audio/analyser";
  33529. import { Nullable } from "babylonjs/types";
  33530. import { Observable } from "babylonjs/Misc/observable";
  33531. /**
  33532. * This represents an audio engine and it is responsible
  33533. * to play, synchronize and analyse sounds throughout the application.
  33534. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33535. */
  33536. export interface IAudioEngine extends IDisposable {
  33537. /**
  33538. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33539. */
  33540. readonly canUseWebAudio: boolean;
  33541. /**
  33542. * Gets the current AudioContext if available.
  33543. */
  33544. readonly audioContext: Nullable<AudioContext>;
  33545. /**
  33546. * The master gain node defines the global audio volume of your audio engine.
  33547. */
  33548. readonly masterGain: GainNode;
  33549. /**
  33550. * Gets whether or not mp3 are supported by your browser.
  33551. */
  33552. readonly isMP3supported: boolean;
  33553. /**
  33554. * Gets whether or not ogg are supported by your browser.
  33555. */
  33556. readonly isOGGsupported: boolean;
  33557. /**
  33558. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33559. * @ignoreNaming
  33560. */
  33561. WarnedWebAudioUnsupported: boolean;
  33562. /**
  33563. * Defines if the audio engine relies on a custom unlocked button.
  33564. * In this case, the embedded button will not be displayed.
  33565. */
  33566. useCustomUnlockedButton: boolean;
  33567. /**
  33568. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  33569. */
  33570. readonly unlocked: boolean;
  33571. /**
  33572. * Event raised when audio has been unlocked on the browser.
  33573. */
  33574. onAudioUnlockedObservable: Observable<AudioEngine>;
  33575. /**
  33576. * Event raised when audio has been locked on the browser.
  33577. */
  33578. onAudioLockedObservable: Observable<AudioEngine>;
  33579. /**
  33580. * Flags the audio engine in Locked state.
  33581. * This happens due to new browser policies preventing audio to autoplay.
  33582. */
  33583. lock(): void;
  33584. /**
  33585. * Unlocks the audio engine once a user action has been done on the dom.
  33586. * This is helpful to resume play once browser policies have been satisfied.
  33587. */
  33588. unlock(): void;
  33589. }
  33590. /**
  33591. * This represents the default audio engine used in babylon.
  33592. * It is responsible to play, synchronize and analyse sounds throughout the application.
  33593. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33594. */
  33595. export class AudioEngine implements IAudioEngine {
  33596. private _audioContext;
  33597. private _audioContextInitialized;
  33598. private _muteButton;
  33599. private _hostElement;
  33600. /**
  33601. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33602. */
  33603. canUseWebAudio: boolean;
  33604. /**
  33605. * The master gain node defines the global audio volume of your audio engine.
  33606. */
  33607. masterGain: GainNode;
  33608. /**
  33609. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33610. * @ignoreNaming
  33611. */
  33612. WarnedWebAudioUnsupported: boolean;
  33613. /**
  33614. * Gets whether or not mp3 are supported by your browser.
  33615. */
  33616. isMP3supported: boolean;
  33617. /**
  33618. * Gets whether or not ogg are supported by your browser.
  33619. */
  33620. isOGGsupported: boolean;
  33621. /**
  33622. * Gets whether audio has been unlocked on the device.
  33623. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  33624. * a user interaction has happened.
  33625. */
  33626. unlocked: boolean;
  33627. /**
  33628. * Defines if the audio engine relies on a custom unlocked button.
  33629. * In this case, the embedded button will not be displayed.
  33630. */
  33631. useCustomUnlockedButton: boolean;
  33632. /**
  33633. * Event raised when audio has been unlocked on the browser.
  33634. */
  33635. onAudioUnlockedObservable: Observable<AudioEngine>;
  33636. /**
  33637. * Event raised when audio has been locked on the browser.
  33638. */
  33639. onAudioLockedObservable: Observable<AudioEngine>;
  33640. /**
  33641. * Gets the current AudioContext if available.
  33642. */
  33643. get audioContext(): Nullable<AudioContext>;
  33644. private _connectedAnalyser;
  33645. /**
  33646. * Instantiates a new audio engine.
  33647. *
  33648. * There should be only one per page as some browsers restrict the number
  33649. * of audio contexts you can create.
  33650. * @param hostElement defines the host element where to display the mute icon if necessary
  33651. */
  33652. constructor(hostElement?: Nullable<HTMLElement>);
  33653. /**
  33654. * Flags the audio engine in Locked state.
  33655. * This happens due to new browser policies preventing audio to autoplay.
  33656. */
  33657. lock(): void;
  33658. /**
  33659. * Unlocks the audio engine once a user action has been done on the dom.
  33660. * This is helpful to resume play once browser policies have been satisfied.
  33661. */
  33662. unlock(): void;
  33663. private _resumeAudioContext;
  33664. private _initializeAudioContext;
  33665. private _tryToRun;
  33666. private _triggerRunningState;
  33667. private _triggerSuspendedState;
  33668. private _displayMuteButton;
  33669. private _moveButtonToTopLeft;
  33670. private _onResize;
  33671. private _hideMuteButton;
  33672. /**
  33673. * Destroy and release the resources associated with the audio ccontext.
  33674. */
  33675. dispose(): void;
  33676. /**
  33677. * Gets the global volume sets on the master gain.
  33678. * @returns the global volume if set or -1 otherwise
  33679. */
  33680. getGlobalVolume(): number;
  33681. /**
  33682. * Sets the global volume of your experience (sets on the master gain).
  33683. * @param newVolume Defines the new global volume of the application
  33684. */
  33685. setGlobalVolume(newVolume: number): void;
  33686. /**
  33687. * Connect the audio engine to an audio analyser allowing some amazing
  33688. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33689. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33690. * @param analyser The analyser to connect to the engine
  33691. */
  33692. connectToAnalyser(analyser: Analyser): void;
  33693. }
  33694. }
  33695. declare module "babylonjs/Loading/loadingScreen" {
  33696. /**
  33697. * Interface used to present a loading screen while loading a scene
  33698. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33699. */
  33700. export interface ILoadingScreen {
  33701. /**
  33702. * Function called to display the loading screen
  33703. */
  33704. displayLoadingUI: () => void;
  33705. /**
  33706. * Function called to hide the loading screen
  33707. */
  33708. hideLoadingUI: () => void;
  33709. /**
  33710. * Gets or sets the color to use for the background
  33711. */
  33712. loadingUIBackgroundColor: string;
  33713. /**
  33714. * Gets or sets the text to display while loading
  33715. */
  33716. loadingUIText: string;
  33717. }
  33718. /**
  33719. * Class used for the default loading screen
  33720. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33721. */
  33722. export class DefaultLoadingScreen implements ILoadingScreen {
  33723. private _renderingCanvas;
  33724. private _loadingText;
  33725. private _loadingDivBackgroundColor;
  33726. private _loadingDiv;
  33727. private _loadingTextDiv;
  33728. /** Gets or sets the logo url to use for the default loading screen */
  33729. static DefaultLogoUrl: string;
  33730. /** Gets or sets the spinner url to use for the default loading screen */
  33731. static DefaultSpinnerUrl: string;
  33732. /**
  33733. * Creates a new default loading screen
  33734. * @param _renderingCanvas defines the canvas used to render the scene
  33735. * @param _loadingText defines the default text to display
  33736. * @param _loadingDivBackgroundColor defines the default background color
  33737. */
  33738. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33739. /**
  33740. * Function called to display the loading screen
  33741. */
  33742. displayLoadingUI(): void;
  33743. /**
  33744. * Function called to hide the loading screen
  33745. */
  33746. hideLoadingUI(): void;
  33747. /**
  33748. * Gets or sets the text to display while loading
  33749. */
  33750. set loadingUIText(text: string);
  33751. get loadingUIText(): string;
  33752. /**
  33753. * Gets or sets the color to use for the background
  33754. */
  33755. get loadingUIBackgroundColor(): string;
  33756. set loadingUIBackgroundColor(color: string);
  33757. private _resizeLoadingUI;
  33758. }
  33759. }
  33760. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  33761. /**
  33762. * Interface for any object that can request an animation frame
  33763. */
  33764. export interface ICustomAnimationFrameRequester {
  33765. /**
  33766. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33767. */
  33768. renderFunction?: Function;
  33769. /**
  33770. * Called to request the next frame to render to
  33771. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33772. */
  33773. requestAnimationFrame: Function;
  33774. /**
  33775. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33776. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33777. */
  33778. requestID?: number;
  33779. }
  33780. }
  33781. declare module "babylonjs/Misc/performanceMonitor" {
  33782. /**
  33783. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33784. */
  33785. export class PerformanceMonitor {
  33786. private _enabled;
  33787. private _rollingFrameTime;
  33788. private _lastFrameTimeMs;
  33789. /**
  33790. * constructor
  33791. * @param frameSampleSize The number of samples required to saturate the sliding window
  33792. */
  33793. constructor(frameSampleSize?: number);
  33794. /**
  33795. * Samples current frame
  33796. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33797. */
  33798. sampleFrame(timeMs?: number): void;
  33799. /**
  33800. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33801. */
  33802. get averageFrameTime(): number;
  33803. /**
  33804. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33805. */
  33806. get averageFrameTimeVariance(): number;
  33807. /**
  33808. * Returns the frame time of the most recent frame
  33809. */
  33810. get instantaneousFrameTime(): number;
  33811. /**
  33812. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33813. */
  33814. get averageFPS(): number;
  33815. /**
  33816. * Returns the average framerate in frames per second using the most recent frame time
  33817. */
  33818. get instantaneousFPS(): number;
  33819. /**
  33820. * Returns true if enough samples have been taken to completely fill the sliding window
  33821. */
  33822. get isSaturated(): boolean;
  33823. /**
  33824. * Enables contributions to the sliding window sample set
  33825. */
  33826. enable(): void;
  33827. /**
  33828. * Disables contributions to the sliding window sample set
  33829. * Samples will not be interpolated over the disabled period
  33830. */
  33831. disable(): void;
  33832. /**
  33833. * Returns true if sampling is enabled
  33834. */
  33835. get isEnabled(): boolean;
  33836. /**
  33837. * Resets performance monitor
  33838. */
  33839. reset(): void;
  33840. }
  33841. /**
  33842. * RollingAverage
  33843. *
  33844. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33845. */
  33846. export class RollingAverage {
  33847. /**
  33848. * Current average
  33849. */
  33850. average: number;
  33851. /**
  33852. * Current variance
  33853. */
  33854. variance: number;
  33855. protected _samples: Array<number>;
  33856. protected _sampleCount: number;
  33857. protected _pos: number;
  33858. protected _m2: number;
  33859. /**
  33860. * constructor
  33861. * @param length The number of samples required to saturate the sliding window
  33862. */
  33863. constructor(length: number);
  33864. /**
  33865. * Adds a sample to the sample set
  33866. * @param v The sample value
  33867. */
  33868. add(v: number): void;
  33869. /**
  33870. * Returns previously added values or null if outside of history or outside the sliding window domain
  33871. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33872. * @return Value previously recorded with add() or null if outside of range
  33873. */
  33874. history(i: number): number;
  33875. /**
  33876. * Returns true if enough samples have been taken to completely fill the sliding window
  33877. * @return true if sample-set saturated
  33878. */
  33879. isSaturated(): boolean;
  33880. /**
  33881. * Resets the rolling average (equivalent to 0 samples taken so far)
  33882. */
  33883. reset(): void;
  33884. /**
  33885. * Wraps a value around the sample range boundaries
  33886. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33887. * @return Wrapped position in sample range
  33888. */
  33889. protected _wrapPosition(i: number): number;
  33890. }
  33891. }
  33892. declare module "babylonjs/Misc/perfCounter" {
  33893. /**
  33894. * This class is used to track a performance counter which is number based.
  33895. * The user has access to many properties which give statistics of different nature.
  33896. *
  33897. * The implementer can track two kinds of Performance Counter: time and count.
  33898. * 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.
  33899. * 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.
  33900. */
  33901. export class PerfCounter {
  33902. /**
  33903. * Gets or sets a global boolean to turn on and off all the counters
  33904. */
  33905. static Enabled: boolean;
  33906. /**
  33907. * Returns the smallest value ever
  33908. */
  33909. get min(): number;
  33910. /**
  33911. * Returns the biggest value ever
  33912. */
  33913. get max(): number;
  33914. /**
  33915. * Returns the average value since the performance counter is running
  33916. */
  33917. get average(): number;
  33918. /**
  33919. * Returns the average value of the last second the counter was monitored
  33920. */
  33921. get lastSecAverage(): number;
  33922. /**
  33923. * Returns the current value
  33924. */
  33925. get current(): number;
  33926. /**
  33927. * Gets the accumulated total
  33928. */
  33929. get total(): number;
  33930. /**
  33931. * Gets the total value count
  33932. */
  33933. get count(): number;
  33934. /**
  33935. * Creates a new counter
  33936. */
  33937. constructor();
  33938. /**
  33939. * Call this method to start monitoring a new frame.
  33940. * 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.
  33941. */
  33942. fetchNewFrame(): void;
  33943. /**
  33944. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33945. * @param newCount the count value to add to the monitored count
  33946. * @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.
  33947. */
  33948. addCount(newCount: number, fetchResult: boolean): void;
  33949. /**
  33950. * Start monitoring this performance counter
  33951. */
  33952. beginMonitoring(): void;
  33953. /**
  33954. * Compute the time lapsed since the previous beginMonitoring() call.
  33955. * @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
  33956. */
  33957. endMonitoring(newFrame?: boolean): void;
  33958. private _fetchResult;
  33959. private _startMonitoringTime;
  33960. private _min;
  33961. private _max;
  33962. private _average;
  33963. private _current;
  33964. private _totalValueCount;
  33965. private _totalAccumulated;
  33966. private _lastSecAverage;
  33967. private _lastSecAccumulated;
  33968. private _lastSecTime;
  33969. private _lastSecValueCount;
  33970. }
  33971. }
  33972. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  33973. module "babylonjs/Engines/thinEngine" {
  33974. interface ThinEngine {
  33975. /**
  33976. * Sets alpha constants used by some alpha blending modes
  33977. * @param r defines the red component
  33978. * @param g defines the green component
  33979. * @param b defines the blue component
  33980. * @param a defines the alpha component
  33981. */
  33982. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33983. /**
  33984. * Sets the current alpha mode
  33985. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33986. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33987. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33988. */
  33989. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33990. /**
  33991. * Gets the current alpha mode
  33992. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33993. * @returns the current alpha mode
  33994. */
  33995. getAlphaMode(): number;
  33996. /**
  33997. * Sets the current alpha equation
  33998. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33999. */
  34000. setAlphaEquation(equation: number): void;
  34001. /**
  34002. * Gets the current alpha equation.
  34003. * @returns the current alpha equation
  34004. */
  34005. getAlphaEquation(): number;
  34006. }
  34007. }
  34008. }
  34009. declare module "babylonjs/Engines/engine" {
  34010. import { Observable } from "babylonjs/Misc/observable";
  34011. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  34012. import { Scene } from "babylonjs/scene";
  34013. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34014. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  34015. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34016. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  34017. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  34018. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  34019. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  34020. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  34021. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  34022. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34023. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  34024. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  34025. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  34026. import "babylonjs/Engines/Extensions/engine.alpha";
  34027. import { Material } from "babylonjs/Materials/material";
  34028. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34029. /**
  34030. * Defines the interface used by display changed events
  34031. */
  34032. export interface IDisplayChangedEventArgs {
  34033. /** Gets the vrDisplay object (if any) */
  34034. vrDisplay: Nullable<any>;
  34035. /** Gets a boolean indicating if webVR is supported */
  34036. vrSupported: boolean;
  34037. }
  34038. /**
  34039. * Defines the interface used by objects containing a viewport (like a camera)
  34040. */
  34041. interface IViewportOwnerLike {
  34042. /**
  34043. * Gets or sets the viewport
  34044. */
  34045. viewport: IViewportLike;
  34046. }
  34047. /**
  34048. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  34049. */
  34050. export class Engine extends ThinEngine {
  34051. /** Defines that alpha blending is disabled */
  34052. static readonly ALPHA_DISABLE: number;
  34053. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  34054. static readonly ALPHA_ADD: number;
  34055. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  34056. static readonly ALPHA_COMBINE: number;
  34057. /** Defines that alpha blending to DEST - SRC * DEST */
  34058. static readonly ALPHA_SUBTRACT: number;
  34059. /** Defines that alpha blending to SRC * DEST */
  34060. static readonly ALPHA_MULTIPLY: number;
  34061. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  34062. static readonly ALPHA_MAXIMIZED: number;
  34063. /** Defines that alpha blending to SRC + DEST */
  34064. static readonly ALPHA_ONEONE: number;
  34065. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  34066. static readonly ALPHA_PREMULTIPLIED: number;
  34067. /**
  34068. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  34069. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  34070. */
  34071. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  34072. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  34073. static readonly ALPHA_INTERPOLATE: number;
  34074. /**
  34075. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  34076. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  34077. */
  34078. static readonly ALPHA_SCREENMODE: number;
  34079. /** Defines that the ressource is not delayed*/
  34080. static readonly DELAYLOADSTATE_NONE: number;
  34081. /** Defines that the ressource was successfully delay loaded */
  34082. static readonly DELAYLOADSTATE_LOADED: number;
  34083. /** Defines that the ressource is currently delay loading */
  34084. static readonly DELAYLOADSTATE_LOADING: number;
  34085. /** Defines that the ressource is delayed and has not started loading */
  34086. static readonly DELAYLOADSTATE_NOTLOADED: number;
  34087. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  34088. static readonly NEVER: number;
  34089. /** 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 */
  34090. static readonly ALWAYS: number;
  34091. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  34092. static readonly LESS: number;
  34093. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  34094. static readonly EQUAL: number;
  34095. /** 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 */
  34096. static readonly LEQUAL: number;
  34097. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  34098. static readonly GREATER: number;
  34099. /** 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 */
  34100. static readonly GEQUAL: number;
  34101. /** 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 */
  34102. static readonly NOTEQUAL: number;
  34103. /** Passed to stencilOperation to specify that stencil value must be kept */
  34104. static readonly KEEP: number;
  34105. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34106. static readonly REPLACE: number;
  34107. /** Passed to stencilOperation to specify that stencil value must be incremented */
  34108. static readonly INCR: number;
  34109. /** Passed to stencilOperation to specify that stencil value must be decremented */
  34110. static readonly DECR: number;
  34111. /** Passed to stencilOperation to specify that stencil value must be inverted */
  34112. static readonly INVERT: number;
  34113. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  34114. static readonly INCR_WRAP: number;
  34115. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  34116. static readonly DECR_WRAP: number;
  34117. /** Texture is not repeating outside of 0..1 UVs */
  34118. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  34119. /** Texture is repeating outside of 0..1 UVs */
  34120. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  34121. /** Texture is repeating and mirrored */
  34122. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  34123. /** ALPHA */
  34124. static readonly TEXTUREFORMAT_ALPHA: number;
  34125. /** LUMINANCE */
  34126. static readonly TEXTUREFORMAT_LUMINANCE: number;
  34127. /** LUMINANCE_ALPHA */
  34128. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  34129. /** RGB */
  34130. static readonly TEXTUREFORMAT_RGB: number;
  34131. /** RGBA */
  34132. static readonly TEXTUREFORMAT_RGBA: number;
  34133. /** RED */
  34134. static readonly TEXTUREFORMAT_RED: number;
  34135. /** RED (2nd reference) */
  34136. static readonly TEXTUREFORMAT_R: number;
  34137. /** RG */
  34138. static readonly TEXTUREFORMAT_RG: number;
  34139. /** RED_INTEGER */
  34140. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  34141. /** RED_INTEGER (2nd reference) */
  34142. static readonly TEXTUREFORMAT_R_INTEGER: number;
  34143. /** RG_INTEGER */
  34144. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  34145. /** RGB_INTEGER */
  34146. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  34147. /** RGBA_INTEGER */
  34148. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  34149. /** UNSIGNED_BYTE */
  34150. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  34151. /** UNSIGNED_BYTE (2nd reference) */
  34152. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  34153. /** FLOAT */
  34154. static readonly TEXTURETYPE_FLOAT: number;
  34155. /** HALF_FLOAT */
  34156. static readonly TEXTURETYPE_HALF_FLOAT: number;
  34157. /** BYTE */
  34158. static readonly TEXTURETYPE_BYTE: number;
  34159. /** SHORT */
  34160. static readonly TEXTURETYPE_SHORT: number;
  34161. /** UNSIGNED_SHORT */
  34162. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  34163. /** INT */
  34164. static readonly TEXTURETYPE_INT: number;
  34165. /** UNSIGNED_INT */
  34166. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  34167. /** UNSIGNED_SHORT_4_4_4_4 */
  34168. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  34169. /** UNSIGNED_SHORT_5_5_5_1 */
  34170. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  34171. /** UNSIGNED_SHORT_5_6_5 */
  34172. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  34173. /** UNSIGNED_INT_2_10_10_10_REV */
  34174. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  34175. /** UNSIGNED_INT_24_8 */
  34176. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  34177. /** UNSIGNED_INT_10F_11F_11F_REV */
  34178. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  34179. /** UNSIGNED_INT_5_9_9_9_REV */
  34180. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  34181. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  34182. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  34183. /** nearest is mag = nearest and min = nearest and mip = linear */
  34184. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  34185. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34186. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  34187. /** Trilinear is mag = linear and min = linear and mip = linear */
  34188. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  34189. /** nearest is mag = nearest and min = nearest and mip = linear */
  34190. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  34191. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34192. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  34193. /** Trilinear is mag = linear and min = linear and mip = linear */
  34194. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  34195. /** mag = nearest and min = nearest and mip = nearest */
  34196. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  34197. /** mag = nearest and min = linear and mip = nearest */
  34198. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  34199. /** mag = nearest and min = linear and mip = linear */
  34200. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  34201. /** mag = nearest and min = linear and mip = none */
  34202. static readonly TEXTURE_NEAREST_LINEAR: number;
  34203. /** mag = nearest and min = nearest and mip = none */
  34204. static readonly TEXTURE_NEAREST_NEAREST: number;
  34205. /** mag = linear and min = nearest and mip = nearest */
  34206. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  34207. /** mag = linear and min = nearest and mip = linear */
  34208. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  34209. /** mag = linear and min = linear and mip = none */
  34210. static readonly TEXTURE_LINEAR_LINEAR: number;
  34211. /** mag = linear and min = nearest and mip = none */
  34212. static readonly TEXTURE_LINEAR_NEAREST: number;
  34213. /** Explicit coordinates mode */
  34214. static readonly TEXTURE_EXPLICIT_MODE: number;
  34215. /** Spherical coordinates mode */
  34216. static readonly TEXTURE_SPHERICAL_MODE: number;
  34217. /** Planar coordinates mode */
  34218. static readonly TEXTURE_PLANAR_MODE: number;
  34219. /** Cubic coordinates mode */
  34220. static readonly TEXTURE_CUBIC_MODE: number;
  34221. /** Projection coordinates mode */
  34222. static readonly TEXTURE_PROJECTION_MODE: number;
  34223. /** Skybox coordinates mode */
  34224. static readonly TEXTURE_SKYBOX_MODE: number;
  34225. /** Inverse Cubic coordinates mode */
  34226. static readonly TEXTURE_INVCUBIC_MODE: number;
  34227. /** Equirectangular coordinates mode */
  34228. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  34229. /** Equirectangular Fixed coordinates mode */
  34230. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  34231. /** Equirectangular Fixed Mirrored coordinates mode */
  34232. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  34233. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  34234. static readonly SCALEMODE_FLOOR: number;
  34235. /** Defines that texture rescaling will look for the nearest power of 2 size */
  34236. static readonly SCALEMODE_NEAREST: number;
  34237. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  34238. static readonly SCALEMODE_CEILING: number;
  34239. /**
  34240. * Returns the current npm package of the sdk
  34241. */
  34242. static get NpmPackage(): string;
  34243. /**
  34244. * Returns the current version of the framework
  34245. */
  34246. static get Version(): string;
  34247. /** Gets the list of created engines */
  34248. static get Instances(): Engine[];
  34249. /**
  34250. * Gets the latest created engine
  34251. */
  34252. static get LastCreatedEngine(): Nullable<Engine>;
  34253. /**
  34254. * Gets the latest created scene
  34255. */
  34256. static get LastCreatedScene(): Nullable<Scene>;
  34257. /**
  34258. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  34259. * @param flag defines which part of the materials must be marked as dirty
  34260. * @param predicate defines a predicate used to filter which materials should be affected
  34261. */
  34262. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34263. /**
  34264. * Method called to create the default loading screen.
  34265. * This can be overriden in your own app.
  34266. * @param canvas The rendering canvas element
  34267. * @returns The loading screen
  34268. */
  34269. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  34270. /**
  34271. * Method called to create the default rescale post process on each engine.
  34272. */
  34273. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  34274. /**
  34275. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  34276. **/
  34277. enableOfflineSupport: boolean;
  34278. /**
  34279. * 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)
  34280. **/
  34281. disableManifestCheck: boolean;
  34282. /**
  34283. * Gets the list of created scenes
  34284. */
  34285. scenes: Scene[];
  34286. /**
  34287. * Event raised when a new scene is created
  34288. */
  34289. onNewSceneAddedObservable: Observable<Scene>;
  34290. /**
  34291. * Gets the list of created postprocesses
  34292. */
  34293. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  34294. /**
  34295. * Gets a boolean indicating if the pointer is currently locked
  34296. */
  34297. isPointerLock: boolean;
  34298. /**
  34299. * Observable event triggered each time the rendering canvas is resized
  34300. */
  34301. onResizeObservable: Observable<Engine>;
  34302. /**
  34303. * Observable event triggered each time the canvas loses focus
  34304. */
  34305. onCanvasBlurObservable: Observable<Engine>;
  34306. /**
  34307. * Observable event triggered each time the canvas gains focus
  34308. */
  34309. onCanvasFocusObservable: Observable<Engine>;
  34310. /**
  34311. * Observable event triggered each time the canvas receives pointerout event
  34312. */
  34313. onCanvasPointerOutObservable: Observable<PointerEvent>;
  34314. /**
  34315. * Observable raised when the engine begins a new frame
  34316. */
  34317. onBeginFrameObservable: Observable<Engine>;
  34318. /**
  34319. * If set, will be used to request the next animation frame for the render loop
  34320. */
  34321. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  34322. /**
  34323. * Observable raised when the engine ends the current frame
  34324. */
  34325. onEndFrameObservable: Observable<Engine>;
  34326. /**
  34327. * Observable raised when the engine is about to compile a shader
  34328. */
  34329. onBeforeShaderCompilationObservable: Observable<Engine>;
  34330. /**
  34331. * Observable raised when the engine has jsut compiled a shader
  34332. */
  34333. onAfterShaderCompilationObservable: Observable<Engine>;
  34334. /**
  34335. * Gets the audio engine
  34336. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34337. * @ignorenaming
  34338. */
  34339. static audioEngine: IAudioEngine;
  34340. /**
  34341. * Default AudioEngine factory responsible of creating the Audio Engine.
  34342. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  34343. */
  34344. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  34345. /**
  34346. * Default offline support factory responsible of creating a tool used to store data locally.
  34347. * By default, this will create a Database object if the workload has been embedded.
  34348. */
  34349. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  34350. private _loadingScreen;
  34351. private _pointerLockRequested;
  34352. private _dummyFramebuffer;
  34353. private _rescalePostProcess;
  34354. private _deterministicLockstep;
  34355. private _lockstepMaxSteps;
  34356. private _timeStep;
  34357. protected get _supportsHardwareTextureRescaling(): boolean;
  34358. private _fps;
  34359. private _deltaTime;
  34360. /** @hidden */
  34361. _drawCalls: PerfCounter;
  34362. /** 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 */
  34363. canvasTabIndex: number;
  34364. /**
  34365. * Turn this value on if you want to pause FPS computation when in background
  34366. */
  34367. disablePerformanceMonitorInBackground: boolean;
  34368. private _performanceMonitor;
  34369. /**
  34370. * Gets the performance monitor attached to this engine
  34371. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  34372. */
  34373. get performanceMonitor(): PerformanceMonitor;
  34374. private _onFocus;
  34375. private _onBlur;
  34376. private _onCanvasPointerOut;
  34377. private _onCanvasBlur;
  34378. private _onCanvasFocus;
  34379. private _onFullscreenChange;
  34380. private _onPointerLockChange;
  34381. /**
  34382. * Gets the HTML element used to attach event listeners
  34383. * @returns a HTML element
  34384. */
  34385. getInputElement(): Nullable<HTMLElement>;
  34386. /**
  34387. * Creates a new engine
  34388. * @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
  34389. * @param antialias defines enable antialiasing (default: false)
  34390. * @param options defines further options to be sent to the getContext() function
  34391. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34392. */
  34393. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34394. /**
  34395. * Gets current aspect ratio
  34396. * @param viewportOwner defines the camera to use to get the aspect ratio
  34397. * @param useScreen defines if screen size must be used (or the current render target if any)
  34398. * @returns a number defining the aspect ratio
  34399. */
  34400. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  34401. /**
  34402. * Gets current screen aspect ratio
  34403. * @returns a number defining the aspect ratio
  34404. */
  34405. getScreenAspectRatio(): number;
  34406. /**
  34407. * Gets the client rect of the HTML canvas attached with the current webGL context
  34408. * @returns a client rectanglee
  34409. */
  34410. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  34411. /**
  34412. * Gets the client rect of the HTML element used for events
  34413. * @returns a client rectanglee
  34414. */
  34415. getInputElementClientRect(): Nullable<ClientRect>;
  34416. /**
  34417. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  34418. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34419. * @returns true if engine is in deterministic lock step mode
  34420. */
  34421. isDeterministicLockStep(): boolean;
  34422. /**
  34423. * Gets the max steps when engine is running in deterministic lock step
  34424. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34425. * @returns the max steps
  34426. */
  34427. getLockstepMaxSteps(): number;
  34428. /**
  34429. * Returns the time in ms between steps when using deterministic lock step.
  34430. * @returns time step in (ms)
  34431. */
  34432. getTimeStep(): number;
  34433. /**
  34434. * Force the mipmap generation for the given render target texture
  34435. * @param texture defines the render target texture to use
  34436. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  34437. */
  34438. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  34439. /** States */
  34440. /**
  34441. * Set various states to the webGL context
  34442. * @param culling defines backface culling state
  34443. * @param zOffset defines the value to apply to zOffset (0 by default)
  34444. * @param force defines if states must be applied even if cache is up to date
  34445. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  34446. */
  34447. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  34448. /**
  34449. * Set the z offset to apply to current rendering
  34450. * @param value defines the offset to apply
  34451. */
  34452. setZOffset(value: number): void;
  34453. /**
  34454. * Gets the current value of the zOffset
  34455. * @returns the current zOffset state
  34456. */
  34457. getZOffset(): number;
  34458. /**
  34459. * Enable or disable depth buffering
  34460. * @param enable defines the state to set
  34461. */
  34462. setDepthBuffer(enable: boolean): void;
  34463. /**
  34464. * Gets a boolean indicating if depth writing is enabled
  34465. * @returns the current depth writing state
  34466. */
  34467. getDepthWrite(): boolean;
  34468. /**
  34469. * Enable or disable depth writing
  34470. * @param enable defines the state to set
  34471. */
  34472. setDepthWrite(enable: boolean): void;
  34473. /**
  34474. * Gets a boolean indicating if stencil buffer is enabled
  34475. * @returns the current stencil buffer state
  34476. */
  34477. getStencilBuffer(): boolean;
  34478. /**
  34479. * Enable or disable the stencil buffer
  34480. * @param enable defines if the stencil buffer must be enabled or disabled
  34481. */
  34482. setStencilBuffer(enable: boolean): void;
  34483. /**
  34484. * Gets the current stencil mask
  34485. * @returns a number defining the new stencil mask to use
  34486. */
  34487. getStencilMask(): number;
  34488. /**
  34489. * Sets the current stencil mask
  34490. * @param mask defines the new stencil mask to use
  34491. */
  34492. setStencilMask(mask: number): void;
  34493. /**
  34494. * Gets the current stencil function
  34495. * @returns a number defining the stencil function to use
  34496. */
  34497. getStencilFunction(): number;
  34498. /**
  34499. * Gets the current stencil reference value
  34500. * @returns a number defining the stencil reference value to use
  34501. */
  34502. getStencilFunctionReference(): number;
  34503. /**
  34504. * Gets the current stencil mask
  34505. * @returns a number defining the stencil mask to use
  34506. */
  34507. getStencilFunctionMask(): number;
  34508. /**
  34509. * Sets the current stencil function
  34510. * @param stencilFunc defines the new stencil function to use
  34511. */
  34512. setStencilFunction(stencilFunc: number): void;
  34513. /**
  34514. * Sets the current stencil reference
  34515. * @param reference defines the new stencil reference to use
  34516. */
  34517. setStencilFunctionReference(reference: number): void;
  34518. /**
  34519. * Sets the current stencil mask
  34520. * @param mask defines the new stencil mask to use
  34521. */
  34522. setStencilFunctionMask(mask: number): void;
  34523. /**
  34524. * Gets the current stencil operation when stencil fails
  34525. * @returns a number defining stencil operation to use when stencil fails
  34526. */
  34527. getStencilOperationFail(): number;
  34528. /**
  34529. * Gets the current stencil operation when depth fails
  34530. * @returns a number defining stencil operation to use when depth fails
  34531. */
  34532. getStencilOperationDepthFail(): number;
  34533. /**
  34534. * Gets the current stencil operation when stencil passes
  34535. * @returns a number defining stencil operation to use when stencil passes
  34536. */
  34537. getStencilOperationPass(): number;
  34538. /**
  34539. * Sets the stencil operation to use when stencil fails
  34540. * @param operation defines the stencil operation to use when stencil fails
  34541. */
  34542. setStencilOperationFail(operation: number): void;
  34543. /**
  34544. * Sets the stencil operation to use when depth fails
  34545. * @param operation defines the stencil operation to use when depth fails
  34546. */
  34547. setStencilOperationDepthFail(operation: number): void;
  34548. /**
  34549. * Sets the stencil operation to use when stencil passes
  34550. * @param operation defines the stencil operation to use when stencil passes
  34551. */
  34552. setStencilOperationPass(operation: number): void;
  34553. /**
  34554. * Sets a boolean indicating if the dithering state is enabled or disabled
  34555. * @param value defines the dithering state
  34556. */
  34557. setDitheringState(value: boolean): void;
  34558. /**
  34559. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  34560. * @param value defines the rasterizer state
  34561. */
  34562. setRasterizerState(value: boolean): void;
  34563. /**
  34564. * Gets the current depth function
  34565. * @returns a number defining the depth function
  34566. */
  34567. getDepthFunction(): Nullable<number>;
  34568. /**
  34569. * Sets the current depth function
  34570. * @param depthFunc defines the function to use
  34571. */
  34572. setDepthFunction(depthFunc: number): void;
  34573. /**
  34574. * Sets the current depth function to GREATER
  34575. */
  34576. setDepthFunctionToGreater(): void;
  34577. /**
  34578. * Sets the current depth function to GEQUAL
  34579. */
  34580. setDepthFunctionToGreaterOrEqual(): void;
  34581. /**
  34582. * Sets the current depth function to LESS
  34583. */
  34584. setDepthFunctionToLess(): void;
  34585. /**
  34586. * Sets the current depth function to LEQUAL
  34587. */
  34588. setDepthFunctionToLessOrEqual(): void;
  34589. private _cachedStencilBuffer;
  34590. private _cachedStencilFunction;
  34591. private _cachedStencilMask;
  34592. private _cachedStencilOperationPass;
  34593. private _cachedStencilOperationFail;
  34594. private _cachedStencilOperationDepthFail;
  34595. private _cachedStencilReference;
  34596. /**
  34597. * Caches the the state of the stencil buffer
  34598. */
  34599. cacheStencilState(): void;
  34600. /**
  34601. * Restores the state of the stencil buffer
  34602. */
  34603. restoreStencilState(): void;
  34604. /**
  34605. * Directly set the WebGL Viewport
  34606. * @param x defines the x coordinate of the viewport (in screen space)
  34607. * @param y defines the y coordinate of the viewport (in screen space)
  34608. * @param width defines the width of the viewport (in screen space)
  34609. * @param height defines the height of the viewport (in screen space)
  34610. * @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
  34611. */
  34612. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  34613. /**
  34614. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  34615. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34616. * @param y defines the y-coordinate of the corner of the clear rectangle
  34617. * @param width defines the width of the clear rectangle
  34618. * @param height defines the height of the clear rectangle
  34619. * @param clearColor defines the clear color
  34620. */
  34621. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  34622. /**
  34623. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  34624. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34625. * @param y defines the y-coordinate of the corner of the clear rectangle
  34626. * @param width defines the width of the clear rectangle
  34627. * @param height defines the height of the clear rectangle
  34628. */
  34629. enableScissor(x: number, y: number, width: number, height: number): void;
  34630. /**
  34631. * Disable previously set scissor test rectangle
  34632. */
  34633. disableScissor(): void;
  34634. protected _reportDrawCall(): void;
  34635. /**
  34636. * Initializes a webVR display and starts listening to display change events
  34637. * The onVRDisplayChangedObservable will be notified upon these changes
  34638. * @returns The onVRDisplayChangedObservable
  34639. */
  34640. initWebVR(): Observable<IDisplayChangedEventArgs>;
  34641. /** @hidden */
  34642. _prepareVRComponent(): void;
  34643. /** @hidden */
  34644. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  34645. /** @hidden */
  34646. _submitVRFrame(): void;
  34647. /**
  34648. * Call this function to leave webVR mode
  34649. * Will do nothing if webVR is not supported or if there is no webVR device
  34650. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34651. */
  34652. disableVR(): void;
  34653. /**
  34654. * Gets a boolean indicating that the system is in VR mode and is presenting
  34655. * @returns true if VR mode is engaged
  34656. */
  34657. isVRPresenting(): boolean;
  34658. /** @hidden */
  34659. _requestVRFrame(): void;
  34660. /** @hidden */
  34661. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34662. /**
  34663. * Gets the source code of the vertex shader associated with a specific webGL program
  34664. * @param program defines the program to use
  34665. * @returns a string containing the source code of the vertex shader associated with the program
  34666. */
  34667. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  34668. /**
  34669. * Gets the source code of the fragment shader associated with a specific webGL program
  34670. * @param program defines the program to use
  34671. * @returns a string containing the source code of the fragment shader associated with the program
  34672. */
  34673. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34674. /**
  34675. * Sets a depth stencil texture from a render target to the according uniform.
  34676. * @param channel The texture channel
  34677. * @param uniform The uniform to set
  34678. * @param texture The render target texture containing the depth stencil texture to apply
  34679. */
  34680. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34681. /**
  34682. * Sets a texture to the webGL context from a postprocess
  34683. * @param channel defines the channel to use
  34684. * @param postProcess defines the source postprocess
  34685. */
  34686. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34687. /**
  34688. * Binds the output of the passed in post process to the texture channel specified
  34689. * @param channel The channel the texture should be bound to
  34690. * @param postProcess The post process which's output should be bound
  34691. */
  34692. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34693. /** @hidden */
  34694. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  34695. protected _rebuildBuffers(): void;
  34696. /** @hidden */
  34697. _renderFrame(): void;
  34698. _renderLoop(): void;
  34699. /** @hidden */
  34700. _renderViews(): boolean;
  34701. /**
  34702. * Toggle full screen mode
  34703. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34704. */
  34705. switchFullscreen(requestPointerLock: boolean): void;
  34706. /**
  34707. * Enters full screen mode
  34708. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34709. */
  34710. enterFullscreen(requestPointerLock: boolean): void;
  34711. /**
  34712. * Exits full screen mode
  34713. */
  34714. exitFullscreen(): void;
  34715. /**
  34716. * Enters Pointerlock mode
  34717. */
  34718. enterPointerlock(): void;
  34719. /**
  34720. * Exits Pointerlock mode
  34721. */
  34722. exitPointerlock(): void;
  34723. /**
  34724. * Begin a new frame
  34725. */
  34726. beginFrame(): void;
  34727. /**
  34728. * Enf the current frame
  34729. */
  34730. endFrame(): void;
  34731. resize(): void;
  34732. /**
  34733. * Set the compressed texture format to use, based on the formats you have, and the formats
  34734. * supported by the hardware / browser.
  34735. *
  34736. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  34737. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  34738. * to API arguments needed to compressed textures. This puts the burden on the container
  34739. * generator to house the arcane code for determining these for current & future formats.
  34740. *
  34741. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  34742. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  34743. *
  34744. * Note: The result of this call is not taken into account when a texture is base64.
  34745. *
  34746. * @param formatsAvailable defines the list of those format families you have created
  34747. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  34748. *
  34749. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  34750. * @returns The extension selected.
  34751. */
  34752. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  34753. /**
  34754. * Set the compressed texture extensions or file names to skip.
  34755. *
  34756. * @param skippedFiles defines the list of those texture files you want to skip
  34757. * Example: [".dds", ".env", "myfile.png"]
  34758. */
  34759. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  34760. /**
  34761. * Force a specific size of the canvas
  34762. * @param width defines the new canvas' width
  34763. * @param height defines the new canvas' height
  34764. */
  34765. setSize(width: number, height: number): void;
  34766. /**
  34767. * Updates a dynamic vertex buffer.
  34768. * @param vertexBuffer the vertex buffer to update
  34769. * @param data the data used to update the vertex buffer
  34770. * @param byteOffset the byte offset of the data
  34771. * @param byteLength the byte length of the data
  34772. */
  34773. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34774. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34775. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34776. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34777. _releaseTexture(texture: InternalTexture): void;
  34778. /**
  34779. * @hidden
  34780. * Rescales a texture
  34781. * @param source input texutre
  34782. * @param destination destination texture
  34783. * @param scene scene to use to render the resize
  34784. * @param internalFormat format to use when resizing
  34785. * @param onComplete callback to be called when resize has completed
  34786. */
  34787. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34788. /**
  34789. * Gets the current framerate
  34790. * @returns a number representing the framerate
  34791. */
  34792. getFps(): number;
  34793. /**
  34794. * Gets the time spent between current and previous frame
  34795. * @returns a number representing the delta time in ms
  34796. */
  34797. getDeltaTime(): number;
  34798. private _measureFps;
  34799. /** @hidden */
  34800. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34801. /**
  34802. * Update a dynamic index buffer
  34803. * @param indexBuffer defines the target index buffer
  34804. * @param indices defines the data to update
  34805. * @param offset defines the offset in the target index buffer where update should start
  34806. */
  34807. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34808. /**
  34809. * Updates the sample count of a render target texture
  34810. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34811. * @param texture defines the texture to update
  34812. * @param samples defines the sample count to set
  34813. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34814. */
  34815. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34816. /**
  34817. * Updates a depth texture Comparison Mode and Function.
  34818. * If the comparison Function is equal to 0, the mode will be set to none.
  34819. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34820. * @param texture The texture to set the comparison function for
  34821. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34822. */
  34823. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34824. /**
  34825. * Creates a webGL buffer to use with instanciation
  34826. * @param capacity defines the size of the buffer
  34827. * @returns the webGL buffer
  34828. */
  34829. createInstancesBuffer(capacity: number): DataBuffer;
  34830. /**
  34831. * Delete a webGL buffer used with instanciation
  34832. * @param buffer defines the webGL buffer to delete
  34833. */
  34834. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34835. /** @hidden */
  34836. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34837. dispose(): void;
  34838. private _disableTouchAction;
  34839. /**
  34840. * Display the loading screen
  34841. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34842. */
  34843. displayLoadingUI(): void;
  34844. /**
  34845. * Hide the loading screen
  34846. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34847. */
  34848. hideLoadingUI(): void;
  34849. /**
  34850. * Gets the current loading screen object
  34851. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34852. */
  34853. get loadingScreen(): ILoadingScreen;
  34854. /**
  34855. * Sets the current loading screen object
  34856. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34857. */
  34858. set loadingScreen(loadingScreen: ILoadingScreen);
  34859. /**
  34860. * Sets the current loading screen text
  34861. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34862. */
  34863. set loadingUIText(text: string);
  34864. /**
  34865. * Sets the current loading screen background color
  34866. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34867. */
  34868. set loadingUIBackgroundColor(color: string);
  34869. /** Pointerlock and fullscreen */
  34870. /**
  34871. * Ask the browser to promote the current element to pointerlock mode
  34872. * @param element defines the DOM element to promote
  34873. */
  34874. static _RequestPointerlock(element: HTMLElement): void;
  34875. /**
  34876. * Asks the browser to exit pointerlock mode
  34877. */
  34878. static _ExitPointerlock(): void;
  34879. /**
  34880. * Ask the browser to promote the current element to fullscreen rendering mode
  34881. * @param element defines the DOM element to promote
  34882. */
  34883. static _RequestFullscreen(element: HTMLElement): void;
  34884. /**
  34885. * Asks the browser to exit fullscreen mode
  34886. */
  34887. static _ExitFullscreen(): void;
  34888. }
  34889. }
  34890. declare module "babylonjs/Engines/engineStore" {
  34891. import { Nullable } from "babylonjs/types";
  34892. import { Engine } from "babylonjs/Engines/engine";
  34893. import { Scene } from "babylonjs/scene";
  34894. /**
  34895. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34896. * during the life time of the application.
  34897. */
  34898. export class EngineStore {
  34899. /** Gets the list of created engines */
  34900. static Instances: import("babylonjs/Engines/engine").Engine[];
  34901. /** @hidden */
  34902. static _LastCreatedScene: Nullable<Scene>;
  34903. /**
  34904. * Gets the latest created engine
  34905. */
  34906. static get LastCreatedEngine(): Nullable<Engine>;
  34907. /**
  34908. * Gets the latest created scene
  34909. */
  34910. static get LastCreatedScene(): Nullable<Scene>;
  34911. /**
  34912. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34913. * @ignorenaming
  34914. */
  34915. static UseFallbackTexture: boolean;
  34916. /**
  34917. * Texture content used if a texture cannot loaded
  34918. * @ignorenaming
  34919. */
  34920. static FallbackTexture: string;
  34921. }
  34922. }
  34923. declare module "babylonjs/Misc/promise" {
  34924. /**
  34925. * Helper class that provides a small promise polyfill
  34926. */
  34927. export class PromisePolyfill {
  34928. /**
  34929. * Static function used to check if the polyfill is required
  34930. * If this is the case then the function will inject the polyfill to window.Promise
  34931. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34932. */
  34933. static Apply(force?: boolean): void;
  34934. }
  34935. }
  34936. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  34937. /**
  34938. * Interface for screenshot methods with describe argument called `size` as object with options
  34939. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34940. */
  34941. export interface IScreenshotSize {
  34942. /**
  34943. * number in pixels for canvas height
  34944. */
  34945. height?: number;
  34946. /**
  34947. * multiplier allowing render at a higher or lower resolution
  34948. * If value is defined then height and width will be ignored and taken from camera
  34949. */
  34950. precision?: number;
  34951. /**
  34952. * number in pixels for canvas width
  34953. */
  34954. width?: number;
  34955. }
  34956. }
  34957. declare module "babylonjs/Misc/tools" {
  34958. import { Nullable, float } from "babylonjs/types";
  34959. import { DomManagement } from "babylonjs/Misc/domManagement";
  34960. import { WebRequest } from "babylonjs/Misc/webRequest";
  34961. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  34962. import { ReadFileError } from "babylonjs/Misc/fileTools";
  34963. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34964. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  34965. import { Camera } from "babylonjs/Cameras/camera";
  34966. import { Engine } from "babylonjs/Engines/engine";
  34967. interface IColor4Like {
  34968. r: float;
  34969. g: float;
  34970. b: float;
  34971. a: float;
  34972. }
  34973. /**
  34974. * Class containing a set of static utilities functions
  34975. */
  34976. export class Tools {
  34977. /**
  34978. * Gets or sets the base URL to use to load assets
  34979. */
  34980. static get BaseUrl(): string;
  34981. static set BaseUrl(value: string);
  34982. /**
  34983. * Enable/Disable Custom HTTP Request Headers globally.
  34984. * default = false
  34985. * @see CustomRequestHeaders
  34986. */
  34987. static UseCustomRequestHeaders: boolean;
  34988. /**
  34989. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  34990. * i.e. when loading files, where the server/service expects an Authorization header
  34991. */
  34992. static CustomRequestHeaders: {
  34993. [key: string]: string;
  34994. };
  34995. /**
  34996. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  34997. */
  34998. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  34999. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  35000. /**
  35001. * Default behaviour for cors in the application.
  35002. * It can be a string if the expected behavior is identical in the entire app.
  35003. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  35004. */
  35005. static CorsBehavior: string | ((url: string | string[]) => string);
  35006. /**
  35007. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  35008. * @ignorenaming
  35009. */
  35010. static get UseFallbackTexture(): boolean;
  35011. static set UseFallbackTexture(value: boolean);
  35012. /**
  35013. * Use this object to register external classes like custom textures or material
  35014. * to allow the laoders to instantiate them
  35015. */
  35016. static get RegisteredExternalClasses(): {
  35017. [key: string]: Object;
  35018. };
  35019. static set RegisteredExternalClasses(classes: {
  35020. [key: string]: Object;
  35021. });
  35022. /**
  35023. * Texture content used if a texture cannot loaded
  35024. * @ignorenaming
  35025. */
  35026. static get fallbackTexture(): string;
  35027. static set fallbackTexture(value: string);
  35028. /**
  35029. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  35030. * @param u defines the coordinate on X axis
  35031. * @param v defines the coordinate on Y axis
  35032. * @param width defines the width of the source data
  35033. * @param height defines the height of the source data
  35034. * @param pixels defines the source byte array
  35035. * @param color defines the output color
  35036. */
  35037. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  35038. /**
  35039. * Interpolates between a and b via alpha
  35040. * @param a The lower value (returned when alpha = 0)
  35041. * @param b The upper value (returned when alpha = 1)
  35042. * @param alpha The interpolation-factor
  35043. * @return The mixed value
  35044. */
  35045. static Mix(a: number, b: number, alpha: number): number;
  35046. /**
  35047. * Tries to instantiate a new object from a given class name
  35048. * @param className defines the class name to instantiate
  35049. * @returns the new object or null if the system was not able to do the instantiation
  35050. */
  35051. static Instantiate(className: string): any;
  35052. /**
  35053. * Provides a slice function that will work even on IE
  35054. * @param data defines the array to slice
  35055. * @param start defines the start of the data (optional)
  35056. * @param end defines the end of the data (optional)
  35057. * @returns the new sliced array
  35058. */
  35059. static Slice<T>(data: T, start?: number, end?: number): T;
  35060. /**
  35061. * Polyfill for setImmediate
  35062. * @param action defines the action to execute after the current execution block
  35063. */
  35064. static SetImmediate(action: () => void): void;
  35065. /**
  35066. * Function indicating if a number is an exponent of 2
  35067. * @param value defines the value to test
  35068. * @returns true if the value is an exponent of 2
  35069. */
  35070. static IsExponentOfTwo(value: number): boolean;
  35071. private static _tmpFloatArray;
  35072. /**
  35073. * Returns the nearest 32-bit single precision float representation of a Number
  35074. * @param value A Number. If the parameter is of a different type, it will get converted
  35075. * to a number or to NaN if it cannot be converted
  35076. * @returns number
  35077. */
  35078. static FloatRound(value: number): number;
  35079. /**
  35080. * Extracts the filename from a path
  35081. * @param path defines the path to use
  35082. * @returns the filename
  35083. */
  35084. static GetFilename(path: string): string;
  35085. /**
  35086. * Extracts the "folder" part of a path (everything before the filename).
  35087. * @param uri The URI to extract the info from
  35088. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  35089. * @returns The "folder" part of the path
  35090. */
  35091. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  35092. /**
  35093. * Extracts text content from a DOM element hierarchy
  35094. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  35095. */
  35096. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  35097. /**
  35098. * Convert an angle in radians to degrees
  35099. * @param angle defines the angle to convert
  35100. * @returns the angle in degrees
  35101. */
  35102. static ToDegrees(angle: number): number;
  35103. /**
  35104. * Convert an angle in degrees to radians
  35105. * @param angle defines the angle to convert
  35106. * @returns the angle in radians
  35107. */
  35108. static ToRadians(angle: number): number;
  35109. /**
  35110. * Returns an array if obj is not an array
  35111. * @param obj defines the object to evaluate as an array
  35112. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  35113. * @returns either obj directly if obj is an array or a new array containing obj
  35114. */
  35115. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  35116. /**
  35117. * Gets the pointer prefix to use
  35118. * @returns "pointer" if touch is enabled. Else returns "mouse"
  35119. */
  35120. static GetPointerPrefix(): string;
  35121. /**
  35122. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  35123. * @param url define the url we are trying
  35124. * @param element define the dom element where to configure the cors policy
  35125. */
  35126. static SetCorsBehavior(url: string | string[], element: {
  35127. crossOrigin: string | null;
  35128. }): void;
  35129. /**
  35130. * Removes unwanted characters from an url
  35131. * @param url defines the url to clean
  35132. * @returns the cleaned url
  35133. */
  35134. static CleanUrl(url: string): string;
  35135. /**
  35136. * Gets or sets a function used to pre-process url before using them to load assets
  35137. */
  35138. static get PreprocessUrl(): (url: string) => string;
  35139. static set PreprocessUrl(processor: (url: string) => string);
  35140. /**
  35141. * Loads an image as an HTMLImageElement.
  35142. * @param input url string, ArrayBuffer, or Blob to load
  35143. * @param onLoad callback called when the image successfully loads
  35144. * @param onError callback called when the image fails to load
  35145. * @param offlineProvider offline provider for caching
  35146. * @param mimeType optional mime type
  35147. * @returns the HTMLImageElement of the loaded image
  35148. */
  35149. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  35150. /**
  35151. * Loads a file from a url
  35152. * @param url url string, ArrayBuffer, or Blob to load
  35153. * @param onSuccess callback called when the file successfully loads
  35154. * @param onProgress callback called while file is loading (if the server supports this mode)
  35155. * @param offlineProvider defines the offline provider for caching
  35156. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35157. * @param onError callback called when the file fails to load
  35158. * @returns a file request object
  35159. */
  35160. 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;
  35161. /**
  35162. * Loads a file from a url
  35163. * @param url the file url to load
  35164. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35165. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  35166. */
  35167. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  35168. /**
  35169. * Load a script (identified by an url). When the url returns, the
  35170. * content of this file is added into a new script element, attached to the DOM (body element)
  35171. * @param scriptUrl defines the url of the script to laod
  35172. * @param onSuccess defines the callback called when the script is loaded
  35173. * @param onError defines the callback to call if an error occurs
  35174. * @param scriptId defines the id of the script element
  35175. */
  35176. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  35177. /**
  35178. * Load an asynchronous script (identified by an url). When the url returns, the
  35179. * content of this file is added into a new script element, attached to the DOM (body element)
  35180. * @param scriptUrl defines the url of the script to laod
  35181. * @param scriptId defines the id of the script element
  35182. * @returns a promise request object
  35183. */
  35184. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  35185. /**
  35186. * Loads a file from a blob
  35187. * @param fileToLoad defines the blob to use
  35188. * @param callback defines the callback to call when data is loaded
  35189. * @param progressCallback defines the callback to call during loading process
  35190. * @returns a file request object
  35191. */
  35192. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  35193. /**
  35194. * Reads a file from a File object
  35195. * @param file defines the file to load
  35196. * @param onSuccess defines the callback to call when data is loaded
  35197. * @param onProgress defines the callback to call during loading process
  35198. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  35199. * @param onError defines the callback to call when an error occurs
  35200. * @returns a file request object
  35201. */
  35202. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  35203. /**
  35204. * Creates a data url from a given string content
  35205. * @param content defines the content to convert
  35206. * @returns the new data url link
  35207. */
  35208. static FileAsURL(content: string): string;
  35209. /**
  35210. * Format the given number to a specific decimal format
  35211. * @param value defines the number to format
  35212. * @param decimals defines the number of decimals to use
  35213. * @returns the formatted string
  35214. */
  35215. static Format(value: number, decimals?: number): string;
  35216. /**
  35217. * Tries to copy an object by duplicating every property
  35218. * @param source defines the source object
  35219. * @param destination defines the target object
  35220. * @param doNotCopyList defines a list of properties to avoid
  35221. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  35222. */
  35223. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  35224. /**
  35225. * Gets a boolean indicating if the given object has no own property
  35226. * @param obj defines the object to test
  35227. * @returns true if object has no own property
  35228. */
  35229. static IsEmpty(obj: any): boolean;
  35230. /**
  35231. * Function used to register events at window level
  35232. * @param windowElement defines the Window object to use
  35233. * @param events defines the events to register
  35234. */
  35235. static RegisterTopRootEvents(windowElement: Window, events: {
  35236. name: string;
  35237. handler: Nullable<(e: FocusEvent) => any>;
  35238. }[]): void;
  35239. /**
  35240. * Function used to unregister events from window level
  35241. * @param windowElement defines the Window object to use
  35242. * @param events defines the events to unregister
  35243. */
  35244. static UnregisterTopRootEvents(windowElement: Window, events: {
  35245. name: string;
  35246. handler: Nullable<(e: FocusEvent) => any>;
  35247. }[]): void;
  35248. /**
  35249. * @ignore
  35250. */
  35251. static _ScreenshotCanvas: HTMLCanvasElement;
  35252. /**
  35253. * Dumps the current bound framebuffer
  35254. * @param width defines the rendering width
  35255. * @param height defines the rendering height
  35256. * @param engine defines the hosting engine
  35257. * @param successCallback defines the callback triggered once the data are available
  35258. * @param mimeType defines the mime type of the result
  35259. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  35260. */
  35261. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35262. /**
  35263. * Converts the canvas data to blob.
  35264. * This acts as a polyfill for browsers not supporting the to blob function.
  35265. * @param canvas Defines the canvas to extract the data from
  35266. * @param successCallback Defines the callback triggered once the data are available
  35267. * @param mimeType Defines the mime type of the result
  35268. */
  35269. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  35270. /**
  35271. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  35272. * @param successCallback defines the callback triggered once the data are available
  35273. * @param mimeType defines the mime type of the result
  35274. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  35275. */
  35276. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35277. /**
  35278. * Downloads a blob in the browser
  35279. * @param blob defines the blob to download
  35280. * @param fileName defines the name of the downloaded file
  35281. */
  35282. static Download(blob: Blob, fileName: string): void;
  35283. /**
  35284. * Captures a screenshot of the current rendering
  35285. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35286. * @param engine defines the rendering engine
  35287. * @param camera defines the source camera
  35288. * @param size This parameter can be set to a single number or to an object with the
  35289. * following (optional) properties: precision, width, height. If a single number is passed,
  35290. * it will be used for both width and height. If an object is passed, the screenshot size
  35291. * will be derived from the parameters. The precision property is a multiplier allowing
  35292. * rendering at a higher or lower resolution
  35293. * @param successCallback defines the callback receives a single parameter which contains the
  35294. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35295. * src parameter of an <img> to display it
  35296. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35297. * Check your browser for supported MIME types
  35298. */
  35299. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  35300. /**
  35301. * Captures a screenshot of the current rendering
  35302. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35303. * @param engine defines the rendering engine
  35304. * @param camera defines the source camera
  35305. * @param size This parameter can be set to a single number or to an object with the
  35306. * following (optional) properties: precision, width, height. If a single number is passed,
  35307. * it will be used for both width and height. If an object is passed, the screenshot size
  35308. * will be derived from the parameters. The precision property is a multiplier allowing
  35309. * rendering at a higher or lower resolution
  35310. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35311. * Check your browser for supported MIME types
  35312. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35313. * to the src parameter of an <img> to display it
  35314. */
  35315. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  35316. /**
  35317. * Generates an image screenshot from the specified camera.
  35318. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35319. * @param engine The engine to use for rendering
  35320. * @param camera The camera to use for rendering
  35321. * @param size This parameter can be set to a single number or to an object with the
  35322. * following (optional) properties: precision, width, height. If a single number is passed,
  35323. * it will be used for both width and height. If an object is passed, the screenshot size
  35324. * will be derived from the parameters. The precision property is a multiplier allowing
  35325. * rendering at a higher or lower resolution
  35326. * @param successCallback The callback receives a single parameter which contains the
  35327. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35328. * src parameter of an <img> to display it
  35329. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35330. * Check your browser for supported MIME types
  35331. * @param samples Texture samples (default: 1)
  35332. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35333. * @param fileName A name for for the downloaded file.
  35334. */
  35335. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  35336. /**
  35337. * Generates an image screenshot from the specified camera.
  35338. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35339. * @param engine The engine to use for rendering
  35340. * @param camera The camera to use for rendering
  35341. * @param size This parameter can be set to a single number or to an object with the
  35342. * following (optional) properties: precision, width, height. If a single number is passed,
  35343. * it will be used for both width and height. If an object is passed, the screenshot size
  35344. * will be derived from the parameters. The precision property is a multiplier allowing
  35345. * rendering at a higher or lower resolution
  35346. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35347. * Check your browser for supported MIME types
  35348. * @param samples Texture samples (default: 1)
  35349. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35350. * @param fileName A name for for the downloaded file.
  35351. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35352. * to the src parameter of an <img> to display it
  35353. */
  35354. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  35355. /**
  35356. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  35357. * Be aware Math.random() could cause collisions, but:
  35358. * "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"
  35359. * @returns a pseudo random id
  35360. */
  35361. static RandomId(): string;
  35362. /**
  35363. * Test if the given uri is a base64 string
  35364. * @param uri The uri to test
  35365. * @return True if the uri is a base64 string or false otherwise
  35366. */
  35367. static IsBase64(uri: string): boolean;
  35368. /**
  35369. * Decode the given base64 uri.
  35370. * @param uri The uri to decode
  35371. * @return The decoded base64 data.
  35372. */
  35373. static DecodeBase64(uri: string): ArrayBuffer;
  35374. /**
  35375. * Gets the absolute url.
  35376. * @param url the input url
  35377. * @return the absolute url
  35378. */
  35379. static GetAbsoluteUrl(url: string): string;
  35380. /**
  35381. * No log
  35382. */
  35383. static readonly NoneLogLevel: number;
  35384. /**
  35385. * Only message logs
  35386. */
  35387. static readonly MessageLogLevel: number;
  35388. /**
  35389. * Only warning logs
  35390. */
  35391. static readonly WarningLogLevel: number;
  35392. /**
  35393. * Only error logs
  35394. */
  35395. static readonly ErrorLogLevel: number;
  35396. /**
  35397. * All logs
  35398. */
  35399. static readonly AllLogLevel: number;
  35400. /**
  35401. * Gets a value indicating the number of loading errors
  35402. * @ignorenaming
  35403. */
  35404. static get errorsCount(): number;
  35405. /**
  35406. * Callback called when a new log is added
  35407. */
  35408. static OnNewCacheEntry: (entry: string) => void;
  35409. /**
  35410. * Log a message to the console
  35411. * @param message defines the message to log
  35412. */
  35413. static Log(message: string): void;
  35414. /**
  35415. * Write a warning message to the console
  35416. * @param message defines the message to log
  35417. */
  35418. static Warn(message: string): void;
  35419. /**
  35420. * Write an error message to the console
  35421. * @param message defines the message to log
  35422. */
  35423. static Error(message: string): void;
  35424. /**
  35425. * Gets current log cache (list of logs)
  35426. */
  35427. static get LogCache(): string;
  35428. /**
  35429. * Clears the log cache
  35430. */
  35431. static ClearLogCache(): void;
  35432. /**
  35433. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  35434. */
  35435. static set LogLevels(level: number);
  35436. /**
  35437. * Checks if the window object exists
  35438. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  35439. */
  35440. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  35441. /**
  35442. * No performance log
  35443. */
  35444. static readonly PerformanceNoneLogLevel: number;
  35445. /**
  35446. * Use user marks to log performance
  35447. */
  35448. static readonly PerformanceUserMarkLogLevel: number;
  35449. /**
  35450. * Log performance to the console
  35451. */
  35452. static readonly PerformanceConsoleLogLevel: number;
  35453. private static _performance;
  35454. /**
  35455. * Sets the current performance log level
  35456. */
  35457. static set PerformanceLogLevel(level: number);
  35458. private static _StartPerformanceCounterDisabled;
  35459. private static _EndPerformanceCounterDisabled;
  35460. private static _StartUserMark;
  35461. private static _EndUserMark;
  35462. private static _StartPerformanceConsole;
  35463. private static _EndPerformanceConsole;
  35464. /**
  35465. * Starts a performance counter
  35466. */
  35467. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35468. /**
  35469. * Ends a specific performance coutner
  35470. */
  35471. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35472. /**
  35473. * Gets either window.performance.now() if supported or Date.now() else
  35474. */
  35475. static get Now(): number;
  35476. /**
  35477. * This method will return the name of the class used to create the instance of the given object.
  35478. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  35479. * @param object the object to get the class name from
  35480. * @param isType defines if the object is actually a type
  35481. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  35482. */
  35483. static GetClassName(object: any, isType?: boolean): string;
  35484. /**
  35485. * Gets the first element of an array satisfying a given predicate
  35486. * @param array defines the array to browse
  35487. * @param predicate defines the predicate to use
  35488. * @returns null if not found or the element
  35489. */
  35490. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  35491. /**
  35492. * This method will return the name of the full name of the class, including its owning module (if any).
  35493. * 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).
  35494. * @param object the object to get the class name from
  35495. * @param isType defines if the object is actually a type
  35496. * @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.
  35497. * @ignorenaming
  35498. */
  35499. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  35500. /**
  35501. * Returns a promise that resolves after the given amount of time.
  35502. * @param delay Number of milliseconds to delay
  35503. * @returns Promise that resolves after the given amount of time
  35504. */
  35505. static DelayAsync(delay: number): Promise<void>;
  35506. /**
  35507. * Utility function to detect if the current user agent is Safari
  35508. * @returns whether or not the current user agent is safari
  35509. */
  35510. static IsSafari(): boolean;
  35511. }
  35512. /**
  35513. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  35514. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  35515. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  35516. * @param name The name of the class, case should be preserved
  35517. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  35518. */
  35519. export function className(name: string, module?: string): (target: Object) => void;
  35520. /**
  35521. * An implementation of a loop for asynchronous functions.
  35522. */
  35523. export class AsyncLoop {
  35524. /**
  35525. * Defines the number of iterations for the loop
  35526. */
  35527. iterations: number;
  35528. /**
  35529. * Defines the current index of the loop.
  35530. */
  35531. index: number;
  35532. private _done;
  35533. private _fn;
  35534. private _successCallback;
  35535. /**
  35536. * Constructor.
  35537. * @param iterations the number of iterations.
  35538. * @param func the function to run each iteration
  35539. * @param successCallback the callback that will be called upon succesful execution
  35540. * @param offset starting offset.
  35541. */
  35542. constructor(
  35543. /**
  35544. * Defines the number of iterations for the loop
  35545. */
  35546. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  35547. /**
  35548. * Execute the next iteration. Must be called after the last iteration was finished.
  35549. */
  35550. executeNext(): void;
  35551. /**
  35552. * Break the loop and run the success callback.
  35553. */
  35554. breakLoop(): void;
  35555. /**
  35556. * Create and run an async loop.
  35557. * @param iterations the number of iterations.
  35558. * @param fn the function to run each iteration
  35559. * @param successCallback the callback that will be called upon succesful execution
  35560. * @param offset starting offset.
  35561. * @returns the created async loop object
  35562. */
  35563. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  35564. /**
  35565. * A for-loop that will run a given number of iterations synchronous and the rest async.
  35566. * @param iterations total number of iterations
  35567. * @param syncedIterations number of synchronous iterations in each async iteration.
  35568. * @param fn the function to call each iteration.
  35569. * @param callback a success call back that will be called when iterating stops.
  35570. * @param breakFunction a break condition (optional)
  35571. * @param timeout timeout settings for the setTimeout function. default - 0.
  35572. * @returns the created async loop object
  35573. */
  35574. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  35575. }
  35576. }
  35577. declare module "babylonjs/Misc/stringDictionary" {
  35578. import { Nullable } from "babylonjs/types";
  35579. /**
  35580. * This class implement a typical dictionary using a string as key and the generic type T as value.
  35581. * The underlying implementation relies on an associative array to ensure the best performances.
  35582. * The value can be anything including 'null' but except 'undefined'
  35583. */
  35584. export class StringDictionary<T> {
  35585. /**
  35586. * This will clear this dictionary and copy the content from the 'source' one.
  35587. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  35588. * @param source the dictionary to take the content from and copy to this dictionary
  35589. */
  35590. copyFrom(source: StringDictionary<T>): void;
  35591. /**
  35592. * Get a value based from its key
  35593. * @param key the given key to get the matching value from
  35594. * @return the value if found, otherwise undefined is returned
  35595. */
  35596. get(key: string): T | undefined;
  35597. /**
  35598. * Get a value from its key or add it if it doesn't exist.
  35599. * This method will ensure you that a given key/data will be present in the dictionary.
  35600. * @param key the given key to get the matching value from
  35601. * @param factory the factory that will create the value if the key is not present in the dictionary.
  35602. * The factory will only be invoked if there's no data for the given key.
  35603. * @return the value corresponding to the key.
  35604. */
  35605. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  35606. /**
  35607. * Get a value from its key if present in the dictionary otherwise add it
  35608. * @param key the key to get the value from
  35609. * @param val if there's no such key/value pair in the dictionary add it with this value
  35610. * @return the value corresponding to the key
  35611. */
  35612. getOrAdd(key: string, val: T): T;
  35613. /**
  35614. * Check if there's a given key in the dictionary
  35615. * @param key the key to check for
  35616. * @return true if the key is present, false otherwise
  35617. */
  35618. contains(key: string): boolean;
  35619. /**
  35620. * Add a new key and its corresponding value
  35621. * @param key the key to add
  35622. * @param value the value corresponding to the key
  35623. * @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
  35624. */
  35625. add(key: string, value: T): boolean;
  35626. /**
  35627. * Update a specific value associated to a key
  35628. * @param key defines the key to use
  35629. * @param value defines the value to store
  35630. * @returns true if the value was updated (or false if the key was not found)
  35631. */
  35632. set(key: string, value: T): boolean;
  35633. /**
  35634. * Get the element of the given key and remove it from the dictionary
  35635. * @param key defines the key to search
  35636. * @returns the value associated with the key or null if not found
  35637. */
  35638. getAndRemove(key: string): Nullable<T>;
  35639. /**
  35640. * Remove a key/value from the dictionary.
  35641. * @param key the key to remove
  35642. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  35643. */
  35644. remove(key: string): boolean;
  35645. /**
  35646. * Clear the whole content of the dictionary
  35647. */
  35648. clear(): void;
  35649. /**
  35650. * Gets the current count
  35651. */
  35652. get count(): number;
  35653. /**
  35654. * Execute a callback on each key/val of the dictionary.
  35655. * Note that you can remove any element in this dictionary in the callback implementation
  35656. * @param callback the callback to execute on a given key/value pair
  35657. */
  35658. forEach(callback: (key: string, val: T) => void): void;
  35659. /**
  35660. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  35661. * If the callback returns null or undefined the method will iterate to the next key/value pair
  35662. * Note that you can remove any element in this dictionary in the callback implementation
  35663. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  35664. * @returns the first item
  35665. */
  35666. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  35667. private _count;
  35668. private _data;
  35669. }
  35670. }
  35671. declare module "babylonjs/Collisions/collisionCoordinator" {
  35672. import { Nullable } from "babylonjs/types";
  35673. import { Scene } from "babylonjs/scene";
  35674. import { Vector3 } from "babylonjs/Maths/math.vector";
  35675. import { Collider } from "babylonjs/Collisions/collider";
  35676. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35677. /** @hidden */
  35678. export interface ICollisionCoordinator {
  35679. createCollider(): Collider;
  35680. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35681. init(scene: Scene): void;
  35682. }
  35683. /** @hidden */
  35684. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  35685. private _scene;
  35686. private _scaledPosition;
  35687. private _scaledVelocity;
  35688. private _finalPosition;
  35689. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35690. createCollider(): Collider;
  35691. init(scene: Scene): void;
  35692. private _collideWithWorld;
  35693. }
  35694. }
  35695. declare module "babylonjs/Inputs/scene.inputManager" {
  35696. import { Nullable } from "babylonjs/types";
  35697. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35698. import { Vector2 } from "babylonjs/Maths/math.vector";
  35699. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35700. import { Scene } from "babylonjs/scene";
  35701. /**
  35702. * Class used to manage all inputs for the scene.
  35703. */
  35704. export class InputManager {
  35705. /** The distance in pixel that you have to move to prevent some events */
  35706. static DragMovementThreshold: number;
  35707. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35708. static LongPressDelay: number;
  35709. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35710. static DoubleClickDelay: number;
  35711. /** If you need to check double click without raising a single click at first click, enable this flag */
  35712. static ExclusiveDoubleClickMode: boolean;
  35713. private _wheelEventName;
  35714. private _onPointerMove;
  35715. private _onPointerDown;
  35716. private _onPointerUp;
  35717. private _initClickEvent;
  35718. private _initActionManager;
  35719. private _delayedSimpleClick;
  35720. private _delayedSimpleClickTimeout;
  35721. private _previousDelayedSimpleClickTimeout;
  35722. private _meshPickProceed;
  35723. private _previousButtonPressed;
  35724. private _currentPickResult;
  35725. private _previousPickResult;
  35726. private _totalPointersPressed;
  35727. private _doubleClickOccured;
  35728. private _pointerOverMesh;
  35729. private _pickedDownMesh;
  35730. private _pickedUpMesh;
  35731. private _pointerX;
  35732. private _pointerY;
  35733. private _unTranslatedPointerX;
  35734. private _unTranslatedPointerY;
  35735. private _startingPointerPosition;
  35736. private _previousStartingPointerPosition;
  35737. private _startingPointerTime;
  35738. private _previousStartingPointerTime;
  35739. private _pointerCaptures;
  35740. private _onKeyDown;
  35741. private _onKeyUp;
  35742. private _onCanvasFocusObserver;
  35743. private _onCanvasBlurObserver;
  35744. private _scene;
  35745. /**
  35746. * Creates a new InputManager
  35747. * @param scene defines the hosting scene
  35748. */
  35749. constructor(scene: Scene);
  35750. /**
  35751. * Gets the mesh that is currently under the pointer
  35752. */
  35753. get meshUnderPointer(): Nullable<AbstractMesh>;
  35754. /**
  35755. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35756. */
  35757. get unTranslatedPointer(): Vector2;
  35758. /**
  35759. * Gets or sets the current on-screen X position of the pointer
  35760. */
  35761. get pointerX(): number;
  35762. set pointerX(value: number);
  35763. /**
  35764. * Gets or sets the current on-screen Y position of the pointer
  35765. */
  35766. get pointerY(): number;
  35767. set pointerY(value: number);
  35768. private _updatePointerPosition;
  35769. private _processPointerMove;
  35770. private _setRayOnPointerInfo;
  35771. private _checkPrePointerObservable;
  35772. /**
  35773. * Use this method to simulate a pointer move on a mesh
  35774. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35775. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35776. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35777. */
  35778. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35779. /**
  35780. * Use this method to simulate a pointer down on a mesh
  35781. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35782. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35783. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35784. */
  35785. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35786. private _processPointerDown;
  35787. /** @hidden */
  35788. _isPointerSwiping(): boolean;
  35789. /**
  35790. * Use this method to simulate a pointer up on a mesh
  35791. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35792. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35793. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35794. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35795. */
  35796. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35797. private _processPointerUp;
  35798. /**
  35799. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35800. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35801. * @returns true if the pointer was captured
  35802. */
  35803. isPointerCaptured(pointerId?: number): boolean;
  35804. /**
  35805. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35806. * @param attachUp defines if you want to attach events to pointerup
  35807. * @param attachDown defines if you want to attach events to pointerdown
  35808. * @param attachMove defines if you want to attach events to pointermove
  35809. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  35810. */
  35811. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  35812. /**
  35813. * Detaches all event handlers
  35814. */
  35815. detachControl(): void;
  35816. /**
  35817. * Force the value of meshUnderPointer
  35818. * @param mesh defines the mesh to use
  35819. */
  35820. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35821. /**
  35822. * Gets the mesh under the pointer
  35823. * @returns a Mesh or null if no mesh is under the pointer
  35824. */
  35825. getPointerOverMesh(): Nullable<AbstractMesh>;
  35826. }
  35827. }
  35828. declare module "babylonjs/Misc/uniqueIdGenerator" {
  35829. /**
  35830. * Helper class used to generate session unique ID
  35831. */
  35832. export class UniqueIdGenerator {
  35833. private static _UniqueIdCounter;
  35834. /**
  35835. * Gets an unique (relatively to the current scene) Id
  35836. */
  35837. static get UniqueId(): number;
  35838. }
  35839. }
  35840. declare module "babylonjs/Animations/animationGroup" {
  35841. import { Animatable } from "babylonjs/Animations/animatable";
  35842. import { Animation } from "babylonjs/Animations/animation";
  35843. import { Scene, IDisposable } from "babylonjs/scene";
  35844. import { Observable } from "babylonjs/Misc/observable";
  35845. import { Nullable } from "babylonjs/types";
  35846. import "babylonjs/Animations/animatable";
  35847. /**
  35848. * This class defines the direct association between an animation and a target
  35849. */
  35850. export class TargetedAnimation {
  35851. /**
  35852. * Animation to perform
  35853. */
  35854. animation: Animation;
  35855. /**
  35856. * Target to animate
  35857. */
  35858. target: any;
  35859. /**
  35860. * Serialize the object
  35861. * @returns the JSON object representing the current entity
  35862. */
  35863. serialize(): any;
  35864. }
  35865. /**
  35866. * Use this class to create coordinated animations on multiple targets
  35867. */
  35868. export class AnimationGroup implements IDisposable {
  35869. /** The name of the animation group */
  35870. name: string;
  35871. private _scene;
  35872. private _targetedAnimations;
  35873. private _animatables;
  35874. private _from;
  35875. private _to;
  35876. private _isStarted;
  35877. private _isPaused;
  35878. private _speedRatio;
  35879. private _loopAnimation;
  35880. /**
  35881. * Gets or sets the unique id of the node
  35882. */
  35883. uniqueId: number;
  35884. /**
  35885. * This observable will notify when one animation have ended
  35886. */
  35887. onAnimationEndObservable: Observable<TargetedAnimation>;
  35888. /**
  35889. * Observer raised when one animation loops
  35890. */
  35891. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35892. /**
  35893. * Observer raised when all animations have looped
  35894. */
  35895. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35896. /**
  35897. * This observable will notify when all animations have ended.
  35898. */
  35899. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35900. /**
  35901. * This observable will notify when all animations have paused.
  35902. */
  35903. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35904. /**
  35905. * This observable will notify when all animations are playing.
  35906. */
  35907. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35908. /**
  35909. * Gets the first frame
  35910. */
  35911. get from(): number;
  35912. /**
  35913. * Gets the last frame
  35914. */
  35915. get to(): number;
  35916. /**
  35917. * Define if the animations are started
  35918. */
  35919. get isStarted(): boolean;
  35920. /**
  35921. * Gets a value indicating that the current group is playing
  35922. */
  35923. get isPlaying(): boolean;
  35924. /**
  35925. * Gets or sets the speed ratio to use for all animations
  35926. */
  35927. get speedRatio(): number;
  35928. /**
  35929. * Gets or sets the speed ratio to use for all animations
  35930. */
  35931. set speedRatio(value: number);
  35932. /**
  35933. * Gets or sets if all animations should loop or not
  35934. */
  35935. get loopAnimation(): boolean;
  35936. set loopAnimation(value: boolean);
  35937. /**
  35938. * Gets the targeted animations for this animation group
  35939. */
  35940. get targetedAnimations(): Array<TargetedAnimation>;
  35941. /**
  35942. * returning the list of animatables controlled by this animation group.
  35943. */
  35944. get animatables(): Array<Animatable>;
  35945. /**
  35946. * Instantiates a new Animation Group.
  35947. * This helps managing several animations at once.
  35948. * @see http://doc.babylonjs.com/how_to/group
  35949. * @param name Defines the name of the group
  35950. * @param scene Defines the scene the group belongs to
  35951. */
  35952. constructor(
  35953. /** The name of the animation group */
  35954. name: string, scene?: Nullable<Scene>);
  35955. /**
  35956. * Add an animation (with its target) in the group
  35957. * @param animation defines the animation we want to add
  35958. * @param target defines the target of the animation
  35959. * @returns the TargetedAnimation object
  35960. */
  35961. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35962. /**
  35963. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35964. * It can add constant keys at begin or end
  35965. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35966. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35967. * @returns the animation group
  35968. */
  35969. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  35970. private _animationLoopCount;
  35971. private _animationLoopFlags;
  35972. private _processLoop;
  35973. /**
  35974. * Start all animations on given targets
  35975. * @param loop defines if animations must loop
  35976. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  35977. * @param from defines the from key (optional)
  35978. * @param to defines the to key (optional)
  35979. * @returns the current animation group
  35980. */
  35981. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  35982. /**
  35983. * Pause all animations
  35984. * @returns the animation group
  35985. */
  35986. pause(): AnimationGroup;
  35987. /**
  35988. * Play all animations to initial state
  35989. * This function will start() the animations if they were not started or will restart() them if they were paused
  35990. * @param loop defines if animations must loop
  35991. * @returns the animation group
  35992. */
  35993. play(loop?: boolean): AnimationGroup;
  35994. /**
  35995. * Reset all animations to initial state
  35996. * @returns the animation group
  35997. */
  35998. reset(): AnimationGroup;
  35999. /**
  36000. * Restart animations from key 0
  36001. * @returns the animation group
  36002. */
  36003. restart(): AnimationGroup;
  36004. /**
  36005. * Stop all animations
  36006. * @returns the animation group
  36007. */
  36008. stop(): AnimationGroup;
  36009. /**
  36010. * Set animation weight for all animatables
  36011. * @param weight defines the weight to use
  36012. * @return the animationGroup
  36013. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  36014. */
  36015. setWeightForAllAnimatables(weight: number): AnimationGroup;
  36016. /**
  36017. * Synchronize and normalize all animatables with a source animatable
  36018. * @param root defines the root animatable to synchronize with
  36019. * @return the animationGroup
  36020. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  36021. */
  36022. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  36023. /**
  36024. * Goes to a specific frame in this animation group
  36025. * @param frame the frame number to go to
  36026. * @return the animationGroup
  36027. */
  36028. goToFrame(frame: number): AnimationGroup;
  36029. /**
  36030. * Dispose all associated resources
  36031. */
  36032. dispose(): void;
  36033. private _checkAnimationGroupEnded;
  36034. /**
  36035. * Clone the current animation group and returns a copy
  36036. * @param newName defines the name of the new group
  36037. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  36038. * @returns the new aniamtion group
  36039. */
  36040. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  36041. /**
  36042. * Serializes the animationGroup to an object
  36043. * @returns Serialized object
  36044. */
  36045. serialize(): any;
  36046. /**
  36047. * Returns a new AnimationGroup object parsed from the source provided.
  36048. * @param parsedAnimationGroup defines the source
  36049. * @param scene defines the scene that will receive the animationGroup
  36050. * @returns a new AnimationGroup
  36051. */
  36052. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  36053. /**
  36054. * Returns the string "AnimationGroup"
  36055. * @returns "AnimationGroup"
  36056. */
  36057. getClassName(): string;
  36058. /**
  36059. * Creates a detailled string about the object
  36060. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  36061. * @returns a string representing the object
  36062. */
  36063. toString(fullDetails?: boolean): string;
  36064. }
  36065. }
  36066. declare module "babylonjs/scene" {
  36067. import { Nullable } from "babylonjs/types";
  36068. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  36069. import { Observable } from "babylonjs/Misc/observable";
  36070. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  36071. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  36072. import { Geometry } from "babylonjs/Meshes/geometry";
  36073. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36074. import { SubMesh } from "babylonjs/Meshes/subMesh";
  36075. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36076. import { Mesh } from "babylonjs/Meshes/mesh";
  36077. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36078. import { Bone } from "babylonjs/Bones/bone";
  36079. import { Skeleton } from "babylonjs/Bones/skeleton";
  36080. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  36081. import { Camera } from "babylonjs/Cameras/camera";
  36082. import { AbstractScene } from "babylonjs/abstractScene";
  36083. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36084. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  36085. import { Material } from "babylonjs/Materials/material";
  36086. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  36087. import { Effect } from "babylonjs/Materials/effect";
  36088. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  36089. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  36090. import { Light } from "babylonjs/Lights/light";
  36091. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36092. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  36093. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  36094. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  36095. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  36096. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  36097. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  36098. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  36099. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  36100. import { Engine } from "babylonjs/Engines/engine";
  36101. import { Node } from "babylonjs/node";
  36102. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  36103. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36104. import { WebRequest } from "babylonjs/Misc/webRequest";
  36105. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  36106. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  36107. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  36108. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  36109. import { Plane } from "babylonjs/Maths/math.plane";
  36110. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  36111. import { Ray } from "babylonjs/Culling/ray";
  36112. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  36113. import { Animation } from "babylonjs/Animations/animation";
  36114. import { Animatable } from "babylonjs/Animations/animatable";
  36115. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  36116. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  36117. import { Collider } from "babylonjs/Collisions/collider";
  36118. /**
  36119. * Define an interface for all classes that will hold resources
  36120. */
  36121. export interface IDisposable {
  36122. /**
  36123. * Releases all held resources
  36124. */
  36125. dispose(): void;
  36126. }
  36127. /** Interface defining initialization parameters for Scene class */
  36128. export interface SceneOptions {
  36129. /**
  36130. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  36131. * It will improve performance when the number of geometries becomes important.
  36132. */
  36133. useGeometryUniqueIdsMap?: boolean;
  36134. /**
  36135. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  36136. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36137. */
  36138. useMaterialMeshMap?: boolean;
  36139. /**
  36140. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  36141. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36142. */
  36143. useClonedMeshMap?: boolean;
  36144. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  36145. virtual?: boolean;
  36146. }
  36147. /**
  36148. * Represents a scene to be rendered by the engine.
  36149. * @see http://doc.babylonjs.com/features/scene
  36150. */
  36151. export class Scene extends AbstractScene implements IAnimatable {
  36152. /** The fog is deactivated */
  36153. static readonly FOGMODE_NONE: number;
  36154. /** The fog density is following an exponential function */
  36155. static readonly FOGMODE_EXP: number;
  36156. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  36157. static readonly FOGMODE_EXP2: number;
  36158. /** The fog density is following a linear function. */
  36159. static readonly FOGMODE_LINEAR: number;
  36160. /**
  36161. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  36162. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36163. */
  36164. static MinDeltaTime: number;
  36165. /**
  36166. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  36167. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36168. */
  36169. static MaxDeltaTime: number;
  36170. /**
  36171. * Factory used to create the default material.
  36172. * @param name The name of the material to create
  36173. * @param scene The scene to create the material for
  36174. * @returns The default material
  36175. */
  36176. static DefaultMaterialFactory(scene: Scene): Material;
  36177. /**
  36178. * Factory used to create the a collision coordinator.
  36179. * @returns The collision coordinator
  36180. */
  36181. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  36182. /** @hidden */
  36183. _inputManager: InputManager;
  36184. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  36185. cameraToUseForPointers: Nullable<Camera>;
  36186. /** @hidden */
  36187. readonly _isScene: boolean;
  36188. /** @hidden */
  36189. _blockEntityCollection: boolean;
  36190. /**
  36191. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  36192. */
  36193. autoClear: boolean;
  36194. /**
  36195. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  36196. */
  36197. autoClearDepthAndStencil: boolean;
  36198. /**
  36199. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  36200. */
  36201. clearColor: Color4;
  36202. /**
  36203. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  36204. */
  36205. ambientColor: Color3;
  36206. /**
  36207. * This is use to store the default BRDF lookup for PBR materials in your scene.
  36208. * It should only be one of the following (if not the default embedded one):
  36209. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  36210. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  36211. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  36212. * The material properties need to be setup according to the type of texture in use.
  36213. */
  36214. environmentBRDFTexture: BaseTexture;
  36215. /** @hidden */
  36216. protected _environmentTexture: Nullable<BaseTexture>;
  36217. /**
  36218. * Texture used in all pbr material as the reflection texture.
  36219. * As in the majority of the scene they are the same (exception for multi room and so on),
  36220. * this is easier to reference from here than from all the materials.
  36221. */
  36222. get environmentTexture(): Nullable<BaseTexture>;
  36223. /**
  36224. * Texture used in all pbr material as the reflection texture.
  36225. * As in the majority of the scene they are the same (exception for multi room and so on),
  36226. * this is easier to set here than in all the materials.
  36227. */
  36228. set environmentTexture(value: Nullable<BaseTexture>);
  36229. /** @hidden */
  36230. protected _environmentIntensity: number;
  36231. /**
  36232. * Intensity of the environment in all pbr material.
  36233. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36234. * As in the majority of the scene they are the same (exception for multi room and so on),
  36235. * this is easier to reference from here than from all the materials.
  36236. */
  36237. get environmentIntensity(): number;
  36238. /**
  36239. * Intensity of the environment in all pbr material.
  36240. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36241. * As in the majority of the scene they are the same (exception for multi room and so on),
  36242. * this is easier to set here than in all the materials.
  36243. */
  36244. set environmentIntensity(value: number);
  36245. /** @hidden */
  36246. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  36247. /**
  36248. * Default image processing configuration used either in the rendering
  36249. * Forward main pass or through the imageProcessingPostProcess if present.
  36250. * As in the majority of the scene they are the same (exception for multi camera),
  36251. * this is easier to reference from here than from all the materials and post process.
  36252. *
  36253. * No setter as we it is a shared configuration, you can set the values instead.
  36254. */
  36255. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  36256. private _forceWireframe;
  36257. /**
  36258. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  36259. */
  36260. set forceWireframe(value: boolean);
  36261. get forceWireframe(): boolean;
  36262. private _skipFrustumClipping;
  36263. /**
  36264. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  36265. */
  36266. set skipFrustumClipping(value: boolean);
  36267. get skipFrustumClipping(): boolean;
  36268. private _forcePointsCloud;
  36269. /**
  36270. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  36271. */
  36272. set forcePointsCloud(value: boolean);
  36273. get forcePointsCloud(): boolean;
  36274. /**
  36275. * Gets or sets the active clipplane 1
  36276. */
  36277. clipPlane: Nullable<Plane>;
  36278. /**
  36279. * Gets or sets the active clipplane 2
  36280. */
  36281. clipPlane2: Nullable<Plane>;
  36282. /**
  36283. * Gets or sets the active clipplane 3
  36284. */
  36285. clipPlane3: Nullable<Plane>;
  36286. /**
  36287. * Gets or sets the active clipplane 4
  36288. */
  36289. clipPlane4: Nullable<Plane>;
  36290. /**
  36291. * Gets or sets the active clipplane 5
  36292. */
  36293. clipPlane5: Nullable<Plane>;
  36294. /**
  36295. * Gets or sets the active clipplane 6
  36296. */
  36297. clipPlane6: Nullable<Plane>;
  36298. /**
  36299. * Gets or sets a boolean indicating if animations are enabled
  36300. */
  36301. animationsEnabled: boolean;
  36302. private _animationPropertiesOverride;
  36303. /**
  36304. * Gets or sets the animation properties override
  36305. */
  36306. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36307. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36308. /**
  36309. * Gets or sets a boolean indicating if a constant deltatime has to be used
  36310. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  36311. */
  36312. useConstantAnimationDeltaTime: boolean;
  36313. /**
  36314. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  36315. * Please note that it requires to run a ray cast through the scene on every frame
  36316. */
  36317. constantlyUpdateMeshUnderPointer: boolean;
  36318. /**
  36319. * Defines the HTML cursor to use when hovering over interactive elements
  36320. */
  36321. hoverCursor: string;
  36322. /**
  36323. * Defines the HTML default cursor to use (empty by default)
  36324. */
  36325. defaultCursor: string;
  36326. /**
  36327. * Defines whether cursors are handled by the scene.
  36328. */
  36329. doNotHandleCursors: boolean;
  36330. /**
  36331. * This is used to call preventDefault() on pointer down
  36332. * in order to block unwanted artifacts like system double clicks
  36333. */
  36334. preventDefaultOnPointerDown: boolean;
  36335. /**
  36336. * This is used to call preventDefault() on pointer up
  36337. * in order to block unwanted artifacts like system double clicks
  36338. */
  36339. preventDefaultOnPointerUp: boolean;
  36340. /**
  36341. * Gets or sets user defined metadata
  36342. */
  36343. metadata: any;
  36344. /**
  36345. * For internal use only. Please do not use.
  36346. */
  36347. reservedDataStore: any;
  36348. /**
  36349. * Gets the name of the plugin used to load this scene (null by default)
  36350. */
  36351. loadingPluginName: string;
  36352. /**
  36353. * Use this array to add regular expressions used to disable offline support for specific urls
  36354. */
  36355. disableOfflineSupportExceptionRules: RegExp[];
  36356. /**
  36357. * An event triggered when the scene is disposed.
  36358. */
  36359. onDisposeObservable: Observable<Scene>;
  36360. private _onDisposeObserver;
  36361. /** Sets a function to be executed when this scene is disposed. */
  36362. set onDispose(callback: () => void);
  36363. /**
  36364. * An event triggered before rendering the scene (right after animations and physics)
  36365. */
  36366. onBeforeRenderObservable: Observable<Scene>;
  36367. private _onBeforeRenderObserver;
  36368. /** Sets a function to be executed before rendering this scene */
  36369. set beforeRender(callback: Nullable<() => void>);
  36370. /**
  36371. * An event triggered after rendering the scene
  36372. */
  36373. onAfterRenderObservable: Observable<Scene>;
  36374. /**
  36375. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  36376. */
  36377. onAfterRenderCameraObservable: Observable<Camera>;
  36378. private _onAfterRenderObserver;
  36379. /** Sets a function to be executed after rendering this scene */
  36380. set afterRender(callback: Nullable<() => void>);
  36381. /**
  36382. * An event triggered before animating the scene
  36383. */
  36384. onBeforeAnimationsObservable: Observable<Scene>;
  36385. /**
  36386. * An event triggered after animations processing
  36387. */
  36388. onAfterAnimationsObservable: Observable<Scene>;
  36389. /**
  36390. * An event triggered before draw calls are ready to be sent
  36391. */
  36392. onBeforeDrawPhaseObservable: Observable<Scene>;
  36393. /**
  36394. * An event triggered after draw calls have been sent
  36395. */
  36396. onAfterDrawPhaseObservable: Observable<Scene>;
  36397. /**
  36398. * An event triggered when the scene is ready
  36399. */
  36400. onReadyObservable: Observable<Scene>;
  36401. /**
  36402. * An event triggered before rendering a camera
  36403. */
  36404. onBeforeCameraRenderObservable: Observable<Camera>;
  36405. private _onBeforeCameraRenderObserver;
  36406. /** Sets a function to be executed before rendering a camera*/
  36407. set beforeCameraRender(callback: () => void);
  36408. /**
  36409. * An event triggered after rendering a camera
  36410. */
  36411. onAfterCameraRenderObservable: Observable<Camera>;
  36412. private _onAfterCameraRenderObserver;
  36413. /** Sets a function to be executed after rendering a camera*/
  36414. set afterCameraRender(callback: () => void);
  36415. /**
  36416. * An event triggered when active meshes evaluation is about to start
  36417. */
  36418. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  36419. /**
  36420. * An event triggered when active meshes evaluation is done
  36421. */
  36422. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  36423. /**
  36424. * An event triggered when particles rendering is about to start
  36425. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36426. */
  36427. onBeforeParticlesRenderingObservable: Observable<Scene>;
  36428. /**
  36429. * An event triggered when particles rendering is done
  36430. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36431. */
  36432. onAfterParticlesRenderingObservable: Observable<Scene>;
  36433. /**
  36434. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  36435. */
  36436. onDataLoadedObservable: Observable<Scene>;
  36437. /**
  36438. * An event triggered when a camera is created
  36439. */
  36440. onNewCameraAddedObservable: Observable<Camera>;
  36441. /**
  36442. * An event triggered when a camera is removed
  36443. */
  36444. onCameraRemovedObservable: Observable<Camera>;
  36445. /**
  36446. * An event triggered when a light is created
  36447. */
  36448. onNewLightAddedObservable: Observable<Light>;
  36449. /**
  36450. * An event triggered when a light is removed
  36451. */
  36452. onLightRemovedObservable: Observable<Light>;
  36453. /**
  36454. * An event triggered when a geometry is created
  36455. */
  36456. onNewGeometryAddedObservable: Observable<Geometry>;
  36457. /**
  36458. * An event triggered when a geometry is removed
  36459. */
  36460. onGeometryRemovedObservable: Observable<Geometry>;
  36461. /**
  36462. * An event triggered when a transform node is created
  36463. */
  36464. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  36465. /**
  36466. * An event triggered when a transform node is removed
  36467. */
  36468. onTransformNodeRemovedObservable: Observable<TransformNode>;
  36469. /**
  36470. * An event triggered when a mesh is created
  36471. */
  36472. onNewMeshAddedObservable: Observable<AbstractMesh>;
  36473. /**
  36474. * An event triggered when a mesh is removed
  36475. */
  36476. onMeshRemovedObservable: Observable<AbstractMesh>;
  36477. /**
  36478. * An event triggered when a skeleton is created
  36479. */
  36480. onNewSkeletonAddedObservable: Observable<Skeleton>;
  36481. /**
  36482. * An event triggered when a skeleton is removed
  36483. */
  36484. onSkeletonRemovedObservable: Observable<Skeleton>;
  36485. /**
  36486. * An event triggered when a material is created
  36487. */
  36488. onNewMaterialAddedObservable: Observable<Material>;
  36489. /**
  36490. * An event triggered when a material is removed
  36491. */
  36492. onMaterialRemovedObservable: Observable<Material>;
  36493. /**
  36494. * An event triggered when a texture is created
  36495. */
  36496. onNewTextureAddedObservable: Observable<BaseTexture>;
  36497. /**
  36498. * An event triggered when a texture is removed
  36499. */
  36500. onTextureRemovedObservable: Observable<BaseTexture>;
  36501. /**
  36502. * An event triggered when render targets are about to be rendered
  36503. * Can happen multiple times per frame.
  36504. */
  36505. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  36506. /**
  36507. * An event triggered when render targets were rendered.
  36508. * Can happen multiple times per frame.
  36509. */
  36510. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  36511. /**
  36512. * An event triggered before calculating deterministic simulation step
  36513. */
  36514. onBeforeStepObservable: Observable<Scene>;
  36515. /**
  36516. * An event triggered after calculating deterministic simulation step
  36517. */
  36518. onAfterStepObservable: Observable<Scene>;
  36519. /**
  36520. * An event triggered when the activeCamera property is updated
  36521. */
  36522. onActiveCameraChanged: Observable<Scene>;
  36523. /**
  36524. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  36525. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36526. * 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)
  36527. */
  36528. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36529. /**
  36530. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  36531. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36532. * 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)
  36533. */
  36534. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36535. /**
  36536. * This Observable will when a mesh has been imported into the scene.
  36537. */
  36538. onMeshImportedObservable: Observable<AbstractMesh>;
  36539. /**
  36540. * This Observable will when an animation file has been imported into the scene.
  36541. */
  36542. onAnimationFileImportedObservable: Observable<Scene>;
  36543. /**
  36544. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  36545. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  36546. */
  36547. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  36548. /** @hidden */
  36549. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  36550. /**
  36551. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  36552. */
  36553. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  36554. /**
  36555. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  36556. */
  36557. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  36558. /**
  36559. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  36560. */
  36561. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  36562. /** Callback called when a pointer move is detected */
  36563. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36564. /** Callback called when a pointer down is detected */
  36565. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36566. /** Callback called when a pointer up is detected */
  36567. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  36568. /** Callback called when a pointer pick is detected */
  36569. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  36570. /**
  36571. * 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).
  36572. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  36573. */
  36574. onPrePointerObservable: Observable<PointerInfoPre>;
  36575. /**
  36576. * Observable event triggered each time an input event is received from the rendering canvas
  36577. */
  36578. onPointerObservable: Observable<PointerInfo>;
  36579. /**
  36580. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  36581. */
  36582. get unTranslatedPointer(): Vector2;
  36583. /**
  36584. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  36585. */
  36586. static get DragMovementThreshold(): number;
  36587. static set DragMovementThreshold(value: number);
  36588. /**
  36589. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  36590. */
  36591. static get LongPressDelay(): number;
  36592. static set LongPressDelay(value: number);
  36593. /**
  36594. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  36595. */
  36596. static get DoubleClickDelay(): number;
  36597. static set DoubleClickDelay(value: number);
  36598. /** If you need to check double click without raising a single click at first click, enable this flag */
  36599. static get ExclusiveDoubleClickMode(): boolean;
  36600. static set ExclusiveDoubleClickMode(value: boolean);
  36601. /** @hidden */
  36602. _mirroredCameraPosition: Nullable<Vector3>;
  36603. /**
  36604. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  36605. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  36606. */
  36607. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  36608. /**
  36609. * Observable event triggered each time an keyboard event is received from the hosting window
  36610. */
  36611. onKeyboardObservable: Observable<KeyboardInfo>;
  36612. private _useRightHandedSystem;
  36613. /**
  36614. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  36615. */
  36616. set useRightHandedSystem(value: boolean);
  36617. get useRightHandedSystem(): boolean;
  36618. private _timeAccumulator;
  36619. private _currentStepId;
  36620. private _currentInternalStep;
  36621. /**
  36622. * Sets the step Id used by deterministic lock step
  36623. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36624. * @param newStepId defines the step Id
  36625. */
  36626. setStepId(newStepId: number): void;
  36627. /**
  36628. * Gets the step Id used by deterministic lock step
  36629. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36630. * @returns the step Id
  36631. */
  36632. getStepId(): number;
  36633. /**
  36634. * Gets the internal step used by deterministic lock step
  36635. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36636. * @returns the internal step
  36637. */
  36638. getInternalStep(): number;
  36639. private _fogEnabled;
  36640. /**
  36641. * Gets or sets a boolean indicating if fog is enabled on this scene
  36642. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36643. * (Default is true)
  36644. */
  36645. set fogEnabled(value: boolean);
  36646. get fogEnabled(): boolean;
  36647. private _fogMode;
  36648. /**
  36649. * Gets or sets the fog mode to use
  36650. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36651. * | mode | value |
  36652. * | --- | --- |
  36653. * | FOGMODE_NONE | 0 |
  36654. * | FOGMODE_EXP | 1 |
  36655. * | FOGMODE_EXP2 | 2 |
  36656. * | FOGMODE_LINEAR | 3 |
  36657. */
  36658. set fogMode(value: number);
  36659. get fogMode(): number;
  36660. /**
  36661. * Gets or sets the fog color to use
  36662. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36663. * (Default is Color3(0.2, 0.2, 0.3))
  36664. */
  36665. fogColor: Color3;
  36666. /**
  36667. * Gets or sets the fog density to use
  36668. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36669. * (Default is 0.1)
  36670. */
  36671. fogDensity: number;
  36672. /**
  36673. * Gets or sets the fog start distance to use
  36674. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36675. * (Default is 0)
  36676. */
  36677. fogStart: number;
  36678. /**
  36679. * Gets or sets the fog end distance to use
  36680. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36681. * (Default is 1000)
  36682. */
  36683. fogEnd: number;
  36684. private _shadowsEnabled;
  36685. /**
  36686. * Gets or sets a boolean indicating if shadows are enabled on this scene
  36687. */
  36688. set shadowsEnabled(value: boolean);
  36689. get shadowsEnabled(): boolean;
  36690. private _lightsEnabled;
  36691. /**
  36692. * Gets or sets a boolean indicating if lights are enabled on this scene
  36693. */
  36694. set lightsEnabled(value: boolean);
  36695. get lightsEnabled(): boolean;
  36696. /** All of the active cameras added to this scene. */
  36697. activeCameras: Camera[];
  36698. /** @hidden */
  36699. _activeCamera: Nullable<Camera>;
  36700. /** Gets or sets the current active camera */
  36701. get activeCamera(): Nullable<Camera>;
  36702. set activeCamera(value: Nullable<Camera>);
  36703. private _defaultMaterial;
  36704. /** The default material used on meshes when no material is affected */
  36705. get defaultMaterial(): Material;
  36706. /** The default material used on meshes when no material is affected */
  36707. set defaultMaterial(value: Material);
  36708. private _texturesEnabled;
  36709. /**
  36710. * Gets or sets a boolean indicating if textures are enabled on this scene
  36711. */
  36712. set texturesEnabled(value: boolean);
  36713. get texturesEnabled(): boolean;
  36714. /**
  36715. * Gets or sets a boolean indicating if particles are enabled on this scene
  36716. */
  36717. particlesEnabled: boolean;
  36718. /**
  36719. * Gets or sets a boolean indicating if sprites are enabled on this scene
  36720. */
  36721. spritesEnabled: boolean;
  36722. private _skeletonsEnabled;
  36723. /**
  36724. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36725. */
  36726. set skeletonsEnabled(value: boolean);
  36727. get skeletonsEnabled(): boolean;
  36728. /**
  36729. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36730. */
  36731. lensFlaresEnabled: boolean;
  36732. /**
  36733. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36734. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36735. */
  36736. collisionsEnabled: boolean;
  36737. private _collisionCoordinator;
  36738. /** @hidden */
  36739. get collisionCoordinator(): ICollisionCoordinator;
  36740. /**
  36741. * Defines the gravity applied to this scene (used only for collisions)
  36742. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36743. */
  36744. gravity: Vector3;
  36745. /**
  36746. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36747. */
  36748. postProcessesEnabled: boolean;
  36749. /**
  36750. * The list of postprocesses added to the scene
  36751. */
  36752. postProcesses: PostProcess[];
  36753. /**
  36754. * Gets the current postprocess manager
  36755. */
  36756. postProcessManager: PostProcessManager;
  36757. /**
  36758. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36759. */
  36760. renderTargetsEnabled: boolean;
  36761. /**
  36762. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36763. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36764. */
  36765. dumpNextRenderTargets: boolean;
  36766. /**
  36767. * The list of user defined render targets added to the scene
  36768. */
  36769. customRenderTargets: RenderTargetTexture[];
  36770. /**
  36771. * Defines if texture loading must be delayed
  36772. * If true, textures will only be loaded when they need to be rendered
  36773. */
  36774. useDelayedTextureLoading: boolean;
  36775. /**
  36776. * Gets the list of meshes imported to the scene through SceneLoader
  36777. */
  36778. importedMeshesFiles: String[];
  36779. /**
  36780. * Gets or sets a boolean indicating if probes are enabled on this scene
  36781. */
  36782. probesEnabled: boolean;
  36783. /**
  36784. * Gets or sets the current offline provider to use to store scene data
  36785. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36786. */
  36787. offlineProvider: IOfflineProvider;
  36788. /**
  36789. * Gets or sets the action manager associated with the scene
  36790. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36791. */
  36792. actionManager: AbstractActionManager;
  36793. private _meshesForIntersections;
  36794. /**
  36795. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36796. */
  36797. proceduralTexturesEnabled: boolean;
  36798. private _engine;
  36799. private _totalVertices;
  36800. /** @hidden */
  36801. _activeIndices: PerfCounter;
  36802. /** @hidden */
  36803. _activeParticles: PerfCounter;
  36804. /** @hidden */
  36805. _activeBones: PerfCounter;
  36806. private _animationRatio;
  36807. /** @hidden */
  36808. _animationTimeLast: number;
  36809. /** @hidden */
  36810. _animationTime: number;
  36811. /**
  36812. * Gets or sets a general scale for animation speed
  36813. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36814. */
  36815. animationTimeScale: number;
  36816. /** @hidden */
  36817. _cachedMaterial: Nullable<Material>;
  36818. /** @hidden */
  36819. _cachedEffect: Nullable<Effect>;
  36820. /** @hidden */
  36821. _cachedVisibility: Nullable<number>;
  36822. private _renderId;
  36823. private _frameId;
  36824. private _executeWhenReadyTimeoutId;
  36825. private _intermediateRendering;
  36826. private _viewUpdateFlag;
  36827. private _projectionUpdateFlag;
  36828. /** @hidden */
  36829. _toBeDisposed: Nullable<IDisposable>[];
  36830. private _activeRequests;
  36831. /** @hidden */
  36832. _pendingData: any[];
  36833. private _isDisposed;
  36834. /**
  36835. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36836. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36837. */
  36838. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36839. private _activeMeshes;
  36840. private _processedMaterials;
  36841. private _renderTargets;
  36842. /** @hidden */
  36843. _activeParticleSystems: SmartArray<IParticleSystem>;
  36844. private _activeSkeletons;
  36845. private _softwareSkinnedMeshes;
  36846. private _renderingManager;
  36847. /** @hidden */
  36848. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  36849. private _transformMatrix;
  36850. private _sceneUbo;
  36851. /** @hidden */
  36852. _viewMatrix: Matrix;
  36853. private _projectionMatrix;
  36854. /** @hidden */
  36855. _forcedViewPosition: Nullable<Vector3>;
  36856. /** @hidden */
  36857. _frustumPlanes: Plane[];
  36858. /**
  36859. * Gets the list of frustum planes (built from the active camera)
  36860. */
  36861. get frustumPlanes(): Plane[];
  36862. /**
  36863. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36864. * This is useful if there are more lights that the maximum simulteanous authorized
  36865. */
  36866. requireLightSorting: boolean;
  36867. /** @hidden */
  36868. readonly useMaterialMeshMap: boolean;
  36869. /** @hidden */
  36870. readonly useClonedMeshMap: boolean;
  36871. private _externalData;
  36872. private _uid;
  36873. /**
  36874. * @hidden
  36875. * Backing store of defined scene components.
  36876. */
  36877. _components: ISceneComponent[];
  36878. /**
  36879. * @hidden
  36880. * Backing store of defined scene components.
  36881. */
  36882. _serializableComponents: ISceneSerializableComponent[];
  36883. /**
  36884. * List of components to register on the next registration step.
  36885. */
  36886. private _transientComponents;
  36887. /**
  36888. * Registers the transient components if needed.
  36889. */
  36890. private _registerTransientComponents;
  36891. /**
  36892. * @hidden
  36893. * Add a component to the scene.
  36894. * Note that the ccomponent could be registered on th next frame if this is called after
  36895. * the register component stage.
  36896. * @param component Defines the component to add to the scene
  36897. */
  36898. _addComponent(component: ISceneComponent): void;
  36899. /**
  36900. * @hidden
  36901. * Gets a component from the scene.
  36902. * @param name defines the name of the component to retrieve
  36903. * @returns the component or null if not present
  36904. */
  36905. _getComponent(name: string): Nullable<ISceneComponent>;
  36906. /**
  36907. * @hidden
  36908. * Defines the actions happening before camera updates.
  36909. */
  36910. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36911. /**
  36912. * @hidden
  36913. * Defines the actions happening before clear the canvas.
  36914. */
  36915. _beforeClearStage: Stage<SimpleStageAction>;
  36916. /**
  36917. * @hidden
  36918. * Defines the actions when collecting render targets for the frame.
  36919. */
  36920. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36921. /**
  36922. * @hidden
  36923. * Defines the actions happening for one camera in the frame.
  36924. */
  36925. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36926. /**
  36927. * @hidden
  36928. * Defines the actions happening during the per mesh ready checks.
  36929. */
  36930. _isReadyForMeshStage: Stage<MeshStageAction>;
  36931. /**
  36932. * @hidden
  36933. * Defines the actions happening before evaluate active mesh checks.
  36934. */
  36935. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36936. /**
  36937. * @hidden
  36938. * Defines the actions happening during the evaluate sub mesh checks.
  36939. */
  36940. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36941. /**
  36942. * @hidden
  36943. * Defines the actions happening during the active mesh stage.
  36944. */
  36945. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36946. /**
  36947. * @hidden
  36948. * Defines the actions happening during the per camera render target step.
  36949. */
  36950. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36951. /**
  36952. * @hidden
  36953. * Defines the actions happening just before the active camera is drawing.
  36954. */
  36955. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36956. /**
  36957. * @hidden
  36958. * Defines the actions happening just before a render target is drawing.
  36959. */
  36960. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36961. /**
  36962. * @hidden
  36963. * Defines the actions happening just before a rendering group is drawing.
  36964. */
  36965. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36966. /**
  36967. * @hidden
  36968. * Defines the actions happening just before a mesh is drawing.
  36969. */
  36970. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36971. /**
  36972. * @hidden
  36973. * Defines the actions happening just after a mesh has been drawn.
  36974. */
  36975. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36976. /**
  36977. * @hidden
  36978. * Defines the actions happening just after a rendering group has been drawn.
  36979. */
  36980. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36981. /**
  36982. * @hidden
  36983. * Defines the actions happening just after the active camera has been drawn.
  36984. */
  36985. _afterCameraDrawStage: Stage<CameraStageAction>;
  36986. /**
  36987. * @hidden
  36988. * Defines the actions happening just after a render target has been drawn.
  36989. */
  36990. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36991. /**
  36992. * @hidden
  36993. * Defines the actions happening just after rendering all cameras and computing intersections.
  36994. */
  36995. _afterRenderStage: Stage<SimpleStageAction>;
  36996. /**
  36997. * @hidden
  36998. * Defines the actions happening when a pointer move event happens.
  36999. */
  37000. _pointerMoveStage: Stage<PointerMoveStageAction>;
  37001. /**
  37002. * @hidden
  37003. * Defines the actions happening when a pointer down event happens.
  37004. */
  37005. _pointerDownStage: Stage<PointerUpDownStageAction>;
  37006. /**
  37007. * @hidden
  37008. * Defines the actions happening when a pointer up event happens.
  37009. */
  37010. _pointerUpStage: Stage<PointerUpDownStageAction>;
  37011. /**
  37012. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  37013. */
  37014. private geometriesByUniqueId;
  37015. /**
  37016. * Creates a new Scene
  37017. * @param engine defines the engine to use to render this scene
  37018. * @param options defines the scene options
  37019. */
  37020. constructor(engine: Engine, options?: SceneOptions);
  37021. /**
  37022. * Gets a string idenfifying the name of the class
  37023. * @returns "Scene" string
  37024. */
  37025. getClassName(): string;
  37026. private _defaultMeshCandidates;
  37027. /**
  37028. * @hidden
  37029. */
  37030. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  37031. private _defaultSubMeshCandidates;
  37032. /**
  37033. * @hidden
  37034. */
  37035. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  37036. /**
  37037. * Sets the default candidate providers for the scene.
  37038. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  37039. * and getCollidingSubMeshCandidates to their default function
  37040. */
  37041. setDefaultCandidateProviders(): void;
  37042. /**
  37043. * Gets the mesh that is currently under the pointer
  37044. */
  37045. get meshUnderPointer(): Nullable<AbstractMesh>;
  37046. /**
  37047. * Gets or sets the current on-screen X position of the pointer
  37048. */
  37049. get pointerX(): number;
  37050. set pointerX(value: number);
  37051. /**
  37052. * Gets or sets the current on-screen Y position of the pointer
  37053. */
  37054. get pointerY(): number;
  37055. set pointerY(value: number);
  37056. /**
  37057. * Gets the cached material (ie. the latest rendered one)
  37058. * @returns the cached material
  37059. */
  37060. getCachedMaterial(): Nullable<Material>;
  37061. /**
  37062. * Gets the cached effect (ie. the latest rendered one)
  37063. * @returns the cached effect
  37064. */
  37065. getCachedEffect(): Nullable<Effect>;
  37066. /**
  37067. * Gets the cached visibility state (ie. the latest rendered one)
  37068. * @returns the cached visibility state
  37069. */
  37070. getCachedVisibility(): Nullable<number>;
  37071. /**
  37072. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  37073. * @param material defines the current material
  37074. * @param effect defines the current effect
  37075. * @param visibility defines the current visibility state
  37076. * @returns true if one parameter is not cached
  37077. */
  37078. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  37079. /**
  37080. * Gets the engine associated with the scene
  37081. * @returns an Engine
  37082. */
  37083. getEngine(): Engine;
  37084. /**
  37085. * Gets the total number of vertices rendered per frame
  37086. * @returns the total number of vertices rendered per frame
  37087. */
  37088. getTotalVertices(): number;
  37089. /**
  37090. * Gets the performance counter for total vertices
  37091. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37092. */
  37093. get totalVerticesPerfCounter(): PerfCounter;
  37094. /**
  37095. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  37096. * @returns the total number of active indices rendered per frame
  37097. */
  37098. getActiveIndices(): number;
  37099. /**
  37100. * Gets the performance counter for active indices
  37101. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37102. */
  37103. get totalActiveIndicesPerfCounter(): PerfCounter;
  37104. /**
  37105. * Gets the total number of active particles rendered per frame
  37106. * @returns the total number of active particles rendered per frame
  37107. */
  37108. getActiveParticles(): number;
  37109. /**
  37110. * Gets the performance counter for active particles
  37111. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37112. */
  37113. get activeParticlesPerfCounter(): PerfCounter;
  37114. /**
  37115. * Gets the total number of active bones rendered per frame
  37116. * @returns the total number of active bones rendered per frame
  37117. */
  37118. getActiveBones(): number;
  37119. /**
  37120. * Gets the performance counter for active bones
  37121. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37122. */
  37123. get activeBonesPerfCounter(): PerfCounter;
  37124. /**
  37125. * Gets the array of active meshes
  37126. * @returns an array of AbstractMesh
  37127. */
  37128. getActiveMeshes(): SmartArray<AbstractMesh>;
  37129. /**
  37130. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  37131. * @returns a number
  37132. */
  37133. getAnimationRatio(): number;
  37134. /**
  37135. * Gets an unique Id for the current render phase
  37136. * @returns a number
  37137. */
  37138. getRenderId(): number;
  37139. /**
  37140. * Gets an unique Id for the current frame
  37141. * @returns a number
  37142. */
  37143. getFrameId(): number;
  37144. /** Call this function if you want to manually increment the render Id*/
  37145. incrementRenderId(): void;
  37146. private _createUbo;
  37147. /**
  37148. * Use this method to simulate a pointer move on a mesh
  37149. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37150. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37151. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37152. * @returns the current scene
  37153. */
  37154. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37155. /**
  37156. * Use this method to simulate a pointer down on a mesh
  37157. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37158. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37159. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37160. * @returns the current scene
  37161. */
  37162. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37163. /**
  37164. * Use this method to simulate a pointer up on a mesh
  37165. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37166. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37167. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37168. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  37169. * @returns the current scene
  37170. */
  37171. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  37172. /**
  37173. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  37174. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  37175. * @returns true if the pointer was captured
  37176. */
  37177. isPointerCaptured(pointerId?: number): boolean;
  37178. /**
  37179. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  37180. * @param attachUp defines if you want to attach events to pointerup
  37181. * @param attachDown defines if you want to attach events to pointerdown
  37182. * @param attachMove defines if you want to attach events to pointermove
  37183. */
  37184. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  37185. /** Detaches all event handlers*/
  37186. detachControl(): void;
  37187. /**
  37188. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  37189. * Delay loaded resources are not taking in account
  37190. * @return true if all required resources are ready
  37191. */
  37192. isReady(): boolean;
  37193. /** Resets all cached information relative to material (including effect and visibility) */
  37194. resetCachedMaterial(): void;
  37195. /**
  37196. * Registers a function to be called before every frame render
  37197. * @param func defines the function to register
  37198. */
  37199. registerBeforeRender(func: () => void): void;
  37200. /**
  37201. * Unregisters a function called before every frame render
  37202. * @param func defines the function to unregister
  37203. */
  37204. unregisterBeforeRender(func: () => void): void;
  37205. /**
  37206. * Registers a function to be called after every frame render
  37207. * @param func defines the function to register
  37208. */
  37209. registerAfterRender(func: () => void): void;
  37210. /**
  37211. * Unregisters a function called after every frame render
  37212. * @param func defines the function to unregister
  37213. */
  37214. unregisterAfterRender(func: () => void): void;
  37215. private _executeOnceBeforeRender;
  37216. /**
  37217. * The provided function will run before render once and will be disposed afterwards.
  37218. * A timeout delay can be provided so that the function will be executed in N ms.
  37219. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  37220. * @param func The function to be executed.
  37221. * @param timeout optional delay in ms
  37222. */
  37223. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  37224. /** @hidden */
  37225. _addPendingData(data: any): void;
  37226. /** @hidden */
  37227. _removePendingData(data: any): void;
  37228. /**
  37229. * Returns the number of items waiting to be loaded
  37230. * @returns the number of items waiting to be loaded
  37231. */
  37232. getWaitingItemsCount(): number;
  37233. /**
  37234. * Returns a boolean indicating if the scene is still loading data
  37235. */
  37236. get isLoading(): boolean;
  37237. /**
  37238. * Registers a function to be executed when the scene is ready
  37239. * @param {Function} func - the function to be executed
  37240. */
  37241. executeWhenReady(func: () => void): void;
  37242. /**
  37243. * Returns a promise that resolves when the scene is ready
  37244. * @returns A promise that resolves when the scene is ready
  37245. */
  37246. whenReadyAsync(): Promise<void>;
  37247. /** @hidden */
  37248. _checkIsReady(): void;
  37249. /**
  37250. * Gets all animatable attached to the scene
  37251. */
  37252. get animatables(): Animatable[];
  37253. /**
  37254. * Resets the last animation time frame.
  37255. * Useful to override when animations start running when loading a scene for the first time.
  37256. */
  37257. resetLastAnimationTimeFrame(): void;
  37258. /**
  37259. * Gets the current view matrix
  37260. * @returns a Matrix
  37261. */
  37262. getViewMatrix(): Matrix;
  37263. /**
  37264. * Gets the current projection matrix
  37265. * @returns a Matrix
  37266. */
  37267. getProjectionMatrix(): Matrix;
  37268. /**
  37269. * Gets the current transform matrix
  37270. * @returns a Matrix made of View * Projection
  37271. */
  37272. getTransformMatrix(): Matrix;
  37273. /**
  37274. * Sets the current transform matrix
  37275. * @param viewL defines the View matrix to use
  37276. * @param projectionL defines the Projection matrix to use
  37277. * @param viewR defines the right View matrix to use (if provided)
  37278. * @param projectionR defines the right Projection matrix to use (if provided)
  37279. */
  37280. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  37281. /**
  37282. * Gets the uniform buffer used to store scene data
  37283. * @returns a UniformBuffer
  37284. */
  37285. getSceneUniformBuffer(): UniformBuffer;
  37286. /**
  37287. * Gets an unique (relatively to the current scene) Id
  37288. * @returns an unique number for the scene
  37289. */
  37290. getUniqueId(): number;
  37291. /**
  37292. * Add a mesh to the list of scene's meshes
  37293. * @param newMesh defines the mesh to add
  37294. * @param recursive if all child meshes should also be added to the scene
  37295. */
  37296. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  37297. /**
  37298. * Remove a mesh for the list of scene's meshes
  37299. * @param toRemove defines the mesh to remove
  37300. * @param recursive if all child meshes should also be removed from the scene
  37301. * @returns the index where the mesh was in the mesh list
  37302. */
  37303. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  37304. /**
  37305. * Add a transform node to the list of scene's transform nodes
  37306. * @param newTransformNode defines the transform node to add
  37307. */
  37308. addTransformNode(newTransformNode: TransformNode): void;
  37309. /**
  37310. * Remove a transform node for the list of scene's transform nodes
  37311. * @param toRemove defines the transform node to remove
  37312. * @returns the index where the transform node was in the transform node list
  37313. */
  37314. removeTransformNode(toRemove: TransformNode): number;
  37315. /**
  37316. * Remove a skeleton for the list of scene's skeletons
  37317. * @param toRemove defines the skeleton to remove
  37318. * @returns the index where the skeleton was in the skeleton list
  37319. */
  37320. removeSkeleton(toRemove: Skeleton): number;
  37321. /**
  37322. * Remove a morph target for the list of scene's morph targets
  37323. * @param toRemove defines the morph target to remove
  37324. * @returns the index where the morph target was in the morph target list
  37325. */
  37326. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  37327. /**
  37328. * Remove a light for the list of scene's lights
  37329. * @param toRemove defines the light to remove
  37330. * @returns the index where the light was in the light list
  37331. */
  37332. removeLight(toRemove: Light): number;
  37333. /**
  37334. * Remove a camera for the list of scene's cameras
  37335. * @param toRemove defines the camera to remove
  37336. * @returns the index where the camera was in the camera list
  37337. */
  37338. removeCamera(toRemove: Camera): number;
  37339. /**
  37340. * Remove a particle system for the list of scene's particle systems
  37341. * @param toRemove defines the particle system to remove
  37342. * @returns the index where the particle system was in the particle system list
  37343. */
  37344. removeParticleSystem(toRemove: IParticleSystem): number;
  37345. /**
  37346. * Remove a animation for the list of scene's animations
  37347. * @param toRemove defines the animation to remove
  37348. * @returns the index where the animation was in the animation list
  37349. */
  37350. removeAnimation(toRemove: Animation): number;
  37351. /**
  37352. * Will stop the animation of the given target
  37353. * @param target - the target
  37354. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  37355. * @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)
  37356. */
  37357. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  37358. /**
  37359. * Removes the given animation group from this scene.
  37360. * @param toRemove The animation group to remove
  37361. * @returns The index of the removed animation group
  37362. */
  37363. removeAnimationGroup(toRemove: AnimationGroup): number;
  37364. /**
  37365. * Removes the given multi-material from this scene.
  37366. * @param toRemove The multi-material to remove
  37367. * @returns The index of the removed multi-material
  37368. */
  37369. removeMultiMaterial(toRemove: MultiMaterial): number;
  37370. /**
  37371. * Removes the given material from this scene.
  37372. * @param toRemove The material to remove
  37373. * @returns The index of the removed material
  37374. */
  37375. removeMaterial(toRemove: Material): number;
  37376. /**
  37377. * Removes the given action manager from this scene.
  37378. * @param toRemove The action manager to remove
  37379. * @returns The index of the removed action manager
  37380. */
  37381. removeActionManager(toRemove: AbstractActionManager): number;
  37382. /**
  37383. * Removes the given texture from this scene.
  37384. * @param toRemove The texture to remove
  37385. * @returns The index of the removed texture
  37386. */
  37387. removeTexture(toRemove: BaseTexture): number;
  37388. /**
  37389. * Adds the given light to this scene
  37390. * @param newLight The light to add
  37391. */
  37392. addLight(newLight: Light): void;
  37393. /**
  37394. * Sorts the list list based on light priorities
  37395. */
  37396. sortLightsByPriority(): void;
  37397. /**
  37398. * Adds the given camera to this scene
  37399. * @param newCamera The camera to add
  37400. */
  37401. addCamera(newCamera: Camera): void;
  37402. /**
  37403. * Adds the given skeleton to this scene
  37404. * @param newSkeleton The skeleton to add
  37405. */
  37406. addSkeleton(newSkeleton: Skeleton): void;
  37407. /**
  37408. * Adds the given particle system to this scene
  37409. * @param newParticleSystem The particle system to add
  37410. */
  37411. addParticleSystem(newParticleSystem: IParticleSystem): void;
  37412. /**
  37413. * Adds the given animation to this scene
  37414. * @param newAnimation The animation to add
  37415. */
  37416. addAnimation(newAnimation: Animation): void;
  37417. /**
  37418. * Adds the given animation group to this scene.
  37419. * @param newAnimationGroup The animation group to add
  37420. */
  37421. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  37422. /**
  37423. * Adds the given multi-material to this scene
  37424. * @param newMultiMaterial The multi-material to add
  37425. */
  37426. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  37427. /**
  37428. * Adds the given material to this scene
  37429. * @param newMaterial The material to add
  37430. */
  37431. addMaterial(newMaterial: Material): void;
  37432. /**
  37433. * Adds the given morph target to this scene
  37434. * @param newMorphTargetManager The morph target to add
  37435. */
  37436. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  37437. /**
  37438. * Adds the given geometry to this scene
  37439. * @param newGeometry The geometry to add
  37440. */
  37441. addGeometry(newGeometry: Geometry): void;
  37442. /**
  37443. * Adds the given action manager to this scene
  37444. * @param newActionManager The action manager to add
  37445. */
  37446. addActionManager(newActionManager: AbstractActionManager): void;
  37447. /**
  37448. * Adds the given texture to this scene.
  37449. * @param newTexture The texture to add
  37450. */
  37451. addTexture(newTexture: BaseTexture): void;
  37452. /**
  37453. * Switch active camera
  37454. * @param newCamera defines the new active camera
  37455. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  37456. */
  37457. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  37458. /**
  37459. * sets the active camera of the scene using its ID
  37460. * @param id defines the camera's ID
  37461. * @return the new active camera or null if none found.
  37462. */
  37463. setActiveCameraByID(id: string): Nullable<Camera>;
  37464. /**
  37465. * sets the active camera of the scene using its name
  37466. * @param name defines the camera's name
  37467. * @returns the new active camera or null if none found.
  37468. */
  37469. setActiveCameraByName(name: string): Nullable<Camera>;
  37470. /**
  37471. * get an animation group using its name
  37472. * @param name defines the material's name
  37473. * @return the animation group or null if none found.
  37474. */
  37475. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  37476. /**
  37477. * Get a material using its unique id
  37478. * @param uniqueId defines the material's unique id
  37479. * @return the material or null if none found.
  37480. */
  37481. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  37482. /**
  37483. * get a material using its id
  37484. * @param id defines the material's ID
  37485. * @return the material or null if none found.
  37486. */
  37487. getMaterialByID(id: string): Nullable<Material>;
  37488. /**
  37489. * Gets a the last added material using a given id
  37490. * @param id defines the material's ID
  37491. * @return the last material with the given id or null if none found.
  37492. */
  37493. getLastMaterialByID(id: string): Nullable<Material>;
  37494. /**
  37495. * Gets a material using its name
  37496. * @param name defines the material's name
  37497. * @return the material or null if none found.
  37498. */
  37499. getMaterialByName(name: string): Nullable<Material>;
  37500. /**
  37501. * Get a texture using its unique id
  37502. * @param uniqueId defines the texture's unique id
  37503. * @return the texture or null if none found.
  37504. */
  37505. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  37506. /**
  37507. * Gets a camera using its id
  37508. * @param id defines the id to look for
  37509. * @returns the camera or null if not found
  37510. */
  37511. getCameraByID(id: string): Nullable<Camera>;
  37512. /**
  37513. * Gets a camera using its unique id
  37514. * @param uniqueId defines the unique id to look for
  37515. * @returns the camera or null if not found
  37516. */
  37517. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  37518. /**
  37519. * Gets a camera using its name
  37520. * @param name defines the camera's name
  37521. * @return the camera or null if none found.
  37522. */
  37523. getCameraByName(name: string): Nullable<Camera>;
  37524. /**
  37525. * Gets a bone using its id
  37526. * @param id defines the bone's id
  37527. * @return the bone or null if not found
  37528. */
  37529. getBoneByID(id: string): Nullable<Bone>;
  37530. /**
  37531. * Gets a bone using its id
  37532. * @param name defines the bone's name
  37533. * @return the bone or null if not found
  37534. */
  37535. getBoneByName(name: string): Nullable<Bone>;
  37536. /**
  37537. * Gets a light node using its name
  37538. * @param name defines the the light's name
  37539. * @return the light or null if none found.
  37540. */
  37541. getLightByName(name: string): Nullable<Light>;
  37542. /**
  37543. * Gets a light node using its id
  37544. * @param id defines the light's id
  37545. * @return the light or null if none found.
  37546. */
  37547. getLightByID(id: string): Nullable<Light>;
  37548. /**
  37549. * Gets a light node using its scene-generated unique ID
  37550. * @param uniqueId defines the light's unique id
  37551. * @return the light or null if none found.
  37552. */
  37553. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  37554. /**
  37555. * Gets a particle system by id
  37556. * @param id defines the particle system id
  37557. * @return the corresponding system or null if none found
  37558. */
  37559. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  37560. /**
  37561. * Gets a geometry using its ID
  37562. * @param id defines the geometry's id
  37563. * @return the geometry or null if none found.
  37564. */
  37565. getGeometryByID(id: string): Nullable<Geometry>;
  37566. private _getGeometryByUniqueID;
  37567. /**
  37568. * Add a new geometry to this scene
  37569. * @param geometry defines the geometry to be added to the scene.
  37570. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  37571. * @return a boolean defining if the geometry was added or not
  37572. */
  37573. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  37574. /**
  37575. * Removes an existing geometry
  37576. * @param geometry defines the geometry to be removed from the scene
  37577. * @return a boolean defining if the geometry was removed or not
  37578. */
  37579. removeGeometry(geometry: Geometry): boolean;
  37580. /**
  37581. * Gets the list of geometries attached to the scene
  37582. * @returns an array of Geometry
  37583. */
  37584. getGeometries(): Geometry[];
  37585. /**
  37586. * Gets the first added mesh found of a given ID
  37587. * @param id defines the id to search for
  37588. * @return the mesh found or null if not found at all
  37589. */
  37590. getMeshByID(id: string): Nullable<AbstractMesh>;
  37591. /**
  37592. * Gets a list of meshes using their id
  37593. * @param id defines the id to search for
  37594. * @returns a list of meshes
  37595. */
  37596. getMeshesByID(id: string): Array<AbstractMesh>;
  37597. /**
  37598. * Gets the first added transform node found of a given ID
  37599. * @param id defines the id to search for
  37600. * @return the found transform node or null if not found at all.
  37601. */
  37602. getTransformNodeByID(id: string): Nullable<TransformNode>;
  37603. /**
  37604. * Gets a transform node with its auto-generated unique id
  37605. * @param uniqueId efines the unique id to search for
  37606. * @return the found transform node or null if not found at all.
  37607. */
  37608. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  37609. /**
  37610. * Gets a list of transform nodes using their id
  37611. * @param id defines the id to search for
  37612. * @returns a list of transform nodes
  37613. */
  37614. getTransformNodesByID(id: string): Array<TransformNode>;
  37615. /**
  37616. * Gets a mesh with its auto-generated unique id
  37617. * @param uniqueId defines the unique id to search for
  37618. * @return the found mesh or null if not found at all.
  37619. */
  37620. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  37621. /**
  37622. * Gets a the last added mesh using a given id
  37623. * @param id defines the id to search for
  37624. * @return the found mesh or null if not found at all.
  37625. */
  37626. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  37627. /**
  37628. * Gets a the last added node (Mesh, Camera, Light) using a given id
  37629. * @param id defines the id to search for
  37630. * @return the found node or null if not found at all
  37631. */
  37632. getLastEntryByID(id: string): Nullable<Node>;
  37633. /**
  37634. * Gets a node (Mesh, Camera, Light) using a given id
  37635. * @param id defines the id to search for
  37636. * @return the found node or null if not found at all
  37637. */
  37638. getNodeByID(id: string): Nullable<Node>;
  37639. /**
  37640. * Gets a node (Mesh, Camera, Light) using a given name
  37641. * @param name defines the name to search for
  37642. * @return the found node or null if not found at all.
  37643. */
  37644. getNodeByName(name: string): Nullable<Node>;
  37645. /**
  37646. * Gets a mesh using a given name
  37647. * @param name defines the name to search for
  37648. * @return the found mesh or null if not found at all.
  37649. */
  37650. getMeshByName(name: string): Nullable<AbstractMesh>;
  37651. /**
  37652. * Gets a transform node using a given name
  37653. * @param name defines the name to search for
  37654. * @return the found transform node or null if not found at all.
  37655. */
  37656. getTransformNodeByName(name: string): Nullable<TransformNode>;
  37657. /**
  37658. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  37659. * @param id defines the id to search for
  37660. * @return the found skeleton or null if not found at all.
  37661. */
  37662. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  37663. /**
  37664. * Gets a skeleton using a given auto generated unique id
  37665. * @param uniqueId defines the unique id to search for
  37666. * @return the found skeleton or null if not found at all.
  37667. */
  37668. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  37669. /**
  37670. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  37671. * @param id defines the id to search for
  37672. * @return the found skeleton or null if not found at all.
  37673. */
  37674. getSkeletonById(id: string): Nullable<Skeleton>;
  37675. /**
  37676. * Gets a skeleton using a given name
  37677. * @param name defines the name to search for
  37678. * @return the found skeleton or null if not found at all.
  37679. */
  37680. getSkeletonByName(name: string): Nullable<Skeleton>;
  37681. /**
  37682. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  37683. * @param id defines the id to search for
  37684. * @return the found morph target manager or null if not found at all.
  37685. */
  37686. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  37687. /**
  37688. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  37689. * @param id defines the id to search for
  37690. * @return the found morph target or null if not found at all.
  37691. */
  37692. getMorphTargetById(id: string): Nullable<MorphTarget>;
  37693. /**
  37694. * Gets a boolean indicating if the given mesh is active
  37695. * @param mesh defines the mesh to look for
  37696. * @returns true if the mesh is in the active list
  37697. */
  37698. isActiveMesh(mesh: AbstractMesh): boolean;
  37699. /**
  37700. * Return a unique id as a string which can serve as an identifier for the scene
  37701. */
  37702. get uid(): string;
  37703. /**
  37704. * Add an externaly attached data from its key.
  37705. * This method call will fail and return false, if such key already exists.
  37706. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  37707. * @param key the unique key that identifies the data
  37708. * @param data the data object to associate to the key for this Engine instance
  37709. * @return true if no such key were already present and the data was added successfully, false otherwise
  37710. */
  37711. addExternalData<T>(key: string, data: T): boolean;
  37712. /**
  37713. * Get an externaly attached data from its key
  37714. * @param key the unique key that identifies the data
  37715. * @return the associated data, if present (can be null), or undefined if not present
  37716. */
  37717. getExternalData<T>(key: string): Nullable<T>;
  37718. /**
  37719. * Get an externaly attached data from its key, create it using a factory if it's not already present
  37720. * @param key the unique key that identifies the data
  37721. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37722. * @return the associated data, can be null if the factory returned null.
  37723. */
  37724. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37725. /**
  37726. * Remove an externaly attached data from the Engine instance
  37727. * @param key the unique key that identifies the data
  37728. * @return true if the data was successfully removed, false if it doesn't exist
  37729. */
  37730. removeExternalData(key: string): boolean;
  37731. private _evaluateSubMesh;
  37732. /**
  37733. * Clear the processed materials smart array preventing retention point in material dispose.
  37734. */
  37735. freeProcessedMaterials(): void;
  37736. private _preventFreeActiveMeshesAndRenderingGroups;
  37737. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37738. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37739. * when disposing several meshes in a row or a hierarchy of meshes.
  37740. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37741. */
  37742. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  37743. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  37744. /**
  37745. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37746. */
  37747. freeActiveMeshes(): void;
  37748. /**
  37749. * Clear the info related to rendering groups preventing retention points during dispose.
  37750. */
  37751. freeRenderingGroups(): void;
  37752. /** @hidden */
  37753. _isInIntermediateRendering(): boolean;
  37754. /**
  37755. * Lambda returning the list of potentially active meshes.
  37756. */
  37757. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37758. /**
  37759. * Lambda returning the list of potentially active sub meshes.
  37760. */
  37761. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37762. /**
  37763. * Lambda returning the list of potentially intersecting sub meshes.
  37764. */
  37765. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37766. /**
  37767. * Lambda returning the list of potentially colliding sub meshes.
  37768. */
  37769. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37770. private _activeMeshesFrozen;
  37771. private _skipEvaluateActiveMeshesCompletely;
  37772. /**
  37773. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37774. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37775. * @returns the current scene
  37776. */
  37777. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37778. /**
  37779. * Use this function to restart evaluating active meshes on every frame
  37780. * @returns the current scene
  37781. */
  37782. unfreezeActiveMeshes(): Scene;
  37783. private _evaluateActiveMeshes;
  37784. private _activeMesh;
  37785. /**
  37786. * Update the transform matrix to update from the current active camera
  37787. * @param force defines a boolean used to force the update even if cache is up to date
  37788. */
  37789. updateTransformMatrix(force?: boolean): void;
  37790. private _bindFrameBuffer;
  37791. /** @hidden */
  37792. _allowPostProcessClearColor: boolean;
  37793. /** @hidden */
  37794. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37795. private _processSubCameras;
  37796. private _checkIntersections;
  37797. /** @hidden */
  37798. _advancePhysicsEngineStep(step: number): void;
  37799. /**
  37800. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37801. */
  37802. getDeterministicFrameTime: () => number;
  37803. /** @hidden */
  37804. _animate(): void;
  37805. /** Execute all animations (for a frame) */
  37806. animate(): void;
  37807. /**
  37808. * Render the scene
  37809. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37810. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37811. */
  37812. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37813. /**
  37814. * Freeze all materials
  37815. * A frozen material will not be updatable but should be faster to render
  37816. */
  37817. freezeMaterials(): void;
  37818. /**
  37819. * Unfreeze all materials
  37820. * A frozen material will not be updatable but should be faster to render
  37821. */
  37822. unfreezeMaterials(): void;
  37823. /**
  37824. * Releases all held ressources
  37825. */
  37826. dispose(): void;
  37827. /**
  37828. * Gets if the scene is already disposed
  37829. */
  37830. get isDisposed(): boolean;
  37831. /**
  37832. * Call this function to reduce memory footprint of the scene.
  37833. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37834. */
  37835. clearCachedVertexData(): void;
  37836. /**
  37837. * This function will remove the local cached buffer data from texture.
  37838. * It will save memory but will prevent the texture from being rebuilt
  37839. */
  37840. cleanCachedTextureBuffer(): void;
  37841. /**
  37842. * Get the world extend vectors with an optional filter
  37843. *
  37844. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37845. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37846. */
  37847. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37848. min: Vector3;
  37849. max: Vector3;
  37850. };
  37851. /**
  37852. * Creates a ray that can be used to pick in the scene
  37853. * @param x defines the x coordinate of the origin (on-screen)
  37854. * @param y defines the y coordinate of the origin (on-screen)
  37855. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37856. * @param camera defines the camera to use for the picking
  37857. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37858. * @returns a Ray
  37859. */
  37860. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37861. /**
  37862. * Creates a ray that can be used to pick in the scene
  37863. * @param x defines the x coordinate of the origin (on-screen)
  37864. * @param y defines the y coordinate of the origin (on-screen)
  37865. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37866. * @param result defines the ray where to store the picking ray
  37867. * @param camera defines the camera to use for the picking
  37868. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37869. * @returns the current scene
  37870. */
  37871. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37872. /**
  37873. * Creates a ray that can be used to pick in the scene
  37874. * @param x defines the x coordinate of the origin (on-screen)
  37875. * @param y defines the y coordinate of the origin (on-screen)
  37876. * @param camera defines the camera to use for the picking
  37877. * @returns a Ray
  37878. */
  37879. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37880. /**
  37881. * Creates a ray that can be used to pick in the scene
  37882. * @param x defines the x coordinate of the origin (on-screen)
  37883. * @param y defines the y coordinate of the origin (on-screen)
  37884. * @param result defines the ray where to store the picking ray
  37885. * @param camera defines the camera to use for the picking
  37886. * @returns the current scene
  37887. */
  37888. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37889. /** Launch a ray to try to pick a mesh in the scene
  37890. * @param x position on screen
  37891. * @param y position on screen
  37892. * @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
  37893. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37894. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37895. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37896. * @returns a PickingInfo
  37897. */
  37898. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37899. /** Use the given ray to pick a mesh in the scene
  37900. * @param ray The ray to use to pick meshes
  37901. * @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
  37902. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  37903. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37904. * @returns a PickingInfo
  37905. */
  37906. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37907. /**
  37908. * Launch a ray to try to pick a mesh in the scene
  37909. * @param x X position on screen
  37910. * @param y Y position on screen
  37911. * @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
  37912. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37913. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37914. * @returns an array of PickingInfo
  37915. */
  37916. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37917. /**
  37918. * Launch a ray to try to pick a mesh in the scene
  37919. * @param ray Ray to use
  37920. * @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
  37921. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37922. * @returns an array of PickingInfo
  37923. */
  37924. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37925. /**
  37926. * Force the value of meshUnderPointer
  37927. * @param mesh defines the mesh to use
  37928. */
  37929. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37930. /**
  37931. * Gets the mesh under the pointer
  37932. * @returns a Mesh or null if no mesh is under the pointer
  37933. */
  37934. getPointerOverMesh(): Nullable<AbstractMesh>;
  37935. /** @hidden */
  37936. _rebuildGeometries(): void;
  37937. /** @hidden */
  37938. _rebuildTextures(): void;
  37939. private _getByTags;
  37940. /**
  37941. * Get a list of meshes by tags
  37942. * @param tagsQuery defines the tags query to use
  37943. * @param forEach defines a predicate used to filter results
  37944. * @returns an array of Mesh
  37945. */
  37946. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37947. /**
  37948. * Get a list of cameras by tags
  37949. * @param tagsQuery defines the tags query to use
  37950. * @param forEach defines a predicate used to filter results
  37951. * @returns an array of Camera
  37952. */
  37953. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37954. /**
  37955. * Get a list of lights by tags
  37956. * @param tagsQuery defines the tags query to use
  37957. * @param forEach defines a predicate used to filter results
  37958. * @returns an array of Light
  37959. */
  37960. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37961. /**
  37962. * Get a list of materials by tags
  37963. * @param tagsQuery defines the tags query to use
  37964. * @param forEach defines a predicate used to filter results
  37965. * @returns an array of Material
  37966. */
  37967. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37968. /**
  37969. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37970. * This allowed control for front to back rendering or reversly depending of the special needs.
  37971. *
  37972. * @param renderingGroupId The rendering group id corresponding to its index
  37973. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37974. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37975. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37976. */
  37977. 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;
  37978. /**
  37979. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37980. *
  37981. * @param renderingGroupId The rendering group id corresponding to its index
  37982. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37983. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37984. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37985. */
  37986. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37987. /**
  37988. * Gets the current auto clear configuration for one rendering group of the rendering
  37989. * manager.
  37990. * @param index the rendering group index to get the information for
  37991. * @returns The auto clear setup for the requested rendering group
  37992. */
  37993. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  37994. private _blockMaterialDirtyMechanism;
  37995. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  37996. get blockMaterialDirtyMechanism(): boolean;
  37997. set blockMaterialDirtyMechanism(value: boolean);
  37998. /**
  37999. * Will flag all materials as dirty to trigger new shader compilation
  38000. * @param flag defines the flag used to specify which material part must be marked as dirty
  38001. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  38002. */
  38003. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  38004. /** @hidden */
  38005. _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;
  38006. /** @hidden */
  38007. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38008. /** @hidden */
  38009. _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;
  38010. /** @hidden */
  38011. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  38012. /** @hidden */
  38013. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38014. /** @hidden */
  38015. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38016. }
  38017. }
  38018. declare module "babylonjs/assetContainer" {
  38019. import { AbstractScene } from "babylonjs/abstractScene";
  38020. import { Scene } from "babylonjs/scene";
  38021. import { Mesh } from "babylonjs/Meshes/mesh";
  38022. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38023. import { Skeleton } from "babylonjs/Bones/skeleton";
  38024. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38025. import { Animatable } from "babylonjs/Animations/animatable";
  38026. import { Nullable } from "babylonjs/types";
  38027. import { Node } from "babylonjs/node";
  38028. /**
  38029. * Set of assets to keep when moving a scene into an asset container.
  38030. */
  38031. export class KeepAssets extends AbstractScene {
  38032. }
  38033. /**
  38034. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  38035. */
  38036. export class InstantiatedEntries {
  38037. /**
  38038. * List of new root nodes (eg. nodes with no parent)
  38039. */
  38040. rootNodes: TransformNode[];
  38041. /**
  38042. * List of new skeletons
  38043. */
  38044. skeletons: Skeleton[];
  38045. /**
  38046. * List of new animation groups
  38047. */
  38048. animationGroups: AnimationGroup[];
  38049. }
  38050. /**
  38051. * Container with a set of assets that can be added or removed from a scene.
  38052. */
  38053. export class AssetContainer extends AbstractScene {
  38054. private _wasAddedToScene;
  38055. /**
  38056. * The scene the AssetContainer belongs to.
  38057. */
  38058. scene: Scene;
  38059. /**
  38060. * Instantiates an AssetContainer.
  38061. * @param scene The scene the AssetContainer belongs to.
  38062. */
  38063. constructor(scene: Scene);
  38064. /**
  38065. * Instantiate or clone all meshes and add the new ones to the scene.
  38066. * Skeletons and animation groups will all be cloned
  38067. * @param nameFunction defines an optional function used to get new names for clones
  38068. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  38069. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  38070. */
  38071. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  38072. /**
  38073. * Adds all the assets from the container to the scene.
  38074. */
  38075. addAllToScene(): void;
  38076. /**
  38077. * Removes all the assets in the container from the scene
  38078. */
  38079. removeAllFromScene(): void;
  38080. /**
  38081. * Disposes all the assets in the container
  38082. */
  38083. dispose(): void;
  38084. private _moveAssets;
  38085. /**
  38086. * Removes all the assets contained in the scene and adds them to the container.
  38087. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  38088. */
  38089. moveAllFromScene(keepAssets?: KeepAssets): void;
  38090. /**
  38091. * 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.
  38092. * @returns the root mesh
  38093. */
  38094. createRootMesh(): Mesh;
  38095. /**
  38096. * Merge animations from this asset container into a scene
  38097. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  38098. * @param animatables set of animatables to retarget to a node from the scene
  38099. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  38100. */
  38101. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  38102. }
  38103. }
  38104. declare module "babylonjs/abstractScene" {
  38105. import { Scene } from "babylonjs/scene";
  38106. import { Nullable } from "babylonjs/types";
  38107. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38108. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38109. import { Geometry } from "babylonjs/Meshes/geometry";
  38110. import { Skeleton } from "babylonjs/Bones/skeleton";
  38111. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  38112. import { AssetContainer } from "babylonjs/assetContainer";
  38113. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  38114. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38115. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38116. import { Material } from "babylonjs/Materials/material";
  38117. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  38118. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  38119. import { Camera } from "babylonjs/Cameras/camera";
  38120. import { Light } from "babylonjs/Lights/light";
  38121. import { Node } from "babylonjs/node";
  38122. import { Animation } from "babylonjs/Animations/animation";
  38123. /**
  38124. * Defines how the parser contract is defined.
  38125. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  38126. */
  38127. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  38128. /**
  38129. * Defines how the individual parser contract is defined.
  38130. * These parser can parse an individual asset
  38131. */
  38132. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  38133. /**
  38134. * Base class of the scene acting as a container for the different elements composing a scene.
  38135. * This class is dynamically extended by the different components of the scene increasing
  38136. * flexibility and reducing coupling
  38137. */
  38138. export abstract class AbstractScene {
  38139. /**
  38140. * Stores the list of available parsers in the application.
  38141. */
  38142. private static _BabylonFileParsers;
  38143. /**
  38144. * Stores the list of available individual parsers in the application.
  38145. */
  38146. private static _IndividualBabylonFileParsers;
  38147. /**
  38148. * Adds a parser in the list of available ones
  38149. * @param name Defines the name of the parser
  38150. * @param parser Defines the parser to add
  38151. */
  38152. static AddParser(name: string, parser: BabylonFileParser): void;
  38153. /**
  38154. * Gets a general parser from the list of avaialble ones
  38155. * @param name Defines the name of the parser
  38156. * @returns the requested parser or null
  38157. */
  38158. static GetParser(name: string): Nullable<BabylonFileParser>;
  38159. /**
  38160. * Adds n individual parser in the list of available ones
  38161. * @param name Defines the name of the parser
  38162. * @param parser Defines the parser to add
  38163. */
  38164. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  38165. /**
  38166. * Gets an individual parser from the list of avaialble ones
  38167. * @param name Defines the name of the parser
  38168. * @returns the requested parser or null
  38169. */
  38170. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  38171. /**
  38172. * Parser json data and populate both a scene and its associated container object
  38173. * @param jsonData Defines the data to parse
  38174. * @param scene Defines the scene to parse the data for
  38175. * @param container Defines the container attached to the parsing sequence
  38176. * @param rootUrl Defines the root url of the data
  38177. */
  38178. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  38179. /**
  38180. * Gets the list of root nodes (ie. nodes with no parent)
  38181. */
  38182. rootNodes: Node[];
  38183. /** All of the cameras added to this scene
  38184. * @see http://doc.babylonjs.com/babylon101/cameras
  38185. */
  38186. cameras: Camera[];
  38187. /**
  38188. * All of the lights added to this scene
  38189. * @see http://doc.babylonjs.com/babylon101/lights
  38190. */
  38191. lights: Light[];
  38192. /**
  38193. * All of the (abstract) meshes added to this scene
  38194. */
  38195. meshes: AbstractMesh[];
  38196. /**
  38197. * The list of skeletons added to the scene
  38198. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  38199. */
  38200. skeletons: Skeleton[];
  38201. /**
  38202. * All of the particle systems added to this scene
  38203. * @see http://doc.babylonjs.com/babylon101/particles
  38204. */
  38205. particleSystems: IParticleSystem[];
  38206. /**
  38207. * Gets a list of Animations associated with the scene
  38208. */
  38209. animations: Animation[];
  38210. /**
  38211. * All of the animation groups added to this scene
  38212. * @see http://doc.babylonjs.com/how_to/group
  38213. */
  38214. animationGroups: AnimationGroup[];
  38215. /**
  38216. * All of the multi-materials added to this scene
  38217. * @see http://doc.babylonjs.com/how_to/multi_materials
  38218. */
  38219. multiMaterials: MultiMaterial[];
  38220. /**
  38221. * All of the materials added to this scene
  38222. * In the context of a Scene, it is not supposed to be modified manually.
  38223. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  38224. * Note also that the order of the Material within the array is not significant and might change.
  38225. * @see http://doc.babylonjs.com/babylon101/materials
  38226. */
  38227. materials: Material[];
  38228. /**
  38229. * The list of morph target managers added to the scene
  38230. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  38231. */
  38232. morphTargetManagers: MorphTargetManager[];
  38233. /**
  38234. * The list of geometries used in the scene.
  38235. */
  38236. geometries: Geometry[];
  38237. /**
  38238. * All of the tranform nodes added to this scene
  38239. * In the context of a Scene, it is not supposed to be modified manually.
  38240. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  38241. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  38242. * @see http://doc.babylonjs.com/how_to/transformnode
  38243. */
  38244. transformNodes: TransformNode[];
  38245. /**
  38246. * ActionManagers available on the scene.
  38247. */
  38248. actionManagers: AbstractActionManager[];
  38249. /**
  38250. * Textures to keep.
  38251. */
  38252. textures: BaseTexture[];
  38253. /**
  38254. * Environment texture for the scene
  38255. */
  38256. environmentTexture: Nullable<BaseTexture>;
  38257. /**
  38258. * @returns all meshes, lights, cameras, transformNodes and bones
  38259. */
  38260. getNodes(): Array<Node>;
  38261. }
  38262. }
  38263. declare module "babylonjs/Audio/sound" {
  38264. import { Observable } from "babylonjs/Misc/observable";
  38265. import { Vector3 } from "babylonjs/Maths/math.vector";
  38266. import { Nullable } from "babylonjs/types";
  38267. import { Scene } from "babylonjs/scene";
  38268. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38269. /**
  38270. * Interface used to define options for Sound class
  38271. */
  38272. export interface ISoundOptions {
  38273. /**
  38274. * Does the sound autoplay once loaded.
  38275. */
  38276. autoplay?: boolean;
  38277. /**
  38278. * Does the sound loop after it finishes playing once.
  38279. */
  38280. loop?: boolean;
  38281. /**
  38282. * Sound's volume
  38283. */
  38284. volume?: number;
  38285. /**
  38286. * Is it a spatial sound?
  38287. */
  38288. spatialSound?: boolean;
  38289. /**
  38290. * Maximum distance to hear that sound
  38291. */
  38292. maxDistance?: number;
  38293. /**
  38294. * Uses user defined attenuation function
  38295. */
  38296. useCustomAttenuation?: boolean;
  38297. /**
  38298. * Define the roll off factor of spatial sounds.
  38299. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38300. */
  38301. rolloffFactor?: number;
  38302. /**
  38303. * Define the reference distance the sound should be heard perfectly.
  38304. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38305. */
  38306. refDistance?: number;
  38307. /**
  38308. * Define the distance attenuation model the sound will follow.
  38309. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38310. */
  38311. distanceModel?: string;
  38312. /**
  38313. * Defines the playback speed (1 by default)
  38314. */
  38315. playbackRate?: number;
  38316. /**
  38317. * Defines if the sound is from a streaming source
  38318. */
  38319. streaming?: boolean;
  38320. /**
  38321. * Defines an optional length (in seconds) inside the sound file
  38322. */
  38323. length?: number;
  38324. /**
  38325. * Defines an optional offset (in seconds) inside the sound file
  38326. */
  38327. offset?: number;
  38328. /**
  38329. * If true, URLs will not be required to state the audio file codec to use.
  38330. */
  38331. skipCodecCheck?: boolean;
  38332. }
  38333. /**
  38334. * Defines a sound that can be played in the application.
  38335. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  38336. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38337. */
  38338. export class Sound {
  38339. /**
  38340. * The name of the sound in the scene.
  38341. */
  38342. name: string;
  38343. /**
  38344. * Does the sound autoplay once loaded.
  38345. */
  38346. autoplay: boolean;
  38347. /**
  38348. * Does the sound loop after it finishes playing once.
  38349. */
  38350. loop: boolean;
  38351. /**
  38352. * Does the sound use a custom attenuation curve to simulate the falloff
  38353. * happening when the source gets further away from the camera.
  38354. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38355. */
  38356. useCustomAttenuation: boolean;
  38357. /**
  38358. * The sound track id this sound belongs to.
  38359. */
  38360. soundTrackId: number;
  38361. /**
  38362. * Is this sound currently played.
  38363. */
  38364. isPlaying: boolean;
  38365. /**
  38366. * Is this sound currently paused.
  38367. */
  38368. isPaused: boolean;
  38369. /**
  38370. * Does this sound enables spatial sound.
  38371. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38372. */
  38373. spatialSound: boolean;
  38374. /**
  38375. * Define the reference distance the sound should be heard perfectly.
  38376. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38377. */
  38378. refDistance: number;
  38379. /**
  38380. * Define the roll off factor of spatial sounds.
  38381. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38382. */
  38383. rolloffFactor: number;
  38384. /**
  38385. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  38386. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38387. */
  38388. maxDistance: number;
  38389. /**
  38390. * Define the distance attenuation model the sound will follow.
  38391. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38392. */
  38393. distanceModel: string;
  38394. /**
  38395. * @hidden
  38396. * Back Compat
  38397. **/
  38398. onended: () => any;
  38399. /**
  38400. * Observable event when the current playing sound finishes.
  38401. */
  38402. onEndedObservable: Observable<Sound>;
  38403. private _panningModel;
  38404. private _playbackRate;
  38405. private _streaming;
  38406. private _startTime;
  38407. private _startOffset;
  38408. private _position;
  38409. /** @hidden */
  38410. _positionInEmitterSpace: boolean;
  38411. private _localDirection;
  38412. private _volume;
  38413. private _isReadyToPlay;
  38414. private _isDirectional;
  38415. private _readyToPlayCallback;
  38416. private _audioBuffer;
  38417. private _soundSource;
  38418. private _streamingSource;
  38419. private _soundPanner;
  38420. private _soundGain;
  38421. private _inputAudioNode;
  38422. private _outputAudioNode;
  38423. private _coneInnerAngle;
  38424. private _coneOuterAngle;
  38425. private _coneOuterGain;
  38426. private _scene;
  38427. private _connectedTransformNode;
  38428. private _customAttenuationFunction;
  38429. private _registerFunc;
  38430. private _isOutputConnected;
  38431. private _htmlAudioElement;
  38432. private _urlType;
  38433. private _length?;
  38434. private _offset?;
  38435. /** @hidden */
  38436. static _SceneComponentInitialization: (scene: Scene) => void;
  38437. /**
  38438. * Create a sound and attach it to a scene
  38439. * @param name Name of your sound
  38440. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  38441. * @param scene defines the scene the sound belongs to
  38442. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  38443. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  38444. */
  38445. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  38446. /**
  38447. * Release the sound and its associated resources
  38448. */
  38449. dispose(): void;
  38450. /**
  38451. * Gets if the sounds is ready to be played or not.
  38452. * @returns true if ready, otherwise false
  38453. */
  38454. isReady(): boolean;
  38455. private _soundLoaded;
  38456. /**
  38457. * Sets the data of the sound from an audiobuffer
  38458. * @param audioBuffer The audioBuffer containing the data
  38459. */
  38460. setAudioBuffer(audioBuffer: AudioBuffer): void;
  38461. /**
  38462. * Updates the current sounds options such as maxdistance, loop...
  38463. * @param options A JSON object containing values named as the object properties
  38464. */
  38465. updateOptions(options: ISoundOptions): void;
  38466. private _createSpatialParameters;
  38467. private _updateSpatialParameters;
  38468. /**
  38469. * Switch the panning model to HRTF:
  38470. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38471. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38472. */
  38473. switchPanningModelToHRTF(): void;
  38474. /**
  38475. * Switch the panning model to Equal Power:
  38476. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38477. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38478. */
  38479. switchPanningModelToEqualPower(): void;
  38480. private _switchPanningModel;
  38481. /**
  38482. * Connect this sound to a sound track audio node like gain...
  38483. * @param soundTrackAudioNode the sound track audio node to connect to
  38484. */
  38485. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  38486. /**
  38487. * Transform this sound into a directional source
  38488. * @param coneInnerAngle Size of the inner cone in degree
  38489. * @param coneOuterAngle Size of the outer cone in degree
  38490. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  38491. */
  38492. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  38493. /**
  38494. * Gets or sets the inner angle for the directional cone.
  38495. */
  38496. get directionalConeInnerAngle(): number;
  38497. /**
  38498. * Gets or sets the inner angle for the directional cone.
  38499. */
  38500. set directionalConeInnerAngle(value: number);
  38501. /**
  38502. * Gets or sets the outer angle for the directional cone.
  38503. */
  38504. get directionalConeOuterAngle(): number;
  38505. /**
  38506. * Gets or sets the outer angle for the directional cone.
  38507. */
  38508. set directionalConeOuterAngle(value: number);
  38509. /**
  38510. * Sets the position of the emitter if spatial sound is enabled
  38511. * @param newPosition Defines the new posisiton
  38512. */
  38513. setPosition(newPosition: Vector3): void;
  38514. /**
  38515. * Sets the local direction of the emitter if spatial sound is enabled
  38516. * @param newLocalDirection Defines the new local direction
  38517. */
  38518. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  38519. private _updateDirection;
  38520. /** @hidden */
  38521. updateDistanceFromListener(): void;
  38522. /**
  38523. * Sets a new custom attenuation function for the sound.
  38524. * @param callback Defines the function used for the attenuation
  38525. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38526. */
  38527. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  38528. /**
  38529. * Play the sound
  38530. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  38531. * @param offset (optional) Start the sound at a specific time in seconds
  38532. * @param length (optional) Sound duration (in seconds)
  38533. */
  38534. play(time?: number, offset?: number, length?: number): void;
  38535. private _onended;
  38536. /**
  38537. * Stop the sound
  38538. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  38539. */
  38540. stop(time?: number): void;
  38541. /**
  38542. * Put the sound in pause
  38543. */
  38544. pause(): void;
  38545. /**
  38546. * Sets a dedicated volume for this sounds
  38547. * @param newVolume Define the new volume of the sound
  38548. * @param time Define time for gradual change to new volume
  38549. */
  38550. setVolume(newVolume: number, time?: number): void;
  38551. /**
  38552. * Set the sound play back rate
  38553. * @param newPlaybackRate Define the playback rate the sound should be played at
  38554. */
  38555. setPlaybackRate(newPlaybackRate: number): void;
  38556. /**
  38557. * Gets the volume of the sound.
  38558. * @returns the volume of the sound
  38559. */
  38560. getVolume(): number;
  38561. /**
  38562. * Attach the sound to a dedicated mesh
  38563. * @param transformNode The transform node to connect the sound with
  38564. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38565. */
  38566. attachToMesh(transformNode: TransformNode): void;
  38567. /**
  38568. * Detach the sound from the previously attached mesh
  38569. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38570. */
  38571. detachFromMesh(): void;
  38572. private _onRegisterAfterWorldMatrixUpdate;
  38573. /**
  38574. * Clone the current sound in the scene.
  38575. * @returns the new sound clone
  38576. */
  38577. clone(): Nullable<Sound>;
  38578. /**
  38579. * Gets the current underlying audio buffer containing the data
  38580. * @returns the audio buffer
  38581. */
  38582. getAudioBuffer(): Nullable<AudioBuffer>;
  38583. /**
  38584. * Serializes the Sound in a JSON representation
  38585. * @returns the JSON representation of the sound
  38586. */
  38587. serialize(): any;
  38588. /**
  38589. * Parse a JSON representation of a sound to innstantiate in a given scene
  38590. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  38591. * @param scene Define the scene the new parsed sound should be created in
  38592. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  38593. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  38594. * @returns the newly parsed sound
  38595. */
  38596. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  38597. }
  38598. }
  38599. declare module "babylonjs/Actions/directAudioActions" {
  38600. import { Action } from "babylonjs/Actions/action";
  38601. import { Condition } from "babylonjs/Actions/condition";
  38602. import { Sound } from "babylonjs/Audio/sound";
  38603. /**
  38604. * This defines an action helpful to play a defined sound on a triggered action.
  38605. */
  38606. export class PlaySoundAction extends Action {
  38607. private _sound;
  38608. /**
  38609. * Instantiate the action
  38610. * @param triggerOptions defines the trigger options
  38611. * @param sound defines the sound to play
  38612. * @param condition defines the trigger related conditions
  38613. */
  38614. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38615. /** @hidden */
  38616. _prepare(): void;
  38617. /**
  38618. * Execute the action and play the sound.
  38619. */
  38620. execute(): void;
  38621. /**
  38622. * Serializes the actions and its related information.
  38623. * @param parent defines the object to serialize in
  38624. * @returns the serialized object
  38625. */
  38626. serialize(parent: any): any;
  38627. }
  38628. /**
  38629. * This defines an action helpful to stop a defined sound on a triggered action.
  38630. */
  38631. export class StopSoundAction extends Action {
  38632. private _sound;
  38633. /**
  38634. * Instantiate the action
  38635. * @param triggerOptions defines the trigger options
  38636. * @param sound defines the sound to stop
  38637. * @param condition defines the trigger related conditions
  38638. */
  38639. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38640. /** @hidden */
  38641. _prepare(): void;
  38642. /**
  38643. * Execute the action and stop the sound.
  38644. */
  38645. execute(): void;
  38646. /**
  38647. * Serializes the actions and its related information.
  38648. * @param parent defines the object to serialize in
  38649. * @returns the serialized object
  38650. */
  38651. serialize(parent: any): any;
  38652. }
  38653. }
  38654. declare module "babylonjs/Actions/interpolateValueAction" {
  38655. import { Action } from "babylonjs/Actions/action";
  38656. import { Condition } from "babylonjs/Actions/condition";
  38657. import { Observable } from "babylonjs/Misc/observable";
  38658. /**
  38659. * This defines an action responsible to change the value of a property
  38660. * by interpolating between its current value and the newly set one once triggered.
  38661. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38662. */
  38663. export class InterpolateValueAction extends Action {
  38664. /**
  38665. * Defines the path of the property where the value should be interpolated
  38666. */
  38667. propertyPath: string;
  38668. /**
  38669. * Defines the target value at the end of the interpolation.
  38670. */
  38671. value: any;
  38672. /**
  38673. * Defines the time it will take for the property to interpolate to the value.
  38674. */
  38675. duration: number;
  38676. /**
  38677. * Defines if the other scene animations should be stopped when the action has been triggered
  38678. */
  38679. stopOtherAnimations?: boolean;
  38680. /**
  38681. * Defines a callback raised once the interpolation animation has been done.
  38682. */
  38683. onInterpolationDone?: () => void;
  38684. /**
  38685. * Observable triggered once the interpolation animation has been done.
  38686. */
  38687. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  38688. private _target;
  38689. private _effectiveTarget;
  38690. private _property;
  38691. /**
  38692. * Instantiate the action
  38693. * @param triggerOptions defines the trigger options
  38694. * @param target defines the object containing the value to interpolate
  38695. * @param propertyPath defines the path to the property in the target object
  38696. * @param value defines the target value at the end of the interpolation
  38697. * @param duration deines the time it will take for the property to interpolate to the value.
  38698. * @param condition defines the trigger related conditions
  38699. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  38700. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  38701. */
  38702. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  38703. /** @hidden */
  38704. _prepare(): void;
  38705. /**
  38706. * Execute the action starts the value interpolation.
  38707. */
  38708. execute(): void;
  38709. /**
  38710. * Serializes the actions and its related information.
  38711. * @param parent defines the object to serialize in
  38712. * @returns the serialized object
  38713. */
  38714. serialize(parent: any): any;
  38715. }
  38716. }
  38717. declare module "babylonjs/Actions/index" {
  38718. export * from "babylonjs/Actions/abstractActionManager";
  38719. export * from "babylonjs/Actions/action";
  38720. export * from "babylonjs/Actions/actionEvent";
  38721. export * from "babylonjs/Actions/actionManager";
  38722. export * from "babylonjs/Actions/condition";
  38723. export * from "babylonjs/Actions/directActions";
  38724. export * from "babylonjs/Actions/directAudioActions";
  38725. export * from "babylonjs/Actions/interpolateValueAction";
  38726. }
  38727. declare module "babylonjs/Animations/index" {
  38728. export * from "babylonjs/Animations/animatable";
  38729. export * from "babylonjs/Animations/animation";
  38730. export * from "babylonjs/Animations/animationGroup";
  38731. export * from "babylonjs/Animations/animationPropertiesOverride";
  38732. export * from "babylonjs/Animations/easing";
  38733. export * from "babylonjs/Animations/runtimeAnimation";
  38734. export * from "babylonjs/Animations/animationEvent";
  38735. export * from "babylonjs/Animations/animationGroup";
  38736. export * from "babylonjs/Animations/animationKey";
  38737. export * from "babylonjs/Animations/animationRange";
  38738. export * from "babylonjs/Animations/animatable.interface";
  38739. }
  38740. declare module "babylonjs/Audio/soundTrack" {
  38741. import { Sound } from "babylonjs/Audio/sound";
  38742. import { Analyser } from "babylonjs/Audio/analyser";
  38743. import { Scene } from "babylonjs/scene";
  38744. /**
  38745. * Options allowed during the creation of a sound track.
  38746. */
  38747. export interface ISoundTrackOptions {
  38748. /**
  38749. * The volume the sound track should take during creation
  38750. */
  38751. volume?: number;
  38752. /**
  38753. * Define if the sound track is the main sound track of the scene
  38754. */
  38755. mainTrack?: boolean;
  38756. }
  38757. /**
  38758. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  38759. * It will be also used in a future release to apply effects on a specific track.
  38760. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38761. */
  38762. export class SoundTrack {
  38763. /**
  38764. * The unique identifier of the sound track in the scene.
  38765. */
  38766. id: number;
  38767. /**
  38768. * The list of sounds included in the sound track.
  38769. */
  38770. soundCollection: Array<Sound>;
  38771. private _outputAudioNode;
  38772. private _scene;
  38773. private _connectedAnalyser;
  38774. private _options;
  38775. private _isInitialized;
  38776. /**
  38777. * Creates a new sound track.
  38778. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38779. * @param scene Define the scene the sound track belongs to
  38780. * @param options
  38781. */
  38782. constructor(scene: Scene, options?: ISoundTrackOptions);
  38783. private _initializeSoundTrackAudioGraph;
  38784. /**
  38785. * Release the sound track and its associated resources
  38786. */
  38787. dispose(): void;
  38788. /**
  38789. * Adds a sound to this sound track
  38790. * @param sound define the cound to add
  38791. * @ignoreNaming
  38792. */
  38793. AddSound(sound: Sound): void;
  38794. /**
  38795. * Removes a sound to this sound track
  38796. * @param sound define the cound to remove
  38797. * @ignoreNaming
  38798. */
  38799. RemoveSound(sound: Sound): void;
  38800. /**
  38801. * Set a global volume for the full sound track.
  38802. * @param newVolume Define the new volume of the sound track
  38803. */
  38804. setVolume(newVolume: number): void;
  38805. /**
  38806. * Switch the panning model to HRTF:
  38807. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38808. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38809. */
  38810. switchPanningModelToHRTF(): void;
  38811. /**
  38812. * Switch the panning model to Equal Power:
  38813. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38814. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38815. */
  38816. switchPanningModelToEqualPower(): void;
  38817. /**
  38818. * Connect the sound track to an audio analyser allowing some amazing
  38819. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38820. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38821. * @param analyser The analyser to connect to the engine
  38822. */
  38823. connectToAnalyser(analyser: Analyser): void;
  38824. }
  38825. }
  38826. declare module "babylonjs/Audio/audioSceneComponent" {
  38827. import { Sound } from "babylonjs/Audio/sound";
  38828. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  38829. import { Nullable } from "babylonjs/types";
  38830. import { Vector3 } from "babylonjs/Maths/math.vector";
  38831. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  38832. import { Scene } from "babylonjs/scene";
  38833. import { AbstractScene } from "babylonjs/abstractScene";
  38834. import "babylonjs/Audio/audioEngine";
  38835. module "babylonjs/abstractScene" {
  38836. interface AbstractScene {
  38837. /**
  38838. * The list of sounds used in the scene.
  38839. */
  38840. sounds: Nullable<Array<Sound>>;
  38841. }
  38842. }
  38843. module "babylonjs/scene" {
  38844. interface Scene {
  38845. /**
  38846. * @hidden
  38847. * Backing field
  38848. */
  38849. _mainSoundTrack: SoundTrack;
  38850. /**
  38851. * The main sound track played by the scene.
  38852. * It cotains your primary collection of sounds.
  38853. */
  38854. mainSoundTrack: SoundTrack;
  38855. /**
  38856. * The list of sound tracks added to the scene
  38857. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38858. */
  38859. soundTracks: Nullable<Array<SoundTrack>>;
  38860. /**
  38861. * Gets a sound using a given name
  38862. * @param name defines the name to search for
  38863. * @return the found sound or null if not found at all.
  38864. */
  38865. getSoundByName(name: string): Nullable<Sound>;
  38866. /**
  38867. * Gets or sets if audio support is enabled
  38868. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38869. */
  38870. audioEnabled: boolean;
  38871. /**
  38872. * Gets or sets if audio will be output to headphones
  38873. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38874. */
  38875. headphone: boolean;
  38876. /**
  38877. * Gets or sets custom audio listener position provider
  38878. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38879. */
  38880. audioListenerPositionProvider: Nullable<() => Vector3>;
  38881. /**
  38882. * Gets or sets a refresh rate when using 3D audio positioning
  38883. */
  38884. audioPositioningRefreshRate: number;
  38885. }
  38886. }
  38887. /**
  38888. * Defines the sound scene component responsible to manage any sounds
  38889. * in a given scene.
  38890. */
  38891. export class AudioSceneComponent implements ISceneSerializableComponent {
  38892. /**
  38893. * The component name helpfull to identify the component in the list of scene components.
  38894. */
  38895. readonly name: string;
  38896. /**
  38897. * The scene the component belongs to.
  38898. */
  38899. scene: Scene;
  38900. private _audioEnabled;
  38901. /**
  38902. * Gets whether audio is enabled or not.
  38903. * Please use related enable/disable method to switch state.
  38904. */
  38905. get audioEnabled(): boolean;
  38906. private _headphone;
  38907. /**
  38908. * Gets whether audio is outputing to headphone or not.
  38909. * Please use the according Switch methods to change output.
  38910. */
  38911. get headphone(): boolean;
  38912. /**
  38913. * Gets or sets a refresh rate when using 3D audio positioning
  38914. */
  38915. audioPositioningRefreshRate: number;
  38916. private _audioListenerPositionProvider;
  38917. /**
  38918. * Gets the current audio listener position provider
  38919. */
  38920. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  38921. /**
  38922. * Sets a custom listener position for all sounds in the scene
  38923. * By default, this is the position of the first active camera
  38924. */
  38925. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  38926. /**
  38927. * Creates a new instance of the component for the given scene
  38928. * @param scene Defines the scene to register the component in
  38929. */
  38930. constructor(scene: Scene);
  38931. /**
  38932. * Registers the component in a given scene
  38933. */
  38934. register(): void;
  38935. /**
  38936. * Rebuilds the elements related to this component in case of
  38937. * context lost for instance.
  38938. */
  38939. rebuild(): void;
  38940. /**
  38941. * Serializes the component data to the specified json object
  38942. * @param serializationObject The object to serialize to
  38943. */
  38944. serialize(serializationObject: any): void;
  38945. /**
  38946. * Adds all the elements from the container to the scene
  38947. * @param container the container holding the elements
  38948. */
  38949. addFromContainer(container: AbstractScene): void;
  38950. /**
  38951. * Removes all the elements in the container from the scene
  38952. * @param container contains the elements to remove
  38953. * @param dispose if the removed element should be disposed (default: false)
  38954. */
  38955. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38956. /**
  38957. * Disposes the component and the associated ressources.
  38958. */
  38959. dispose(): void;
  38960. /**
  38961. * Disables audio in the associated scene.
  38962. */
  38963. disableAudio(): void;
  38964. /**
  38965. * Enables audio in the associated scene.
  38966. */
  38967. enableAudio(): void;
  38968. /**
  38969. * Switch audio to headphone output.
  38970. */
  38971. switchAudioModeForHeadphones(): void;
  38972. /**
  38973. * Switch audio to normal speakers.
  38974. */
  38975. switchAudioModeForNormalSpeakers(): void;
  38976. private _cachedCameraDirection;
  38977. private _cachedCameraPosition;
  38978. private _lastCheck;
  38979. private _afterRender;
  38980. }
  38981. }
  38982. declare module "babylonjs/Audio/weightedsound" {
  38983. import { Sound } from "babylonjs/Audio/sound";
  38984. /**
  38985. * Wraps one or more Sound objects and selects one with random weight for playback.
  38986. */
  38987. export class WeightedSound {
  38988. /** When true a Sound will be selected and played when the current playing Sound completes. */
  38989. loop: boolean;
  38990. private _coneInnerAngle;
  38991. private _coneOuterAngle;
  38992. private _volume;
  38993. /** A Sound is currently playing. */
  38994. isPlaying: boolean;
  38995. /** A Sound is currently paused. */
  38996. isPaused: boolean;
  38997. private _sounds;
  38998. private _weights;
  38999. private _currentIndex?;
  39000. /**
  39001. * Creates a new WeightedSound from the list of sounds given.
  39002. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  39003. * @param sounds Array of Sounds that will be selected from.
  39004. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  39005. */
  39006. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  39007. /**
  39008. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  39009. */
  39010. get directionalConeInnerAngle(): number;
  39011. /**
  39012. * The size of cone in degress for a directional sound in which there will be no attenuation.
  39013. */
  39014. set directionalConeInnerAngle(value: number);
  39015. /**
  39016. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  39017. * Listener angles between innerAngle and outerAngle will falloff linearly.
  39018. */
  39019. get directionalConeOuterAngle(): number;
  39020. /**
  39021. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  39022. * Listener angles between innerAngle and outerAngle will falloff linearly.
  39023. */
  39024. set directionalConeOuterAngle(value: number);
  39025. /**
  39026. * Playback volume.
  39027. */
  39028. get volume(): number;
  39029. /**
  39030. * Playback volume.
  39031. */
  39032. set volume(value: number);
  39033. private _onended;
  39034. /**
  39035. * Suspend playback
  39036. */
  39037. pause(): void;
  39038. /**
  39039. * Stop playback
  39040. */
  39041. stop(): void;
  39042. /**
  39043. * Start playback.
  39044. * @param startOffset Position the clip head at a specific time in seconds.
  39045. */
  39046. play(startOffset?: number): void;
  39047. }
  39048. }
  39049. declare module "babylonjs/Audio/index" {
  39050. export * from "babylonjs/Audio/analyser";
  39051. export * from "babylonjs/Audio/audioEngine";
  39052. export * from "babylonjs/Audio/audioSceneComponent";
  39053. export * from "babylonjs/Audio/sound";
  39054. export * from "babylonjs/Audio/soundTrack";
  39055. export * from "babylonjs/Audio/weightedsound";
  39056. }
  39057. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  39058. import { Behavior } from "babylonjs/Behaviors/behavior";
  39059. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39060. import { BackEase } from "babylonjs/Animations/easing";
  39061. /**
  39062. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  39063. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39064. */
  39065. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  39066. /**
  39067. * Gets the name of the behavior.
  39068. */
  39069. get name(): string;
  39070. /**
  39071. * The easing function used by animations
  39072. */
  39073. static EasingFunction: BackEase;
  39074. /**
  39075. * The easing mode used by animations
  39076. */
  39077. static EasingMode: number;
  39078. /**
  39079. * The duration of the animation, in milliseconds
  39080. */
  39081. transitionDuration: number;
  39082. /**
  39083. * Length of the distance animated by the transition when lower radius is reached
  39084. */
  39085. lowerRadiusTransitionRange: number;
  39086. /**
  39087. * Length of the distance animated by the transition when upper radius is reached
  39088. */
  39089. upperRadiusTransitionRange: number;
  39090. private _autoTransitionRange;
  39091. /**
  39092. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39093. */
  39094. get autoTransitionRange(): boolean;
  39095. /**
  39096. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39097. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  39098. */
  39099. set autoTransitionRange(value: boolean);
  39100. private _attachedCamera;
  39101. private _onAfterCheckInputsObserver;
  39102. private _onMeshTargetChangedObserver;
  39103. /**
  39104. * Initializes the behavior.
  39105. */
  39106. init(): void;
  39107. /**
  39108. * Attaches the behavior to its arc rotate camera.
  39109. * @param camera Defines the camera to attach the behavior to
  39110. */
  39111. attach(camera: ArcRotateCamera): void;
  39112. /**
  39113. * Detaches the behavior from its current arc rotate camera.
  39114. */
  39115. detach(): void;
  39116. private _radiusIsAnimating;
  39117. private _radiusBounceTransition;
  39118. private _animatables;
  39119. private _cachedWheelPrecision;
  39120. /**
  39121. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  39122. * @param radiusLimit The limit to check against.
  39123. * @return Bool to indicate if at limit.
  39124. */
  39125. private _isRadiusAtLimit;
  39126. /**
  39127. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  39128. * @param radiusDelta The delta by which to animate to. Can be negative.
  39129. */
  39130. private _applyBoundRadiusAnimation;
  39131. /**
  39132. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  39133. */
  39134. protected _clearAnimationLocks(): void;
  39135. /**
  39136. * Stops and removes all animations that have been applied to the camera
  39137. */
  39138. stopAllAnimations(): void;
  39139. }
  39140. }
  39141. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  39142. import { Behavior } from "babylonjs/Behaviors/behavior";
  39143. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39144. import { ExponentialEase } from "babylonjs/Animations/easing";
  39145. import { Nullable } from "babylonjs/types";
  39146. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39147. import { Vector3 } from "babylonjs/Maths/math.vector";
  39148. /**
  39149. * 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.
  39150. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39151. */
  39152. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  39153. /**
  39154. * Gets the name of the behavior.
  39155. */
  39156. get name(): string;
  39157. private _mode;
  39158. private _radiusScale;
  39159. private _positionScale;
  39160. private _defaultElevation;
  39161. private _elevationReturnTime;
  39162. private _elevationReturnWaitTime;
  39163. private _zoomStopsAnimation;
  39164. private _framingTime;
  39165. /**
  39166. * The easing function used by animations
  39167. */
  39168. static EasingFunction: ExponentialEase;
  39169. /**
  39170. * The easing mode used by animations
  39171. */
  39172. static EasingMode: number;
  39173. /**
  39174. * Sets the current mode used by the behavior
  39175. */
  39176. set mode(mode: number);
  39177. /**
  39178. * Gets current mode used by the behavior.
  39179. */
  39180. get mode(): number;
  39181. /**
  39182. * Sets the scale applied to the radius (1 by default)
  39183. */
  39184. set radiusScale(radius: number);
  39185. /**
  39186. * Gets the scale applied to the radius
  39187. */
  39188. get radiusScale(): number;
  39189. /**
  39190. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39191. */
  39192. set positionScale(scale: number);
  39193. /**
  39194. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39195. */
  39196. get positionScale(): number;
  39197. /**
  39198. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39199. * behaviour is triggered, in radians.
  39200. */
  39201. set defaultElevation(elevation: number);
  39202. /**
  39203. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39204. * behaviour is triggered, in radians.
  39205. */
  39206. get defaultElevation(): number;
  39207. /**
  39208. * Sets the time (in milliseconds) taken to return to the default beta position.
  39209. * Negative value indicates camera should not return to default.
  39210. */
  39211. set elevationReturnTime(speed: number);
  39212. /**
  39213. * Gets the time (in milliseconds) taken to return to the default beta position.
  39214. * Negative value indicates camera should not return to default.
  39215. */
  39216. get elevationReturnTime(): number;
  39217. /**
  39218. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39219. */
  39220. set elevationReturnWaitTime(time: number);
  39221. /**
  39222. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39223. */
  39224. get elevationReturnWaitTime(): number;
  39225. /**
  39226. * Sets the flag that indicates if user zooming should stop animation.
  39227. */
  39228. set zoomStopsAnimation(flag: boolean);
  39229. /**
  39230. * Gets the flag that indicates if user zooming should stop animation.
  39231. */
  39232. get zoomStopsAnimation(): boolean;
  39233. /**
  39234. * Sets the transition time when framing the mesh, in milliseconds
  39235. */
  39236. set framingTime(time: number);
  39237. /**
  39238. * Gets the transition time when framing the mesh, in milliseconds
  39239. */
  39240. get framingTime(): number;
  39241. /**
  39242. * Define if the behavior should automatically change the configured
  39243. * camera limits and sensibilities.
  39244. */
  39245. autoCorrectCameraLimitsAndSensibility: boolean;
  39246. private _onPrePointerObservableObserver;
  39247. private _onAfterCheckInputsObserver;
  39248. private _onMeshTargetChangedObserver;
  39249. private _attachedCamera;
  39250. private _isPointerDown;
  39251. private _lastInteractionTime;
  39252. /**
  39253. * Initializes the behavior.
  39254. */
  39255. init(): void;
  39256. /**
  39257. * Attaches the behavior to its arc rotate camera.
  39258. * @param camera Defines the camera to attach the behavior to
  39259. */
  39260. attach(camera: ArcRotateCamera): void;
  39261. /**
  39262. * Detaches the behavior from its current arc rotate camera.
  39263. */
  39264. detach(): void;
  39265. private _animatables;
  39266. private _betaIsAnimating;
  39267. private _betaTransition;
  39268. private _radiusTransition;
  39269. private _vectorTransition;
  39270. /**
  39271. * Targets the given mesh and updates zoom level accordingly.
  39272. * @param mesh The mesh to target.
  39273. * @param radius Optional. If a cached radius position already exists, overrides default.
  39274. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  39275. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39276. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39277. */
  39278. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39279. /**
  39280. * Targets the given mesh with its children and updates zoom level accordingly.
  39281. * @param mesh The mesh to target.
  39282. * @param radius Optional. If a cached radius position already exists, overrides default.
  39283. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  39284. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39285. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39286. */
  39287. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39288. /**
  39289. * Targets the given meshes with their children and updates zoom level accordingly.
  39290. * @param meshes The mesh to target.
  39291. * @param radius Optional. If a cached radius position already exists, overrides default.
  39292. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  39293. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39294. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39295. */
  39296. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39297. /**
  39298. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  39299. * @param minimumWorld Determines the smaller position of the bounding box extend
  39300. * @param maximumWorld Determines the bigger position of the bounding box extend
  39301. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39302. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39303. */
  39304. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39305. /**
  39306. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  39307. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  39308. * frustum width.
  39309. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  39310. * to fully enclose the mesh in the viewing frustum.
  39311. */
  39312. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  39313. /**
  39314. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  39315. * is automatically returned to its default position (expected to be above ground plane).
  39316. */
  39317. private _maintainCameraAboveGround;
  39318. /**
  39319. * Returns the frustum slope based on the canvas ratio and camera FOV
  39320. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  39321. */
  39322. private _getFrustumSlope;
  39323. /**
  39324. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  39325. */
  39326. private _clearAnimationLocks;
  39327. /**
  39328. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39329. */
  39330. private _applyUserInteraction;
  39331. /**
  39332. * Stops and removes all animations that have been applied to the camera
  39333. */
  39334. stopAllAnimations(): void;
  39335. /**
  39336. * Gets a value indicating if the user is moving the camera
  39337. */
  39338. get isUserIsMoving(): boolean;
  39339. /**
  39340. * The camera can move all the way towards the mesh.
  39341. */
  39342. static IgnoreBoundsSizeMode: number;
  39343. /**
  39344. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  39345. */
  39346. static FitFrustumSidesMode: number;
  39347. }
  39348. }
  39349. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  39350. import { Nullable } from "babylonjs/types";
  39351. import { Camera } from "babylonjs/Cameras/camera";
  39352. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39353. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39354. /**
  39355. * Base class for Camera Pointer Inputs.
  39356. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  39357. * for example usage.
  39358. */
  39359. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  39360. /**
  39361. * Defines the camera the input is attached to.
  39362. */
  39363. abstract camera: Camera;
  39364. /**
  39365. * Whether keyboard modifier keys are pressed at time of last mouse event.
  39366. */
  39367. protected _altKey: boolean;
  39368. protected _ctrlKey: boolean;
  39369. protected _metaKey: boolean;
  39370. protected _shiftKey: boolean;
  39371. /**
  39372. * Which mouse buttons were pressed at time of last mouse event.
  39373. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  39374. */
  39375. protected _buttonsPressed: number;
  39376. /**
  39377. * Defines the buttons associated with the input to handle camera move.
  39378. */
  39379. buttons: number[];
  39380. /**
  39381. * Attach the input controls to a specific dom element to get the input from.
  39382. * @param element Defines the element the controls should be listened from
  39383. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39384. */
  39385. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39386. /**
  39387. * Detach the current controls from the specified dom element.
  39388. * @param element Defines the element to stop listening the inputs from
  39389. */
  39390. detachControl(element: Nullable<HTMLElement>): void;
  39391. /**
  39392. * Gets the class name of the current input.
  39393. * @returns the class name
  39394. */
  39395. getClassName(): string;
  39396. /**
  39397. * Get the friendly name associated with the input class.
  39398. * @returns the input friendly name
  39399. */
  39400. getSimpleName(): string;
  39401. /**
  39402. * Called on pointer POINTERDOUBLETAP event.
  39403. * Override this method to provide functionality on POINTERDOUBLETAP event.
  39404. */
  39405. protected onDoubleTap(type: string): void;
  39406. /**
  39407. * Called on pointer POINTERMOVE event if only a single touch is active.
  39408. * Override this method to provide functionality.
  39409. */
  39410. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39411. /**
  39412. * Called on pointer POINTERMOVE event if multiple touches are active.
  39413. * Override this method to provide functionality.
  39414. */
  39415. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39416. /**
  39417. * Called on JS contextmenu event.
  39418. * Override this method to provide functionality.
  39419. */
  39420. protected onContextMenu(evt: PointerEvent): void;
  39421. /**
  39422. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39423. * press.
  39424. * Override this method to provide functionality.
  39425. */
  39426. protected onButtonDown(evt: PointerEvent): void;
  39427. /**
  39428. * Called each time a new POINTERUP event occurs. Ie, for each button
  39429. * release.
  39430. * Override this method to provide functionality.
  39431. */
  39432. protected onButtonUp(evt: PointerEvent): void;
  39433. /**
  39434. * Called when window becomes inactive.
  39435. * Override this method to provide functionality.
  39436. */
  39437. protected onLostFocus(): void;
  39438. private _pointerInput;
  39439. private _observer;
  39440. private _onLostFocus;
  39441. private pointA;
  39442. private pointB;
  39443. }
  39444. }
  39445. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  39446. import { Nullable } from "babylonjs/types";
  39447. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39448. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39449. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39450. /**
  39451. * Manage the pointers inputs to control an arc rotate camera.
  39452. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39453. */
  39454. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  39455. /**
  39456. * Defines the camera the input is attached to.
  39457. */
  39458. camera: ArcRotateCamera;
  39459. /**
  39460. * Gets the class name of the current input.
  39461. * @returns the class name
  39462. */
  39463. getClassName(): string;
  39464. /**
  39465. * Defines the buttons associated with the input to handle camera move.
  39466. */
  39467. buttons: number[];
  39468. /**
  39469. * Defines the pointer angular sensibility along the X axis or how fast is
  39470. * the camera rotating.
  39471. */
  39472. angularSensibilityX: number;
  39473. /**
  39474. * Defines the pointer angular sensibility along the Y axis or how fast is
  39475. * the camera rotating.
  39476. */
  39477. angularSensibilityY: number;
  39478. /**
  39479. * Defines the pointer pinch precision or how fast is the camera zooming.
  39480. */
  39481. pinchPrecision: number;
  39482. /**
  39483. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39484. * from 0.
  39485. * It defines the percentage of current camera.radius to use as delta when
  39486. * pinch zoom is used.
  39487. */
  39488. pinchDeltaPercentage: number;
  39489. /**
  39490. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39491. * that any object in the plane at the camera's target point will scale
  39492. * perfectly with finger motion.
  39493. * Overrides pinchDeltaPercentage and pinchPrecision.
  39494. */
  39495. useNaturalPinchZoom: boolean;
  39496. /**
  39497. * Defines the pointer panning sensibility or how fast is the camera moving.
  39498. */
  39499. panningSensibility: number;
  39500. /**
  39501. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  39502. */
  39503. multiTouchPanning: boolean;
  39504. /**
  39505. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  39506. * zoom (pinch) through multitouch.
  39507. */
  39508. multiTouchPanAndZoom: boolean;
  39509. /**
  39510. * Revers pinch action direction.
  39511. */
  39512. pinchInwards: boolean;
  39513. private _isPanClick;
  39514. private _twoFingerActivityCount;
  39515. private _isPinching;
  39516. /**
  39517. * Called on pointer POINTERMOVE event if only a single touch is active.
  39518. */
  39519. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39520. /**
  39521. * Called on pointer POINTERDOUBLETAP event.
  39522. */
  39523. protected onDoubleTap(type: string): void;
  39524. /**
  39525. * Called on pointer POINTERMOVE event if multiple touches are active.
  39526. */
  39527. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39528. /**
  39529. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39530. * press.
  39531. */
  39532. protected onButtonDown(evt: PointerEvent): void;
  39533. /**
  39534. * Called each time a new POINTERUP event occurs. Ie, for each button
  39535. * release.
  39536. */
  39537. protected onButtonUp(evt: PointerEvent): void;
  39538. /**
  39539. * Called when window becomes inactive.
  39540. */
  39541. protected onLostFocus(): void;
  39542. }
  39543. }
  39544. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  39545. import { Nullable } from "babylonjs/types";
  39546. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39547. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39548. /**
  39549. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  39550. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39551. */
  39552. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  39553. /**
  39554. * Defines the camera the input is attached to.
  39555. */
  39556. camera: ArcRotateCamera;
  39557. /**
  39558. * Defines the list of key codes associated with the up action (increase alpha)
  39559. */
  39560. keysUp: number[];
  39561. /**
  39562. * Defines the list of key codes associated with the down action (decrease alpha)
  39563. */
  39564. keysDown: number[];
  39565. /**
  39566. * Defines the list of key codes associated with the left action (increase beta)
  39567. */
  39568. keysLeft: number[];
  39569. /**
  39570. * Defines the list of key codes associated with the right action (decrease beta)
  39571. */
  39572. keysRight: number[];
  39573. /**
  39574. * Defines the list of key codes associated with the reset action.
  39575. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  39576. */
  39577. keysReset: number[];
  39578. /**
  39579. * Defines the panning sensibility of the inputs.
  39580. * (How fast is the camera panning)
  39581. */
  39582. panningSensibility: number;
  39583. /**
  39584. * Defines the zooming sensibility of the inputs.
  39585. * (How fast is the camera zooming)
  39586. */
  39587. zoomingSensibility: number;
  39588. /**
  39589. * Defines whether maintaining the alt key down switch the movement mode from
  39590. * orientation to zoom.
  39591. */
  39592. useAltToZoom: boolean;
  39593. /**
  39594. * Rotation speed of the camera
  39595. */
  39596. angularSpeed: number;
  39597. private _keys;
  39598. private _ctrlPressed;
  39599. private _altPressed;
  39600. private _onCanvasBlurObserver;
  39601. private _onKeyboardObserver;
  39602. private _engine;
  39603. private _scene;
  39604. /**
  39605. * Attach the input controls to a specific dom element to get the input from.
  39606. * @param element Defines the element the controls should be listened from
  39607. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39608. */
  39609. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39610. /**
  39611. * Detach the current controls from the specified dom element.
  39612. * @param element Defines the element to stop listening the inputs from
  39613. */
  39614. detachControl(element: Nullable<HTMLElement>): void;
  39615. /**
  39616. * Update the current camera state depending on the inputs that have been used this frame.
  39617. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39618. */
  39619. checkInputs(): void;
  39620. /**
  39621. * Gets the class name of the current intput.
  39622. * @returns the class name
  39623. */
  39624. getClassName(): string;
  39625. /**
  39626. * Get the friendly name associated with the input class.
  39627. * @returns the input friendly name
  39628. */
  39629. getSimpleName(): string;
  39630. }
  39631. }
  39632. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  39633. import { Nullable } from "babylonjs/types";
  39634. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39635. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39636. /**
  39637. * Manage the mouse wheel inputs to control an arc rotate camera.
  39638. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39639. */
  39640. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  39641. /**
  39642. * Defines the camera the input is attached to.
  39643. */
  39644. camera: ArcRotateCamera;
  39645. /**
  39646. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39647. */
  39648. wheelPrecision: number;
  39649. /**
  39650. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39651. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39652. */
  39653. wheelDeltaPercentage: number;
  39654. private _wheel;
  39655. private _observer;
  39656. private computeDeltaFromMouseWheelLegacyEvent;
  39657. /**
  39658. * Attach the input controls to a specific dom element to get the input from.
  39659. * @param element Defines the element the controls should be listened from
  39660. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39661. */
  39662. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39663. /**
  39664. * Detach the current controls from the specified dom element.
  39665. * @param element Defines the element to stop listening the inputs from
  39666. */
  39667. detachControl(element: Nullable<HTMLElement>): void;
  39668. /**
  39669. * Gets the class name of the current intput.
  39670. * @returns the class name
  39671. */
  39672. getClassName(): string;
  39673. /**
  39674. * Get the friendly name associated with the input class.
  39675. * @returns the input friendly name
  39676. */
  39677. getSimpleName(): string;
  39678. }
  39679. }
  39680. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39681. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39682. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39683. /**
  39684. * Default Inputs manager for the ArcRotateCamera.
  39685. * It groups all the default supported inputs for ease of use.
  39686. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39687. */
  39688. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  39689. /**
  39690. * Instantiates a new ArcRotateCameraInputsManager.
  39691. * @param camera Defines the camera the inputs belong to
  39692. */
  39693. constructor(camera: ArcRotateCamera);
  39694. /**
  39695. * Add mouse wheel input support to the input manager.
  39696. * @returns the current input manager
  39697. */
  39698. addMouseWheel(): ArcRotateCameraInputsManager;
  39699. /**
  39700. * Add pointers input support to the input manager.
  39701. * @returns the current input manager
  39702. */
  39703. addPointers(): ArcRotateCameraInputsManager;
  39704. /**
  39705. * Add keyboard input support to the input manager.
  39706. * @returns the current input manager
  39707. */
  39708. addKeyboard(): ArcRotateCameraInputsManager;
  39709. }
  39710. }
  39711. declare module "babylonjs/Cameras/arcRotateCamera" {
  39712. import { Observable } from "babylonjs/Misc/observable";
  39713. import { Nullable } from "babylonjs/types";
  39714. import { Scene } from "babylonjs/scene";
  39715. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  39716. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39717. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  39718. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  39719. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  39720. import { Camera } from "babylonjs/Cameras/camera";
  39721. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39722. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  39723. import { Collider } from "babylonjs/Collisions/collider";
  39724. /**
  39725. * This represents an orbital type of camera.
  39726. *
  39727. * 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.
  39728. * 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.
  39729. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  39730. */
  39731. export class ArcRotateCamera extends TargetCamera {
  39732. /**
  39733. * Defines the rotation angle of the camera along the longitudinal axis.
  39734. */
  39735. alpha: number;
  39736. /**
  39737. * Defines the rotation angle of the camera along the latitudinal axis.
  39738. */
  39739. beta: number;
  39740. /**
  39741. * Defines the radius of the camera from it s target point.
  39742. */
  39743. radius: number;
  39744. protected _target: Vector3;
  39745. protected _targetHost: Nullable<AbstractMesh>;
  39746. /**
  39747. * Defines the target point of the camera.
  39748. * The camera looks towards it form the radius distance.
  39749. */
  39750. get target(): Vector3;
  39751. set target(value: Vector3);
  39752. /**
  39753. * Define the current local position of the camera in the scene
  39754. */
  39755. get position(): Vector3;
  39756. set position(newPosition: Vector3);
  39757. protected _upVector: Vector3;
  39758. protected _upToYMatrix: Matrix;
  39759. protected _YToUpMatrix: Matrix;
  39760. /**
  39761. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  39762. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  39763. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  39764. */
  39765. set upVector(vec: Vector3);
  39766. get upVector(): Vector3;
  39767. /**
  39768. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  39769. */
  39770. setMatUp(): void;
  39771. /**
  39772. * Current inertia value on the longitudinal axis.
  39773. * The bigger this number the longer it will take for the camera to stop.
  39774. */
  39775. inertialAlphaOffset: number;
  39776. /**
  39777. * Current inertia value on the latitudinal axis.
  39778. * The bigger this number the longer it will take for the camera to stop.
  39779. */
  39780. inertialBetaOffset: number;
  39781. /**
  39782. * Current inertia value on the radius axis.
  39783. * The bigger this number the longer it will take for the camera to stop.
  39784. */
  39785. inertialRadiusOffset: number;
  39786. /**
  39787. * Minimum allowed angle on the longitudinal axis.
  39788. * This can help limiting how the Camera is able to move in the scene.
  39789. */
  39790. lowerAlphaLimit: Nullable<number>;
  39791. /**
  39792. * Maximum allowed angle on the longitudinal axis.
  39793. * This can help limiting how the Camera is able to move in the scene.
  39794. */
  39795. upperAlphaLimit: Nullable<number>;
  39796. /**
  39797. * Minimum allowed angle on the latitudinal axis.
  39798. * This can help limiting how the Camera is able to move in the scene.
  39799. */
  39800. lowerBetaLimit: number;
  39801. /**
  39802. * Maximum allowed angle on the latitudinal axis.
  39803. * This can help limiting how the Camera is able to move in the scene.
  39804. */
  39805. upperBetaLimit: number;
  39806. /**
  39807. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  39808. * This can help limiting how the Camera is able to move in the scene.
  39809. */
  39810. lowerRadiusLimit: Nullable<number>;
  39811. /**
  39812. * Maximum allowed distance of the camera to the target (The camera can not get further).
  39813. * This can help limiting how the Camera is able to move in the scene.
  39814. */
  39815. upperRadiusLimit: Nullable<number>;
  39816. /**
  39817. * Defines the current inertia value used during panning of the camera along the X axis.
  39818. */
  39819. inertialPanningX: number;
  39820. /**
  39821. * Defines the current inertia value used during panning of the camera along the Y axis.
  39822. */
  39823. inertialPanningY: number;
  39824. /**
  39825. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  39826. * Basically if your fingers moves away from more than this distance you will be considered
  39827. * in pinch mode.
  39828. */
  39829. pinchToPanMaxDistance: number;
  39830. /**
  39831. * Defines the maximum distance the camera can pan.
  39832. * This could help keeping the cammera always in your scene.
  39833. */
  39834. panningDistanceLimit: Nullable<number>;
  39835. /**
  39836. * Defines the target of the camera before paning.
  39837. */
  39838. panningOriginTarget: Vector3;
  39839. /**
  39840. * Defines the value of the inertia used during panning.
  39841. * 0 would mean stop inertia and one would mean no decelleration at all.
  39842. */
  39843. panningInertia: number;
  39844. /**
  39845. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39846. */
  39847. get angularSensibilityX(): number;
  39848. set angularSensibilityX(value: number);
  39849. /**
  39850. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39851. */
  39852. get angularSensibilityY(): number;
  39853. set angularSensibilityY(value: number);
  39854. /**
  39855. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  39856. */
  39857. get pinchPrecision(): number;
  39858. set pinchPrecision(value: number);
  39859. /**
  39860. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  39861. * It will be used instead of pinchDeltaPrecision if different from 0.
  39862. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39863. */
  39864. get pinchDeltaPercentage(): number;
  39865. set pinchDeltaPercentage(value: number);
  39866. /**
  39867. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  39868. * and pinch delta percentage.
  39869. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39870. * that any object in the plane at the camera's target point will scale
  39871. * perfectly with finger motion.
  39872. */
  39873. get useNaturalPinchZoom(): boolean;
  39874. set useNaturalPinchZoom(value: boolean);
  39875. /**
  39876. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39877. */
  39878. get panningSensibility(): number;
  39879. set panningSensibility(value: number);
  39880. /**
  39881. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39882. */
  39883. get keysUp(): number[];
  39884. set keysUp(value: number[]);
  39885. /**
  39886. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39887. */
  39888. get keysDown(): number[];
  39889. set keysDown(value: number[]);
  39890. /**
  39891. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39892. */
  39893. get keysLeft(): number[];
  39894. set keysLeft(value: number[]);
  39895. /**
  39896. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39897. */
  39898. get keysRight(): number[];
  39899. set keysRight(value: number[]);
  39900. /**
  39901. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39902. */
  39903. get wheelPrecision(): number;
  39904. set wheelPrecision(value: number);
  39905. /**
  39906. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  39907. * It will be used instead of pinchDeltaPrecision if different from 0.
  39908. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39909. */
  39910. get wheelDeltaPercentage(): number;
  39911. set wheelDeltaPercentage(value: number);
  39912. /**
  39913. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39914. */
  39915. zoomOnFactor: number;
  39916. /**
  39917. * Defines a screen offset for the camera position.
  39918. */
  39919. targetScreenOffset: Vector2;
  39920. /**
  39921. * Allows the camera to be completely reversed.
  39922. * If false the camera can not arrive upside down.
  39923. */
  39924. allowUpsideDown: boolean;
  39925. /**
  39926. * Define if double tap/click is used to restore the previously saved state of the camera.
  39927. */
  39928. useInputToRestoreState: boolean;
  39929. /** @hidden */
  39930. _viewMatrix: Matrix;
  39931. /** @hidden */
  39932. _useCtrlForPanning: boolean;
  39933. /** @hidden */
  39934. _panningMouseButton: number;
  39935. /**
  39936. * Defines the input associated to the camera.
  39937. */
  39938. inputs: ArcRotateCameraInputsManager;
  39939. /** @hidden */
  39940. _reset: () => void;
  39941. /**
  39942. * Defines the allowed panning axis.
  39943. */
  39944. panningAxis: Vector3;
  39945. protected _localDirection: Vector3;
  39946. protected _transformedDirection: Vector3;
  39947. private _bouncingBehavior;
  39948. /**
  39949. * Gets the bouncing behavior of the camera if it has been enabled.
  39950. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39951. */
  39952. get bouncingBehavior(): Nullable<BouncingBehavior>;
  39953. /**
  39954. * Defines if the bouncing behavior of the camera is enabled on the camera.
  39955. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39956. */
  39957. get useBouncingBehavior(): boolean;
  39958. set useBouncingBehavior(value: boolean);
  39959. private _framingBehavior;
  39960. /**
  39961. * Gets the framing behavior of the camera if it has been enabled.
  39962. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39963. */
  39964. get framingBehavior(): Nullable<FramingBehavior>;
  39965. /**
  39966. * Defines if the framing behavior of the camera is enabled on the camera.
  39967. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39968. */
  39969. get useFramingBehavior(): boolean;
  39970. set useFramingBehavior(value: boolean);
  39971. private _autoRotationBehavior;
  39972. /**
  39973. * Gets the auto rotation behavior of the camera if it has been enabled.
  39974. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39975. */
  39976. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  39977. /**
  39978. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  39979. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39980. */
  39981. get useAutoRotationBehavior(): boolean;
  39982. set useAutoRotationBehavior(value: boolean);
  39983. /**
  39984. * Observable triggered when the mesh target has been changed on the camera.
  39985. */
  39986. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  39987. /**
  39988. * Event raised when the camera is colliding with a mesh.
  39989. */
  39990. onCollide: (collidedMesh: AbstractMesh) => void;
  39991. /**
  39992. * Defines whether the camera should check collision with the objects oh the scene.
  39993. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  39994. */
  39995. checkCollisions: boolean;
  39996. /**
  39997. * Defines the collision radius of the camera.
  39998. * This simulates a sphere around the camera.
  39999. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40000. */
  40001. collisionRadius: Vector3;
  40002. protected _collider: Collider;
  40003. protected _previousPosition: Vector3;
  40004. protected _collisionVelocity: Vector3;
  40005. protected _newPosition: Vector3;
  40006. protected _previousAlpha: number;
  40007. protected _previousBeta: number;
  40008. protected _previousRadius: number;
  40009. protected _collisionTriggered: boolean;
  40010. protected _targetBoundingCenter: Nullable<Vector3>;
  40011. private _computationVector;
  40012. /**
  40013. * Instantiates a new ArcRotateCamera in a given scene
  40014. * @param name Defines the name of the camera
  40015. * @param alpha Defines the camera rotation along the logitudinal axis
  40016. * @param beta Defines the camera rotation along the latitudinal axis
  40017. * @param radius Defines the camera distance from its target
  40018. * @param target Defines the camera target
  40019. * @param scene Defines the scene the camera belongs to
  40020. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  40021. */
  40022. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40023. /** @hidden */
  40024. _initCache(): void;
  40025. /** @hidden */
  40026. _updateCache(ignoreParentClass?: boolean): void;
  40027. protected _getTargetPosition(): Vector3;
  40028. private _storedAlpha;
  40029. private _storedBeta;
  40030. private _storedRadius;
  40031. private _storedTarget;
  40032. private _storedTargetScreenOffset;
  40033. /**
  40034. * Stores the current state of the camera (alpha, beta, radius and target)
  40035. * @returns the camera itself
  40036. */
  40037. storeState(): Camera;
  40038. /**
  40039. * @hidden
  40040. * Restored camera state. You must call storeState() first
  40041. */
  40042. _restoreStateValues(): boolean;
  40043. /** @hidden */
  40044. _isSynchronizedViewMatrix(): boolean;
  40045. /**
  40046. * Attached controls to the current camera.
  40047. * @param element Defines the element the controls should be listened from
  40048. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40049. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  40050. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  40051. */
  40052. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  40053. /**
  40054. * Detach the current controls from the camera.
  40055. * The camera will stop reacting to inputs.
  40056. * @param element Defines the element to stop listening the inputs from
  40057. */
  40058. detachControl(element: HTMLElement): void;
  40059. /** @hidden */
  40060. _checkInputs(): void;
  40061. protected _checkLimits(): void;
  40062. /**
  40063. * Rebuilds angles (alpha, beta) and radius from the give position and target
  40064. */
  40065. rebuildAnglesAndRadius(): void;
  40066. /**
  40067. * Use a position to define the current camera related information like alpha, beta and radius
  40068. * @param position Defines the position to set the camera at
  40069. */
  40070. setPosition(position: Vector3): void;
  40071. /**
  40072. * Defines the target the camera should look at.
  40073. * This will automatically adapt alpha beta and radius to fit within the new target.
  40074. * @param target Defines the new target as a Vector or a mesh
  40075. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  40076. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  40077. */
  40078. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  40079. /** @hidden */
  40080. _getViewMatrix(): Matrix;
  40081. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  40082. /**
  40083. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  40084. * @param meshes Defines the mesh to zoom on
  40085. * @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)
  40086. */
  40087. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  40088. /**
  40089. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  40090. * The target will be changed but the radius
  40091. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  40092. * @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)
  40093. */
  40094. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  40095. min: Vector3;
  40096. max: Vector3;
  40097. distance: number;
  40098. }, doNotUpdateMaxZ?: boolean): void;
  40099. /**
  40100. * @override
  40101. * Override Camera.createRigCamera
  40102. */
  40103. createRigCamera(name: string, cameraIndex: number): Camera;
  40104. /**
  40105. * @hidden
  40106. * @override
  40107. * Override Camera._updateRigCameras
  40108. */
  40109. _updateRigCameras(): void;
  40110. /**
  40111. * Destroy the camera and release the current resources hold by it.
  40112. */
  40113. dispose(): void;
  40114. /**
  40115. * Gets the current object class name.
  40116. * @return the class name
  40117. */
  40118. getClassName(): string;
  40119. }
  40120. }
  40121. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  40122. import { Behavior } from "babylonjs/Behaviors/behavior";
  40123. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40124. /**
  40125. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  40126. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40127. */
  40128. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  40129. /**
  40130. * Gets the name of the behavior.
  40131. */
  40132. get name(): string;
  40133. private _zoomStopsAnimation;
  40134. private _idleRotationSpeed;
  40135. private _idleRotationWaitTime;
  40136. private _idleRotationSpinupTime;
  40137. /**
  40138. * Sets the flag that indicates if user zooming should stop animation.
  40139. */
  40140. set zoomStopsAnimation(flag: boolean);
  40141. /**
  40142. * Gets the flag that indicates if user zooming should stop animation.
  40143. */
  40144. get zoomStopsAnimation(): boolean;
  40145. /**
  40146. * Sets the default speed at which the camera rotates around the model.
  40147. */
  40148. set idleRotationSpeed(speed: number);
  40149. /**
  40150. * Gets the default speed at which the camera rotates around the model.
  40151. */
  40152. get idleRotationSpeed(): number;
  40153. /**
  40154. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  40155. */
  40156. set idleRotationWaitTime(time: number);
  40157. /**
  40158. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  40159. */
  40160. get idleRotationWaitTime(): number;
  40161. /**
  40162. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40163. */
  40164. set idleRotationSpinupTime(time: number);
  40165. /**
  40166. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40167. */
  40168. get idleRotationSpinupTime(): number;
  40169. /**
  40170. * Gets a value indicating if the camera is currently rotating because of this behavior
  40171. */
  40172. get rotationInProgress(): boolean;
  40173. private _onPrePointerObservableObserver;
  40174. private _onAfterCheckInputsObserver;
  40175. private _attachedCamera;
  40176. private _isPointerDown;
  40177. private _lastFrameTime;
  40178. private _lastInteractionTime;
  40179. private _cameraRotationSpeed;
  40180. /**
  40181. * Initializes the behavior.
  40182. */
  40183. init(): void;
  40184. /**
  40185. * Attaches the behavior to its arc rotate camera.
  40186. * @param camera Defines the camera to attach the behavior to
  40187. */
  40188. attach(camera: ArcRotateCamera): void;
  40189. /**
  40190. * Detaches the behavior from its current arc rotate camera.
  40191. */
  40192. detach(): void;
  40193. /**
  40194. * Returns true if user is scrolling.
  40195. * @return true if user is scrolling.
  40196. */
  40197. private _userIsZooming;
  40198. private _lastFrameRadius;
  40199. private _shouldAnimationStopForInteraction;
  40200. /**
  40201. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40202. */
  40203. private _applyUserInteraction;
  40204. private _userIsMoving;
  40205. }
  40206. }
  40207. declare module "babylonjs/Behaviors/Cameras/index" {
  40208. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  40209. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  40210. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  40211. }
  40212. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  40213. import { Mesh } from "babylonjs/Meshes/mesh";
  40214. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40215. import { Behavior } from "babylonjs/Behaviors/behavior";
  40216. /**
  40217. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  40218. */
  40219. export class AttachToBoxBehavior implements Behavior<Mesh> {
  40220. private ui;
  40221. /**
  40222. * The name of the behavior
  40223. */
  40224. name: string;
  40225. /**
  40226. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  40227. */
  40228. distanceAwayFromFace: number;
  40229. /**
  40230. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  40231. */
  40232. distanceAwayFromBottomOfFace: number;
  40233. private _faceVectors;
  40234. private _target;
  40235. private _scene;
  40236. private _onRenderObserver;
  40237. private _tmpMatrix;
  40238. private _tmpVector;
  40239. /**
  40240. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  40241. * @param ui The transform node that should be attched to the mesh
  40242. */
  40243. constructor(ui: TransformNode);
  40244. /**
  40245. * Initializes the behavior
  40246. */
  40247. init(): void;
  40248. private _closestFace;
  40249. private _zeroVector;
  40250. private _lookAtTmpMatrix;
  40251. private _lookAtToRef;
  40252. /**
  40253. * Attaches the AttachToBoxBehavior to the passed in mesh
  40254. * @param target The mesh that the specified node will be attached to
  40255. */
  40256. attach(target: Mesh): void;
  40257. /**
  40258. * Detaches the behavior from the mesh
  40259. */
  40260. detach(): void;
  40261. }
  40262. }
  40263. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  40264. import { Behavior } from "babylonjs/Behaviors/behavior";
  40265. import { Mesh } from "babylonjs/Meshes/mesh";
  40266. /**
  40267. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  40268. */
  40269. export class FadeInOutBehavior implements Behavior<Mesh> {
  40270. /**
  40271. * Time in milliseconds to delay before fading in (Default: 0)
  40272. */
  40273. delay: number;
  40274. /**
  40275. * Time in milliseconds for the mesh to fade in (Default: 300)
  40276. */
  40277. fadeInTime: number;
  40278. private _millisecondsPerFrame;
  40279. private _hovered;
  40280. private _hoverValue;
  40281. private _ownerNode;
  40282. /**
  40283. * Instatiates the FadeInOutBehavior
  40284. */
  40285. constructor();
  40286. /**
  40287. * The name of the behavior
  40288. */
  40289. get name(): string;
  40290. /**
  40291. * Initializes the behavior
  40292. */
  40293. init(): void;
  40294. /**
  40295. * Attaches the fade behavior on the passed in mesh
  40296. * @param ownerNode The mesh that will be faded in/out once attached
  40297. */
  40298. attach(ownerNode: Mesh): void;
  40299. /**
  40300. * Detaches the behavior from the mesh
  40301. */
  40302. detach(): void;
  40303. /**
  40304. * Triggers the mesh to begin fading in or out
  40305. * @param value if the object should fade in or out (true to fade in)
  40306. */
  40307. fadeIn(value: boolean): void;
  40308. private _update;
  40309. private _setAllVisibility;
  40310. }
  40311. }
  40312. declare module "babylonjs/Misc/pivotTools" {
  40313. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40314. /**
  40315. * Class containing a set of static utilities functions for managing Pivots
  40316. * @hidden
  40317. */
  40318. export class PivotTools {
  40319. private static _PivotCached;
  40320. private static _OldPivotPoint;
  40321. private static _PivotTranslation;
  40322. private static _PivotTmpVector;
  40323. /** @hidden */
  40324. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  40325. /** @hidden */
  40326. static _RestorePivotPoint(mesh: AbstractMesh): void;
  40327. }
  40328. }
  40329. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  40330. import { Scene } from "babylonjs/scene";
  40331. import { Vector4 } from "babylonjs/Maths/math.vector";
  40332. import { Mesh } from "babylonjs/Meshes/mesh";
  40333. import { Nullable } from "babylonjs/types";
  40334. import { Plane } from "babylonjs/Maths/math.plane";
  40335. /**
  40336. * Class containing static functions to help procedurally build meshes
  40337. */
  40338. export class PlaneBuilder {
  40339. /**
  40340. * Creates a plane mesh
  40341. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  40342. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  40343. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  40344. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40345. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40346. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40347. * @param name defines the name of the mesh
  40348. * @param options defines the options used to create the mesh
  40349. * @param scene defines the hosting scene
  40350. * @returns the plane mesh
  40351. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  40352. */
  40353. static CreatePlane(name: string, options: {
  40354. size?: number;
  40355. width?: number;
  40356. height?: number;
  40357. sideOrientation?: number;
  40358. frontUVs?: Vector4;
  40359. backUVs?: Vector4;
  40360. updatable?: boolean;
  40361. sourcePlane?: Plane;
  40362. }, scene?: Nullable<Scene>): Mesh;
  40363. }
  40364. }
  40365. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  40366. import { Behavior } from "babylonjs/Behaviors/behavior";
  40367. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40368. import { Observable } from "babylonjs/Misc/observable";
  40369. import { Vector3 } from "babylonjs/Maths/math.vector";
  40370. import { Ray } from "babylonjs/Culling/ray";
  40371. import "babylonjs/Meshes/Builders/planeBuilder";
  40372. /**
  40373. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  40374. */
  40375. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  40376. private static _AnyMouseID;
  40377. /**
  40378. * Abstract mesh the behavior is set on
  40379. */
  40380. attachedNode: AbstractMesh;
  40381. private _dragPlane;
  40382. private _scene;
  40383. private _pointerObserver;
  40384. private _beforeRenderObserver;
  40385. private static _planeScene;
  40386. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  40387. /**
  40388. * 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)
  40389. */
  40390. maxDragAngle: number;
  40391. /**
  40392. * @hidden
  40393. */
  40394. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  40395. /**
  40396. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40397. */
  40398. currentDraggingPointerID: number;
  40399. /**
  40400. * The last position where the pointer hit the drag plane in world space
  40401. */
  40402. lastDragPosition: Vector3;
  40403. /**
  40404. * If the behavior is currently in a dragging state
  40405. */
  40406. dragging: boolean;
  40407. /**
  40408. * 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)
  40409. */
  40410. dragDeltaRatio: number;
  40411. /**
  40412. * If the drag plane orientation should be updated during the dragging (Default: true)
  40413. */
  40414. updateDragPlane: boolean;
  40415. private _debugMode;
  40416. private _moving;
  40417. /**
  40418. * Fires each time the attached mesh is dragged with the pointer
  40419. * * delta between last drag position and current drag position in world space
  40420. * * dragDistance along the drag axis
  40421. * * dragPlaneNormal normal of the current drag plane used during the drag
  40422. * * dragPlanePoint in world space where the drag intersects the drag plane
  40423. */
  40424. onDragObservable: Observable<{
  40425. delta: Vector3;
  40426. dragPlanePoint: Vector3;
  40427. dragPlaneNormal: Vector3;
  40428. dragDistance: number;
  40429. pointerId: number;
  40430. }>;
  40431. /**
  40432. * Fires each time a drag begins (eg. mouse down on mesh)
  40433. */
  40434. onDragStartObservable: Observable<{
  40435. dragPlanePoint: Vector3;
  40436. pointerId: number;
  40437. }>;
  40438. /**
  40439. * Fires each time a drag ends (eg. mouse release after drag)
  40440. */
  40441. onDragEndObservable: Observable<{
  40442. dragPlanePoint: Vector3;
  40443. pointerId: number;
  40444. }>;
  40445. /**
  40446. * If the attached mesh should be moved when dragged
  40447. */
  40448. moveAttached: boolean;
  40449. /**
  40450. * If the drag behavior will react to drag events (Default: true)
  40451. */
  40452. enabled: boolean;
  40453. /**
  40454. * If pointer events should start and release the drag (Default: true)
  40455. */
  40456. startAndReleaseDragOnPointerEvents: boolean;
  40457. /**
  40458. * If camera controls should be detached during the drag
  40459. */
  40460. detachCameraControls: boolean;
  40461. /**
  40462. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  40463. */
  40464. useObjectOrientationForDragging: boolean;
  40465. private _options;
  40466. /**
  40467. * Gets the options used by the behavior
  40468. */
  40469. get options(): {
  40470. dragAxis?: Vector3;
  40471. dragPlaneNormal?: Vector3;
  40472. };
  40473. /**
  40474. * Sets the options used by the behavior
  40475. */
  40476. set options(options: {
  40477. dragAxis?: Vector3;
  40478. dragPlaneNormal?: Vector3;
  40479. });
  40480. /**
  40481. * Creates a pointer drag behavior that can be attached to a mesh
  40482. * @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)
  40483. */
  40484. constructor(options?: {
  40485. dragAxis?: Vector3;
  40486. dragPlaneNormal?: Vector3;
  40487. });
  40488. /**
  40489. * Predicate to determine if it is valid to move the object to a new position when it is moved
  40490. */
  40491. validateDrag: (targetPosition: Vector3) => boolean;
  40492. /**
  40493. * The name of the behavior
  40494. */
  40495. get name(): string;
  40496. /**
  40497. * Initializes the behavior
  40498. */
  40499. init(): void;
  40500. private _tmpVector;
  40501. private _alternatePickedPoint;
  40502. private _worldDragAxis;
  40503. private _targetPosition;
  40504. private _attachedElement;
  40505. /**
  40506. * Attaches the drag behavior the passed in mesh
  40507. * @param ownerNode The mesh that will be dragged around once attached
  40508. * @param predicate Predicate to use for pick filtering
  40509. */
  40510. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  40511. /**
  40512. * Force relase the drag action by code.
  40513. */
  40514. releaseDrag(): void;
  40515. private _startDragRay;
  40516. private _lastPointerRay;
  40517. /**
  40518. * Simulates the start of a pointer drag event on the behavior
  40519. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  40520. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  40521. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  40522. */
  40523. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  40524. private _startDrag;
  40525. private _dragDelta;
  40526. private _moveDrag;
  40527. private _pickWithRayOnDragPlane;
  40528. private _pointA;
  40529. private _pointB;
  40530. private _pointC;
  40531. private _lineA;
  40532. private _lineB;
  40533. private _localAxis;
  40534. private _lookAt;
  40535. private _updateDragPlanePosition;
  40536. /**
  40537. * Detaches the behavior from the mesh
  40538. */
  40539. detach(): void;
  40540. }
  40541. }
  40542. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  40543. import { Mesh } from "babylonjs/Meshes/mesh";
  40544. import { Behavior } from "babylonjs/Behaviors/behavior";
  40545. /**
  40546. * A behavior that when attached to a mesh will allow the mesh to be scaled
  40547. */
  40548. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  40549. private _dragBehaviorA;
  40550. private _dragBehaviorB;
  40551. private _startDistance;
  40552. private _initialScale;
  40553. private _targetScale;
  40554. private _ownerNode;
  40555. private _sceneRenderObserver;
  40556. /**
  40557. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  40558. */
  40559. constructor();
  40560. /**
  40561. * The name of the behavior
  40562. */
  40563. get name(): string;
  40564. /**
  40565. * Initializes the behavior
  40566. */
  40567. init(): void;
  40568. private _getCurrentDistance;
  40569. /**
  40570. * Attaches the scale behavior the passed in mesh
  40571. * @param ownerNode The mesh that will be scaled around once attached
  40572. */
  40573. attach(ownerNode: Mesh): void;
  40574. /**
  40575. * Detaches the behavior from the mesh
  40576. */
  40577. detach(): void;
  40578. }
  40579. }
  40580. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  40581. import { Behavior } from "babylonjs/Behaviors/behavior";
  40582. import { Mesh } from "babylonjs/Meshes/mesh";
  40583. import { Observable } from "babylonjs/Misc/observable";
  40584. /**
  40585. * 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
  40586. */
  40587. export class SixDofDragBehavior implements Behavior<Mesh> {
  40588. private static _virtualScene;
  40589. private _ownerNode;
  40590. private _sceneRenderObserver;
  40591. private _scene;
  40592. private _targetPosition;
  40593. private _virtualOriginMesh;
  40594. private _virtualDragMesh;
  40595. private _pointerObserver;
  40596. private _moving;
  40597. private _startingOrientation;
  40598. /**
  40599. * 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)
  40600. */
  40601. private zDragFactor;
  40602. /**
  40603. * If the object should rotate to face the drag origin
  40604. */
  40605. rotateDraggedObject: boolean;
  40606. /**
  40607. * If the behavior is currently in a dragging state
  40608. */
  40609. dragging: boolean;
  40610. /**
  40611. * 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)
  40612. */
  40613. dragDeltaRatio: number;
  40614. /**
  40615. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40616. */
  40617. currentDraggingPointerID: number;
  40618. /**
  40619. * If camera controls should be detached during the drag
  40620. */
  40621. detachCameraControls: boolean;
  40622. /**
  40623. * Fires each time a drag starts
  40624. */
  40625. onDragStartObservable: Observable<{}>;
  40626. /**
  40627. * Fires each time a drag ends (eg. mouse release after drag)
  40628. */
  40629. onDragEndObservable: Observable<{}>;
  40630. /**
  40631. * 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
  40632. */
  40633. constructor();
  40634. /**
  40635. * The name of the behavior
  40636. */
  40637. get name(): string;
  40638. /**
  40639. * Initializes the behavior
  40640. */
  40641. init(): void;
  40642. /**
  40643. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  40644. */
  40645. private get _pointerCamera();
  40646. /**
  40647. * Attaches the scale behavior the passed in mesh
  40648. * @param ownerNode The mesh that will be scaled around once attached
  40649. */
  40650. attach(ownerNode: Mesh): void;
  40651. /**
  40652. * Detaches the behavior from the mesh
  40653. */
  40654. detach(): void;
  40655. }
  40656. }
  40657. declare module "babylonjs/Behaviors/Meshes/index" {
  40658. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  40659. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  40660. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  40661. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  40662. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  40663. }
  40664. declare module "babylonjs/Behaviors/index" {
  40665. export * from "babylonjs/Behaviors/behavior";
  40666. export * from "babylonjs/Behaviors/Cameras/index";
  40667. export * from "babylonjs/Behaviors/Meshes/index";
  40668. }
  40669. declare module "babylonjs/Bones/boneIKController" {
  40670. import { Bone } from "babylonjs/Bones/bone";
  40671. import { Vector3 } from "babylonjs/Maths/math.vector";
  40672. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40673. import { Nullable } from "babylonjs/types";
  40674. /**
  40675. * Class used to apply inverse kinematics to bones
  40676. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  40677. */
  40678. export class BoneIKController {
  40679. private static _tmpVecs;
  40680. private static _tmpQuat;
  40681. private static _tmpMats;
  40682. /**
  40683. * Gets or sets the target mesh
  40684. */
  40685. targetMesh: AbstractMesh;
  40686. /** Gets or sets the mesh used as pole */
  40687. poleTargetMesh: AbstractMesh;
  40688. /**
  40689. * Gets or sets the bone used as pole
  40690. */
  40691. poleTargetBone: Nullable<Bone>;
  40692. /**
  40693. * Gets or sets the target position
  40694. */
  40695. targetPosition: Vector3;
  40696. /**
  40697. * Gets or sets the pole target position
  40698. */
  40699. poleTargetPosition: Vector3;
  40700. /**
  40701. * Gets or sets the pole target local offset
  40702. */
  40703. poleTargetLocalOffset: Vector3;
  40704. /**
  40705. * Gets or sets the pole angle
  40706. */
  40707. poleAngle: number;
  40708. /**
  40709. * Gets or sets the mesh associated with the controller
  40710. */
  40711. mesh: AbstractMesh;
  40712. /**
  40713. * 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)
  40714. */
  40715. slerpAmount: number;
  40716. private _bone1Quat;
  40717. private _bone1Mat;
  40718. private _bone2Ang;
  40719. private _bone1;
  40720. private _bone2;
  40721. private _bone1Length;
  40722. private _bone2Length;
  40723. private _maxAngle;
  40724. private _maxReach;
  40725. private _rightHandedSystem;
  40726. private _bendAxis;
  40727. private _slerping;
  40728. private _adjustRoll;
  40729. /**
  40730. * Gets or sets maximum allowed angle
  40731. */
  40732. get maxAngle(): number;
  40733. set maxAngle(value: number);
  40734. /**
  40735. * Creates a new BoneIKController
  40736. * @param mesh defines the mesh to control
  40737. * @param bone defines the bone to control
  40738. * @param options defines options to set up the controller
  40739. */
  40740. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  40741. targetMesh?: AbstractMesh;
  40742. poleTargetMesh?: AbstractMesh;
  40743. poleTargetBone?: Bone;
  40744. poleTargetLocalOffset?: Vector3;
  40745. poleAngle?: number;
  40746. bendAxis?: Vector3;
  40747. maxAngle?: number;
  40748. slerpAmount?: number;
  40749. });
  40750. private _setMaxAngle;
  40751. /**
  40752. * Force the controller to update the bones
  40753. */
  40754. update(): void;
  40755. }
  40756. }
  40757. declare module "babylonjs/Bones/boneLookController" {
  40758. import { Vector3 } from "babylonjs/Maths/math.vector";
  40759. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40760. import { Bone } from "babylonjs/Bones/bone";
  40761. import { Space } from "babylonjs/Maths/math.axis";
  40762. /**
  40763. * Class used to make a bone look toward a point in space
  40764. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  40765. */
  40766. export class BoneLookController {
  40767. private static _tmpVecs;
  40768. private static _tmpQuat;
  40769. private static _tmpMats;
  40770. /**
  40771. * The target Vector3 that the bone will look at
  40772. */
  40773. target: Vector3;
  40774. /**
  40775. * The mesh that the bone is attached to
  40776. */
  40777. mesh: AbstractMesh;
  40778. /**
  40779. * The bone that will be looking to the target
  40780. */
  40781. bone: Bone;
  40782. /**
  40783. * The up axis of the coordinate system that is used when the bone is rotated
  40784. */
  40785. upAxis: Vector3;
  40786. /**
  40787. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  40788. */
  40789. upAxisSpace: Space;
  40790. /**
  40791. * Used to make an adjustment to the yaw of the bone
  40792. */
  40793. adjustYaw: number;
  40794. /**
  40795. * Used to make an adjustment to the pitch of the bone
  40796. */
  40797. adjustPitch: number;
  40798. /**
  40799. * Used to make an adjustment to the roll of the bone
  40800. */
  40801. adjustRoll: number;
  40802. /**
  40803. * 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)
  40804. */
  40805. slerpAmount: number;
  40806. private _minYaw;
  40807. private _maxYaw;
  40808. private _minPitch;
  40809. private _maxPitch;
  40810. private _minYawSin;
  40811. private _minYawCos;
  40812. private _maxYawSin;
  40813. private _maxYawCos;
  40814. private _midYawConstraint;
  40815. private _minPitchTan;
  40816. private _maxPitchTan;
  40817. private _boneQuat;
  40818. private _slerping;
  40819. private _transformYawPitch;
  40820. private _transformYawPitchInv;
  40821. private _firstFrameSkipped;
  40822. private _yawRange;
  40823. private _fowardAxis;
  40824. /**
  40825. * Gets or sets the minimum yaw angle that the bone can look to
  40826. */
  40827. get minYaw(): number;
  40828. set minYaw(value: number);
  40829. /**
  40830. * Gets or sets the maximum yaw angle that the bone can look to
  40831. */
  40832. get maxYaw(): number;
  40833. set maxYaw(value: number);
  40834. /**
  40835. * Gets or sets the minimum pitch angle that the bone can look to
  40836. */
  40837. get minPitch(): number;
  40838. set minPitch(value: number);
  40839. /**
  40840. * Gets or sets the maximum pitch angle that the bone can look to
  40841. */
  40842. get maxPitch(): number;
  40843. set maxPitch(value: number);
  40844. /**
  40845. * Create a BoneLookController
  40846. * @param mesh the mesh that the bone belongs to
  40847. * @param bone the bone that will be looking to the target
  40848. * @param target the target Vector3 to look at
  40849. * @param options optional settings:
  40850. * * maxYaw: the maximum angle the bone will yaw to
  40851. * * minYaw: the minimum angle the bone will yaw to
  40852. * * maxPitch: the maximum angle the bone will pitch to
  40853. * * minPitch: the minimum angle the bone will yaw to
  40854. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  40855. * * upAxis: the up axis of the coordinate system
  40856. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  40857. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  40858. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  40859. * * adjustYaw: used to make an adjustment to the yaw of the bone
  40860. * * adjustPitch: used to make an adjustment to the pitch of the bone
  40861. * * adjustRoll: used to make an adjustment to the roll of the bone
  40862. **/
  40863. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  40864. maxYaw?: number;
  40865. minYaw?: number;
  40866. maxPitch?: number;
  40867. minPitch?: number;
  40868. slerpAmount?: number;
  40869. upAxis?: Vector3;
  40870. upAxisSpace?: Space;
  40871. yawAxis?: Vector3;
  40872. pitchAxis?: Vector3;
  40873. adjustYaw?: number;
  40874. adjustPitch?: number;
  40875. adjustRoll?: number;
  40876. });
  40877. /**
  40878. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  40879. */
  40880. update(): void;
  40881. private _getAngleDiff;
  40882. private _getAngleBetween;
  40883. private _isAngleBetween;
  40884. }
  40885. }
  40886. declare module "babylonjs/Bones/index" {
  40887. export * from "babylonjs/Bones/bone";
  40888. export * from "babylonjs/Bones/boneIKController";
  40889. export * from "babylonjs/Bones/boneLookController";
  40890. export * from "babylonjs/Bones/skeleton";
  40891. }
  40892. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  40893. import { Nullable } from "babylonjs/types";
  40894. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40895. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40896. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40897. /**
  40898. * Manage the gamepad inputs to control an arc rotate camera.
  40899. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40900. */
  40901. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40902. /**
  40903. * Defines the camera the input is attached to.
  40904. */
  40905. camera: ArcRotateCamera;
  40906. /**
  40907. * Defines the gamepad the input is gathering event from.
  40908. */
  40909. gamepad: Nullable<Gamepad>;
  40910. /**
  40911. * Defines the gamepad rotation sensiblity.
  40912. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40913. */
  40914. gamepadRotationSensibility: number;
  40915. /**
  40916. * Defines the gamepad move sensiblity.
  40917. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40918. */
  40919. gamepadMoveSensibility: number;
  40920. private _yAxisScale;
  40921. /**
  40922. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40923. */
  40924. get invertYAxis(): boolean;
  40925. set invertYAxis(value: boolean);
  40926. private _onGamepadConnectedObserver;
  40927. private _onGamepadDisconnectedObserver;
  40928. /**
  40929. * Attach the input controls to a specific dom element to get the input from.
  40930. * @param element Defines the element the controls should be listened from
  40931. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40932. */
  40933. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40934. /**
  40935. * Detach the current controls from the specified dom element.
  40936. * @param element Defines the element to stop listening the inputs from
  40937. */
  40938. detachControl(element: Nullable<HTMLElement>): void;
  40939. /**
  40940. * Update the current camera state depending on the inputs that have been used this frame.
  40941. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40942. */
  40943. checkInputs(): void;
  40944. /**
  40945. * Gets the class name of the current intput.
  40946. * @returns the class name
  40947. */
  40948. getClassName(): string;
  40949. /**
  40950. * Get the friendly name associated with the input class.
  40951. * @returns the input friendly name
  40952. */
  40953. getSimpleName(): string;
  40954. }
  40955. }
  40956. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  40957. import { Nullable } from "babylonjs/types";
  40958. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40959. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40960. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40961. interface ArcRotateCameraInputsManager {
  40962. /**
  40963. * Add orientation input support to the input manager.
  40964. * @returns the current input manager
  40965. */
  40966. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  40967. }
  40968. }
  40969. /**
  40970. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40971. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40972. */
  40973. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40974. /**
  40975. * Defines the camera the input is attached to.
  40976. */
  40977. camera: ArcRotateCamera;
  40978. /**
  40979. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40980. */
  40981. alphaCorrection: number;
  40982. /**
  40983. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40984. */
  40985. gammaCorrection: number;
  40986. private _alpha;
  40987. private _gamma;
  40988. private _dirty;
  40989. private _deviceOrientationHandler;
  40990. /**
  40991. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40992. */
  40993. constructor();
  40994. /**
  40995. * Attach the input controls to a specific dom element to get the input from.
  40996. * @param element Defines the element the controls should be listened from
  40997. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40998. */
  40999. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41000. /** @hidden */
  41001. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  41002. /**
  41003. * Update the current camera state depending on the inputs that have been used this frame.
  41004. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41005. */
  41006. checkInputs(): void;
  41007. /**
  41008. * Detach the current controls from the specified dom element.
  41009. * @param element Defines the element to stop listening the inputs from
  41010. */
  41011. detachControl(element: Nullable<HTMLElement>): void;
  41012. /**
  41013. * Gets the class name of the current intput.
  41014. * @returns the class name
  41015. */
  41016. getClassName(): string;
  41017. /**
  41018. * Get the friendly name associated with the input class.
  41019. * @returns the input friendly name
  41020. */
  41021. getSimpleName(): string;
  41022. }
  41023. }
  41024. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  41025. import { Nullable } from "babylonjs/types";
  41026. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41027. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41028. /**
  41029. * Listen to mouse events to control the camera.
  41030. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41031. */
  41032. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  41033. /**
  41034. * Defines the camera the input is attached to.
  41035. */
  41036. camera: FlyCamera;
  41037. /**
  41038. * Defines if touch is enabled. (Default is true.)
  41039. */
  41040. touchEnabled: boolean;
  41041. /**
  41042. * Defines the buttons associated with the input to handle camera rotation.
  41043. */
  41044. buttons: number[];
  41045. /**
  41046. * Assign buttons for Yaw control.
  41047. */
  41048. buttonsYaw: number[];
  41049. /**
  41050. * Assign buttons for Pitch control.
  41051. */
  41052. buttonsPitch: number[];
  41053. /**
  41054. * Assign buttons for Roll control.
  41055. */
  41056. buttonsRoll: number[];
  41057. /**
  41058. * Detect if any button is being pressed while mouse is moved.
  41059. * -1 = Mouse locked.
  41060. * 0 = Left button.
  41061. * 1 = Middle Button.
  41062. * 2 = Right Button.
  41063. */
  41064. activeButton: number;
  41065. /**
  41066. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  41067. * Higher values reduce its sensitivity.
  41068. */
  41069. angularSensibility: number;
  41070. private _mousemoveCallback;
  41071. private _observer;
  41072. private _rollObserver;
  41073. private previousPosition;
  41074. private noPreventDefault;
  41075. private element;
  41076. /**
  41077. * Listen to mouse events to control the camera.
  41078. * @param touchEnabled Define if touch is enabled. (Default is true.)
  41079. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41080. */
  41081. constructor(touchEnabled?: boolean);
  41082. /**
  41083. * Attach the mouse control to the HTML DOM element.
  41084. * @param element Defines the element that listens to the input events.
  41085. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  41086. */
  41087. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41088. /**
  41089. * Detach the current controls from the specified dom element.
  41090. * @param element Defines the element to stop listening the inputs from
  41091. */
  41092. detachControl(element: Nullable<HTMLElement>): void;
  41093. /**
  41094. * Gets the class name of the current input.
  41095. * @returns the class name.
  41096. */
  41097. getClassName(): string;
  41098. /**
  41099. * Get the friendly name associated with the input class.
  41100. * @returns the input's friendly name.
  41101. */
  41102. getSimpleName(): string;
  41103. private _pointerInput;
  41104. private _onMouseMove;
  41105. /**
  41106. * Rotate camera by mouse offset.
  41107. */
  41108. private rotateCamera;
  41109. }
  41110. }
  41111. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  41112. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41113. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41114. /**
  41115. * Default Inputs manager for the FlyCamera.
  41116. * It groups all the default supported inputs for ease of use.
  41117. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41118. */
  41119. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  41120. /**
  41121. * Instantiates a new FlyCameraInputsManager.
  41122. * @param camera Defines the camera the inputs belong to.
  41123. */
  41124. constructor(camera: FlyCamera);
  41125. /**
  41126. * Add keyboard input support to the input manager.
  41127. * @returns the new FlyCameraKeyboardMoveInput().
  41128. */
  41129. addKeyboard(): FlyCameraInputsManager;
  41130. /**
  41131. * Add mouse input support to the input manager.
  41132. * @param touchEnabled Enable touch screen support.
  41133. * @returns the new FlyCameraMouseInput().
  41134. */
  41135. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  41136. }
  41137. }
  41138. declare module "babylonjs/Cameras/flyCamera" {
  41139. import { Scene } from "babylonjs/scene";
  41140. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  41141. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41142. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41143. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  41144. /**
  41145. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41146. * such as in a 3D Space Shooter or a Flight Simulator.
  41147. */
  41148. export class FlyCamera extends TargetCamera {
  41149. /**
  41150. * Define the collision ellipsoid of the camera.
  41151. * This is helpful for simulating a camera body, like a player's body.
  41152. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  41153. */
  41154. ellipsoid: Vector3;
  41155. /**
  41156. * Define an offset for the position of the ellipsoid around the camera.
  41157. * This can be helpful if the camera is attached away from the player's body center,
  41158. * such as at its head.
  41159. */
  41160. ellipsoidOffset: Vector3;
  41161. /**
  41162. * Enable or disable collisions of the camera with the rest of the scene objects.
  41163. */
  41164. checkCollisions: boolean;
  41165. /**
  41166. * Enable or disable gravity on the camera.
  41167. */
  41168. applyGravity: boolean;
  41169. /**
  41170. * Define the current direction the camera is moving to.
  41171. */
  41172. cameraDirection: Vector3;
  41173. /**
  41174. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  41175. * This overrides and empties cameraRotation.
  41176. */
  41177. rotationQuaternion: Quaternion;
  41178. /**
  41179. * Track Roll to maintain the wanted Rolling when looking around.
  41180. */
  41181. _trackRoll: number;
  41182. /**
  41183. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  41184. */
  41185. rollCorrect: number;
  41186. /**
  41187. * Mimic a banked turn, Rolling the camera when Yawing.
  41188. * It's recommended to use rollCorrect = 10 for faster banking correction.
  41189. */
  41190. bankedTurn: boolean;
  41191. /**
  41192. * Limit in radians for how much Roll banking will add. (Default: 90°)
  41193. */
  41194. bankedTurnLimit: number;
  41195. /**
  41196. * Value of 0 disables the banked Roll.
  41197. * Value of 1 is equal to the Yaw angle in radians.
  41198. */
  41199. bankedTurnMultiplier: number;
  41200. /**
  41201. * The inputs manager loads all the input sources, such as keyboard and mouse.
  41202. */
  41203. inputs: FlyCameraInputsManager;
  41204. /**
  41205. * Gets the input sensibility for mouse input.
  41206. * Higher values reduce sensitivity.
  41207. */
  41208. get angularSensibility(): number;
  41209. /**
  41210. * Sets the input sensibility for a mouse input.
  41211. * Higher values reduce sensitivity.
  41212. */
  41213. set angularSensibility(value: number);
  41214. /**
  41215. * Get the keys for camera movement forward.
  41216. */
  41217. get keysForward(): number[];
  41218. /**
  41219. * Set the keys for camera movement forward.
  41220. */
  41221. set keysForward(value: number[]);
  41222. /**
  41223. * Get the keys for camera movement backward.
  41224. */
  41225. get keysBackward(): number[];
  41226. set keysBackward(value: number[]);
  41227. /**
  41228. * Get the keys for camera movement up.
  41229. */
  41230. get keysUp(): number[];
  41231. /**
  41232. * Set the keys for camera movement up.
  41233. */
  41234. set keysUp(value: number[]);
  41235. /**
  41236. * Get the keys for camera movement down.
  41237. */
  41238. get keysDown(): number[];
  41239. /**
  41240. * Set the keys for camera movement down.
  41241. */
  41242. set keysDown(value: number[]);
  41243. /**
  41244. * Get the keys for camera movement left.
  41245. */
  41246. get keysLeft(): number[];
  41247. /**
  41248. * Set the keys for camera movement left.
  41249. */
  41250. set keysLeft(value: number[]);
  41251. /**
  41252. * Set the keys for camera movement right.
  41253. */
  41254. get keysRight(): number[];
  41255. /**
  41256. * Set the keys for camera movement right.
  41257. */
  41258. set keysRight(value: number[]);
  41259. /**
  41260. * Event raised when the camera collides with a mesh in the scene.
  41261. */
  41262. onCollide: (collidedMesh: AbstractMesh) => void;
  41263. private _collider;
  41264. private _needMoveForGravity;
  41265. private _oldPosition;
  41266. private _diffPosition;
  41267. private _newPosition;
  41268. /** @hidden */
  41269. _localDirection: Vector3;
  41270. /** @hidden */
  41271. _transformedDirection: Vector3;
  41272. /**
  41273. * Instantiates a FlyCamera.
  41274. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41275. * such as in a 3D Space Shooter or a Flight Simulator.
  41276. * @param name Define the name of the camera in the scene.
  41277. * @param position Define the starting position of the camera in the scene.
  41278. * @param scene Define the scene the camera belongs to.
  41279. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  41280. */
  41281. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  41282. /**
  41283. * Attach a control to the HTML DOM element.
  41284. * @param element Defines the element that listens to the input events.
  41285. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  41286. */
  41287. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41288. /**
  41289. * Detach a control from the HTML DOM element.
  41290. * The camera will stop reacting to that input.
  41291. * @param element Defines the element that listens to the input events.
  41292. */
  41293. detachControl(element: HTMLElement): void;
  41294. private _collisionMask;
  41295. /**
  41296. * Get the mask that the camera ignores in collision events.
  41297. */
  41298. get collisionMask(): number;
  41299. /**
  41300. * Set the mask that the camera ignores in collision events.
  41301. */
  41302. set collisionMask(mask: number);
  41303. /** @hidden */
  41304. _collideWithWorld(displacement: Vector3): void;
  41305. /** @hidden */
  41306. private _onCollisionPositionChange;
  41307. /** @hidden */
  41308. _checkInputs(): void;
  41309. /** @hidden */
  41310. _decideIfNeedsToMove(): boolean;
  41311. /** @hidden */
  41312. _updatePosition(): void;
  41313. /**
  41314. * Restore the Roll to its target value at the rate specified.
  41315. * @param rate - Higher means slower restoring.
  41316. * @hidden
  41317. */
  41318. restoreRoll(rate: number): void;
  41319. /**
  41320. * Destroy the camera and release the current resources held by it.
  41321. */
  41322. dispose(): void;
  41323. /**
  41324. * Get the current object class name.
  41325. * @returns the class name.
  41326. */
  41327. getClassName(): string;
  41328. }
  41329. }
  41330. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  41331. import { Nullable } from "babylonjs/types";
  41332. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41333. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41334. /**
  41335. * Listen to keyboard events to control the camera.
  41336. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41337. */
  41338. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41339. /**
  41340. * Defines the camera the input is attached to.
  41341. */
  41342. camera: FlyCamera;
  41343. /**
  41344. * The list of keyboard keys used to control the forward move of the camera.
  41345. */
  41346. keysForward: number[];
  41347. /**
  41348. * The list of keyboard keys used to control the backward move of the camera.
  41349. */
  41350. keysBackward: number[];
  41351. /**
  41352. * The list of keyboard keys used to control the forward move of the camera.
  41353. */
  41354. keysUp: number[];
  41355. /**
  41356. * The list of keyboard keys used to control the backward move of the camera.
  41357. */
  41358. keysDown: number[];
  41359. /**
  41360. * The list of keyboard keys used to control the right strafe move of the camera.
  41361. */
  41362. keysRight: number[];
  41363. /**
  41364. * The list of keyboard keys used to control the left strafe move of the camera.
  41365. */
  41366. keysLeft: number[];
  41367. private _keys;
  41368. private _onCanvasBlurObserver;
  41369. private _onKeyboardObserver;
  41370. private _engine;
  41371. private _scene;
  41372. /**
  41373. * Attach the input controls to a specific dom element to get the input from.
  41374. * @param element Defines the element the controls should be listened from
  41375. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41376. */
  41377. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41378. /**
  41379. * Detach the current controls from the specified dom element.
  41380. * @param element Defines the element to stop listening the inputs from
  41381. */
  41382. detachControl(element: Nullable<HTMLElement>): void;
  41383. /**
  41384. * Gets the class name of the current intput.
  41385. * @returns the class name
  41386. */
  41387. getClassName(): string;
  41388. /** @hidden */
  41389. _onLostFocus(e: FocusEvent): void;
  41390. /**
  41391. * Get the friendly name associated with the input class.
  41392. * @returns the input friendly name
  41393. */
  41394. getSimpleName(): string;
  41395. /**
  41396. * Update the current camera state depending on the inputs that have been used this frame.
  41397. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41398. */
  41399. checkInputs(): void;
  41400. }
  41401. }
  41402. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  41403. import { Nullable } from "babylonjs/types";
  41404. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41405. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41406. /**
  41407. * Manage the mouse wheel inputs to control a follow camera.
  41408. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41409. */
  41410. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  41411. /**
  41412. * Defines the camera the input is attached to.
  41413. */
  41414. camera: FollowCamera;
  41415. /**
  41416. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  41417. */
  41418. axisControlRadius: boolean;
  41419. /**
  41420. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  41421. */
  41422. axisControlHeight: boolean;
  41423. /**
  41424. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  41425. */
  41426. axisControlRotation: boolean;
  41427. /**
  41428. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  41429. * relation to mouseWheel events.
  41430. */
  41431. wheelPrecision: number;
  41432. /**
  41433. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41434. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41435. */
  41436. wheelDeltaPercentage: number;
  41437. private _wheel;
  41438. private _observer;
  41439. /**
  41440. * Attach the input controls to a specific dom element to get the input from.
  41441. * @param element Defines the element the controls should be listened from
  41442. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41443. */
  41444. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41445. /**
  41446. * Detach the current controls from the specified dom element.
  41447. * @param element Defines the element to stop listening the inputs from
  41448. */
  41449. detachControl(element: Nullable<HTMLElement>): void;
  41450. /**
  41451. * Gets the class name of the current intput.
  41452. * @returns the class name
  41453. */
  41454. getClassName(): string;
  41455. /**
  41456. * Get the friendly name associated with the input class.
  41457. * @returns the input friendly name
  41458. */
  41459. getSimpleName(): string;
  41460. }
  41461. }
  41462. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  41463. import { Nullable } from "babylonjs/types";
  41464. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41465. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  41466. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  41467. /**
  41468. * Manage the pointers inputs to control an follow camera.
  41469. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41470. */
  41471. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  41472. /**
  41473. * Defines the camera the input is attached to.
  41474. */
  41475. camera: FollowCamera;
  41476. /**
  41477. * Gets the class name of the current input.
  41478. * @returns the class name
  41479. */
  41480. getClassName(): string;
  41481. /**
  41482. * Defines the pointer angular sensibility along the X axis or how fast is
  41483. * the camera rotating.
  41484. * A negative number will reverse the axis direction.
  41485. */
  41486. angularSensibilityX: number;
  41487. /**
  41488. * Defines the pointer angular sensibility along the Y axis or how fast is
  41489. * the camera rotating.
  41490. * A negative number will reverse the axis direction.
  41491. */
  41492. angularSensibilityY: number;
  41493. /**
  41494. * Defines the pointer pinch precision or how fast is the camera zooming.
  41495. * A negative number will reverse the axis direction.
  41496. */
  41497. pinchPrecision: number;
  41498. /**
  41499. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41500. * from 0.
  41501. * It defines the percentage of current camera.radius to use as delta when
  41502. * pinch zoom is used.
  41503. */
  41504. pinchDeltaPercentage: number;
  41505. /**
  41506. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  41507. */
  41508. axisXControlRadius: boolean;
  41509. /**
  41510. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  41511. */
  41512. axisXControlHeight: boolean;
  41513. /**
  41514. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  41515. */
  41516. axisXControlRotation: boolean;
  41517. /**
  41518. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  41519. */
  41520. axisYControlRadius: boolean;
  41521. /**
  41522. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  41523. */
  41524. axisYControlHeight: boolean;
  41525. /**
  41526. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  41527. */
  41528. axisYControlRotation: boolean;
  41529. /**
  41530. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  41531. */
  41532. axisPinchControlRadius: boolean;
  41533. /**
  41534. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  41535. */
  41536. axisPinchControlHeight: boolean;
  41537. /**
  41538. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  41539. */
  41540. axisPinchControlRotation: boolean;
  41541. /**
  41542. * Log error messages if basic misconfiguration has occurred.
  41543. */
  41544. warningEnable: boolean;
  41545. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41546. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41547. private _warningCounter;
  41548. private _warning;
  41549. }
  41550. }
  41551. declare module "babylonjs/Cameras/followCameraInputsManager" {
  41552. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41553. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41554. /**
  41555. * Default Inputs manager for the FollowCamera.
  41556. * It groups all the default supported inputs for ease of use.
  41557. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41558. */
  41559. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  41560. /**
  41561. * Instantiates a new FollowCameraInputsManager.
  41562. * @param camera Defines the camera the inputs belong to
  41563. */
  41564. constructor(camera: FollowCamera);
  41565. /**
  41566. * Add keyboard input support to the input manager.
  41567. * @returns the current input manager
  41568. */
  41569. addKeyboard(): FollowCameraInputsManager;
  41570. /**
  41571. * Add mouse wheel input support to the input manager.
  41572. * @returns the current input manager
  41573. */
  41574. addMouseWheel(): FollowCameraInputsManager;
  41575. /**
  41576. * Add pointers input support to the input manager.
  41577. * @returns the current input manager
  41578. */
  41579. addPointers(): FollowCameraInputsManager;
  41580. /**
  41581. * Add orientation input support to the input manager.
  41582. * @returns the current input manager
  41583. */
  41584. addVRDeviceOrientation(): FollowCameraInputsManager;
  41585. }
  41586. }
  41587. declare module "babylonjs/Cameras/followCamera" {
  41588. import { Nullable } from "babylonjs/types";
  41589. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41590. import { Scene } from "babylonjs/scene";
  41591. import { Vector3 } from "babylonjs/Maths/math.vector";
  41592. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41593. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  41594. /**
  41595. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  41596. * an arc rotate version arcFollowCamera are available.
  41597. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41598. */
  41599. export class FollowCamera extends TargetCamera {
  41600. /**
  41601. * Distance the follow camera should follow an object at
  41602. */
  41603. radius: number;
  41604. /**
  41605. * Minimum allowed distance of the camera to the axis of rotation
  41606. * (The camera can not get closer).
  41607. * This can help limiting how the Camera is able to move in the scene.
  41608. */
  41609. lowerRadiusLimit: Nullable<number>;
  41610. /**
  41611. * Maximum allowed distance of the camera to the axis of rotation
  41612. * (The camera can not get further).
  41613. * This can help limiting how the Camera is able to move in the scene.
  41614. */
  41615. upperRadiusLimit: Nullable<number>;
  41616. /**
  41617. * Define a rotation offset between the camera and the object it follows
  41618. */
  41619. rotationOffset: number;
  41620. /**
  41621. * Minimum allowed angle to camera position relative to target object.
  41622. * This can help limiting how the Camera is able to move in the scene.
  41623. */
  41624. lowerRotationOffsetLimit: Nullable<number>;
  41625. /**
  41626. * Maximum allowed angle to camera position relative to target object.
  41627. * This can help limiting how the Camera is able to move in the scene.
  41628. */
  41629. upperRotationOffsetLimit: Nullable<number>;
  41630. /**
  41631. * Define a height offset between the camera and the object it follows.
  41632. * It can help following an object from the top (like a car chaing a plane)
  41633. */
  41634. heightOffset: number;
  41635. /**
  41636. * Minimum allowed height of camera position relative to target object.
  41637. * This can help limiting how the Camera is able to move in the scene.
  41638. */
  41639. lowerHeightOffsetLimit: Nullable<number>;
  41640. /**
  41641. * Maximum allowed height of camera position relative to target object.
  41642. * This can help limiting how the Camera is able to move in the scene.
  41643. */
  41644. upperHeightOffsetLimit: Nullable<number>;
  41645. /**
  41646. * Define how fast the camera can accelerate to follow it s target.
  41647. */
  41648. cameraAcceleration: number;
  41649. /**
  41650. * Define the speed limit of the camera following an object.
  41651. */
  41652. maxCameraSpeed: number;
  41653. /**
  41654. * Define the target of the camera.
  41655. */
  41656. lockedTarget: Nullable<AbstractMesh>;
  41657. /**
  41658. * Defines the input associated with the camera.
  41659. */
  41660. inputs: FollowCameraInputsManager;
  41661. /**
  41662. * Instantiates the follow camera.
  41663. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41664. * @param name Define the name of the camera in the scene
  41665. * @param position Define the position of the camera
  41666. * @param scene Define the scene the camera belong to
  41667. * @param lockedTarget Define the target of the camera
  41668. */
  41669. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  41670. private _follow;
  41671. /**
  41672. * Attached controls to the current camera.
  41673. * @param element Defines the element the controls should be listened from
  41674. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41675. */
  41676. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41677. /**
  41678. * Detach the current controls from the camera.
  41679. * The camera will stop reacting to inputs.
  41680. * @param element Defines the element to stop listening the inputs from
  41681. */
  41682. detachControl(element: HTMLElement): void;
  41683. /** @hidden */
  41684. _checkInputs(): void;
  41685. private _checkLimits;
  41686. /**
  41687. * Gets the camera class name.
  41688. * @returns the class name
  41689. */
  41690. getClassName(): string;
  41691. }
  41692. /**
  41693. * Arc Rotate version of the follow camera.
  41694. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  41695. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41696. */
  41697. export class ArcFollowCamera extends TargetCamera {
  41698. /** The longitudinal angle of the camera */
  41699. alpha: number;
  41700. /** The latitudinal angle of the camera */
  41701. beta: number;
  41702. /** The radius of the camera from its target */
  41703. radius: number;
  41704. /** Define the camera target (the messh it should follow) */
  41705. target: Nullable<AbstractMesh>;
  41706. private _cartesianCoordinates;
  41707. /**
  41708. * Instantiates a new ArcFollowCamera
  41709. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41710. * @param name Define the name of the camera
  41711. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  41712. * @param beta Define the rotation angle of the camera around the elevation axis
  41713. * @param radius Define the radius of the camera from its target point
  41714. * @param target Define the target of the camera
  41715. * @param scene Define the scene the camera belongs to
  41716. */
  41717. constructor(name: string,
  41718. /** The longitudinal angle of the camera */
  41719. alpha: number,
  41720. /** The latitudinal angle of the camera */
  41721. beta: number,
  41722. /** The radius of the camera from its target */
  41723. radius: number,
  41724. /** Define the camera target (the messh it should follow) */
  41725. target: Nullable<AbstractMesh>, scene: Scene);
  41726. private _follow;
  41727. /** @hidden */
  41728. _checkInputs(): void;
  41729. /**
  41730. * Returns the class name of the object.
  41731. * It is mostly used internally for serialization purposes.
  41732. */
  41733. getClassName(): string;
  41734. }
  41735. }
  41736. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  41737. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41738. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41739. import { Nullable } from "babylonjs/types";
  41740. /**
  41741. * Manage the keyboard inputs to control the movement of a follow camera.
  41742. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41743. */
  41744. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  41745. /**
  41746. * Defines the camera the input is attached to.
  41747. */
  41748. camera: FollowCamera;
  41749. /**
  41750. * Defines the list of key codes associated with the up action (increase heightOffset)
  41751. */
  41752. keysHeightOffsetIncr: number[];
  41753. /**
  41754. * Defines the list of key codes associated with the down action (decrease heightOffset)
  41755. */
  41756. keysHeightOffsetDecr: number[];
  41757. /**
  41758. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  41759. */
  41760. keysHeightOffsetModifierAlt: boolean;
  41761. /**
  41762. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  41763. */
  41764. keysHeightOffsetModifierCtrl: boolean;
  41765. /**
  41766. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  41767. */
  41768. keysHeightOffsetModifierShift: boolean;
  41769. /**
  41770. * Defines the list of key codes associated with the left action (increase rotationOffset)
  41771. */
  41772. keysRotationOffsetIncr: number[];
  41773. /**
  41774. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  41775. */
  41776. keysRotationOffsetDecr: number[];
  41777. /**
  41778. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  41779. */
  41780. keysRotationOffsetModifierAlt: boolean;
  41781. /**
  41782. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  41783. */
  41784. keysRotationOffsetModifierCtrl: boolean;
  41785. /**
  41786. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  41787. */
  41788. keysRotationOffsetModifierShift: boolean;
  41789. /**
  41790. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  41791. */
  41792. keysRadiusIncr: number[];
  41793. /**
  41794. * Defines the list of key codes associated with the zoom-out action (increase radius)
  41795. */
  41796. keysRadiusDecr: number[];
  41797. /**
  41798. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  41799. */
  41800. keysRadiusModifierAlt: boolean;
  41801. /**
  41802. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  41803. */
  41804. keysRadiusModifierCtrl: boolean;
  41805. /**
  41806. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  41807. */
  41808. keysRadiusModifierShift: boolean;
  41809. /**
  41810. * Defines the rate of change of heightOffset.
  41811. */
  41812. heightSensibility: number;
  41813. /**
  41814. * Defines the rate of change of rotationOffset.
  41815. */
  41816. rotationSensibility: number;
  41817. /**
  41818. * Defines the rate of change of radius.
  41819. */
  41820. radiusSensibility: number;
  41821. private _keys;
  41822. private _ctrlPressed;
  41823. private _altPressed;
  41824. private _shiftPressed;
  41825. private _onCanvasBlurObserver;
  41826. private _onKeyboardObserver;
  41827. private _engine;
  41828. private _scene;
  41829. /**
  41830. * Attach the input controls to a specific dom element to get the input from.
  41831. * @param element Defines the element the controls should be listened from
  41832. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41833. */
  41834. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41835. /**
  41836. * Detach the current controls from the specified dom element.
  41837. * @param element Defines the element to stop listening the inputs from
  41838. */
  41839. detachControl(element: Nullable<HTMLElement>): void;
  41840. /**
  41841. * Update the current camera state depending on the inputs that have been used this frame.
  41842. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41843. */
  41844. checkInputs(): void;
  41845. /**
  41846. * Gets the class name of the current input.
  41847. * @returns the class name
  41848. */
  41849. getClassName(): string;
  41850. /**
  41851. * Get the friendly name associated with the input class.
  41852. * @returns the input friendly name
  41853. */
  41854. getSimpleName(): string;
  41855. /**
  41856. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41857. * allow modification of the heightOffset value.
  41858. */
  41859. private _modifierHeightOffset;
  41860. /**
  41861. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41862. * allow modification of the rotationOffset value.
  41863. */
  41864. private _modifierRotationOffset;
  41865. /**
  41866. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41867. * allow modification of the radius value.
  41868. */
  41869. private _modifierRadius;
  41870. }
  41871. }
  41872. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  41873. import { Nullable } from "babylonjs/types";
  41874. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41875. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41876. import { Observable } from "babylonjs/Misc/observable";
  41877. module "babylonjs/Cameras/freeCameraInputsManager" {
  41878. interface FreeCameraInputsManager {
  41879. /**
  41880. * @hidden
  41881. */
  41882. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  41883. /**
  41884. * Add orientation input support to the input manager.
  41885. * @returns the current input manager
  41886. */
  41887. addDeviceOrientation(): FreeCameraInputsManager;
  41888. }
  41889. }
  41890. /**
  41891. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41892. * Screen rotation is taken into account.
  41893. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41894. */
  41895. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41896. private _camera;
  41897. private _screenOrientationAngle;
  41898. private _constantTranform;
  41899. private _screenQuaternion;
  41900. private _alpha;
  41901. private _beta;
  41902. private _gamma;
  41903. /**
  41904. * Can be used to detect if a device orientation sensor is available on a device
  41905. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  41906. * @returns a promise that will resolve on orientation change
  41907. */
  41908. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  41909. /**
  41910. * @hidden
  41911. */
  41912. _onDeviceOrientationChangedObservable: Observable<void>;
  41913. /**
  41914. * Instantiates a new input
  41915. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41916. */
  41917. constructor();
  41918. /**
  41919. * Define the camera controlled by the input.
  41920. */
  41921. get camera(): FreeCamera;
  41922. set camera(camera: FreeCamera);
  41923. /**
  41924. * Attach the input controls to a specific dom element to get the input from.
  41925. * @param element Defines the element the controls should be listened from
  41926. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41927. */
  41928. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41929. private _orientationChanged;
  41930. private _deviceOrientation;
  41931. /**
  41932. * Detach the current controls from the specified dom element.
  41933. * @param element Defines the element to stop listening the inputs from
  41934. */
  41935. detachControl(element: Nullable<HTMLElement>): void;
  41936. /**
  41937. * Update the current camera state depending on the inputs that have been used this frame.
  41938. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41939. */
  41940. checkInputs(): void;
  41941. /**
  41942. * Gets the class name of the current intput.
  41943. * @returns the class name
  41944. */
  41945. getClassName(): string;
  41946. /**
  41947. * Get the friendly name associated with the input class.
  41948. * @returns the input friendly name
  41949. */
  41950. getSimpleName(): string;
  41951. }
  41952. }
  41953. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  41954. import { Nullable } from "babylonjs/types";
  41955. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41956. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41957. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41958. /**
  41959. * Manage the gamepad inputs to control a free camera.
  41960. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41961. */
  41962. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41963. /**
  41964. * Define the camera the input is attached to.
  41965. */
  41966. camera: FreeCamera;
  41967. /**
  41968. * Define the Gamepad controlling the input
  41969. */
  41970. gamepad: Nullable<Gamepad>;
  41971. /**
  41972. * Defines the gamepad rotation sensiblity.
  41973. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41974. */
  41975. gamepadAngularSensibility: number;
  41976. /**
  41977. * Defines the gamepad move sensiblity.
  41978. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41979. */
  41980. gamepadMoveSensibility: number;
  41981. private _yAxisScale;
  41982. /**
  41983. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41984. */
  41985. get invertYAxis(): boolean;
  41986. set invertYAxis(value: boolean);
  41987. private _onGamepadConnectedObserver;
  41988. private _onGamepadDisconnectedObserver;
  41989. private _cameraTransform;
  41990. private _deltaTransform;
  41991. private _vector3;
  41992. private _vector2;
  41993. /**
  41994. * Attach the input controls to a specific dom element to get the input from.
  41995. * @param element Defines the element the controls should be listened from
  41996. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41997. */
  41998. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41999. /**
  42000. * Detach the current controls from the specified dom element.
  42001. * @param element Defines the element to stop listening the inputs from
  42002. */
  42003. detachControl(element: Nullable<HTMLElement>): void;
  42004. /**
  42005. * Update the current camera state depending on the inputs that have been used this frame.
  42006. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42007. */
  42008. checkInputs(): void;
  42009. /**
  42010. * Gets the class name of the current intput.
  42011. * @returns the class name
  42012. */
  42013. getClassName(): string;
  42014. /**
  42015. * Get the friendly name associated with the input class.
  42016. * @returns the input friendly name
  42017. */
  42018. getSimpleName(): string;
  42019. }
  42020. }
  42021. declare module "babylonjs/Misc/virtualJoystick" {
  42022. import { Nullable } from "babylonjs/types";
  42023. import { Vector3 } from "babylonjs/Maths/math.vector";
  42024. /**
  42025. * Defines the potential axis of a Joystick
  42026. */
  42027. export enum JoystickAxis {
  42028. /** X axis */
  42029. X = 0,
  42030. /** Y axis */
  42031. Y = 1,
  42032. /** Z axis */
  42033. Z = 2
  42034. }
  42035. /**
  42036. * Class used to define virtual joystick (used in touch mode)
  42037. */
  42038. export class VirtualJoystick {
  42039. /**
  42040. * Gets or sets a boolean indicating that left and right values must be inverted
  42041. */
  42042. reverseLeftRight: boolean;
  42043. /**
  42044. * Gets or sets a boolean indicating that up and down values must be inverted
  42045. */
  42046. reverseUpDown: boolean;
  42047. /**
  42048. * Gets the offset value for the position (ie. the change of the position value)
  42049. */
  42050. deltaPosition: Vector3;
  42051. /**
  42052. * Gets a boolean indicating if the virtual joystick was pressed
  42053. */
  42054. pressed: boolean;
  42055. /**
  42056. * Canvas the virtual joystick will render onto, default z-index of this is 5
  42057. */
  42058. static Canvas: Nullable<HTMLCanvasElement>;
  42059. private static _globalJoystickIndex;
  42060. private static vjCanvasContext;
  42061. private static vjCanvasWidth;
  42062. private static vjCanvasHeight;
  42063. private static halfWidth;
  42064. private _action;
  42065. private _axisTargetedByLeftAndRight;
  42066. private _axisTargetedByUpAndDown;
  42067. private _joystickSensibility;
  42068. private _inversedSensibility;
  42069. private _joystickPointerID;
  42070. private _joystickColor;
  42071. private _joystickPointerPos;
  42072. private _joystickPreviousPointerPos;
  42073. private _joystickPointerStartPos;
  42074. private _deltaJoystickVector;
  42075. private _leftJoystick;
  42076. private _touches;
  42077. private _onPointerDownHandlerRef;
  42078. private _onPointerMoveHandlerRef;
  42079. private _onPointerUpHandlerRef;
  42080. private _onResize;
  42081. /**
  42082. * Creates a new virtual joystick
  42083. * @param leftJoystick defines that the joystick is for left hand (false by default)
  42084. */
  42085. constructor(leftJoystick?: boolean);
  42086. /**
  42087. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  42088. * @param newJoystickSensibility defines the new sensibility
  42089. */
  42090. setJoystickSensibility(newJoystickSensibility: number): void;
  42091. private _onPointerDown;
  42092. private _onPointerMove;
  42093. private _onPointerUp;
  42094. /**
  42095. * Change the color of the virtual joystick
  42096. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  42097. */
  42098. setJoystickColor(newColor: string): void;
  42099. /**
  42100. * Defines a callback to call when the joystick is touched
  42101. * @param action defines the callback
  42102. */
  42103. setActionOnTouch(action: () => any): void;
  42104. /**
  42105. * Defines which axis you'd like to control for left & right
  42106. * @param axis defines the axis to use
  42107. */
  42108. setAxisForLeftRight(axis: JoystickAxis): void;
  42109. /**
  42110. * Defines which axis you'd like to control for up & down
  42111. * @param axis defines the axis to use
  42112. */
  42113. setAxisForUpDown(axis: JoystickAxis): void;
  42114. private _drawVirtualJoystick;
  42115. /**
  42116. * Release internal HTML canvas
  42117. */
  42118. releaseCanvas(): void;
  42119. }
  42120. }
  42121. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  42122. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  42123. import { Nullable } from "babylonjs/types";
  42124. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42125. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42126. module "babylonjs/Cameras/freeCameraInputsManager" {
  42127. interface FreeCameraInputsManager {
  42128. /**
  42129. * Add virtual joystick input support to the input manager.
  42130. * @returns the current input manager
  42131. */
  42132. addVirtualJoystick(): FreeCameraInputsManager;
  42133. }
  42134. }
  42135. /**
  42136. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  42137. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42138. */
  42139. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  42140. /**
  42141. * Defines the camera the input is attached to.
  42142. */
  42143. camera: FreeCamera;
  42144. private _leftjoystick;
  42145. private _rightjoystick;
  42146. /**
  42147. * Gets the left stick of the virtual joystick.
  42148. * @returns The virtual Joystick
  42149. */
  42150. getLeftJoystick(): VirtualJoystick;
  42151. /**
  42152. * Gets the right stick of the virtual joystick.
  42153. * @returns The virtual Joystick
  42154. */
  42155. getRightJoystick(): VirtualJoystick;
  42156. /**
  42157. * Update the current camera state depending on the inputs that have been used this frame.
  42158. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42159. */
  42160. checkInputs(): void;
  42161. /**
  42162. * Attach the input controls to a specific dom element to get the input from.
  42163. * @param element Defines the element the controls should be listened from
  42164. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42165. */
  42166. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42167. /**
  42168. * Detach the current controls from the specified dom element.
  42169. * @param element Defines the element to stop listening the inputs from
  42170. */
  42171. detachControl(element: Nullable<HTMLElement>): void;
  42172. /**
  42173. * Gets the class name of the current intput.
  42174. * @returns the class name
  42175. */
  42176. getClassName(): string;
  42177. /**
  42178. * Get the friendly name associated with the input class.
  42179. * @returns the input friendly name
  42180. */
  42181. getSimpleName(): string;
  42182. }
  42183. }
  42184. declare module "babylonjs/Cameras/Inputs/index" {
  42185. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  42186. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  42187. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  42188. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  42189. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  42190. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  42191. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  42192. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  42193. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  42194. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  42195. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42196. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  42197. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  42198. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  42199. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  42200. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  42201. }
  42202. declare module "babylonjs/Cameras/touchCamera" {
  42203. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42204. import { Scene } from "babylonjs/scene";
  42205. import { Vector3 } from "babylonjs/Maths/math.vector";
  42206. /**
  42207. * This represents a FPS type of camera controlled by touch.
  42208. * This is like a universal camera minus the Gamepad controls.
  42209. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42210. */
  42211. export class TouchCamera extends FreeCamera {
  42212. /**
  42213. * Defines the touch sensibility for rotation.
  42214. * The higher the faster.
  42215. */
  42216. get touchAngularSensibility(): number;
  42217. set touchAngularSensibility(value: number);
  42218. /**
  42219. * Defines the touch sensibility for move.
  42220. * The higher the faster.
  42221. */
  42222. get touchMoveSensibility(): number;
  42223. set touchMoveSensibility(value: number);
  42224. /**
  42225. * Instantiates a new touch camera.
  42226. * This represents a FPS type of camera controlled by touch.
  42227. * This is like a universal camera minus the Gamepad controls.
  42228. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42229. * @param name Define the name of the camera in the scene
  42230. * @param position Define the start position of the camera in the scene
  42231. * @param scene Define the scene the camera belongs to
  42232. */
  42233. constructor(name: string, position: Vector3, scene: Scene);
  42234. /**
  42235. * Gets the current object class name.
  42236. * @return the class name
  42237. */
  42238. getClassName(): string;
  42239. /** @hidden */
  42240. _setupInputs(): void;
  42241. }
  42242. }
  42243. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  42244. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42245. import { Scene } from "babylonjs/scene";
  42246. import { Vector3 } from "babylonjs/Maths/math.vector";
  42247. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42248. import { Axis } from "babylonjs/Maths/math.axis";
  42249. /**
  42250. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  42251. * being tilted forward or back and left or right.
  42252. */
  42253. export class DeviceOrientationCamera extends FreeCamera {
  42254. private _initialQuaternion;
  42255. private _quaternionCache;
  42256. private _tmpDragQuaternion;
  42257. private _disablePointerInputWhenUsingDeviceOrientation;
  42258. /**
  42259. * Creates a new device orientation camera
  42260. * @param name The name of the camera
  42261. * @param position The start position camera
  42262. * @param scene The scene the camera belongs to
  42263. */
  42264. constructor(name: string, position: Vector3, scene: Scene);
  42265. /**
  42266. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  42267. */
  42268. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  42269. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  42270. private _dragFactor;
  42271. /**
  42272. * Enabled turning on the y axis when the orientation sensor is active
  42273. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  42274. */
  42275. enableHorizontalDragging(dragFactor?: number): void;
  42276. /**
  42277. * Gets the current instance class name ("DeviceOrientationCamera").
  42278. * This helps avoiding instanceof at run time.
  42279. * @returns the class name
  42280. */
  42281. getClassName(): string;
  42282. /**
  42283. * @hidden
  42284. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  42285. */
  42286. _checkInputs(): void;
  42287. /**
  42288. * Reset the camera to its default orientation on the specified axis only.
  42289. * @param axis The axis to reset
  42290. */
  42291. resetToCurrentRotation(axis?: Axis): void;
  42292. }
  42293. }
  42294. declare module "babylonjs/Gamepads/xboxGamepad" {
  42295. import { Observable } from "babylonjs/Misc/observable";
  42296. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42297. /**
  42298. * Defines supported buttons for XBox360 compatible gamepads
  42299. */
  42300. export enum Xbox360Button {
  42301. /** A */
  42302. A = 0,
  42303. /** B */
  42304. B = 1,
  42305. /** X */
  42306. X = 2,
  42307. /** Y */
  42308. Y = 3,
  42309. /** Start */
  42310. Start = 4,
  42311. /** Back */
  42312. Back = 5,
  42313. /** Left button */
  42314. LB = 6,
  42315. /** Right button */
  42316. RB = 7,
  42317. /** Left stick */
  42318. LeftStick = 8,
  42319. /** Right stick */
  42320. RightStick = 9
  42321. }
  42322. /** Defines values for XBox360 DPad */
  42323. export enum Xbox360Dpad {
  42324. /** Up */
  42325. Up = 0,
  42326. /** Down */
  42327. Down = 1,
  42328. /** Left */
  42329. Left = 2,
  42330. /** Right */
  42331. Right = 3
  42332. }
  42333. /**
  42334. * Defines a XBox360 gamepad
  42335. */
  42336. export class Xbox360Pad extends Gamepad {
  42337. private _leftTrigger;
  42338. private _rightTrigger;
  42339. private _onlefttriggerchanged;
  42340. private _onrighttriggerchanged;
  42341. private _onbuttondown;
  42342. private _onbuttonup;
  42343. private _ondpaddown;
  42344. private _ondpadup;
  42345. /** Observable raised when a button is pressed */
  42346. onButtonDownObservable: Observable<Xbox360Button>;
  42347. /** Observable raised when a button is released */
  42348. onButtonUpObservable: Observable<Xbox360Button>;
  42349. /** Observable raised when a pad is pressed */
  42350. onPadDownObservable: Observable<Xbox360Dpad>;
  42351. /** Observable raised when a pad is released */
  42352. onPadUpObservable: Observable<Xbox360Dpad>;
  42353. private _buttonA;
  42354. private _buttonB;
  42355. private _buttonX;
  42356. private _buttonY;
  42357. private _buttonBack;
  42358. private _buttonStart;
  42359. private _buttonLB;
  42360. private _buttonRB;
  42361. private _buttonLeftStick;
  42362. private _buttonRightStick;
  42363. private _dPadUp;
  42364. private _dPadDown;
  42365. private _dPadLeft;
  42366. private _dPadRight;
  42367. private _isXboxOnePad;
  42368. /**
  42369. * Creates a new XBox360 gamepad object
  42370. * @param id defines the id of this gamepad
  42371. * @param index defines its index
  42372. * @param gamepad defines the internal HTML gamepad object
  42373. * @param xboxOne defines if it is a XBox One gamepad
  42374. */
  42375. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  42376. /**
  42377. * Defines the callback to call when left trigger is pressed
  42378. * @param callback defines the callback to use
  42379. */
  42380. onlefttriggerchanged(callback: (value: number) => void): void;
  42381. /**
  42382. * Defines the callback to call when right trigger is pressed
  42383. * @param callback defines the callback to use
  42384. */
  42385. onrighttriggerchanged(callback: (value: number) => void): void;
  42386. /**
  42387. * Gets the left trigger value
  42388. */
  42389. get leftTrigger(): number;
  42390. /**
  42391. * Sets the left trigger value
  42392. */
  42393. set leftTrigger(newValue: number);
  42394. /**
  42395. * Gets the right trigger value
  42396. */
  42397. get rightTrigger(): number;
  42398. /**
  42399. * Sets the right trigger value
  42400. */
  42401. set rightTrigger(newValue: number);
  42402. /**
  42403. * Defines the callback to call when a button is pressed
  42404. * @param callback defines the callback to use
  42405. */
  42406. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  42407. /**
  42408. * Defines the callback to call when a button is released
  42409. * @param callback defines the callback to use
  42410. */
  42411. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  42412. /**
  42413. * Defines the callback to call when a pad is pressed
  42414. * @param callback defines the callback to use
  42415. */
  42416. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  42417. /**
  42418. * Defines the callback to call when a pad is released
  42419. * @param callback defines the callback to use
  42420. */
  42421. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  42422. private _setButtonValue;
  42423. private _setDPadValue;
  42424. /**
  42425. * Gets the value of the `A` button
  42426. */
  42427. get buttonA(): number;
  42428. /**
  42429. * Sets the value of the `A` button
  42430. */
  42431. set buttonA(value: number);
  42432. /**
  42433. * Gets the value of the `B` button
  42434. */
  42435. get buttonB(): number;
  42436. /**
  42437. * Sets the value of the `B` button
  42438. */
  42439. set buttonB(value: number);
  42440. /**
  42441. * Gets the value of the `X` button
  42442. */
  42443. get buttonX(): number;
  42444. /**
  42445. * Sets the value of the `X` button
  42446. */
  42447. set buttonX(value: number);
  42448. /**
  42449. * Gets the value of the `Y` button
  42450. */
  42451. get buttonY(): number;
  42452. /**
  42453. * Sets the value of the `Y` button
  42454. */
  42455. set buttonY(value: number);
  42456. /**
  42457. * Gets the value of the `Start` button
  42458. */
  42459. get buttonStart(): number;
  42460. /**
  42461. * Sets the value of the `Start` button
  42462. */
  42463. set buttonStart(value: number);
  42464. /**
  42465. * Gets the value of the `Back` button
  42466. */
  42467. get buttonBack(): number;
  42468. /**
  42469. * Sets the value of the `Back` button
  42470. */
  42471. set buttonBack(value: number);
  42472. /**
  42473. * Gets the value of the `Left` button
  42474. */
  42475. get buttonLB(): number;
  42476. /**
  42477. * Sets the value of the `Left` button
  42478. */
  42479. set buttonLB(value: number);
  42480. /**
  42481. * Gets the value of the `Right` button
  42482. */
  42483. get buttonRB(): number;
  42484. /**
  42485. * Sets the value of the `Right` button
  42486. */
  42487. set buttonRB(value: number);
  42488. /**
  42489. * Gets the value of the Left joystick
  42490. */
  42491. get buttonLeftStick(): number;
  42492. /**
  42493. * Sets the value of the Left joystick
  42494. */
  42495. set buttonLeftStick(value: number);
  42496. /**
  42497. * Gets the value of the Right joystick
  42498. */
  42499. get buttonRightStick(): number;
  42500. /**
  42501. * Sets the value of the Right joystick
  42502. */
  42503. set buttonRightStick(value: number);
  42504. /**
  42505. * Gets the value of D-pad up
  42506. */
  42507. get dPadUp(): number;
  42508. /**
  42509. * Sets the value of D-pad up
  42510. */
  42511. set dPadUp(value: number);
  42512. /**
  42513. * Gets the value of D-pad down
  42514. */
  42515. get dPadDown(): number;
  42516. /**
  42517. * Sets the value of D-pad down
  42518. */
  42519. set dPadDown(value: number);
  42520. /**
  42521. * Gets the value of D-pad left
  42522. */
  42523. get dPadLeft(): number;
  42524. /**
  42525. * Sets the value of D-pad left
  42526. */
  42527. set dPadLeft(value: number);
  42528. /**
  42529. * Gets the value of D-pad right
  42530. */
  42531. get dPadRight(): number;
  42532. /**
  42533. * Sets the value of D-pad right
  42534. */
  42535. set dPadRight(value: number);
  42536. /**
  42537. * Force the gamepad to synchronize with device values
  42538. */
  42539. update(): void;
  42540. /**
  42541. * Disposes the gamepad
  42542. */
  42543. dispose(): void;
  42544. }
  42545. }
  42546. declare module "babylonjs/Gamepads/dualShockGamepad" {
  42547. import { Observable } from "babylonjs/Misc/observable";
  42548. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42549. /**
  42550. * Defines supported buttons for DualShock compatible gamepads
  42551. */
  42552. export enum DualShockButton {
  42553. /** Cross */
  42554. Cross = 0,
  42555. /** Circle */
  42556. Circle = 1,
  42557. /** Square */
  42558. Square = 2,
  42559. /** Triangle */
  42560. Triangle = 3,
  42561. /** Options */
  42562. Options = 4,
  42563. /** Share */
  42564. Share = 5,
  42565. /** L1 */
  42566. L1 = 6,
  42567. /** R1 */
  42568. R1 = 7,
  42569. /** Left stick */
  42570. LeftStick = 8,
  42571. /** Right stick */
  42572. RightStick = 9
  42573. }
  42574. /** Defines values for DualShock DPad */
  42575. export enum DualShockDpad {
  42576. /** Up */
  42577. Up = 0,
  42578. /** Down */
  42579. Down = 1,
  42580. /** Left */
  42581. Left = 2,
  42582. /** Right */
  42583. Right = 3
  42584. }
  42585. /**
  42586. * Defines a DualShock gamepad
  42587. */
  42588. export class DualShockPad extends Gamepad {
  42589. private _leftTrigger;
  42590. private _rightTrigger;
  42591. private _onlefttriggerchanged;
  42592. private _onrighttriggerchanged;
  42593. private _onbuttondown;
  42594. private _onbuttonup;
  42595. private _ondpaddown;
  42596. private _ondpadup;
  42597. /** Observable raised when a button is pressed */
  42598. onButtonDownObservable: Observable<DualShockButton>;
  42599. /** Observable raised when a button is released */
  42600. onButtonUpObservable: Observable<DualShockButton>;
  42601. /** Observable raised when a pad is pressed */
  42602. onPadDownObservable: Observable<DualShockDpad>;
  42603. /** Observable raised when a pad is released */
  42604. onPadUpObservable: Observable<DualShockDpad>;
  42605. private _buttonCross;
  42606. private _buttonCircle;
  42607. private _buttonSquare;
  42608. private _buttonTriangle;
  42609. private _buttonShare;
  42610. private _buttonOptions;
  42611. private _buttonL1;
  42612. private _buttonR1;
  42613. private _buttonLeftStick;
  42614. private _buttonRightStick;
  42615. private _dPadUp;
  42616. private _dPadDown;
  42617. private _dPadLeft;
  42618. private _dPadRight;
  42619. /**
  42620. * Creates a new DualShock gamepad object
  42621. * @param id defines the id of this gamepad
  42622. * @param index defines its index
  42623. * @param gamepad defines the internal HTML gamepad object
  42624. */
  42625. constructor(id: string, index: number, gamepad: any);
  42626. /**
  42627. * Defines the callback to call when left trigger is pressed
  42628. * @param callback defines the callback to use
  42629. */
  42630. onlefttriggerchanged(callback: (value: number) => void): void;
  42631. /**
  42632. * Defines the callback to call when right trigger is pressed
  42633. * @param callback defines the callback to use
  42634. */
  42635. onrighttriggerchanged(callback: (value: number) => void): void;
  42636. /**
  42637. * Gets the left trigger value
  42638. */
  42639. get leftTrigger(): number;
  42640. /**
  42641. * Sets the left trigger value
  42642. */
  42643. set leftTrigger(newValue: number);
  42644. /**
  42645. * Gets the right trigger value
  42646. */
  42647. get rightTrigger(): number;
  42648. /**
  42649. * Sets the right trigger value
  42650. */
  42651. set rightTrigger(newValue: number);
  42652. /**
  42653. * Defines the callback to call when a button is pressed
  42654. * @param callback defines the callback to use
  42655. */
  42656. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  42657. /**
  42658. * Defines the callback to call when a button is released
  42659. * @param callback defines the callback to use
  42660. */
  42661. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  42662. /**
  42663. * Defines the callback to call when a pad is pressed
  42664. * @param callback defines the callback to use
  42665. */
  42666. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  42667. /**
  42668. * Defines the callback to call when a pad is released
  42669. * @param callback defines the callback to use
  42670. */
  42671. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  42672. private _setButtonValue;
  42673. private _setDPadValue;
  42674. /**
  42675. * Gets the value of the `Cross` button
  42676. */
  42677. get buttonCross(): number;
  42678. /**
  42679. * Sets the value of the `Cross` button
  42680. */
  42681. set buttonCross(value: number);
  42682. /**
  42683. * Gets the value of the `Circle` button
  42684. */
  42685. get buttonCircle(): number;
  42686. /**
  42687. * Sets the value of the `Circle` button
  42688. */
  42689. set buttonCircle(value: number);
  42690. /**
  42691. * Gets the value of the `Square` button
  42692. */
  42693. get buttonSquare(): number;
  42694. /**
  42695. * Sets the value of the `Square` button
  42696. */
  42697. set buttonSquare(value: number);
  42698. /**
  42699. * Gets the value of the `Triangle` button
  42700. */
  42701. get buttonTriangle(): number;
  42702. /**
  42703. * Sets the value of the `Triangle` button
  42704. */
  42705. set buttonTriangle(value: number);
  42706. /**
  42707. * Gets the value of the `Options` button
  42708. */
  42709. get buttonOptions(): number;
  42710. /**
  42711. * Sets the value of the `Options` button
  42712. */
  42713. set buttonOptions(value: number);
  42714. /**
  42715. * Gets the value of the `Share` button
  42716. */
  42717. get buttonShare(): number;
  42718. /**
  42719. * Sets the value of the `Share` button
  42720. */
  42721. set buttonShare(value: number);
  42722. /**
  42723. * Gets the value of the `L1` button
  42724. */
  42725. get buttonL1(): number;
  42726. /**
  42727. * Sets the value of the `L1` button
  42728. */
  42729. set buttonL1(value: number);
  42730. /**
  42731. * Gets the value of the `R1` button
  42732. */
  42733. get buttonR1(): number;
  42734. /**
  42735. * Sets the value of the `R1` button
  42736. */
  42737. set buttonR1(value: number);
  42738. /**
  42739. * Gets the value of the Left joystick
  42740. */
  42741. get buttonLeftStick(): number;
  42742. /**
  42743. * Sets the value of the Left joystick
  42744. */
  42745. set buttonLeftStick(value: number);
  42746. /**
  42747. * Gets the value of the Right joystick
  42748. */
  42749. get buttonRightStick(): number;
  42750. /**
  42751. * Sets the value of the Right joystick
  42752. */
  42753. set buttonRightStick(value: number);
  42754. /**
  42755. * Gets the value of D-pad up
  42756. */
  42757. get dPadUp(): number;
  42758. /**
  42759. * Sets the value of D-pad up
  42760. */
  42761. set dPadUp(value: number);
  42762. /**
  42763. * Gets the value of D-pad down
  42764. */
  42765. get dPadDown(): number;
  42766. /**
  42767. * Sets the value of D-pad down
  42768. */
  42769. set dPadDown(value: number);
  42770. /**
  42771. * Gets the value of D-pad left
  42772. */
  42773. get dPadLeft(): number;
  42774. /**
  42775. * Sets the value of D-pad left
  42776. */
  42777. set dPadLeft(value: number);
  42778. /**
  42779. * Gets the value of D-pad right
  42780. */
  42781. get dPadRight(): number;
  42782. /**
  42783. * Sets the value of D-pad right
  42784. */
  42785. set dPadRight(value: number);
  42786. /**
  42787. * Force the gamepad to synchronize with device values
  42788. */
  42789. update(): void;
  42790. /**
  42791. * Disposes the gamepad
  42792. */
  42793. dispose(): void;
  42794. }
  42795. }
  42796. declare module "babylonjs/Gamepads/gamepadManager" {
  42797. import { Observable } from "babylonjs/Misc/observable";
  42798. import { Nullable } from "babylonjs/types";
  42799. import { Scene } from "babylonjs/scene";
  42800. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42801. /**
  42802. * Manager for handling gamepads
  42803. */
  42804. export class GamepadManager {
  42805. private _scene?;
  42806. private _babylonGamepads;
  42807. private _oneGamepadConnected;
  42808. /** @hidden */
  42809. _isMonitoring: boolean;
  42810. private _gamepadEventSupported;
  42811. private _gamepadSupport?;
  42812. /**
  42813. * observable to be triggered when the gamepad controller has been connected
  42814. */
  42815. onGamepadConnectedObservable: Observable<Gamepad>;
  42816. /**
  42817. * observable to be triggered when the gamepad controller has been disconnected
  42818. */
  42819. onGamepadDisconnectedObservable: Observable<Gamepad>;
  42820. private _onGamepadConnectedEvent;
  42821. private _onGamepadDisconnectedEvent;
  42822. /**
  42823. * Initializes the gamepad manager
  42824. * @param _scene BabylonJS scene
  42825. */
  42826. constructor(_scene?: Scene | undefined);
  42827. /**
  42828. * The gamepads in the game pad manager
  42829. */
  42830. get gamepads(): Gamepad[];
  42831. /**
  42832. * Get the gamepad controllers based on type
  42833. * @param type The type of gamepad controller
  42834. * @returns Nullable gamepad
  42835. */
  42836. getGamepadByType(type?: number): Nullable<Gamepad>;
  42837. /**
  42838. * Disposes the gamepad manager
  42839. */
  42840. dispose(): void;
  42841. private _addNewGamepad;
  42842. private _startMonitoringGamepads;
  42843. private _stopMonitoringGamepads;
  42844. /** @hidden */
  42845. _checkGamepadsStatus(): void;
  42846. private _updateGamepadObjects;
  42847. }
  42848. }
  42849. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  42850. import { Nullable } from "babylonjs/types";
  42851. import { Scene } from "babylonjs/scene";
  42852. import { ISceneComponent } from "babylonjs/sceneComponent";
  42853. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  42854. module "babylonjs/scene" {
  42855. interface Scene {
  42856. /** @hidden */
  42857. _gamepadManager: Nullable<GamepadManager>;
  42858. /**
  42859. * Gets the gamepad manager associated with the scene
  42860. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  42861. */
  42862. gamepadManager: GamepadManager;
  42863. }
  42864. }
  42865. module "babylonjs/Cameras/freeCameraInputsManager" {
  42866. /**
  42867. * Interface representing a free camera inputs manager
  42868. */
  42869. interface FreeCameraInputsManager {
  42870. /**
  42871. * Adds gamepad input support to the FreeCameraInputsManager.
  42872. * @returns the FreeCameraInputsManager
  42873. */
  42874. addGamepad(): FreeCameraInputsManager;
  42875. }
  42876. }
  42877. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  42878. /**
  42879. * Interface representing an arc rotate camera inputs manager
  42880. */
  42881. interface ArcRotateCameraInputsManager {
  42882. /**
  42883. * Adds gamepad input support to the ArcRotateCamera InputManager.
  42884. * @returns the camera inputs manager
  42885. */
  42886. addGamepad(): ArcRotateCameraInputsManager;
  42887. }
  42888. }
  42889. /**
  42890. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  42891. */
  42892. export class GamepadSystemSceneComponent implements ISceneComponent {
  42893. /**
  42894. * The component name helpfull to identify the component in the list of scene components.
  42895. */
  42896. readonly name: string;
  42897. /**
  42898. * The scene the component belongs to.
  42899. */
  42900. scene: Scene;
  42901. /**
  42902. * Creates a new instance of the component for the given scene
  42903. * @param scene Defines the scene to register the component in
  42904. */
  42905. constructor(scene: Scene);
  42906. /**
  42907. * Registers the component in a given scene
  42908. */
  42909. register(): void;
  42910. /**
  42911. * Rebuilds the elements related to this component in case of
  42912. * context lost for instance.
  42913. */
  42914. rebuild(): void;
  42915. /**
  42916. * Disposes the component and the associated ressources
  42917. */
  42918. dispose(): void;
  42919. private _beforeCameraUpdate;
  42920. }
  42921. }
  42922. declare module "babylonjs/Cameras/universalCamera" {
  42923. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  42924. import { Scene } from "babylonjs/scene";
  42925. import { Vector3 } from "babylonjs/Maths/math.vector";
  42926. import "babylonjs/Gamepads/gamepadSceneComponent";
  42927. /**
  42928. * 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,
  42929. * which still works and will still be found in many Playgrounds.
  42930. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42931. */
  42932. export class UniversalCamera extends TouchCamera {
  42933. /**
  42934. * Defines the gamepad rotation sensiblity.
  42935. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42936. */
  42937. get gamepadAngularSensibility(): number;
  42938. set gamepadAngularSensibility(value: number);
  42939. /**
  42940. * Defines the gamepad move sensiblity.
  42941. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42942. */
  42943. get gamepadMoveSensibility(): number;
  42944. set gamepadMoveSensibility(value: number);
  42945. /**
  42946. * 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,
  42947. * which still works and will still be found in many Playgrounds.
  42948. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42949. * @param name Define the name of the camera in the scene
  42950. * @param position Define the start position of the camera in the scene
  42951. * @param scene Define the scene the camera belongs to
  42952. */
  42953. constructor(name: string, position: Vector3, scene: Scene);
  42954. /**
  42955. * Gets the current object class name.
  42956. * @return the class name
  42957. */
  42958. getClassName(): string;
  42959. }
  42960. }
  42961. declare module "babylonjs/Cameras/gamepadCamera" {
  42962. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42963. import { Scene } from "babylonjs/scene";
  42964. import { Vector3 } from "babylonjs/Maths/math.vector";
  42965. /**
  42966. * This represents a FPS type of camera. This is only here for back compat purpose.
  42967. * Please use the UniversalCamera instead as both are identical.
  42968. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42969. */
  42970. export class GamepadCamera extends UniversalCamera {
  42971. /**
  42972. * Instantiates a new Gamepad Camera
  42973. * This represents a FPS type of camera. This is only here for back compat purpose.
  42974. * Please use the UniversalCamera instead as both are identical.
  42975. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42976. * @param name Define the name of the camera in the scene
  42977. * @param position Define the start position of the camera in the scene
  42978. * @param scene Define the scene the camera belongs to
  42979. */
  42980. constructor(name: string, position: Vector3, scene: Scene);
  42981. /**
  42982. * Gets the current object class name.
  42983. * @return the class name
  42984. */
  42985. getClassName(): string;
  42986. }
  42987. }
  42988. declare module "babylonjs/Shaders/pass.fragment" {
  42989. /** @hidden */
  42990. export var passPixelShader: {
  42991. name: string;
  42992. shader: string;
  42993. };
  42994. }
  42995. declare module "babylonjs/Shaders/passCube.fragment" {
  42996. /** @hidden */
  42997. export var passCubePixelShader: {
  42998. name: string;
  42999. shader: string;
  43000. };
  43001. }
  43002. declare module "babylonjs/PostProcesses/passPostProcess" {
  43003. import { Nullable } from "babylonjs/types";
  43004. import { Camera } from "babylonjs/Cameras/camera";
  43005. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43006. import { Engine } from "babylonjs/Engines/engine";
  43007. import "babylonjs/Shaders/pass.fragment";
  43008. import "babylonjs/Shaders/passCube.fragment";
  43009. /**
  43010. * PassPostProcess which produces an output the same as it's input
  43011. */
  43012. export class PassPostProcess extends PostProcess {
  43013. /**
  43014. * Creates the PassPostProcess
  43015. * @param name The name of the effect.
  43016. * @param options The required width/height ratio to downsize to before computing the render pass.
  43017. * @param camera The camera to apply the render pass to.
  43018. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43019. * @param engine The engine which the post process will be applied. (default: current engine)
  43020. * @param reusable If the post process can be reused on the same frame. (default: false)
  43021. * @param textureType The type of texture to be used when performing the post processing.
  43022. * @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)
  43023. */
  43024. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  43025. }
  43026. /**
  43027. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  43028. */
  43029. export class PassCubePostProcess extends PostProcess {
  43030. private _face;
  43031. /**
  43032. * Gets or sets the cube face to display.
  43033. * * 0 is +X
  43034. * * 1 is -X
  43035. * * 2 is +Y
  43036. * * 3 is -Y
  43037. * * 4 is +Z
  43038. * * 5 is -Z
  43039. */
  43040. get face(): number;
  43041. set face(value: number);
  43042. /**
  43043. * Creates the PassCubePostProcess
  43044. * @param name The name of the effect.
  43045. * @param options The required width/height ratio to downsize to before computing the render pass.
  43046. * @param camera The camera to apply the render pass to.
  43047. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43048. * @param engine The engine which the post process will be applied. (default: current engine)
  43049. * @param reusable If the post process can be reused on the same frame. (default: false)
  43050. * @param textureType The type of texture to be used when performing the post processing.
  43051. * @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)
  43052. */
  43053. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  43054. }
  43055. }
  43056. declare module "babylonjs/Shaders/anaglyph.fragment" {
  43057. /** @hidden */
  43058. export var anaglyphPixelShader: {
  43059. name: string;
  43060. shader: string;
  43061. };
  43062. }
  43063. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  43064. import { Engine } from "babylonjs/Engines/engine";
  43065. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43066. import { Camera } from "babylonjs/Cameras/camera";
  43067. import "babylonjs/Shaders/anaglyph.fragment";
  43068. /**
  43069. * Postprocess used to generate anaglyphic rendering
  43070. */
  43071. export class AnaglyphPostProcess extends PostProcess {
  43072. private _passedProcess;
  43073. /**
  43074. * Creates a new AnaglyphPostProcess
  43075. * @param name defines postprocess name
  43076. * @param options defines creation options or target ratio scale
  43077. * @param rigCameras defines cameras using this postprocess
  43078. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  43079. * @param engine defines hosting engine
  43080. * @param reusable defines if the postprocess will be reused multiple times per frame
  43081. */
  43082. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  43083. }
  43084. }
  43085. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  43086. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  43087. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43088. import { Scene } from "babylonjs/scene";
  43089. import { Vector3 } from "babylonjs/Maths/math.vector";
  43090. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43091. /**
  43092. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  43093. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43094. */
  43095. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  43096. /**
  43097. * Creates a new AnaglyphArcRotateCamera
  43098. * @param name defines camera name
  43099. * @param alpha defines alpha angle (in radians)
  43100. * @param beta defines beta angle (in radians)
  43101. * @param radius defines radius
  43102. * @param target defines camera target
  43103. * @param interaxialDistance defines distance between each color axis
  43104. * @param scene defines the hosting scene
  43105. */
  43106. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  43107. /**
  43108. * Gets camera class name
  43109. * @returns AnaglyphArcRotateCamera
  43110. */
  43111. getClassName(): string;
  43112. }
  43113. }
  43114. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  43115. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43116. import { Scene } from "babylonjs/scene";
  43117. import { Vector3 } from "babylonjs/Maths/math.vector";
  43118. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43119. /**
  43120. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  43121. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43122. */
  43123. export class AnaglyphFreeCamera extends FreeCamera {
  43124. /**
  43125. * Creates a new AnaglyphFreeCamera
  43126. * @param name defines camera name
  43127. * @param position defines initial position
  43128. * @param interaxialDistance defines distance between each color axis
  43129. * @param scene defines the hosting scene
  43130. */
  43131. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43132. /**
  43133. * Gets camera class name
  43134. * @returns AnaglyphFreeCamera
  43135. */
  43136. getClassName(): string;
  43137. }
  43138. }
  43139. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  43140. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43141. import { Scene } from "babylonjs/scene";
  43142. import { Vector3 } from "babylonjs/Maths/math.vector";
  43143. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43144. /**
  43145. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  43146. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43147. */
  43148. export class AnaglyphGamepadCamera extends GamepadCamera {
  43149. /**
  43150. * Creates a new AnaglyphGamepadCamera
  43151. * @param name defines camera name
  43152. * @param position defines initial position
  43153. * @param interaxialDistance defines distance between each color axis
  43154. * @param scene defines the hosting scene
  43155. */
  43156. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43157. /**
  43158. * Gets camera class name
  43159. * @returns AnaglyphGamepadCamera
  43160. */
  43161. getClassName(): string;
  43162. }
  43163. }
  43164. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  43165. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43166. import { Scene } from "babylonjs/scene";
  43167. import { Vector3 } from "babylonjs/Maths/math.vector";
  43168. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43169. /**
  43170. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  43171. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43172. */
  43173. export class AnaglyphUniversalCamera extends UniversalCamera {
  43174. /**
  43175. * Creates a new AnaglyphUniversalCamera
  43176. * @param name defines camera name
  43177. * @param position defines initial position
  43178. * @param interaxialDistance defines distance between each color axis
  43179. * @param scene defines the hosting scene
  43180. */
  43181. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43182. /**
  43183. * Gets camera class name
  43184. * @returns AnaglyphUniversalCamera
  43185. */
  43186. getClassName(): string;
  43187. }
  43188. }
  43189. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  43190. /** @hidden */
  43191. export var stereoscopicInterlacePixelShader: {
  43192. name: string;
  43193. shader: string;
  43194. };
  43195. }
  43196. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  43197. import { Camera } from "babylonjs/Cameras/camera";
  43198. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43199. import { Engine } from "babylonjs/Engines/engine";
  43200. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  43201. /**
  43202. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  43203. */
  43204. export class StereoscopicInterlacePostProcessI extends PostProcess {
  43205. private _stepSize;
  43206. private _passedProcess;
  43207. /**
  43208. * Initializes a StereoscopicInterlacePostProcessI
  43209. * @param name The name of the effect.
  43210. * @param rigCameras The rig cameras to be appled to the post process
  43211. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  43212. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  43213. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43214. * @param engine The engine which the post process will be applied. (default: current engine)
  43215. * @param reusable If the post process can be reused on the same frame. (default: false)
  43216. */
  43217. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  43218. }
  43219. /**
  43220. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  43221. */
  43222. export class StereoscopicInterlacePostProcess extends PostProcess {
  43223. private _stepSize;
  43224. private _passedProcess;
  43225. /**
  43226. * Initializes a StereoscopicInterlacePostProcess
  43227. * @param name The name of the effect.
  43228. * @param rigCameras The rig cameras to be appled to the post process
  43229. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  43230. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43231. * @param engine The engine which the post process will be applied. (default: current engine)
  43232. * @param reusable If the post process can be reused on the same frame. (default: false)
  43233. */
  43234. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  43235. }
  43236. }
  43237. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  43238. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  43239. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43240. import { Scene } from "babylonjs/scene";
  43241. import { Vector3 } from "babylonjs/Maths/math.vector";
  43242. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43243. /**
  43244. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  43245. * @see http://doc.babylonjs.com/features/cameras
  43246. */
  43247. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  43248. /**
  43249. * Creates a new StereoscopicArcRotateCamera
  43250. * @param name defines camera name
  43251. * @param alpha defines alpha angle (in radians)
  43252. * @param beta defines beta angle (in radians)
  43253. * @param radius defines radius
  43254. * @param target defines camera target
  43255. * @param interaxialDistance defines distance between each color axis
  43256. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43257. * @param scene defines the hosting scene
  43258. */
  43259. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43260. /**
  43261. * Gets camera class name
  43262. * @returns StereoscopicArcRotateCamera
  43263. */
  43264. getClassName(): string;
  43265. }
  43266. }
  43267. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  43268. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43269. import { Scene } from "babylonjs/scene";
  43270. import { Vector3 } from "babylonjs/Maths/math.vector";
  43271. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43272. /**
  43273. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  43274. * @see http://doc.babylonjs.com/features/cameras
  43275. */
  43276. export class StereoscopicFreeCamera extends FreeCamera {
  43277. /**
  43278. * Creates a new StereoscopicFreeCamera
  43279. * @param name defines camera name
  43280. * @param position defines initial position
  43281. * @param interaxialDistance defines distance between each color axis
  43282. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43283. * @param scene defines the hosting scene
  43284. */
  43285. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43286. /**
  43287. * Gets camera class name
  43288. * @returns StereoscopicFreeCamera
  43289. */
  43290. getClassName(): string;
  43291. }
  43292. }
  43293. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  43294. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43295. import { Scene } from "babylonjs/scene";
  43296. import { Vector3 } from "babylonjs/Maths/math.vector";
  43297. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43298. /**
  43299. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  43300. * @see http://doc.babylonjs.com/features/cameras
  43301. */
  43302. export class StereoscopicGamepadCamera extends GamepadCamera {
  43303. /**
  43304. * Creates a new StereoscopicGamepadCamera
  43305. * @param name defines camera name
  43306. * @param position defines initial position
  43307. * @param interaxialDistance defines distance between each color axis
  43308. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43309. * @param scene defines the hosting scene
  43310. */
  43311. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43312. /**
  43313. * Gets camera class name
  43314. * @returns StereoscopicGamepadCamera
  43315. */
  43316. getClassName(): string;
  43317. }
  43318. }
  43319. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  43320. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43321. import { Scene } from "babylonjs/scene";
  43322. import { Vector3 } from "babylonjs/Maths/math.vector";
  43323. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43324. /**
  43325. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  43326. * @see http://doc.babylonjs.com/features/cameras
  43327. */
  43328. export class StereoscopicUniversalCamera extends UniversalCamera {
  43329. /**
  43330. * Creates a new StereoscopicUniversalCamera
  43331. * @param name defines camera name
  43332. * @param position defines initial position
  43333. * @param interaxialDistance defines distance between each color axis
  43334. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43335. * @param scene defines the hosting scene
  43336. */
  43337. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43338. /**
  43339. * Gets camera class name
  43340. * @returns StereoscopicUniversalCamera
  43341. */
  43342. getClassName(): string;
  43343. }
  43344. }
  43345. declare module "babylonjs/Cameras/Stereoscopic/index" {
  43346. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  43347. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  43348. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  43349. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  43350. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  43351. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  43352. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  43353. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  43354. }
  43355. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  43356. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43357. import { Scene } from "babylonjs/scene";
  43358. import { Vector3 } from "babylonjs/Maths/math.vector";
  43359. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  43360. /**
  43361. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  43362. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43363. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43364. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43365. */
  43366. export class VirtualJoysticksCamera extends FreeCamera {
  43367. /**
  43368. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  43369. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43370. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43371. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43372. * @param name Define the name of the camera in the scene
  43373. * @param position Define the start position of the camera in the scene
  43374. * @param scene Define the scene the camera belongs to
  43375. */
  43376. constructor(name: string, position: Vector3, scene: Scene);
  43377. /**
  43378. * Gets the current object class name.
  43379. * @return the class name
  43380. */
  43381. getClassName(): string;
  43382. }
  43383. }
  43384. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  43385. import { Matrix } from "babylonjs/Maths/math.vector";
  43386. /**
  43387. * This represents all the required metrics to create a VR camera.
  43388. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  43389. */
  43390. export class VRCameraMetrics {
  43391. /**
  43392. * Define the horizontal resolution off the screen.
  43393. */
  43394. hResolution: number;
  43395. /**
  43396. * Define the vertical resolution off the screen.
  43397. */
  43398. vResolution: number;
  43399. /**
  43400. * Define the horizontal screen size.
  43401. */
  43402. hScreenSize: number;
  43403. /**
  43404. * Define the vertical screen size.
  43405. */
  43406. vScreenSize: number;
  43407. /**
  43408. * Define the vertical screen center position.
  43409. */
  43410. vScreenCenter: number;
  43411. /**
  43412. * Define the distance of the eyes to the screen.
  43413. */
  43414. eyeToScreenDistance: number;
  43415. /**
  43416. * Define the distance between both lenses
  43417. */
  43418. lensSeparationDistance: number;
  43419. /**
  43420. * Define the distance between both viewer's eyes.
  43421. */
  43422. interpupillaryDistance: number;
  43423. /**
  43424. * Define the distortion factor of the VR postprocess.
  43425. * Please, touch with care.
  43426. */
  43427. distortionK: number[];
  43428. /**
  43429. * Define the chromatic aberration correction factors for the VR post process.
  43430. */
  43431. chromaAbCorrection: number[];
  43432. /**
  43433. * Define the scale factor of the post process.
  43434. * The smaller the better but the slower.
  43435. */
  43436. postProcessScaleFactor: number;
  43437. /**
  43438. * Define an offset for the lens center.
  43439. */
  43440. lensCenterOffset: number;
  43441. /**
  43442. * Define if the current vr camera should compensate the distortion of the lense or not.
  43443. */
  43444. compensateDistortion: boolean;
  43445. /**
  43446. * Defines if multiview should be enabled when rendering (Default: false)
  43447. */
  43448. multiviewEnabled: boolean;
  43449. /**
  43450. * Gets the rendering aspect ratio based on the provided resolutions.
  43451. */
  43452. get aspectRatio(): number;
  43453. /**
  43454. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  43455. */
  43456. get aspectRatioFov(): number;
  43457. /**
  43458. * @hidden
  43459. */
  43460. get leftHMatrix(): Matrix;
  43461. /**
  43462. * @hidden
  43463. */
  43464. get rightHMatrix(): Matrix;
  43465. /**
  43466. * @hidden
  43467. */
  43468. get leftPreViewMatrix(): Matrix;
  43469. /**
  43470. * @hidden
  43471. */
  43472. get rightPreViewMatrix(): Matrix;
  43473. /**
  43474. * Get the default VRMetrics based on the most generic setup.
  43475. * @returns the default vr metrics
  43476. */
  43477. static GetDefault(): VRCameraMetrics;
  43478. }
  43479. }
  43480. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  43481. /** @hidden */
  43482. export var vrDistortionCorrectionPixelShader: {
  43483. name: string;
  43484. shader: string;
  43485. };
  43486. }
  43487. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  43488. import { Camera } from "babylonjs/Cameras/camera";
  43489. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43490. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43491. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  43492. /**
  43493. * VRDistortionCorrectionPostProcess used for mobile VR
  43494. */
  43495. export class VRDistortionCorrectionPostProcess extends PostProcess {
  43496. private _isRightEye;
  43497. private _distortionFactors;
  43498. private _postProcessScaleFactor;
  43499. private _lensCenterOffset;
  43500. private _scaleIn;
  43501. private _scaleFactor;
  43502. private _lensCenter;
  43503. /**
  43504. * Initializes the VRDistortionCorrectionPostProcess
  43505. * @param name The name of the effect.
  43506. * @param camera The camera to apply the render pass to.
  43507. * @param isRightEye If this is for the right eye distortion
  43508. * @param vrMetrics All the required metrics for the VR camera
  43509. */
  43510. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  43511. }
  43512. }
  43513. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  43514. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  43515. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43516. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43517. import { Scene } from "babylonjs/scene";
  43518. import { Vector3 } from "babylonjs/Maths/math.vector";
  43519. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  43520. import "babylonjs/Cameras/RigModes/vrRigMode";
  43521. /**
  43522. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  43523. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43524. */
  43525. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  43526. /**
  43527. * Creates a new VRDeviceOrientationArcRotateCamera
  43528. * @param name defines camera name
  43529. * @param alpha defines the camera rotation along the logitudinal axis
  43530. * @param beta defines the camera rotation along the latitudinal axis
  43531. * @param radius defines the camera distance from its target
  43532. * @param target defines the camera target
  43533. * @param scene defines the scene the camera belongs to
  43534. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43535. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43536. */
  43537. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43538. /**
  43539. * Gets camera class name
  43540. * @returns VRDeviceOrientationArcRotateCamera
  43541. */
  43542. getClassName(): string;
  43543. }
  43544. }
  43545. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  43546. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  43547. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43548. import { Scene } from "babylonjs/scene";
  43549. import { Vector3 } from "babylonjs/Maths/math.vector";
  43550. import "babylonjs/Cameras/RigModes/vrRigMode";
  43551. /**
  43552. * Camera used to simulate VR rendering (based on FreeCamera)
  43553. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43554. */
  43555. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  43556. /**
  43557. * Creates a new VRDeviceOrientationFreeCamera
  43558. * @param name defines camera name
  43559. * @param position defines the start position of the camera
  43560. * @param scene defines the scene the camera belongs to
  43561. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43562. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43563. */
  43564. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43565. /**
  43566. * Gets camera class name
  43567. * @returns VRDeviceOrientationFreeCamera
  43568. */
  43569. getClassName(): string;
  43570. }
  43571. }
  43572. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  43573. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  43574. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43575. import { Scene } from "babylonjs/scene";
  43576. import { Vector3 } from "babylonjs/Maths/math.vector";
  43577. import "babylonjs/Gamepads/gamepadSceneComponent";
  43578. /**
  43579. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  43580. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43581. */
  43582. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  43583. /**
  43584. * Creates a new VRDeviceOrientationGamepadCamera
  43585. * @param name defines camera name
  43586. * @param position defines the start position of the camera
  43587. * @param scene defines the scene the camera belongs to
  43588. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43589. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43590. */
  43591. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43592. /**
  43593. * Gets camera class name
  43594. * @returns VRDeviceOrientationGamepadCamera
  43595. */
  43596. getClassName(): string;
  43597. }
  43598. }
  43599. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  43600. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43601. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43602. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43603. /** @hidden */
  43604. export var imageProcessingPixelShader: {
  43605. name: string;
  43606. shader: string;
  43607. };
  43608. }
  43609. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  43610. import { Nullable } from "babylonjs/types";
  43611. import { Color4 } from "babylonjs/Maths/math.color";
  43612. import { Camera } from "babylonjs/Cameras/camera";
  43613. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43614. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43615. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43616. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43617. import { Engine } from "babylonjs/Engines/engine";
  43618. import "babylonjs/Shaders/imageProcessing.fragment";
  43619. import "babylonjs/Shaders/postprocess.vertex";
  43620. /**
  43621. * ImageProcessingPostProcess
  43622. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  43623. */
  43624. export class ImageProcessingPostProcess extends PostProcess {
  43625. /**
  43626. * Default configuration related to image processing available in the PBR Material.
  43627. */
  43628. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43629. /**
  43630. * Gets the image processing configuration used either in this material.
  43631. */
  43632. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  43633. /**
  43634. * Sets the Default image processing configuration used either in the this material.
  43635. *
  43636. * If sets to null, the scene one is in use.
  43637. */
  43638. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  43639. /**
  43640. * Keep track of the image processing observer to allow dispose and replace.
  43641. */
  43642. private _imageProcessingObserver;
  43643. /**
  43644. * Attaches a new image processing configuration to the PBR Material.
  43645. * @param configuration
  43646. */
  43647. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  43648. /**
  43649. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43650. */
  43651. get colorCurves(): Nullable<ColorCurves>;
  43652. /**
  43653. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43654. */
  43655. set colorCurves(value: Nullable<ColorCurves>);
  43656. /**
  43657. * Gets wether the color curves effect is enabled.
  43658. */
  43659. get colorCurvesEnabled(): boolean;
  43660. /**
  43661. * Sets wether the color curves effect is enabled.
  43662. */
  43663. set colorCurvesEnabled(value: boolean);
  43664. /**
  43665. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43666. */
  43667. get colorGradingTexture(): Nullable<BaseTexture>;
  43668. /**
  43669. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43670. */
  43671. set colorGradingTexture(value: Nullable<BaseTexture>);
  43672. /**
  43673. * Gets wether the color grading effect is enabled.
  43674. */
  43675. get colorGradingEnabled(): boolean;
  43676. /**
  43677. * Gets wether the color grading effect is enabled.
  43678. */
  43679. set colorGradingEnabled(value: boolean);
  43680. /**
  43681. * Gets exposure used in the effect.
  43682. */
  43683. get exposure(): number;
  43684. /**
  43685. * Sets exposure used in the effect.
  43686. */
  43687. set exposure(value: number);
  43688. /**
  43689. * Gets wether tonemapping is enabled or not.
  43690. */
  43691. get toneMappingEnabled(): boolean;
  43692. /**
  43693. * Sets wether tonemapping is enabled or not
  43694. */
  43695. set toneMappingEnabled(value: boolean);
  43696. /**
  43697. * Gets the type of tone mapping effect.
  43698. */
  43699. get toneMappingType(): number;
  43700. /**
  43701. * Sets the type of tone mapping effect.
  43702. */
  43703. set toneMappingType(value: number);
  43704. /**
  43705. * Gets contrast used in the effect.
  43706. */
  43707. get contrast(): number;
  43708. /**
  43709. * Sets contrast used in the effect.
  43710. */
  43711. set contrast(value: number);
  43712. /**
  43713. * Gets Vignette stretch size.
  43714. */
  43715. get vignetteStretch(): number;
  43716. /**
  43717. * Sets Vignette stretch size.
  43718. */
  43719. set vignetteStretch(value: number);
  43720. /**
  43721. * Gets Vignette centre X Offset.
  43722. */
  43723. get vignetteCentreX(): number;
  43724. /**
  43725. * Sets Vignette centre X Offset.
  43726. */
  43727. set vignetteCentreX(value: number);
  43728. /**
  43729. * Gets Vignette centre Y Offset.
  43730. */
  43731. get vignetteCentreY(): number;
  43732. /**
  43733. * Sets Vignette centre Y Offset.
  43734. */
  43735. set vignetteCentreY(value: number);
  43736. /**
  43737. * Gets Vignette weight or intensity of the vignette effect.
  43738. */
  43739. get vignetteWeight(): number;
  43740. /**
  43741. * Sets Vignette weight or intensity of the vignette effect.
  43742. */
  43743. set vignetteWeight(value: number);
  43744. /**
  43745. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43746. * if vignetteEnabled is set to true.
  43747. */
  43748. get vignetteColor(): Color4;
  43749. /**
  43750. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43751. * if vignetteEnabled is set to true.
  43752. */
  43753. set vignetteColor(value: Color4);
  43754. /**
  43755. * Gets Camera field of view used by the Vignette effect.
  43756. */
  43757. get vignetteCameraFov(): number;
  43758. /**
  43759. * Sets Camera field of view used by the Vignette effect.
  43760. */
  43761. set vignetteCameraFov(value: number);
  43762. /**
  43763. * Gets the vignette blend mode allowing different kind of effect.
  43764. */
  43765. get vignetteBlendMode(): number;
  43766. /**
  43767. * Sets the vignette blend mode allowing different kind of effect.
  43768. */
  43769. set vignetteBlendMode(value: number);
  43770. /**
  43771. * Gets wether the vignette effect is enabled.
  43772. */
  43773. get vignetteEnabled(): boolean;
  43774. /**
  43775. * Sets wether the vignette effect is enabled.
  43776. */
  43777. set vignetteEnabled(value: boolean);
  43778. private _fromLinearSpace;
  43779. /**
  43780. * Gets wether the input of the processing is in Gamma or Linear Space.
  43781. */
  43782. get fromLinearSpace(): boolean;
  43783. /**
  43784. * Sets wether the input of the processing is in Gamma or Linear Space.
  43785. */
  43786. set fromLinearSpace(value: boolean);
  43787. /**
  43788. * Defines cache preventing GC.
  43789. */
  43790. private _defines;
  43791. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  43792. /**
  43793. * "ImageProcessingPostProcess"
  43794. * @returns "ImageProcessingPostProcess"
  43795. */
  43796. getClassName(): string;
  43797. protected _updateParameters(): void;
  43798. dispose(camera?: Camera): void;
  43799. }
  43800. }
  43801. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  43802. import { Scene } from "babylonjs/scene";
  43803. import { Color3 } from "babylonjs/Maths/math.color";
  43804. import { Mesh } from "babylonjs/Meshes/mesh";
  43805. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  43806. import { Nullable } from "babylonjs/types";
  43807. /**
  43808. * Class containing static functions to help procedurally build meshes
  43809. */
  43810. export class GroundBuilder {
  43811. /**
  43812. * Creates a ground mesh
  43813. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  43814. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  43815. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43816. * @param name defines the name of the mesh
  43817. * @param options defines the options used to create the mesh
  43818. * @param scene defines the hosting scene
  43819. * @returns the ground mesh
  43820. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  43821. */
  43822. static CreateGround(name: string, options: {
  43823. width?: number;
  43824. height?: number;
  43825. subdivisions?: number;
  43826. subdivisionsX?: number;
  43827. subdivisionsY?: number;
  43828. updatable?: boolean;
  43829. }, scene: any): Mesh;
  43830. /**
  43831. * Creates a tiled ground mesh
  43832. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  43833. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  43834. * * 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
  43835. * * 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
  43836. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43837. * @param name defines the name of the mesh
  43838. * @param options defines the options used to create the mesh
  43839. * @param scene defines the hosting scene
  43840. * @returns the tiled ground mesh
  43841. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  43842. */
  43843. static CreateTiledGround(name: string, options: {
  43844. xmin: number;
  43845. zmin: number;
  43846. xmax: number;
  43847. zmax: number;
  43848. subdivisions?: {
  43849. w: number;
  43850. h: number;
  43851. };
  43852. precision?: {
  43853. w: number;
  43854. h: number;
  43855. };
  43856. updatable?: boolean;
  43857. }, scene?: Nullable<Scene>): Mesh;
  43858. /**
  43859. * Creates a ground mesh from a height map
  43860. * * The parameter `url` sets the URL of the height map image resource.
  43861. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  43862. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  43863. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  43864. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  43865. * * 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.
  43866. * * 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).
  43867. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  43868. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43869. * @param name defines the name of the mesh
  43870. * @param url defines the url to the height map
  43871. * @param options defines the options used to create the mesh
  43872. * @param scene defines the hosting scene
  43873. * @returns the ground mesh
  43874. * @see https://doc.babylonjs.com/babylon101/height_map
  43875. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  43876. */
  43877. static CreateGroundFromHeightMap(name: string, url: string, options: {
  43878. width?: number;
  43879. height?: number;
  43880. subdivisions?: number;
  43881. minHeight?: number;
  43882. maxHeight?: number;
  43883. colorFilter?: Color3;
  43884. alphaFilter?: number;
  43885. updatable?: boolean;
  43886. onReady?: (mesh: GroundMesh) => void;
  43887. }, scene?: Nullable<Scene>): GroundMesh;
  43888. }
  43889. }
  43890. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  43891. import { Vector4 } from "babylonjs/Maths/math.vector";
  43892. import { Mesh } from "babylonjs/Meshes/mesh";
  43893. /**
  43894. * Class containing static functions to help procedurally build meshes
  43895. */
  43896. export class TorusBuilder {
  43897. /**
  43898. * Creates a torus mesh
  43899. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  43900. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  43901. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  43902. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43903. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43904. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43905. * @param name defines the name of the mesh
  43906. * @param options defines the options used to create the mesh
  43907. * @param scene defines the hosting scene
  43908. * @returns the torus mesh
  43909. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  43910. */
  43911. static CreateTorus(name: string, options: {
  43912. diameter?: number;
  43913. thickness?: number;
  43914. tessellation?: number;
  43915. updatable?: boolean;
  43916. sideOrientation?: number;
  43917. frontUVs?: Vector4;
  43918. backUVs?: Vector4;
  43919. }, scene: any): Mesh;
  43920. }
  43921. }
  43922. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  43923. import { Vector4 } from "babylonjs/Maths/math.vector";
  43924. import { Color4 } from "babylonjs/Maths/math.color";
  43925. import { Mesh } from "babylonjs/Meshes/mesh";
  43926. /**
  43927. * Class containing static functions to help procedurally build meshes
  43928. */
  43929. export class CylinderBuilder {
  43930. /**
  43931. * Creates a cylinder or a cone mesh
  43932. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  43933. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  43934. * * 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.
  43935. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  43936. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  43937. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  43938. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  43939. * * 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).
  43940. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  43941. * * 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).
  43942. * * 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
  43943. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  43944. * * 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
  43945. * * 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.
  43946. * * If `enclose` is false, a ring surface is one element.
  43947. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  43948. * * 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
  43949. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43950. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43951. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43952. * @param name defines the name of the mesh
  43953. * @param options defines the options used to create the mesh
  43954. * @param scene defines the hosting scene
  43955. * @returns the cylinder mesh
  43956. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  43957. */
  43958. static CreateCylinder(name: string, options: {
  43959. height?: number;
  43960. diameterTop?: number;
  43961. diameterBottom?: number;
  43962. diameter?: number;
  43963. tessellation?: number;
  43964. subdivisions?: number;
  43965. arc?: number;
  43966. faceColors?: Color4[];
  43967. faceUV?: Vector4[];
  43968. updatable?: boolean;
  43969. hasRings?: boolean;
  43970. enclose?: boolean;
  43971. cap?: number;
  43972. sideOrientation?: number;
  43973. frontUVs?: Vector4;
  43974. backUVs?: Vector4;
  43975. }, scene: any): Mesh;
  43976. }
  43977. }
  43978. declare module "babylonjs/XR/webXRTypes" {
  43979. import { Nullable } from "babylonjs/types";
  43980. import { IDisposable } from "babylonjs/scene";
  43981. /**
  43982. * States of the webXR experience
  43983. */
  43984. export enum WebXRState {
  43985. /**
  43986. * Transitioning to being in XR mode
  43987. */
  43988. ENTERING_XR = 0,
  43989. /**
  43990. * Transitioning to non XR mode
  43991. */
  43992. EXITING_XR = 1,
  43993. /**
  43994. * In XR mode and presenting
  43995. */
  43996. IN_XR = 2,
  43997. /**
  43998. * Not entered XR mode
  43999. */
  44000. NOT_IN_XR = 3
  44001. }
  44002. /**
  44003. * Abstraction of the XR render target
  44004. */
  44005. export interface WebXRRenderTarget extends IDisposable {
  44006. /**
  44007. * xrpresent context of the canvas which can be used to display/mirror xr content
  44008. */
  44009. canvasContext: WebGLRenderingContext;
  44010. /**
  44011. * xr layer for the canvas
  44012. */
  44013. xrLayer: Nullable<XRWebGLLayer>;
  44014. /**
  44015. * Initializes the xr layer for the session
  44016. * @param xrSession xr session
  44017. * @returns a promise that will resolve once the XR Layer has been created
  44018. */
  44019. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  44020. }
  44021. }
  44022. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  44023. import { Nullable } from "babylonjs/types";
  44024. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44025. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44026. /**
  44027. * COnfiguration object for WebXR output canvas
  44028. */
  44029. export class WebXRManagedOutputCanvasOptions {
  44030. /**
  44031. * Options for this XR Layer output
  44032. */
  44033. canvasOptions?: XRWebGLLayerOptions;
  44034. /**
  44035. * CSS styling for a newly created canvas (if not provided)
  44036. */
  44037. newCanvasCssStyle?: string;
  44038. /**
  44039. * An optional canvas in case you wish to create it yourself and provide it here.
  44040. * If not provided, a new canvas will be created
  44041. */
  44042. canvasElement?: HTMLCanvasElement;
  44043. /**
  44044. * Get the default values of the configuration object
  44045. * @returns default values of this configuration object
  44046. */
  44047. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  44048. }
  44049. /**
  44050. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  44051. */
  44052. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  44053. private _options;
  44054. private _engine;
  44055. private _canvas;
  44056. /**
  44057. * Rendering context of the canvas which can be used to display/mirror xr content
  44058. */
  44059. canvasContext: WebGLRenderingContext;
  44060. /**
  44061. * xr layer for the canvas
  44062. */
  44063. xrLayer: Nullable<XRWebGLLayer>;
  44064. /**
  44065. * Initializes the xr layer for the session
  44066. * @param xrSession xr session
  44067. * @returns a promise that will resolve once the XR Layer has been created
  44068. */
  44069. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  44070. /**
  44071. * Initializes the canvas to be added/removed upon entering/exiting xr
  44072. * @param _xrSessionManager The XR Session manager
  44073. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  44074. */
  44075. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  44076. /**
  44077. * Disposes of the object
  44078. */
  44079. dispose(): void;
  44080. private _setManagedOutputCanvas;
  44081. private _addCanvas;
  44082. private _removeCanvas;
  44083. }
  44084. }
  44085. declare module "babylonjs/XR/webXRSessionManager" {
  44086. import { Observable } from "babylonjs/Misc/observable";
  44087. import { Nullable } from "babylonjs/types";
  44088. import { IDisposable, Scene } from "babylonjs/scene";
  44089. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  44090. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44091. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  44092. /**
  44093. * Manages an XRSession to work with Babylon's engine
  44094. * @see https://doc.babylonjs.com/how_to/webxr
  44095. */
  44096. export class WebXRSessionManager implements IDisposable {
  44097. /** The scene which the session should be created for */
  44098. scene: Scene;
  44099. /**
  44100. * Fires every time a new xrFrame arrives which can be used to update the camera
  44101. */
  44102. onXRFrameObservable: Observable<XRFrame>;
  44103. /**
  44104. * Fires when the xr session is ended either by the device or manually done
  44105. */
  44106. onXRSessionEnded: Observable<any>;
  44107. /**
  44108. * Fires when the xr session is ended either by the device or manually done
  44109. */
  44110. onXRSessionInit: Observable<XRSession>;
  44111. /**
  44112. * Fires when the reference space changed
  44113. */
  44114. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  44115. /**
  44116. * Underlying xr session
  44117. */
  44118. session: XRSession;
  44119. /**
  44120. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  44121. * or get the offset the player is currently at.
  44122. */
  44123. viewerReferenceSpace: XRReferenceSpace;
  44124. private _referenceSpace;
  44125. /**
  44126. * The current reference space used in this session. This reference space can constantly change!
  44127. * It is mainly used to offset the camera's position.
  44128. */
  44129. get referenceSpace(): XRReferenceSpace;
  44130. /**
  44131. * Set a new reference space and triggers the observable
  44132. */
  44133. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  44134. /**
  44135. * The base reference space from which the session started. good if you want to reset your
  44136. * reference space
  44137. */
  44138. baseReferenceSpace: XRReferenceSpace;
  44139. /**
  44140. * Used just in case of a failure to initialize an immersive session.
  44141. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  44142. */
  44143. defaultHeightCompensation: number;
  44144. /**
  44145. * Current XR frame
  44146. */
  44147. currentFrame: Nullable<XRFrame>;
  44148. /** WebXR timestamp updated every frame */
  44149. currentTimestamp: number;
  44150. private _xrNavigator;
  44151. private baseLayer;
  44152. private _rttProvider;
  44153. private _sessionEnded;
  44154. /**
  44155. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  44156. * @param scene The scene which the session should be created for
  44157. */
  44158. constructor(
  44159. /** The scene which the session should be created for */
  44160. scene: Scene);
  44161. /**
  44162. * Initializes the manager
  44163. * After initialization enterXR can be called to start an XR session
  44164. * @returns Promise which resolves after it is initialized
  44165. */
  44166. initializeAsync(): Promise<void>;
  44167. /**
  44168. * Initializes an xr session
  44169. * @param xrSessionMode mode to initialize
  44170. * @param xrSessionInit defines optional and required values to pass to the session builder
  44171. * @returns a promise which will resolve once the session has been initialized
  44172. */
  44173. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  44174. /**
  44175. * Sets the reference space on the xr session
  44176. * @param referenceSpaceType space to set
  44177. * @returns a promise that will resolve once the reference space has been set
  44178. */
  44179. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  44180. /**
  44181. * Resets the reference space to the one started the session
  44182. */
  44183. resetReferenceSpace(): void;
  44184. /**
  44185. * Updates the render state of the session
  44186. * @param state state to set
  44187. * @returns a promise that resolves once the render state has been updated
  44188. */
  44189. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  44190. /**
  44191. * Starts rendering to the xr layer
  44192. */
  44193. runXRRenderLoop(): void;
  44194. /**
  44195. * Gets the correct render target texture to be rendered this frame for this eye
  44196. * @param eye the eye for which to get the render target
  44197. * @returns the render target for the specified eye
  44198. */
  44199. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  44200. /**
  44201. * Stops the xrSession and restores the renderloop
  44202. * @returns Promise which resolves after it exits XR
  44203. */
  44204. exitXRAsync(): Promise<void>;
  44205. /**
  44206. * Checks if a session would be supported for the creation options specified
  44207. * @param sessionMode session mode to check if supported eg. immersive-vr
  44208. * @returns A Promise that resolves to true if supported and false if not
  44209. */
  44210. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44211. /**
  44212. * Creates a WebXRRenderTarget object for the XR session
  44213. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  44214. * @param options optional options to provide when creating a new render target
  44215. * @returns a WebXR render target to which the session can render
  44216. */
  44217. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  44218. /**
  44219. * @hidden
  44220. * Converts the render layer of xrSession to a render target
  44221. * @param session session to create render target for
  44222. * @param scene scene the new render target should be created for
  44223. * @param baseLayer the webgl layer to create the render target for
  44224. */
  44225. static _CreateRenderTargetTextureFromSession(_session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  44226. /**
  44227. * Disposes of the session manager
  44228. */
  44229. dispose(): void;
  44230. /**
  44231. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  44232. * @param sessionMode defines the session to test
  44233. * @returns a promise with boolean as final value
  44234. */
  44235. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44236. }
  44237. }
  44238. declare module "babylonjs/XR/webXRCamera" {
  44239. import { Scene } from "babylonjs/scene";
  44240. import { Camera } from "babylonjs/Cameras/camera";
  44241. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  44242. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44243. /**
  44244. * WebXR Camera which holds the views for the xrSession
  44245. * @see https://doc.babylonjs.com/how_to/webxr_camera
  44246. */
  44247. export class WebXRCamera extends FreeCamera {
  44248. private _xrSessionManager;
  44249. private _firstFrame;
  44250. private _referenceQuaternion;
  44251. private _referencedPosition;
  44252. private _xrInvPositionCache;
  44253. private _xrInvQuaternionCache;
  44254. /**
  44255. * Should position compensation execute on first frame.
  44256. * This is used when copying the position from a native (non XR) camera
  44257. */
  44258. compensateOnFirstFrame: boolean;
  44259. /**
  44260. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  44261. * @param name the name of the camera
  44262. * @param scene the scene to add the camera to
  44263. * @param _xrSessionManager a constructed xr session manager
  44264. */
  44265. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  44266. /**
  44267. * Return the user's height, unrelated to the current ground.
  44268. * This will be the y position of this camera, when ground level is 0.
  44269. */
  44270. get realWorldHeight(): number;
  44271. /** @hidden */
  44272. _updateForDualEyeDebugging(): void;
  44273. /**
  44274. * Sets this camera's transformation based on a non-vr camera
  44275. * @param otherCamera the non-vr camera to copy the transformation from
  44276. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  44277. */
  44278. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  44279. private _updateFromXRSession;
  44280. private _updateNumberOfRigCameras;
  44281. private _updateReferenceSpace;
  44282. private _updateReferenceSpaceOffset;
  44283. }
  44284. }
  44285. declare module "babylonjs/XR/webXRFeaturesManager" {
  44286. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44287. import { IDisposable } from "babylonjs/scene";
  44288. /**
  44289. * Defining the interface required for a (webxr) feature
  44290. */
  44291. export interface IWebXRFeature extends IDisposable {
  44292. /**
  44293. * Is this feature attached
  44294. */
  44295. attached: boolean;
  44296. /**
  44297. * Should auto-attach be disabled?
  44298. */
  44299. disableAutoAttach: boolean;
  44300. /**
  44301. * Attach the feature to the session
  44302. * Will usually be called by the features manager
  44303. *
  44304. * @param force should attachment be forced (even when already attached)
  44305. * @returns true if successful.
  44306. */
  44307. attach(force?: boolean): boolean;
  44308. /**
  44309. * Detach the feature from the session
  44310. * Will usually be called by the features manager
  44311. *
  44312. * @returns true if successful.
  44313. */
  44314. detach(): boolean;
  44315. }
  44316. /**
  44317. * A list of the currently available features without referencing them
  44318. */
  44319. export class WebXRFeatureName {
  44320. /**
  44321. * The name of the hit test feature
  44322. */
  44323. static HIT_TEST: string;
  44324. /**
  44325. * The name of the anchor system feature
  44326. */
  44327. static ANCHOR_SYSTEM: string;
  44328. /**
  44329. * The name of the background remover feature
  44330. */
  44331. static BACKGROUND_REMOVER: string;
  44332. /**
  44333. * The name of the pointer selection feature
  44334. */
  44335. static POINTER_SELECTION: string;
  44336. /**
  44337. * The name of the teleportation feature
  44338. */
  44339. static TELEPORTATION: string;
  44340. /**
  44341. * The name of the plane detection feature
  44342. */
  44343. static PLANE_DETECTION: string;
  44344. /**
  44345. * physics impostors for xr controllers feature
  44346. */
  44347. static PHYSICS_CONTROLLERS: string;
  44348. }
  44349. /**
  44350. * Defining the constructor of a feature. Used to register the modules.
  44351. */
  44352. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  44353. /**
  44354. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  44355. * It is mainly used in AR sessions.
  44356. *
  44357. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  44358. */
  44359. export class WebXRFeaturesManager implements IDisposable {
  44360. private _xrSessionManager;
  44361. private static readonly _AvailableFeatures;
  44362. /**
  44363. * Used to register a module. After calling this function a developer can use this feature in the scene.
  44364. * Mainly used internally.
  44365. *
  44366. * @param featureName the name of the feature to register
  44367. * @param constructorFunction the function used to construct the module
  44368. * @param version the (babylon) version of the module
  44369. * @param stable is that a stable version of this module
  44370. */
  44371. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  44372. /**
  44373. * Returns a constructor of a specific feature.
  44374. *
  44375. * @param featureName the name of the feature to construct
  44376. * @param version the version of the feature to load
  44377. * @param xrSessionManager the xrSessionManager. Used to construct the module
  44378. * @param options optional options provided to the module.
  44379. * @returns a function that, when called, will return a new instance of this feature
  44380. */
  44381. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  44382. /**
  44383. * Return the latest unstable version of this feature
  44384. * @param featureName the name of the feature to search
  44385. * @returns the version number. if not found will return -1
  44386. */
  44387. static GetLatestVersionOfFeature(featureName: string): number;
  44388. /**
  44389. * Return the latest stable version of this feature
  44390. * @param featureName the name of the feature to search
  44391. * @returns the version number. if not found will return -1
  44392. */
  44393. static GetStableVersionOfFeature(featureName: string): number;
  44394. /**
  44395. * Can be used to return the list of features currently registered
  44396. *
  44397. * @returns an Array of available features
  44398. */
  44399. static GetAvailableFeatures(): string[];
  44400. /**
  44401. * Gets the versions available for a specific feature
  44402. * @param featureName the name of the feature
  44403. * @returns an array with the available versions
  44404. */
  44405. static GetAvailableVersions(featureName: string): string[];
  44406. private _features;
  44407. /**
  44408. * constructs a new features manages.
  44409. *
  44410. * @param _xrSessionManager an instance of WebXRSessionManager
  44411. */
  44412. constructor(_xrSessionManager: WebXRSessionManager);
  44413. /**
  44414. * 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.
  44415. * 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.
  44416. *
  44417. * @param featureName the name of the feature to load or the class of the feature
  44418. * @param version optional version to load. if not provided the latest version will be enabled
  44419. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  44420. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  44421. * @returns a new constructed feature or throws an error if feature not found.
  44422. */
  44423. enableFeature(featureName: string | {
  44424. Name: string;
  44425. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  44426. /**
  44427. * Used to disable an already-enabled feature
  44428. * The feature will be disposed and will be recreated once enabled.
  44429. * @param featureName the feature to disable
  44430. * @returns true if disable was successful
  44431. */
  44432. disableFeature(featureName: string | {
  44433. Name: string;
  44434. }): boolean;
  44435. /**
  44436. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  44437. * Can be used during a session to start a feature
  44438. * @param featureName the name of feature to attach
  44439. */
  44440. attachFeature(featureName: string): void;
  44441. /**
  44442. * Can be used inside a session or when the session ends to detach a specific feature
  44443. * @param featureName the name of the feature to detach
  44444. */
  44445. detachFeature(featureName: string): void;
  44446. /**
  44447. * Get the list of enabled features
  44448. * @returns an array of enabled features
  44449. */
  44450. getEnabledFeatures(): string[];
  44451. /**
  44452. * get the implementation of an enabled feature.
  44453. * @param featureName the name of the feature to load
  44454. * @returns the feature class, if found
  44455. */
  44456. getEnabledFeature(featureName: string): IWebXRFeature;
  44457. /**
  44458. * dispose this features manager
  44459. */
  44460. dispose(): void;
  44461. }
  44462. }
  44463. declare module "babylonjs/XR/webXRExperienceHelper" {
  44464. import { Observable } from "babylonjs/Misc/observable";
  44465. import { IDisposable, Scene } from "babylonjs/scene";
  44466. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44467. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  44468. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44469. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  44470. /**
  44471. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  44472. * @see https://doc.babylonjs.com/how_to/webxr
  44473. */
  44474. export class WebXRExperienceHelper implements IDisposable {
  44475. private scene;
  44476. /**
  44477. * Camera used to render xr content
  44478. */
  44479. camera: WebXRCamera;
  44480. /**
  44481. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  44482. */
  44483. state: WebXRState;
  44484. private _setState;
  44485. /**
  44486. * Fires when the state of the experience helper has changed
  44487. */
  44488. onStateChangedObservable: Observable<WebXRState>;
  44489. /**
  44490. * Observers registered here will be triggered after the camera's initial transformation is set
  44491. * This can be used to set a different ground level or an extra rotation.
  44492. *
  44493. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  44494. * to the position set after this observable is done executing.
  44495. */
  44496. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  44497. /** Session manager used to keep track of xr session */
  44498. sessionManager: WebXRSessionManager;
  44499. /** A features manager for this xr session */
  44500. featuresManager: WebXRFeaturesManager;
  44501. private _nonVRCamera;
  44502. private _originalSceneAutoClear;
  44503. private _supported;
  44504. /**
  44505. * Creates the experience helper
  44506. * @param scene the scene to attach the experience helper to
  44507. * @returns a promise for the experience helper
  44508. */
  44509. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  44510. /**
  44511. * Creates a WebXRExperienceHelper
  44512. * @param scene The scene the helper should be created in
  44513. */
  44514. private constructor();
  44515. /**
  44516. * Exits XR mode and returns the scene to its original state
  44517. * @returns promise that resolves after xr mode has exited
  44518. */
  44519. exitXRAsync(): Promise<void>;
  44520. /**
  44521. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  44522. * @param sessionMode options for the XR session
  44523. * @param referenceSpaceType frame of reference of the XR session
  44524. * @param renderTarget the output canvas that will be used to enter XR mode
  44525. * @returns promise that resolves after xr mode has entered
  44526. */
  44527. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  44528. /**
  44529. * Disposes of the experience helper
  44530. */
  44531. dispose(): void;
  44532. private _nonXRToXRCamera;
  44533. }
  44534. }
  44535. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  44536. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  44537. import { Observable } from "babylonjs/Misc/observable";
  44538. import { IDisposable } from "babylonjs/scene";
  44539. /**
  44540. * X-Y values for axes in WebXR
  44541. */
  44542. export interface IWebXRMotionControllerAxesValue {
  44543. /**
  44544. * The value of the x axis
  44545. */
  44546. x: number;
  44547. /**
  44548. * The value of the y-axis
  44549. */
  44550. y: number;
  44551. }
  44552. /**
  44553. * changed / previous values for the values of this component
  44554. */
  44555. export interface IWebXRMotionControllerComponentChangesValues<T> {
  44556. /**
  44557. * current (this frame) value
  44558. */
  44559. current: T;
  44560. /**
  44561. * previous (last change) value
  44562. */
  44563. previous: T;
  44564. }
  44565. /**
  44566. * Represents changes in the component between current frame and last values recorded
  44567. */
  44568. export interface IWebXRMotionControllerComponentChanges {
  44569. /**
  44570. * will be populated with previous and current values if touched changed
  44571. */
  44572. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44573. /**
  44574. * will be populated with previous and current values if pressed changed
  44575. */
  44576. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44577. /**
  44578. * will be populated with previous and current values if value changed
  44579. */
  44580. value?: IWebXRMotionControllerComponentChangesValues<number>;
  44581. /**
  44582. * will be populated with previous and current values if axes changed
  44583. */
  44584. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  44585. }
  44586. /**
  44587. * This class represents a single component (for example button or thumbstick) of a motion controller
  44588. */
  44589. export class WebXRControllerComponent implements IDisposable {
  44590. /**
  44591. * the id of this component
  44592. */
  44593. id: string;
  44594. /**
  44595. * the type of the component
  44596. */
  44597. type: MotionControllerComponentType;
  44598. private _buttonIndex;
  44599. private _axesIndices;
  44600. /**
  44601. * Thumbstick component type
  44602. */
  44603. static THUMBSTICK: MotionControllerComponentType;
  44604. /**
  44605. * Touchpad component type
  44606. */
  44607. static TOUCHPAD: MotionControllerComponentType;
  44608. /**
  44609. * trigger component type
  44610. */
  44611. static TRIGGER: MotionControllerComponentType;
  44612. /**
  44613. * squeeze component type
  44614. */
  44615. static SQUEEZE: MotionControllerComponentType;
  44616. /**
  44617. * button component type
  44618. */
  44619. static BUTTON: MotionControllerComponentType;
  44620. /**
  44621. * Observers registered here will be triggered when the state of a button changes
  44622. * State change is either pressed / touched / value
  44623. */
  44624. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  44625. /**
  44626. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  44627. * the axes data changes
  44628. */
  44629. onAxisValueChangedObservable: Observable<{
  44630. x: number;
  44631. y: number;
  44632. }>;
  44633. private _currentValue;
  44634. private _touched;
  44635. private _pressed;
  44636. private _axes;
  44637. private _changes;
  44638. private _hasChanges;
  44639. /**
  44640. * Return whether or not the component changed the last frame
  44641. */
  44642. get hasChanges(): boolean;
  44643. /**
  44644. * Creates a new component for a motion controller.
  44645. * It is created by the motion controller itself
  44646. *
  44647. * @param id the id of this component
  44648. * @param type the type of the component
  44649. * @param _buttonIndex index in the buttons array of the gamepad
  44650. * @param _axesIndices indices of the values in the axes array of the gamepad
  44651. */
  44652. constructor(
  44653. /**
  44654. * the id of this component
  44655. */
  44656. id: string,
  44657. /**
  44658. * the type of the component
  44659. */
  44660. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  44661. /**
  44662. * Get the current value of this component
  44663. */
  44664. get value(): number;
  44665. /**
  44666. * is the button currently pressed
  44667. */
  44668. get pressed(): boolean;
  44669. /**
  44670. * is the button currently touched
  44671. */
  44672. get touched(): boolean;
  44673. /**
  44674. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  44675. */
  44676. get axes(): IWebXRMotionControllerAxesValue;
  44677. /**
  44678. * Get the changes. Elements will be populated only if they changed with their previous and current value
  44679. */
  44680. get changes(): IWebXRMotionControllerComponentChanges;
  44681. /**
  44682. * Is this component a button (hence - pressable)
  44683. * @returns true if can be pressed
  44684. */
  44685. isButton(): boolean;
  44686. /**
  44687. * Are there axes correlating to this component
  44688. * @return true is axes data is available
  44689. */
  44690. isAxes(): boolean;
  44691. /**
  44692. * update this component using the gamepad object it is in. Called on every frame
  44693. * @param nativeController the native gamepad controller object
  44694. */
  44695. update(nativeController: IMinimalMotionControllerObject): void;
  44696. /**
  44697. * Dispose this component
  44698. */
  44699. dispose(): void;
  44700. }
  44701. }
  44702. declare module "babylonjs/Loading/sceneLoader" {
  44703. import { Observable } from "babylonjs/Misc/observable";
  44704. import { Nullable } from "babylonjs/types";
  44705. import { Scene } from "babylonjs/scene";
  44706. import { Engine } from "babylonjs/Engines/engine";
  44707. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44708. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  44709. import { AssetContainer } from "babylonjs/assetContainer";
  44710. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  44711. import { Skeleton } from "babylonjs/Bones/skeleton";
  44712. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  44713. import { WebRequest } from "babylonjs/Misc/webRequest";
  44714. /**
  44715. * Class used to represent data loading progression
  44716. */
  44717. export class SceneLoaderProgressEvent {
  44718. /** defines if data length to load can be evaluated */
  44719. readonly lengthComputable: boolean;
  44720. /** defines the loaded data length */
  44721. readonly loaded: number;
  44722. /** defines the data length to load */
  44723. readonly total: number;
  44724. /**
  44725. * Create a new progress event
  44726. * @param lengthComputable defines if data length to load can be evaluated
  44727. * @param loaded defines the loaded data length
  44728. * @param total defines the data length to load
  44729. */
  44730. constructor(
  44731. /** defines if data length to load can be evaluated */
  44732. lengthComputable: boolean,
  44733. /** defines the loaded data length */
  44734. loaded: number,
  44735. /** defines the data length to load */
  44736. total: number);
  44737. /**
  44738. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  44739. * @param event defines the source event
  44740. * @returns a new SceneLoaderProgressEvent
  44741. */
  44742. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  44743. }
  44744. /**
  44745. * Interface used by SceneLoader plugins to define supported file extensions
  44746. */
  44747. export interface ISceneLoaderPluginExtensions {
  44748. /**
  44749. * Defines the list of supported extensions
  44750. */
  44751. [extension: string]: {
  44752. isBinary: boolean;
  44753. };
  44754. }
  44755. /**
  44756. * Interface used by SceneLoader plugin factory
  44757. */
  44758. export interface ISceneLoaderPluginFactory {
  44759. /**
  44760. * Defines the name of the factory
  44761. */
  44762. name: string;
  44763. /**
  44764. * Function called to create a new plugin
  44765. * @return the new plugin
  44766. */
  44767. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  44768. /**
  44769. * The callback that returns true if the data can be directly loaded.
  44770. * @param data string containing the file data
  44771. * @returns if the data can be loaded directly
  44772. */
  44773. canDirectLoad?(data: string): boolean;
  44774. }
  44775. /**
  44776. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  44777. */
  44778. export interface ISceneLoaderPluginBase {
  44779. /**
  44780. * The friendly name of this plugin.
  44781. */
  44782. name: string;
  44783. /**
  44784. * The file extensions supported by this plugin.
  44785. */
  44786. extensions: string | ISceneLoaderPluginExtensions;
  44787. /**
  44788. * The callback called when loading from a url.
  44789. * @param scene scene loading this url
  44790. * @param url url to load
  44791. * @param onSuccess callback called when the file successfully loads
  44792. * @param onProgress callback called while file is loading (if the server supports this mode)
  44793. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  44794. * @param onError callback called when the file fails to load
  44795. * @returns a file request object
  44796. */
  44797. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44798. /**
  44799. * The callback called when loading from a file object.
  44800. * @param scene scene loading this file
  44801. * @param file defines the file to load
  44802. * @param onSuccess defines the callback to call when data is loaded
  44803. * @param onProgress defines the callback to call during loading process
  44804. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  44805. * @param onError defines the callback to call when an error occurs
  44806. * @returns a file request object
  44807. */
  44808. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44809. /**
  44810. * The callback that returns true if the data can be directly loaded.
  44811. * @param data string containing the file data
  44812. * @returns if the data can be loaded directly
  44813. */
  44814. canDirectLoad?(data: string): boolean;
  44815. /**
  44816. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  44817. * @param scene scene loading this data
  44818. * @param data string containing the data
  44819. * @returns data to pass to the plugin
  44820. */
  44821. directLoad?(scene: Scene, data: string): any;
  44822. /**
  44823. * The callback that allows custom handling of the root url based on the response url.
  44824. * @param rootUrl the original root url
  44825. * @param responseURL the response url if available
  44826. * @returns the new root url
  44827. */
  44828. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  44829. }
  44830. /**
  44831. * Interface used to define a SceneLoader plugin
  44832. */
  44833. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  44834. /**
  44835. * Import meshes into a scene.
  44836. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44837. * @param scene The scene to import into
  44838. * @param data The data to import
  44839. * @param rootUrl The root url for scene and resources
  44840. * @param meshes The meshes array to import into
  44841. * @param particleSystems The particle systems array to import into
  44842. * @param skeletons The skeletons array to import into
  44843. * @param onError The callback when import fails
  44844. * @returns True if successful or false otherwise
  44845. */
  44846. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  44847. /**
  44848. * Load into a scene.
  44849. * @param scene The scene to load into
  44850. * @param data The data to import
  44851. * @param rootUrl The root url for scene and resources
  44852. * @param onError The callback when import fails
  44853. * @returns True if successful or false otherwise
  44854. */
  44855. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  44856. /**
  44857. * Load into an asset container.
  44858. * @param scene The scene to load into
  44859. * @param data The data to import
  44860. * @param rootUrl The root url for scene and resources
  44861. * @param onError The callback when import fails
  44862. * @returns The loaded asset container
  44863. */
  44864. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  44865. }
  44866. /**
  44867. * Interface used to define an async SceneLoader plugin
  44868. */
  44869. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  44870. /**
  44871. * Import meshes into a scene.
  44872. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44873. * @param scene The scene to import into
  44874. * @param data The data to import
  44875. * @param rootUrl The root url for scene and resources
  44876. * @param onProgress The callback when the load progresses
  44877. * @param fileName Defines the name of the file to load
  44878. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  44879. */
  44880. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  44881. meshes: AbstractMesh[];
  44882. particleSystems: IParticleSystem[];
  44883. skeletons: Skeleton[];
  44884. animationGroups: AnimationGroup[];
  44885. }>;
  44886. /**
  44887. * Load into a scene.
  44888. * @param scene The scene to load into
  44889. * @param data The data to import
  44890. * @param rootUrl The root url for scene and resources
  44891. * @param onProgress The callback when the load progresses
  44892. * @param fileName Defines the name of the file to load
  44893. * @returns Nothing
  44894. */
  44895. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  44896. /**
  44897. * Load into an asset container.
  44898. * @param scene The scene to load into
  44899. * @param data The data to import
  44900. * @param rootUrl The root url for scene and resources
  44901. * @param onProgress The callback when the load progresses
  44902. * @param fileName Defines the name of the file to load
  44903. * @returns The loaded asset container
  44904. */
  44905. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  44906. }
  44907. /**
  44908. * Mode that determines how to handle old animation groups before loading new ones.
  44909. */
  44910. export enum SceneLoaderAnimationGroupLoadingMode {
  44911. /**
  44912. * Reset all old animations to initial state then dispose them.
  44913. */
  44914. Clean = 0,
  44915. /**
  44916. * Stop all old animations.
  44917. */
  44918. Stop = 1,
  44919. /**
  44920. * Restart old animations from first frame.
  44921. */
  44922. Sync = 2,
  44923. /**
  44924. * Old animations remains untouched.
  44925. */
  44926. NoSync = 3
  44927. }
  44928. /**
  44929. * Class used to load scene from various file formats using registered plugins
  44930. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  44931. */
  44932. export class SceneLoader {
  44933. /**
  44934. * No logging while loading
  44935. */
  44936. static readonly NO_LOGGING: number;
  44937. /**
  44938. * Minimal logging while loading
  44939. */
  44940. static readonly MINIMAL_LOGGING: number;
  44941. /**
  44942. * Summary logging while loading
  44943. */
  44944. static readonly SUMMARY_LOGGING: number;
  44945. /**
  44946. * Detailled logging while loading
  44947. */
  44948. static readonly DETAILED_LOGGING: number;
  44949. /**
  44950. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  44951. */
  44952. static get ForceFullSceneLoadingForIncremental(): boolean;
  44953. static set ForceFullSceneLoadingForIncremental(value: boolean);
  44954. /**
  44955. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  44956. */
  44957. static get ShowLoadingScreen(): boolean;
  44958. static set ShowLoadingScreen(value: boolean);
  44959. /**
  44960. * Defines the current logging level (while loading the scene)
  44961. * @ignorenaming
  44962. */
  44963. static get loggingLevel(): number;
  44964. static set loggingLevel(value: number);
  44965. /**
  44966. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  44967. */
  44968. static get CleanBoneMatrixWeights(): boolean;
  44969. static set CleanBoneMatrixWeights(value: boolean);
  44970. /**
  44971. * Event raised when a plugin is used to load a scene
  44972. */
  44973. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  44974. private static _registeredPlugins;
  44975. private static _getDefaultPlugin;
  44976. private static _getPluginForExtension;
  44977. private static _getPluginForDirectLoad;
  44978. private static _getPluginForFilename;
  44979. private static _getDirectLoad;
  44980. private static _loadData;
  44981. private static _getFileInfo;
  44982. /**
  44983. * Gets a plugin that can load the given extension
  44984. * @param extension defines the extension to load
  44985. * @returns a plugin or null if none works
  44986. */
  44987. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  44988. /**
  44989. * Gets a boolean indicating that the given extension can be loaded
  44990. * @param extension defines the extension to load
  44991. * @returns true if the extension is supported
  44992. */
  44993. static IsPluginForExtensionAvailable(extension: string): boolean;
  44994. /**
  44995. * Adds a new plugin to the list of registered plugins
  44996. * @param plugin defines the plugin to add
  44997. */
  44998. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  44999. /**
  45000. * Import meshes into a scene
  45001. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45002. * @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)
  45003. * @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)
  45004. * @param scene the instance of BABYLON.Scene to append to
  45005. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  45006. * @param onProgress a callback with a progress event for each file being loaded
  45007. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45008. * @param pluginExtension the extension used to determine the plugin
  45009. * @returns The loaded plugin
  45010. */
  45011. 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>;
  45012. /**
  45013. * Import meshes into a scene
  45014. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45015. * @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)
  45016. * @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)
  45017. * @param scene the instance of BABYLON.Scene to append to
  45018. * @param onProgress a callback with a progress event for each file being loaded
  45019. * @param pluginExtension the extension used to determine the plugin
  45020. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  45021. */
  45022. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  45023. meshes: AbstractMesh[];
  45024. particleSystems: IParticleSystem[];
  45025. skeletons: Skeleton[];
  45026. animationGroups: AnimationGroup[];
  45027. }>;
  45028. /**
  45029. * Load a scene
  45030. * @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)
  45031. * @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)
  45032. * @param engine is the instance of BABYLON.Engine to use to create the scene
  45033. * @param onSuccess a callback with the scene when import succeeds
  45034. * @param onProgress a callback with a progress event for each file being loaded
  45035. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45036. * @param pluginExtension the extension used to determine the plugin
  45037. * @returns The loaded plugin
  45038. */
  45039. 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>;
  45040. /**
  45041. * Load a scene
  45042. * @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)
  45043. * @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)
  45044. * @param engine is the instance of BABYLON.Engine to use to create the scene
  45045. * @param onProgress a callback with a progress event for each file being loaded
  45046. * @param pluginExtension the extension used to determine the plugin
  45047. * @returns The loaded scene
  45048. */
  45049. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45050. /**
  45051. * Append a scene
  45052. * @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)
  45053. * @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)
  45054. * @param scene is the instance of BABYLON.Scene to append to
  45055. * @param onSuccess a callback with the scene when import succeeds
  45056. * @param onProgress a callback with a progress event for each file being loaded
  45057. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45058. * @param pluginExtension the extension used to determine the plugin
  45059. * @returns The loaded plugin
  45060. */
  45061. 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>;
  45062. /**
  45063. * Append a scene
  45064. * @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)
  45065. * @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)
  45066. * @param scene is the instance of BABYLON.Scene to append to
  45067. * @param onProgress a callback with a progress event for each file being loaded
  45068. * @param pluginExtension the extension used to determine the plugin
  45069. * @returns The given scene
  45070. */
  45071. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45072. /**
  45073. * Load a scene into an asset container
  45074. * @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)
  45075. * @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)
  45076. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45077. * @param onSuccess a callback with the scene when import succeeds
  45078. * @param onProgress a callback with a progress event for each file being loaded
  45079. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45080. * @param pluginExtension the extension used to determine the plugin
  45081. * @returns The loaded plugin
  45082. */
  45083. 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>;
  45084. /**
  45085. * Load a scene into an asset container
  45086. * @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)
  45087. * @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)
  45088. * @param scene is the instance of Scene to append to
  45089. * @param onProgress a callback with a progress event for each file being loaded
  45090. * @param pluginExtension the extension used to determine the plugin
  45091. * @returns The loaded asset container
  45092. */
  45093. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  45094. /**
  45095. * Import animations from a file into a scene
  45096. * @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)
  45097. * @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)
  45098. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45099. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45100. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45101. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45102. * @param onSuccess a callback with the scene when import succeeds
  45103. * @param onProgress a callback with a progress event for each file being loaded
  45104. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45105. */
  45106. 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;
  45107. /**
  45108. * Import animations from a file into a scene
  45109. * @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)
  45110. * @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)
  45111. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45112. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45113. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45114. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45115. * @param onSuccess a callback with the scene when import succeeds
  45116. * @param onProgress a callback with a progress event for each file being loaded
  45117. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45118. * @returns the updated scene with imported animations
  45119. */
  45120. 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>;
  45121. }
  45122. }
  45123. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  45124. import { IDisposable, Scene } from "babylonjs/scene";
  45125. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  45126. import { Observable } from "babylonjs/Misc/observable";
  45127. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45128. import { Nullable } from "babylonjs/types";
  45129. /**
  45130. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  45131. */
  45132. export type MotionControllerHandness = "none" | "left" | "right";
  45133. /**
  45134. * The type of components available in motion controllers.
  45135. * This is not the name of the component.
  45136. */
  45137. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  45138. /**
  45139. * The state of a controller component
  45140. */
  45141. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  45142. /**
  45143. * The schema of motion controller layout.
  45144. * No object will be initialized using this interface
  45145. * This is used just to define the profile.
  45146. */
  45147. export interface IMotionControllerLayout {
  45148. /**
  45149. * Defines the main button component id
  45150. */
  45151. selectComponentId: string;
  45152. /**
  45153. * Available components (unsorted)
  45154. */
  45155. components: {
  45156. /**
  45157. * A map of component Ids
  45158. */
  45159. [componentId: string]: {
  45160. /**
  45161. * The type of input the component outputs
  45162. */
  45163. type: MotionControllerComponentType;
  45164. /**
  45165. * The indices of this component in the gamepad object
  45166. */
  45167. gamepadIndices: {
  45168. /**
  45169. * Index of button
  45170. */
  45171. button?: number;
  45172. /**
  45173. * If available, index of x-axis
  45174. */
  45175. xAxis?: number;
  45176. /**
  45177. * If available, index of y-axis
  45178. */
  45179. yAxis?: number;
  45180. };
  45181. /**
  45182. * The mesh's root node name
  45183. */
  45184. rootNodeName: string;
  45185. /**
  45186. * Animation definitions for this model
  45187. */
  45188. visualResponses: {
  45189. [stateKey: string]: {
  45190. /**
  45191. * What property will be animated
  45192. */
  45193. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  45194. /**
  45195. * What states influence this visual reponse
  45196. */
  45197. states: MotionControllerComponentStateType[];
  45198. /**
  45199. * Type of animation - movement or visibility
  45200. */
  45201. valueNodeProperty: "transform" | "visibility";
  45202. /**
  45203. * Base node name to move. Its position will be calculated according to the min and max nodes
  45204. */
  45205. valueNodeName?: string;
  45206. /**
  45207. * Minimum movement node
  45208. */
  45209. minNodeName?: string;
  45210. /**
  45211. * Max movement node
  45212. */
  45213. maxNodeName?: string;
  45214. };
  45215. };
  45216. /**
  45217. * If touch enabled, what is the name of node to display user feedback
  45218. */
  45219. touchPointNodeName?: string;
  45220. };
  45221. };
  45222. /**
  45223. * Is it xr standard mapping or not
  45224. */
  45225. gamepadMapping: "" | "xr-standard";
  45226. /**
  45227. * Base root node of this entire model
  45228. */
  45229. rootNodeName: string;
  45230. /**
  45231. * Path to load the assets. Usually relative to the base path
  45232. */
  45233. assetPath: string;
  45234. }
  45235. /**
  45236. * A definition for the layout map in the input profile
  45237. */
  45238. export interface IMotionControllerLayoutMap {
  45239. /**
  45240. * Layouts with handness type as a key
  45241. */
  45242. [handness: string]: IMotionControllerLayout;
  45243. }
  45244. /**
  45245. * The XR Input profile schema
  45246. * Profiles can be found here:
  45247. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  45248. */
  45249. export interface IMotionControllerProfile {
  45250. /**
  45251. * The id of this profile
  45252. * correlates to the profile(s) in the xrInput.profiles array
  45253. */
  45254. profileId: string;
  45255. /**
  45256. * fallback profiles for this profileId
  45257. */
  45258. fallbackProfileIds: string[];
  45259. /**
  45260. * The layout map, with handness as key
  45261. */
  45262. layouts: IMotionControllerLayoutMap;
  45263. }
  45264. /**
  45265. * A helper-interface for the 3 meshes needed for controller button animation
  45266. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  45267. */
  45268. export interface IMotionControllerButtonMeshMap {
  45269. /**
  45270. * The mesh that will be changed when value changes
  45271. */
  45272. valueMesh: AbstractMesh;
  45273. /**
  45274. * the mesh that defines the pressed value mesh position.
  45275. * This is used to find the max-position of this button
  45276. */
  45277. pressedMesh: AbstractMesh;
  45278. /**
  45279. * the mesh that defines the unpressed value mesh position.
  45280. * This is used to find the min (or initial) position of this button
  45281. */
  45282. unpressedMesh: AbstractMesh;
  45283. }
  45284. /**
  45285. * A helper-interface for the 3 meshes needed for controller axis animation.
  45286. * This will be expanded when touchpad animations are fully supported
  45287. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  45288. */
  45289. export interface IMotionControllerMeshMap {
  45290. /**
  45291. * The mesh that will be changed when axis value changes
  45292. */
  45293. valueMesh: AbstractMesh;
  45294. /**
  45295. * the mesh that defines the minimum value mesh position.
  45296. */
  45297. minMesh?: AbstractMesh;
  45298. /**
  45299. * the mesh that defines the maximum value mesh position.
  45300. */
  45301. maxMesh?: AbstractMesh;
  45302. }
  45303. /**
  45304. * The elements needed for change-detection of the gamepad objects in motion controllers
  45305. */
  45306. export interface IMinimalMotionControllerObject {
  45307. /**
  45308. * An array of available buttons
  45309. */
  45310. buttons: Array<{
  45311. /**
  45312. * Value of the button/trigger
  45313. */
  45314. value: number;
  45315. /**
  45316. * If the button/trigger is currently touched
  45317. */
  45318. touched: boolean;
  45319. /**
  45320. * If the button/trigger is currently pressed
  45321. */
  45322. pressed: boolean;
  45323. }>;
  45324. /**
  45325. * Available axes of this controller
  45326. */
  45327. axes: number[];
  45328. }
  45329. /**
  45330. * An Abstract Motion controller
  45331. * This class receives an xrInput and a profile layout and uses those to initialize the components
  45332. * Each component has an observable to check for changes in value and state
  45333. */
  45334. export abstract class WebXRAbstractMotionController implements IDisposable {
  45335. protected scene: Scene;
  45336. protected layout: IMotionControllerLayout;
  45337. /**
  45338. * The gamepad object correlating to this controller
  45339. */
  45340. gamepadObject: IMinimalMotionControllerObject;
  45341. /**
  45342. * handness (left/right/none) of this controller
  45343. */
  45344. handness: MotionControllerHandness;
  45345. /**
  45346. * The profile id of this motion controller
  45347. */
  45348. abstract profileId: string;
  45349. /**
  45350. * A map of components (WebXRControllerComponent) in this motion controller
  45351. * Components have a ComponentType and can also have both button and axis definitions
  45352. */
  45353. readonly components: {
  45354. [id: string]: WebXRControllerComponent;
  45355. };
  45356. /**
  45357. * Observers registered here will be triggered when the model of this controller is done loading
  45358. */
  45359. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  45360. /**
  45361. * The root mesh of the model. It is null if the model was not yet initialized
  45362. */
  45363. rootMesh: Nullable<AbstractMesh>;
  45364. /**
  45365. * Disable the model's animation. Can be set at any time.
  45366. */
  45367. disableAnimation: boolean;
  45368. private _modelReady;
  45369. /**
  45370. * constructs a new abstract motion controller
  45371. * @param scene the scene to which the model of the controller will be added
  45372. * @param layout The profile layout to load
  45373. * @param gamepadObject The gamepad object correlating to this controller
  45374. * @param handness handness (left/right/none) of this controller
  45375. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  45376. */
  45377. constructor(scene: Scene, layout: IMotionControllerLayout,
  45378. /**
  45379. * The gamepad object correlating to this controller
  45380. */
  45381. gamepadObject: IMinimalMotionControllerObject,
  45382. /**
  45383. * handness (left/right/none) of this controller
  45384. */
  45385. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  45386. private _initComponent;
  45387. /**
  45388. * Update this model using the current XRFrame
  45389. * @param xrFrame the current xr frame to use and update the model
  45390. */
  45391. updateFromXRFrame(xrFrame: XRFrame): void;
  45392. /**
  45393. * Get the list of components available in this motion controller
  45394. * @returns an array of strings correlating to available components
  45395. */
  45396. getComponentIds(): string[];
  45397. /**
  45398. * Get the main (Select) component of this controller as defined in the layout
  45399. * @returns the main component of this controller
  45400. */
  45401. getMainComponent(): WebXRControllerComponent;
  45402. /**
  45403. * get a component based an its component id as defined in layout.components
  45404. * @param id the id of the component
  45405. * @returns the component correlates to the id or undefined if not found
  45406. */
  45407. getComponent(id: string): WebXRControllerComponent;
  45408. /**
  45409. * Get the first component of specific type
  45410. * @param type type of component to find
  45411. * @return a controller component or null if not found
  45412. */
  45413. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  45414. /**
  45415. * Returns all components of specific type
  45416. * @param type the type to search for
  45417. * @return an array of components with this type
  45418. */
  45419. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  45420. /**
  45421. * Loads the model correlating to this controller
  45422. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  45423. * @returns A promise fulfilled with the result of the model loading
  45424. */
  45425. loadModel(): Promise<boolean>;
  45426. /**
  45427. * Update the model itself with the current frame data
  45428. * @param xrFrame the frame to use for updating the model mesh
  45429. */
  45430. protected updateModel(xrFrame: XRFrame): void;
  45431. /**
  45432. * Moves the axis on the controller mesh based on its current state
  45433. * @param axis the index of the axis
  45434. * @param axisValue the value of the axis which determines the meshes new position
  45435. * @hidden
  45436. */
  45437. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  45438. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  45439. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  45440. private _getGenericFilenameAndPath;
  45441. private _getGenericParentMesh;
  45442. /**
  45443. * Get the filename and path for this controller's model
  45444. * @returns a map of filename and path
  45445. */
  45446. protected abstract _getFilenameAndPath(): {
  45447. filename: string;
  45448. path: string;
  45449. };
  45450. /**
  45451. * This function will be called after the model was successfully loaded and can be used
  45452. * for mesh transformations before it is available for the user
  45453. * @param meshes the loaded meshes
  45454. */
  45455. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  45456. /**
  45457. * Set the root mesh for this controller. Important for the WebXR controller class
  45458. * @param meshes the loaded meshes
  45459. */
  45460. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  45461. /**
  45462. * A function executed each frame that updates the mesh (if needed)
  45463. * @param xrFrame the current xrFrame
  45464. */
  45465. protected abstract _updateModel(xrFrame: XRFrame): void;
  45466. /**
  45467. * This function is called before the mesh is loaded. It checks for loading constraints.
  45468. * For example, this function can check if the GLB loader is available
  45469. * If this function returns false, the generic controller will be loaded instead
  45470. * @returns Is the client ready to load the mesh
  45471. */
  45472. protected abstract _getModelLoadingConstraints(): boolean;
  45473. /**
  45474. * Dispose this controller, the model mesh and all its components
  45475. */
  45476. dispose(): void;
  45477. }
  45478. }
  45479. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  45480. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45481. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45482. import { Scene } from "babylonjs/scene";
  45483. /**
  45484. * A generic trigger-only motion controller for WebXR
  45485. */
  45486. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  45487. /**
  45488. * Static version of the profile id of this controller
  45489. */
  45490. static ProfileId: string;
  45491. profileId: string;
  45492. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  45493. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  45494. protected _updateModel(): void;
  45495. protected _getFilenameAndPath(): {
  45496. filename: string;
  45497. path: string;
  45498. };
  45499. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45500. protected _getModelLoadingConstraints(): boolean;
  45501. }
  45502. }
  45503. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  45504. import { Vector4 } from "babylonjs/Maths/math.vector";
  45505. import { Mesh } from "babylonjs/Meshes/mesh";
  45506. import { Scene } from "babylonjs/scene";
  45507. import { Nullable } from "babylonjs/types";
  45508. /**
  45509. * Class containing static functions to help procedurally build meshes
  45510. */
  45511. export class SphereBuilder {
  45512. /**
  45513. * Creates a sphere mesh
  45514. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45515. * * 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`)
  45516. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45517. * * 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
  45518. * * 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)
  45519. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45520. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45521. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45522. * @param name defines the name of the mesh
  45523. * @param options defines the options used to create the mesh
  45524. * @param scene defines the hosting scene
  45525. * @returns the sphere mesh
  45526. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45527. */
  45528. static CreateSphere(name: string, options: {
  45529. segments?: number;
  45530. diameter?: number;
  45531. diameterX?: number;
  45532. diameterY?: number;
  45533. diameterZ?: number;
  45534. arc?: number;
  45535. slice?: number;
  45536. sideOrientation?: number;
  45537. frontUVs?: Vector4;
  45538. backUVs?: Vector4;
  45539. updatable?: boolean;
  45540. }, scene?: Nullable<Scene>): Mesh;
  45541. }
  45542. }
  45543. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  45544. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45545. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45546. import { Scene } from "babylonjs/scene";
  45547. /**
  45548. * A profiled motion controller has its profile loaded from an online repository.
  45549. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  45550. */
  45551. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  45552. private _repositoryUrl;
  45553. /**
  45554. * The profile ID of this controller. Will be populated when the controller initializes.
  45555. */
  45556. profileId: string;
  45557. private _buttonMeshMapping;
  45558. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  45559. protected _getFilenameAndPath(): {
  45560. filename: string;
  45561. path: string;
  45562. };
  45563. private _touchDots;
  45564. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  45565. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45566. protected _updateModel(_xrFrame: XRFrame): void;
  45567. protected _getModelLoadingConstraints(): boolean;
  45568. dispose(): void;
  45569. }
  45570. }
  45571. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  45572. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45573. import { Scene } from "babylonjs/scene";
  45574. /**
  45575. * A construction function type to create a new controller based on an xrInput object
  45576. */
  45577. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  45578. /**
  45579. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  45580. *
  45581. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  45582. * it should be replaced with auto-loaded controllers.
  45583. *
  45584. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  45585. */
  45586. export class WebXRMotionControllerManager {
  45587. /**
  45588. * The base URL of the online controller repository. Can be changed at any time.
  45589. */
  45590. static BaseRepositoryUrl: string;
  45591. /**
  45592. * Use the online repository, or use only locally-defined controllers
  45593. */
  45594. static UseOnlineRepository: boolean;
  45595. /**
  45596. * Which repository gets priority - local or online
  45597. */
  45598. static PrioritizeOnlineRepository: boolean;
  45599. private static _AvailableControllers;
  45600. private static _Fallbacks;
  45601. /**
  45602. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  45603. *
  45604. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  45605. *
  45606. * @param type the profile type to register
  45607. * @param constructFunction the function to be called when loading this profile
  45608. */
  45609. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  45610. /**
  45611. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  45612. * The order of search:
  45613. *
  45614. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  45615. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  45616. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  45617. * 4) return the generic trigger controller if none were found
  45618. *
  45619. * @param xrInput the xrInput to which a new controller is initialized
  45620. * @param scene the scene to which the model will be added
  45621. * @param forceProfile force a certain profile for this controller
  45622. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  45623. */
  45624. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  45625. private static _LoadProfilesFromAvailableControllers;
  45626. private static _ProfilesList;
  45627. private static _ProfileLoadingPromises;
  45628. private static _LoadProfileFromRepository;
  45629. /**
  45630. * Clear the cache used for profile loading and reload when requested again
  45631. */
  45632. static ClearProfilesCache(): void;
  45633. /**
  45634. * Will update the list of profiles available in the repository
  45635. * @return a promise that resolves to a map of profiles available online
  45636. */
  45637. static UpdateProfilesList(): Promise<{
  45638. [profile: string]: string;
  45639. }>;
  45640. /**
  45641. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  45642. * @param profileId the profile to which a fallback needs to be found
  45643. * @return an array with corresponding fallback profiles
  45644. */
  45645. static FindFallbackWithProfileId(profileId: string): string[];
  45646. /**
  45647. * Register a fallback to a specific profile.
  45648. * @param profileId the profileId that will receive the fallbacks
  45649. * @param fallbacks A list of fallback profiles
  45650. */
  45651. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  45652. /**
  45653. * Register the default fallbacks.
  45654. * This function is called automatically when this file is imported.
  45655. */
  45656. static DefaultFallbacks(): void;
  45657. }
  45658. }
  45659. declare module "babylonjs/XR/webXRInputSource" {
  45660. import { Observable } from "babylonjs/Misc/observable";
  45661. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45662. import { Ray } from "babylonjs/Culling/ray";
  45663. import { Scene } from "babylonjs/scene";
  45664. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45665. /**
  45666. * Configuration options for the WebXR controller creation
  45667. */
  45668. export interface IWebXRControllerOptions {
  45669. /**
  45670. * Force a specific controller type for this controller.
  45671. * This can be used when creating your own profile or when testing different controllers
  45672. */
  45673. forceControllerProfile?: string;
  45674. /**
  45675. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  45676. */
  45677. doNotLoadControllerMesh?: boolean;
  45678. /**
  45679. * Should the controller mesh be animated when a user interacts with it
  45680. * The pressed buttons / thumbstick and touchpad animations will be disabled
  45681. */
  45682. disableMotionControllerAnimation?: boolean;
  45683. }
  45684. /**
  45685. * Represents an XR controller
  45686. */
  45687. export class WebXRInputSource {
  45688. private _scene;
  45689. /** The underlying input source for the controller */
  45690. inputSource: XRInputSource;
  45691. private _options;
  45692. /**
  45693. * 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
  45694. */
  45695. grip?: AbstractMesh;
  45696. /**
  45697. * Pointer which can be used to select objects or attach a visible laser to
  45698. */
  45699. pointer: AbstractMesh;
  45700. /**
  45701. * If available, this is the gamepad object related to this controller.
  45702. * Using this object it is possible to get click events and trackpad changes of the
  45703. * webxr controller that is currently being used.
  45704. */
  45705. motionController?: WebXRAbstractMotionController;
  45706. /**
  45707. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  45708. */
  45709. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  45710. /**
  45711. * Will be triggered when the mesh associated with the motion controller is done loading.
  45712. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  45713. * A shortened version of controller -> motion controller -> on mesh loaded.
  45714. */
  45715. onMeshLoadedObservable: Observable<AbstractMesh>;
  45716. /**
  45717. * Event that fires when the controller is removed/disposed.
  45718. * The object provided as event data is this controller, after associated assets were disposed.
  45719. * uniqueId is still available.
  45720. */
  45721. onDisposeObservable: Observable<WebXRInputSource>;
  45722. private _tmpQuaternion;
  45723. private _tmpVector;
  45724. private _uniqueId;
  45725. /**
  45726. * Creates the controller
  45727. * @see https://doc.babylonjs.com/how_to/webxr
  45728. * @param _scene the scene which the controller should be associated to
  45729. * @param inputSource the underlying input source for the controller
  45730. * @param _options options for this controller creation
  45731. */
  45732. constructor(_scene: Scene,
  45733. /** The underlying input source for the controller */
  45734. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  45735. /**
  45736. * Get this controllers unique id
  45737. */
  45738. get uniqueId(): string;
  45739. /**
  45740. * Updates the controller pose based on the given XRFrame
  45741. * @param xrFrame xr frame to update the pose with
  45742. * @param referenceSpace reference space to use
  45743. */
  45744. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  45745. /**
  45746. * Gets a world space ray coming from the pointer or grip
  45747. * @param result the resulting ray
  45748. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  45749. */
  45750. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  45751. /**
  45752. * Disposes of the object
  45753. */
  45754. dispose(): void;
  45755. }
  45756. }
  45757. declare module "babylonjs/XR/webXRInput" {
  45758. import { Observable } from "babylonjs/Misc/observable";
  45759. import { IDisposable } from "babylonjs/scene";
  45760. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  45761. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45762. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  45763. /**
  45764. * The schema for initialization options of the XR Input class
  45765. */
  45766. export interface IWebXRInputOptions {
  45767. /**
  45768. * If set to true no model will be automatically loaded
  45769. */
  45770. doNotLoadControllerMeshes?: boolean;
  45771. /**
  45772. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  45773. * If not found, the xr input profile data will be used.
  45774. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  45775. */
  45776. forceInputProfile?: string;
  45777. /**
  45778. * Do not send a request to the controlle repository to load the profile.
  45779. *
  45780. * Instead, use the controllers available in babylon itself.
  45781. */
  45782. disableOnlineControllerRepository?: boolean;
  45783. /**
  45784. * A custom URL for the controllers repository
  45785. */
  45786. customControllersRepositoryURL?: string;
  45787. /**
  45788. * Should the controller model's components not move according to the user input
  45789. */
  45790. disableControllerAnimation?: boolean;
  45791. }
  45792. /**
  45793. * XR input used to track XR inputs such as controllers/rays
  45794. */
  45795. export class WebXRInput implements IDisposable {
  45796. /**
  45797. * the xr session manager for this session
  45798. */
  45799. xrSessionManager: WebXRSessionManager;
  45800. /**
  45801. * the WebXR camera for this session. Mainly used for teleportation
  45802. */
  45803. xrCamera: WebXRCamera;
  45804. private readonly options;
  45805. /**
  45806. * XR controllers being tracked
  45807. */
  45808. controllers: Array<WebXRInputSource>;
  45809. private _frameObserver;
  45810. private _sessionEndedObserver;
  45811. private _sessionInitObserver;
  45812. /**
  45813. * Event when a controller has been connected/added
  45814. */
  45815. onControllerAddedObservable: Observable<WebXRInputSource>;
  45816. /**
  45817. * Event when a controller has been removed/disconnected
  45818. */
  45819. onControllerRemovedObservable: Observable<WebXRInputSource>;
  45820. /**
  45821. * Initializes the WebXRInput
  45822. * @param xrSessionManager the xr session manager for this session
  45823. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  45824. * @param options = initialization options for this xr input
  45825. */
  45826. constructor(
  45827. /**
  45828. * the xr session manager for this session
  45829. */
  45830. xrSessionManager: WebXRSessionManager,
  45831. /**
  45832. * the WebXR camera for this session. Mainly used for teleportation
  45833. */
  45834. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  45835. private _onInputSourcesChange;
  45836. private _addAndRemoveControllers;
  45837. /**
  45838. * Disposes of the object
  45839. */
  45840. dispose(): void;
  45841. }
  45842. }
  45843. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  45844. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  45845. import { Observable, EventState } from "babylonjs/Misc/observable";
  45846. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45847. /**
  45848. * This is the base class for all WebXR features.
  45849. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  45850. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  45851. */
  45852. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  45853. protected _xrSessionManager: WebXRSessionManager;
  45854. /**
  45855. * Construct a new (abstract) webxr feature
  45856. * @param _xrSessionManager the xr session manager for this feature
  45857. */
  45858. constructor(_xrSessionManager: WebXRSessionManager);
  45859. private _attached;
  45860. private _removeOnDetach;
  45861. /**
  45862. * Is this feature attached
  45863. */
  45864. get attached(): boolean;
  45865. /**
  45866. * Should auto-attach be disabled?
  45867. */
  45868. disableAutoAttach: boolean;
  45869. /**
  45870. * attach this feature
  45871. *
  45872. * @param force should attachment be forced (even when already attached)
  45873. * @returns true if successful, false is failed or already attached
  45874. */
  45875. attach(force?: boolean): boolean;
  45876. /**
  45877. * detach this feature.
  45878. *
  45879. * @returns true if successful, false if failed or already detached
  45880. */
  45881. detach(): boolean;
  45882. /**
  45883. * Dispose this feature and all of the resources attached
  45884. */
  45885. dispose(): void;
  45886. /**
  45887. * Code in this function will be executed on each xrFrame received from the browser.
  45888. * This function will not execute after the feature is detached.
  45889. * @param _xrFrame the current frame
  45890. */
  45891. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  45892. /**
  45893. * This is used to register callbacks that will automatically be removed when detach is called.
  45894. * @param observable the observable to which the observer will be attached
  45895. * @param callback the callback to register
  45896. */
  45897. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  45898. }
  45899. }
  45900. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  45901. import { IDisposable, Scene } from "babylonjs/scene";
  45902. import { Nullable } from "babylonjs/types";
  45903. import { Observable } from "babylonjs/Misc/observable";
  45904. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45905. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  45906. import { Camera } from "babylonjs/Cameras/camera";
  45907. /**
  45908. * Renders a layer on top of an existing scene
  45909. */
  45910. export class UtilityLayerRenderer implements IDisposable {
  45911. /** the original scene that will be rendered on top of */
  45912. originalScene: Scene;
  45913. private _pointerCaptures;
  45914. private _lastPointerEvents;
  45915. private static _DefaultUtilityLayer;
  45916. private static _DefaultKeepDepthUtilityLayer;
  45917. private _sharedGizmoLight;
  45918. private _renderCamera;
  45919. /**
  45920. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  45921. * @returns the camera that is used when rendering the utility layer
  45922. */
  45923. getRenderCamera(): Camera;
  45924. /**
  45925. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  45926. * @param cam the camera that should be used when rendering the utility layer
  45927. */
  45928. setRenderCamera(cam: Nullable<Camera>): void;
  45929. /**
  45930. * @hidden
  45931. * Light which used by gizmos to get light shading
  45932. */
  45933. _getSharedGizmoLight(): HemisphericLight;
  45934. /**
  45935. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  45936. */
  45937. pickUtilitySceneFirst: boolean;
  45938. /**
  45939. * 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)
  45940. */
  45941. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  45942. /**
  45943. * 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)
  45944. */
  45945. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  45946. /**
  45947. * The scene that is rendered on top of the original scene
  45948. */
  45949. utilityLayerScene: Scene;
  45950. /**
  45951. * If the utility layer should automatically be rendered on top of existing scene
  45952. */
  45953. shouldRender: boolean;
  45954. /**
  45955. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  45956. */
  45957. onlyCheckPointerDownEvents: boolean;
  45958. /**
  45959. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  45960. */
  45961. processAllEvents: boolean;
  45962. /**
  45963. * Observable raised when the pointer move from the utility layer scene to the main scene
  45964. */
  45965. onPointerOutObservable: Observable<number>;
  45966. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  45967. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  45968. private _afterRenderObserver;
  45969. private _sceneDisposeObserver;
  45970. private _originalPointerObserver;
  45971. /**
  45972. * Instantiates a UtilityLayerRenderer
  45973. * @param originalScene the original scene that will be rendered on top of
  45974. * @param handleEvents boolean indicating if the utility layer should handle events
  45975. */
  45976. constructor(
  45977. /** the original scene that will be rendered on top of */
  45978. originalScene: Scene, handleEvents?: boolean);
  45979. private _notifyObservers;
  45980. /**
  45981. * Renders the utility layers scene on top of the original scene
  45982. */
  45983. render(): void;
  45984. /**
  45985. * Disposes of the renderer
  45986. */
  45987. dispose(): void;
  45988. private _updateCamera;
  45989. }
  45990. }
  45991. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  45992. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45993. import { WebXRInput } from "babylonjs/XR/webXRInput";
  45994. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  45995. import { Scene } from "babylonjs/scene";
  45996. import { Nullable } from "babylonjs/types";
  45997. import { Color3 } from "babylonjs/Maths/math.color";
  45998. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  45999. /**
  46000. * Options interface for the pointer selection module
  46001. */
  46002. export interface IWebXRControllerPointerSelectionOptions {
  46003. /**
  46004. * the xr input to use with this pointer selection
  46005. */
  46006. xrInput: WebXRInput;
  46007. /**
  46008. * Different button type to use instead of the main component
  46009. */
  46010. overrideButtonId?: string;
  46011. /**
  46012. * The amount of time in miliseconds it takes between pick found something to a pointer down event.
  46013. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  46014. * 3000 means 3 seconds between pointing at something and selecting it
  46015. */
  46016. timeToSelect?: number;
  46017. /**
  46018. * 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)
  46019. * If not disabled, the last picked point will be used to execute a pointer up event
  46020. * If disabled, pointer up event will be triggered right after the pointer down event.
  46021. * Used in screen and gaze target ray mode only
  46022. */
  46023. disablePointerUpOnTouchOut: boolean;
  46024. /**
  46025. * For gaze mode (time to select instead of press)
  46026. */
  46027. forceGazeMode: boolean;
  46028. /**
  46029. * 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
  46030. * to start a new countdown to the pointer down event.
  46031. * Defaults to 1.
  46032. */
  46033. gazeModePointerMovedFactor?: number;
  46034. /**
  46035. * Should meshes created here be added to a utility layer or the main scene
  46036. */
  46037. useUtilityLayer?: boolean;
  46038. /**
  46039. * if provided, this scene will be used to render meshes.
  46040. */
  46041. customUtilityLayerScene?: Scene;
  46042. }
  46043. /**
  46044. * A module that will enable pointer selection for motion controllers of XR Input Sources
  46045. */
  46046. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  46047. private readonly _options;
  46048. /**
  46049. * The module's name
  46050. */
  46051. static readonly Name: string;
  46052. /**
  46053. * The (Babylon) version of this module.
  46054. * This is an integer representing the implementation version.
  46055. * This number does not correspond to the webxr specs version
  46056. */
  46057. static readonly Version: number;
  46058. /**
  46059. * This color will be set to the laser pointer when selection is triggered
  46060. */
  46061. laserPointerPickedColor: Color3;
  46062. /**
  46063. * This color will be applied to the selection ring when selection is triggered
  46064. */
  46065. selectionMeshPickedColor: Color3;
  46066. /**
  46067. * default color of the selection ring
  46068. */
  46069. selectionMeshDefaultColor: Color3;
  46070. /**
  46071. * Default color of the laser pointer
  46072. */
  46073. lasterPointerDefaultColor: Color3;
  46074. /**
  46075. * Should the laser pointer be displayed
  46076. */
  46077. displayLaserPointer: boolean;
  46078. /**
  46079. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  46080. */
  46081. displaySelectionMesh: boolean;
  46082. /**
  46083. * Disable lighting on the laser pointer (so it will always be visible)
  46084. */
  46085. disablePointerLighting: boolean;
  46086. /**
  46087. * Disable lighting on the selection mesh (so it will always be visible)
  46088. */
  46089. disableSelectionMeshLighting: boolean;
  46090. private static _idCounter;
  46091. private _tmpRay;
  46092. private _controllers;
  46093. private _scene;
  46094. /**
  46095. * constructs a new background remover module
  46096. * @param _xrSessionManager the session manager for this module
  46097. * @param _options read-only options to be used in this module
  46098. */
  46099. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  46100. /**
  46101. * attach this feature
  46102. * Will usually be called by the features manager
  46103. *
  46104. * @returns true if successful.
  46105. */
  46106. attach(): boolean;
  46107. /**
  46108. * detach this feature.
  46109. * Will usually be called by the features manager
  46110. *
  46111. * @returns true if successful.
  46112. */
  46113. detach(): boolean;
  46114. /**
  46115. * Get the xr controller that correlates to the pointer id in the pointer event
  46116. *
  46117. * @param id the pointer id to search for
  46118. * @returns the controller that correlates to this id or null if not found
  46119. */
  46120. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  46121. protected _onXRFrame(_xrFrame: XRFrame): void;
  46122. private _attachController;
  46123. private _attachScreenRayMode;
  46124. private _attachGazeMode;
  46125. private _tmpVectorForPickCompare;
  46126. private _pickingMoved;
  46127. private _attachTrackedPointerRayMode;
  46128. private _detachController;
  46129. private _generateNewMeshPair;
  46130. private _convertNormalToDirectionOfRay;
  46131. private _updatePointerDistance;
  46132. }
  46133. }
  46134. declare module "babylonjs/XR/webXREnterExitUI" {
  46135. import { Nullable } from "babylonjs/types";
  46136. import { Observable } from "babylonjs/Misc/observable";
  46137. import { IDisposable, Scene } from "babylonjs/scene";
  46138. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  46139. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  46140. /**
  46141. * Button which can be used to enter a different mode of XR
  46142. */
  46143. export class WebXREnterExitUIButton {
  46144. /** button element */
  46145. element: HTMLElement;
  46146. /** XR initialization options for the button */
  46147. sessionMode: XRSessionMode;
  46148. /** Reference space type */
  46149. referenceSpaceType: XRReferenceSpaceType;
  46150. /**
  46151. * Creates a WebXREnterExitUIButton
  46152. * @param element button element
  46153. * @param sessionMode XR initialization session mode
  46154. * @param referenceSpaceType the type of reference space to be used
  46155. */
  46156. constructor(
  46157. /** button element */
  46158. element: HTMLElement,
  46159. /** XR initialization options for the button */
  46160. sessionMode: XRSessionMode,
  46161. /** Reference space type */
  46162. referenceSpaceType: XRReferenceSpaceType);
  46163. /**
  46164. * Overwritable function which can be used to update the button's visuals when the state changes
  46165. * @param activeButton the current active button in the UI
  46166. */
  46167. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  46168. }
  46169. /**
  46170. * Options to create the webXR UI
  46171. */
  46172. export class WebXREnterExitUIOptions {
  46173. /**
  46174. * Context to enter xr with
  46175. */
  46176. renderTarget?: Nullable<WebXRRenderTarget>;
  46177. /**
  46178. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  46179. */
  46180. customButtons?: Array<WebXREnterExitUIButton>;
  46181. /**
  46182. * A session mode to use when creating the default button.
  46183. * Default is immersive-vr
  46184. */
  46185. sessionMode?: XRSessionMode;
  46186. /**
  46187. * A reference space type to use when creating the default button.
  46188. * Default is local-floor
  46189. */
  46190. referenceSpaceType?: XRReferenceSpaceType;
  46191. }
  46192. /**
  46193. * UI to allow the user to enter/exit XR mode
  46194. */
  46195. export class WebXREnterExitUI implements IDisposable {
  46196. private scene;
  46197. /** version of the options passed to this UI */
  46198. options: WebXREnterExitUIOptions;
  46199. private _overlay;
  46200. private _buttons;
  46201. private _activeButton;
  46202. /**
  46203. * Fired every time the active button is changed.
  46204. *
  46205. * When xr is entered via a button that launches xr that button will be the callback parameter
  46206. *
  46207. * When exiting xr the callback parameter will be null)
  46208. */
  46209. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  46210. /**
  46211. * Creates UI to allow the user to enter/exit XR mode
  46212. * @param scene the scene to add the ui to
  46213. * @param helper the xr experience helper to enter/exit xr with
  46214. * @param options options to configure the UI
  46215. * @returns the created ui
  46216. */
  46217. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  46218. /**
  46219. *
  46220. * @param scene babylon scene object to use
  46221. * @param options (read-only) version of the options passed to this UI
  46222. */
  46223. private constructor();
  46224. private _updateButtons;
  46225. /**
  46226. * Disposes of the object
  46227. */
  46228. dispose(): void;
  46229. }
  46230. }
  46231. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  46232. import { Vector3 } from "babylonjs/Maths/math.vector";
  46233. import { Color4 } from "babylonjs/Maths/math.color";
  46234. import { Nullable } from "babylonjs/types";
  46235. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  46236. import { Scene } from "babylonjs/scene";
  46237. /**
  46238. * Class containing static functions to help procedurally build meshes
  46239. */
  46240. export class LinesBuilder {
  46241. /**
  46242. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  46243. * * 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
  46244. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  46245. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  46246. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  46247. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  46248. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46249. * * 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
  46250. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  46251. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46252. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  46253. * @param name defines the name of the new line system
  46254. * @param options defines the options used to create the line system
  46255. * @param scene defines the hosting scene
  46256. * @returns a new line system mesh
  46257. */
  46258. static CreateLineSystem(name: string, options: {
  46259. lines: Vector3[][];
  46260. updatable?: boolean;
  46261. instance?: Nullable<LinesMesh>;
  46262. colors?: Nullable<Color4[][]>;
  46263. useVertexAlpha?: boolean;
  46264. }, scene: Nullable<Scene>): LinesMesh;
  46265. /**
  46266. * Creates a line mesh
  46267. * 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
  46268. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46269. * * The parameter `points` is an array successive Vector3
  46270. * * 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
  46271. * * The optional parameter `colors` is an array of successive Color4, one per line point
  46272. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  46273. * * When updating an instance, remember that only point positions can change, not the number of points
  46274. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46275. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  46276. * @param name defines the name of the new line system
  46277. * @param options defines the options used to create the line system
  46278. * @param scene defines the hosting scene
  46279. * @returns a new line mesh
  46280. */
  46281. static CreateLines(name: string, options: {
  46282. points: Vector3[];
  46283. updatable?: boolean;
  46284. instance?: Nullable<LinesMesh>;
  46285. colors?: Color4[];
  46286. useVertexAlpha?: boolean;
  46287. }, scene?: Nullable<Scene>): LinesMesh;
  46288. /**
  46289. * Creates a dashed line mesh
  46290. * * 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
  46291. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46292. * * The parameter `points` is an array successive Vector3
  46293. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  46294. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  46295. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  46296. * * 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
  46297. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46298. * * When updating an instance, remember that only point positions can change, not the number of points
  46299. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46300. * @param name defines the name of the mesh
  46301. * @param options defines the options used to create the mesh
  46302. * @param scene defines the hosting scene
  46303. * @returns the dashed line mesh
  46304. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  46305. */
  46306. static CreateDashedLines(name: string, options: {
  46307. points: Vector3[];
  46308. dashSize?: number;
  46309. gapSize?: number;
  46310. dashNb?: number;
  46311. updatable?: boolean;
  46312. instance?: LinesMesh;
  46313. useVertexAlpha?: boolean;
  46314. }, scene?: Nullable<Scene>): LinesMesh;
  46315. }
  46316. }
  46317. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  46318. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  46319. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46320. import { WebXRInput } from "babylonjs/XR/webXRInput";
  46321. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46322. import { Material } from "babylonjs/Materials/material";
  46323. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  46324. import { Scene } from "babylonjs/scene";
  46325. /**
  46326. * The options container for the teleportation module
  46327. */
  46328. export interface IWebXRTeleportationOptions {
  46329. /**
  46330. * Babylon XR Input class for controller
  46331. */
  46332. xrInput: WebXRInput;
  46333. /**
  46334. * A list of meshes to use as floor meshes.
  46335. * Meshes can be added and removed after initializing the feature using the
  46336. * addFloorMesh and removeFloorMesh functions
  46337. * If empty, rotation will still work
  46338. */
  46339. floorMeshes?: AbstractMesh[];
  46340. /**
  46341. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  46342. * If you want to support rotation, make sure your mesh has a direction indicator.
  46343. *
  46344. * When left untouched, the default mesh will be initialized.
  46345. */
  46346. teleportationTargetMesh?: AbstractMesh;
  46347. /**
  46348. * Values to configure the default target mesh
  46349. */
  46350. defaultTargetMeshOptions?: {
  46351. /**
  46352. * Fill color of the teleportation area
  46353. */
  46354. teleportationFillColor?: string;
  46355. /**
  46356. * Border color for the teleportation area
  46357. */
  46358. teleportationBorderColor?: string;
  46359. /**
  46360. * Disable the mesh's animation sequence
  46361. */
  46362. disableAnimation?: boolean;
  46363. /**
  46364. * Disable lighting on the material or the ring and arrow
  46365. */
  46366. disableLighting?: boolean;
  46367. /**
  46368. * Override the default material of the torus and arrow
  46369. */
  46370. torusArrowMaterial?: Material;
  46371. };
  46372. /**
  46373. * Disable using the thumbstick and use the main component (usuallly trigger) on long press.
  46374. * This will be automatically true if the controller doesnt have a thumbstick or touchpad.
  46375. */
  46376. useMainComponentOnly?: boolean;
  46377. /**
  46378. * If main component is used (no thumbstick), how long should the "long press" take before teleporting
  46379. */
  46380. timeToTeleport?: number;
  46381. /**
  46382. * Should meshes created here be added to a utility layer or the main scene
  46383. */
  46384. useUtilityLayer?: boolean;
  46385. /**
  46386. * if provided, this scene will be used to render meshes.
  46387. */
  46388. customUtilityLayerScene?: Scene;
  46389. }
  46390. /**
  46391. * This is a teleportation feature to be used with webxr-enabled motion controllers.
  46392. * When enabled and attached, the feature will allow a user to move aroundand rotate in the scene using
  46393. * the input of the attached controllers.
  46394. */
  46395. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  46396. private _options;
  46397. /**
  46398. * The module's name
  46399. */
  46400. static readonly Name: string;
  46401. /**
  46402. * The (Babylon) version of this module.
  46403. * This is an integer representing the implementation version.
  46404. * This number does not correspond to the webxr specs version
  46405. */
  46406. static readonly Version: number;
  46407. /**
  46408. * Is rotation enabled when moving forward?
  46409. * Disabling this feature will prevent the user from deciding the direction when teleporting
  46410. */
  46411. rotationEnabled: boolean;
  46412. /**
  46413. * Should the module support parabolic ray on top of direct ray
  46414. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  46415. * Very helpful when moving between floors / different heights
  46416. */
  46417. parabolicRayEnabled: boolean;
  46418. /**
  46419. * The distance from the user to the inspection point in the direction of the controller
  46420. * A higher number will allow the user to move further
  46421. * defaults to 5 (meters, in xr units)
  46422. */
  46423. parabolicCheckRadius: number;
  46424. /**
  46425. * How much rotation should be applied when rotating right and left
  46426. */
  46427. rotationAngle: number;
  46428. /**
  46429. * Is movement backwards enabled
  46430. */
  46431. backwardsMovementEnabled: boolean;
  46432. /**
  46433. * Distance to travel when moving backwards
  46434. */
  46435. backwardsTeleportationDistance: number;
  46436. /**
  46437. * Add a new mesh to the floor meshes array
  46438. * @param mesh the mesh to use as floor mesh
  46439. */
  46440. addFloorMesh(mesh: AbstractMesh): void;
  46441. /**
  46442. * Remove a mesh from the floor meshes array
  46443. * @param mesh the mesh to remove
  46444. */
  46445. removeFloorMesh(mesh: AbstractMesh): void;
  46446. /**
  46447. * Remove a mesh from the floor meshes array using its name
  46448. * @param name the mesh name to remove
  46449. */
  46450. removeFloorMeshByName(name: string): void;
  46451. private _tmpRay;
  46452. private _tmpVector;
  46453. private _floorMeshes;
  46454. private _controllers;
  46455. /**
  46456. * constructs a new anchor system
  46457. * @param _xrSessionManager an instance of WebXRSessionManager
  46458. * @param _options configuration object for this feature
  46459. */
  46460. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  46461. private _selectionFeature;
  46462. /**
  46463. * This function sets a selection feature that will be disabled when
  46464. * the forward ray is shown and will be reattached when hidden.
  46465. * This is used to remove the selection rays when moving.
  46466. * @param selectionFeature the feature to disable when forward movement is enabled
  46467. */
  46468. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  46469. attach(): boolean;
  46470. detach(): boolean;
  46471. dispose(): void;
  46472. protected _onXRFrame(_xrFrame: XRFrame): void;
  46473. private _currentTeleportationControllerId;
  46474. private _attachController;
  46475. private _teleportForward;
  46476. private _detachController;
  46477. private createDefaultTargetMesh;
  46478. private setTargetMeshVisibility;
  46479. private setTargetMeshPosition;
  46480. private _quadraticBezierCurve;
  46481. private _showParabolicPath;
  46482. }
  46483. }
  46484. declare module "babylonjs/XR/webXRDefaultExperience" {
  46485. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  46486. import { Scene } from "babylonjs/scene";
  46487. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  46488. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  46489. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  46490. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  46491. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46492. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  46493. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  46494. /**
  46495. * Options for the default xr helper
  46496. */
  46497. export class WebXRDefaultExperienceOptions {
  46498. /**
  46499. * Floor meshes that will be used for teleporting
  46500. */
  46501. floorMeshes?: Array<AbstractMesh>;
  46502. /**
  46503. * Enable or disable default UI to enter XR
  46504. */
  46505. disableDefaultUI?: boolean;
  46506. /**
  46507. * optional configuration for the output canvas
  46508. */
  46509. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  46510. /**
  46511. * optional UI options. This can be used among other to change session mode and reference space type
  46512. */
  46513. uiOptions?: WebXREnterExitUIOptions;
  46514. /**
  46515. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  46516. */
  46517. inputOptions?: IWebXRInputOptions;
  46518. /**
  46519. * Should teleportation not initialize. defaults to false.
  46520. */
  46521. disableTeleportation?: boolean;
  46522. /**
  46523. * If set to true, the first frame will not be used to reset position
  46524. * The first frame is mainly used when copying transformation from the old camera
  46525. * Mainly used in AR
  46526. */
  46527. ignoreNativeCameraTransformation?: boolean;
  46528. /**
  46529. * When loading teleportation and pointer select, use stable versions instead of latest.
  46530. */
  46531. useStablePlugins?: boolean;
  46532. }
  46533. /**
  46534. * Default experience which provides a similar setup to the previous webVRExperience
  46535. */
  46536. export class WebXRDefaultExperience {
  46537. /**
  46538. * Base experience
  46539. */
  46540. baseExperience: WebXRExperienceHelper;
  46541. /**
  46542. * Input experience extension
  46543. */
  46544. input: WebXRInput;
  46545. /**
  46546. * Enables laser pointer and selection
  46547. */
  46548. pointerSelection: WebXRControllerPointerSelection;
  46549. /**
  46550. * Enables teleportation
  46551. */
  46552. teleportation: WebXRMotionControllerTeleportation;
  46553. /**
  46554. * Enables ui for entering/exiting xr
  46555. */
  46556. enterExitUI: WebXREnterExitUI;
  46557. /**
  46558. * Default target xr should render to
  46559. */
  46560. renderTarget: WebXRRenderTarget;
  46561. /**
  46562. * Creates the default xr experience
  46563. * @param scene scene
  46564. * @param options options for basic configuration
  46565. * @returns resulting WebXRDefaultExperience
  46566. */
  46567. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  46568. private constructor();
  46569. /**
  46570. * DIsposes of the experience helper
  46571. */
  46572. dispose(): void;
  46573. }
  46574. }
  46575. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  46576. import { Observable } from "babylonjs/Misc/observable";
  46577. import { Nullable } from "babylonjs/types";
  46578. import { Camera } from "babylonjs/Cameras/camera";
  46579. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  46580. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  46581. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  46582. import { Scene } from "babylonjs/scene";
  46583. import { Vector3 } from "babylonjs/Maths/math.vector";
  46584. import { Color3 } from "babylonjs/Maths/math.color";
  46585. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46586. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46587. import { Mesh } from "babylonjs/Meshes/mesh";
  46588. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  46589. import { EasingFunction } from "babylonjs/Animations/easing";
  46590. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  46591. import "babylonjs/Meshes/Builders/groundBuilder";
  46592. import "babylonjs/Meshes/Builders/torusBuilder";
  46593. import "babylonjs/Meshes/Builders/cylinderBuilder";
  46594. import "babylonjs/Gamepads/gamepadSceneComponent";
  46595. import "babylonjs/Animations/animatable";
  46596. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  46597. /**
  46598. * Options to modify the vr teleportation behavior.
  46599. */
  46600. export interface VRTeleportationOptions {
  46601. /**
  46602. * The name of the mesh which should be used as the teleportation floor. (default: null)
  46603. */
  46604. floorMeshName?: string;
  46605. /**
  46606. * A list of meshes to be used as the teleportation floor. (default: empty)
  46607. */
  46608. floorMeshes?: Mesh[];
  46609. /**
  46610. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  46611. */
  46612. teleportationMode?: number;
  46613. /**
  46614. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  46615. */
  46616. teleportationTime?: number;
  46617. /**
  46618. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  46619. */
  46620. teleportationSpeed?: number;
  46621. /**
  46622. * The easing function used in the animation or null for Linear. (default CircleEase)
  46623. */
  46624. easingFunction?: EasingFunction;
  46625. }
  46626. /**
  46627. * Options to modify the vr experience helper's behavior.
  46628. */
  46629. export interface VRExperienceHelperOptions extends WebVROptions {
  46630. /**
  46631. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  46632. */
  46633. createDeviceOrientationCamera?: boolean;
  46634. /**
  46635. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  46636. */
  46637. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  46638. /**
  46639. * Uses the main button on the controller to toggle the laser casted. (default: true)
  46640. */
  46641. laserToggle?: boolean;
  46642. /**
  46643. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  46644. */
  46645. floorMeshes?: Mesh[];
  46646. /**
  46647. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  46648. */
  46649. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  46650. /**
  46651. * Defines if WebXR should be used instead of WebVR (if available)
  46652. */
  46653. useXR?: boolean;
  46654. }
  46655. /**
  46656. * Event containing information after VR has been entered
  46657. */
  46658. export class OnAfterEnteringVRObservableEvent {
  46659. /**
  46660. * If entering vr was successful
  46661. */
  46662. success: boolean;
  46663. }
  46664. /**
  46665. * Helps to quickly add VR support to an existing scene.
  46666. * See http://doc.babylonjs.com/how_to/webvr_helper
  46667. */
  46668. export class VRExperienceHelper {
  46669. /** Options to modify the vr experience helper's behavior. */
  46670. webVROptions: VRExperienceHelperOptions;
  46671. private _scene;
  46672. private _position;
  46673. private _btnVR;
  46674. private _btnVRDisplayed;
  46675. private _webVRsupported;
  46676. private _webVRready;
  46677. private _webVRrequesting;
  46678. private _webVRpresenting;
  46679. private _hasEnteredVR;
  46680. private _fullscreenVRpresenting;
  46681. private _inputElement;
  46682. private _webVRCamera;
  46683. private _vrDeviceOrientationCamera;
  46684. private _deviceOrientationCamera;
  46685. private _existingCamera;
  46686. private _onKeyDown;
  46687. private _onVrDisplayPresentChange;
  46688. private _onVRDisplayChanged;
  46689. private _onVRRequestPresentStart;
  46690. private _onVRRequestPresentComplete;
  46691. /**
  46692. * 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)
  46693. */
  46694. enableGazeEvenWhenNoPointerLock: boolean;
  46695. /**
  46696. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  46697. */
  46698. exitVROnDoubleTap: boolean;
  46699. /**
  46700. * Observable raised right before entering VR.
  46701. */
  46702. onEnteringVRObservable: Observable<VRExperienceHelper>;
  46703. /**
  46704. * Observable raised when entering VR has completed.
  46705. */
  46706. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  46707. /**
  46708. * Observable raised when exiting VR.
  46709. */
  46710. onExitingVRObservable: Observable<VRExperienceHelper>;
  46711. /**
  46712. * Observable raised when controller mesh is loaded.
  46713. */
  46714. onControllerMeshLoadedObservable: Observable<WebVRController>;
  46715. /** Return this.onEnteringVRObservable
  46716. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  46717. */
  46718. get onEnteringVR(): Observable<VRExperienceHelper>;
  46719. /** Return this.onExitingVRObservable
  46720. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  46721. */
  46722. get onExitingVR(): Observable<VRExperienceHelper>;
  46723. /** Return this.onControllerMeshLoadedObservable
  46724. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  46725. */
  46726. get onControllerMeshLoaded(): Observable<WebVRController>;
  46727. private _rayLength;
  46728. private _useCustomVRButton;
  46729. private _teleportationRequested;
  46730. private _teleportActive;
  46731. private _floorMeshName;
  46732. private _floorMeshesCollection;
  46733. private _teleportationMode;
  46734. private _teleportationTime;
  46735. private _teleportationSpeed;
  46736. private _teleportationEasing;
  46737. private _rotationAllowed;
  46738. private _teleportBackwardsVector;
  46739. private _teleportationTarget;
  46740. private _isDefaultTeleportationTarget;
  46741. private _postProcessMove;
  46742. private _teleportationFillColor;
  46743. private _teleportationBorderColor;
  46744. private _rotationAngle;
  46745. private _haloCenter;
  46746. private _cameraGazer;
  46747. private _padSensibilityUp;
  46748. private _padSensibilityDown;
  46749. private _leftController;
  46750. private _rightController;
  46751. private _gazeColor;
  46752. private _laserColor;
  46753. private _pickedLaserColor;
  46754. private _pickedGazeColor;
  46755. /**
  46756. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  46757. */
  46758. onNewMeshSelected: Observable<AbstractMesh>;
  46759. /**
  46760. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  46761. * This observable will provide the mesh and the controller used to select the mesh
  46762. */
  46763. onMeshSelectedWithController: Observable<{
  46764. mesh: AbstractMesh;
  46765. controller: WebVRController;
  46766. }>;
  46767. /**
  46768. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  46769. */
  46770. onNewMeshPicked: Observable<PickingInfo>;
  46771. private _circleEase;
  46772. /**
  46773. * Observable raised before camera teleportation
  46774. */
  46775. onBeforeCameraTeleport: Observable<Vector3>;
  46776. /**
  46777. * Observable raised after camera teleportation
  46778. */
  46779. onAfterCameraTeleport: Observable<Vector3>;
  46780. /**
  46781. * Observable raised when current selected mesh gets unselected
  46782. */
  46783. onSelectedMeshUnselected: Observable<AbstractMesh>;
  46784. private _raySelectionPredicate;
  46785. /**
  46786. * To be optionaly changed by user to define custom ray selection
  46787. */
  46788. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  46789. /**
  46790. * To be optionaly changed by user to define custom selection logic (after ray selection)
  46791. */
  46792. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  46793. /**
  46794. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  46795. */
  46796. teleportationEnabled: boolean;
  46797. private _defaultHeight;
  46798. private _teleportationInitialized;
  46799. private _interactionsEnabled;
  46800. private _interactionsRequested;
  46801. private _displayGaze;
  46802. private _displayLaserPointer;
  46803. /**
  46804. * The mesh used to display where the user is going to teleport.
  46805. */
  46806. get teleportationTarget(): Mesh;
  46807. /**
  46808. * Sets the mesh to be used to display where the user is going to teleport.
  46809. */
  46810. set teleportationTarget(value: Mesh);
  46811. /**
  46812. * 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
  46813. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  46814. * See http://doc.babylonjs.com/resources/baking_transformations
  46815. */
  46816. get gazeTrackerMesh(): Mesh;
  46817. set gazeTrackerMesh(value: Mesh);
  46818. /**
  46819. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  46820. */
  46821. updateGazeTrackerScale: boolean;
  46822. /**
  46823. * If the gaze trackers color should be updated when selecting meshes
  46824. */
  46825. updateGazeTrackerColor: boolean;
  46826. /**
  46827. * If the controller laser color should be updated when selecting meshes
  46828. */
  46829. updateControllerLaserColor: boolean;
  46830. /**
  46831. * The gaze tracking mesh corresponding to the left controller
  46832. */
  46833. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  46834. /**
  46835. * The gaze tracking mesh corresponding to the right controller
  46836. */
  46837. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  46838. /**
  46839. * If the ray of the gaze should be displayed.
  46840. */
  46841. get displayGaze(): boolean;
  46842. /**
  46843. * Sets if the ray of the gaze should be displayed.
  46844. */
  46845. set displayGaze(value: boolean);
  46846. /**
  46847. * If the ray of the LaserPointer should be displayed.
  46848. */
  46849. get displayLaserPointer(): boolean;
  46850. /**
  46851. * Sets if the ray of the LaserPointer should be displayed.
  46852. */
  46853. set displayLaserPointer(value: boolean);
  46854. /**
  46855. * The deviceOrientationCamera used as the camera when not in VR.
  46856. */
  46857. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  46858. /**
  46859. * Based on the current WebVR support, returns the current VR camera used.
  46860. */
  46861. get currentVRCamera(): Nullable<Camera>;
  46862. /**
  46863. * The webVRCamera which is used when in VR.
  46864. */
  46865. get webVRCamera(): WebVRFreeCamera;
  46866. /**
  46867. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  46868. */
  46869. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  46870. /**
  46871. * The html button that is used to trigger entering into VR.
  46872. */
  46873. get vrButton(): Nullable<HTMLButtonElement>;
  46874. private get _teleportationRequestInitiated();
  46875. /**
  46876. * Defines whether or not Pointer lock should be requested when switching to
  46877. * full screen.
  46878. */
  46879. requestPointerLockOnFullScreen: boolean;
  46880. /**
  46881. * If asking to force XR, this will be populated with the default xr experience
  46882. */
  46883. xr: WebXRDefaultExperience;
  46884. /**
  46885. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  46886. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  46887. */
  46888. xrTestDone: boolean;
  46889. /**
  46890. * Instantiates a VRExperienceHelper.
  46891. * Helps to quickly add VR support to an existing scene.
  46892. * @param scene The scene the VRExperienceHelper belongs to.
  46893. * @param webVROptions Options to modify the vr experience helper's behavior.
  46894. */
  46895. constructor(scene: Scene,
  46896. /** Options to modify the vr experience helper's behavior. */
  46897. webVROptions?: VRExperienceHelperOptions);
  46898. private completeVRInit;
  46899. private _onDefaultMeshLoaded;
  46900. private _onResize;
  46901. private _onFullscreenChange;
  46902. /**
  46903. * Gets a value indicating if we are currently in VR mode.
  46904. */
  46905. get isInVRMode(): boolean;
  46906. private onVrDisplayPresentChange;
  46907. private onVRDisplayChanged;
  46908. private moveButtonToBottomRight;
  46909. private displayVRButton;
  46910. private updateButtonVisibility;
  46911. private _cachedAngularSensibility;
  46912. /**
  46913. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  46914. * Otherwise, will use the fullscreen API.
  46915. */
  46916. enterVR(): void;
  46917. /**
  46918. * Attempt to exit VR, or fullscreen.
  46919. */
  46920. exitVR(): void;
  46921. /**
  46922. * The position of the vr experience helper.
  46923. */
  46924. get position(): Vector3;
  46925. /**
  46926. * Sets the position of the vr experience helper.
  46927. */
  46928. set position(value: Vector3);
  46929. /**
  46930. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  46931. */
  46932. enableInteractions(): void;
  46933. private get _noControllerIsActive();
  46934. private beforeRender;
  46935. private _isTeleportationFloor;
  46936. /**
  46937. * Adds a floor mesh to be used for teleportation.
  46938. * @param floorMesh the mesh to be used for teleportation.
  46939. */
  46940. addFloorMesh(floorMesh: Mesh): void;
  46941. /**
  46942. * Removes a floor mesh from being used for teleportation.
  46943. * @param floorMesh the mesh to be removed.
  46944. */
  46945. removeFloorMesh(floorMesh: Mesh): void;
  46946. /**
  46947. * Enables interactions and teleportation using the VR controllers and gaze.
  46948. * @param vrTeleportationOptions options to modify teleportation behavior.
  46949. */
  46950. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  46951. private _onNewGamepadConnected;
  46952. private _tryEnableInteractionOnController;
  46953. private _onNewGamepadDisconnected;
  46954. private _enableInteractionOnController;
  46955. private _checkTeleportWithRay;
  46956. private _checkRotate;
  46957. private _checkTeleportBackwards;
  46958. private _enableTeleportationOnController;
  46959. private _createTeleportationCircles;
  46960. private _displayTeleportationTarget;
  46961. private _hideTeleportationTarget;
  46962. private _rotateCamera;
  46963. private _moveTeleportationSelectorTo;
  46964. private _workingVector;
  46965. private _workingQuaternion;
  46966. private _workingMatrix;
  46967. /**
  46968. * Time Constant Teleportation Mode
  46969. */
  46970. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  46971. /**
  46972. * Speed Constant Teleportation Mode
  46973. */
  46974. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  46975. /**
  46976. * Teleports the users feet to the desired location
  46977. * @param location The location where the user's feet should be placed
  46978. */
  46979. teleportCamera(location: Vector3): void;
  46980. private _convertNormalToDirectionOfRay;
  46981. private _castRayAndSelectObject;
  46982. private _notifySelectedMeshUnselected;
  46983. /**
  46984. * Permanently set new colors for the laser pointer
  46985. * @param color the new laser color
  46986. * @param pickedColor the new laser color when picked mesh detected
  46987. */
  46988. setLaserColor(color: Color3, pickedColor?: Color3): void;
  46989. /**
  46990. * Set lighting enabled / disabled on the laser pointer of both controllers
  46991. * @param enabled should the lighting be enabled on the laser pointer
  46992. */
  46993. setLaserLightingState(enabled?: boolean): void;
  46994. /**
  46995. * Permanently set new colors for the gaze pointer
  46996. * @param color the new gaze color
  46997. * @param pickedColor the new gaze color when picked mesh detected
  46998. */
  46999. setGazeColor(color: Color3, pickedColor?: Color3): void;
  47000. /**
  47001. * Sets the color of the laser ray from the vr controllers.
  47002. * @param color new color for the ray.
  47003. */
  47004. changeLaserColor(color: Color3): void;
  47005. /**
  47006. * Sets the color of the ray from the vr headsets gaze.
  47007. * @param color new color for the ray.
  47008. */
  47009. changeGazeColor(color: Color3): void;
  47010. /**
  47011. * Exits VR and disposes of the vr experience helper
  47012. */
  47013. dispose(): void;
  47014. /**
  47015. * Gets the name of the VRExperienceHelper class
  47016. * @returns "VRExperienceHelper"
  47017. */
  47018. getClassName(): string;
  47019. }
  47020. }
  47021. declare module "babylonjs/Cameras/VR/index" {
  47022. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  47023. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  47024. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  47025. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  47026. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  47027. export * from "babylonjs/Cameras/VR/webVRCamera";
  47028. }
  47029. declare module "babylonjs/Cameras/RigModes/index" {
  47030. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47031. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47032. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  47033. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  47034. }
  47035. declare module "babylonjs/Cameras/index" {
  47036. export * from "babylonjs/Cameras/Inputs/index";
  47037. export * from "babylonjs/Cameras/cameraInputsManager";
  47038. export * from "babylonjs/Cameras/camera";
  47039. export * from "babylonjs/Cameras/targetCamera";
  47040. export * from "babylonjs/Cameras/freeCamera";
  47041. export * from "babylonjs/Cameras/freeCameraInputsManager";
  47042. export * from "babylonjs/Cameras/touchCamera";
  47043. export * from "babylonjs/Cameras/arcRotateCamera";
  47044. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  47045. export * from "babylonjs/Cameras/deviceOrientationCamera";
  47046. export * from "babylonjs/Cameras/flyCamera";
  47047. export * from "babylonjs/Cameras/flyCameraInputsManager";
  47048. export * from "babylonjs/Cameras/followCamera";
  47049. export * from "babylonjs/Cameras/followCameraInputsManager";
  47050. export * from "babylonjs/Cameras/gamepadCamera";
  47051. export * from "babylonjs/Cameras/Stereoscopic/index";
  47052. export * from "babylonjs/Cameras/universalCamera";
  47053. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  47054. export * from "babylonjs/Cameras/VR/index";
  47055. export * from "babylonjs/Cameras/RigModes/index";
  47056. }
  47057. declare module "babylonjs/Collisions/index" {
  47058. export * from "babylonjs/Collisions/collider";
  47059. export * from "babylonjs/Collisions/collisionCoordinator";
  47060. export * from "babylonjs/Collisions/pickingInfo";
  47061. export * from "babylonjs/Collisions/intersectionInfo";
  47062. export * from "babylonjs/Collisions/meshCollisionData";
  47063. }
  47064. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  47065. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  47066. import { Vector3 } from "babylonjs/Maths/math.vector";
  47067. import { Ray } from "babylonjs/Culling/ray";
  47068. import { Plane } from "babylonjs/Maths/math.plane";
  47069. /**
  47070. * Contains an array of blocks representing the octree
  47071. */
  47072. export interface IOctreeContainer<T> {
  47073. /**
  47074. * Blocks within the octree
  47075. */
  47076. blocks: Array<OctreeBlock<T>>;
  47077. }
  47078. /**
  47079. * Class used to store a cell in an octree
  47080. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47081. */
  47082. export class OctreeBlock<T> {
  47083. /**
  47084. * Gets the content of the current block
  47085. */
  47086. entries: T[];
  47087. /**
  47088. * Gets the list of block children
  47089. */
  47090. blocks: Array<OctreeBlock<T>>;
  47091. private _depth;
  47092. private _maxDepth;
  47093. private _capacity;
  47094. private _minPoint;
  47095. private _maxPoint;
  47096. private _boundingVectors;
  47097. private _creationFunc;
  47098. /**
  47099. * Creates a new block
  47100. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  47101. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  47102. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47103. * @param depth defines the current depth of this block in the octree
  47104. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  47105. * @param creationFunc defines a callback to call when an element is added to the block
  47106. */
  47107. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  47108. /**
  47109. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47110. */
  47111. get capacity(): number;
  47112. /**
  47113. * Gets the minimum vector (in world space) of the block's bounding box
  47114. */
  47115. get minPoint(): Vector3;
  47116. /**
  47117. * Gets the maximum vector (in world space) of the block's bounding box
  47118. */
  47119. get maxPoint(): Vector3;
  47120. /**
  47121. * Add a new element to this block
  47122. * @param entry defines the element to add
  47123. */
  47124. addEntry(entry: T): void;
  47125. /**
  47126. * Remove an element from this block
  47127. * @param entry defines the element to remove
  47128. */
  47129. removeEntry(entry: T): void;
  47130. /**
  47131. * Add an array of elements to this block
  47132. * @param entries defines the array of elements to add
  47133. */
  47134. addEntries(entries: T[]): void;
  47135. /**
  47136. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  47137. * @param frustumPlanes defines the frustum planes to test
  47138. * @param selection defines the array to store current content if selection is positive
  47139. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47140. */
  47141. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47142. /**
  47143. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  47144. * @param sphereCenter defines the bounding sphere center
  47145. * @param sphereRadius defines the bounding sphere radius
  47146. * @param selection defines the array to store current content if selection is positive
  47147. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47148. */
  47149. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47150. /**
  47151. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  47152. * @param ray defines the ray to test with
  47153. * @param selection defines the array to store current content if selection is positive
  47154. */
  47155. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  47156. /**
  47157. * Subdivide the content into child blocks (this block will then be empty)
  47158. */
  47159. createInnerBlocks(): void;
  47160. /**
  47161. * @hidden
  47162. */
  47163. 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;
  47164. }
  47165. }
  47166. declare module "babylonjs/Culling/Octrees/octree" {
  47167. import { SmartArray } from "babylonjs/Misc/smartArray";
  47168. import { Vector3 } from "babylonjs/Maths/math.vector";
  47169. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47170. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47171. import { Ray } from "babylonjs/Culling/ray";
  47172. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  47173. import { Plane } from "babylonjs/Maths/math.plane";
  47174. /**
  47175. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  47176. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47177. */
  47178. export class Octree<T> {
  47179. /** 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.) */
  47180. maxDepth: number;
  47181. /**
  47182. * Blocks within the octree containing objects
  47183. */
  47184. blocks: Array<OctreeBlock<T>>;
  47185. /**
  47186. * Content stored in the octree
  47187. */
  47188. dynamicContent: T[];
  47189. private _maxBlockCapacity;
  47190. private _selectionContent;
  47191. private _creationFunc;
  47192. /**
  47193. * Creates a octree
  47194. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47195. * @param creationFunc function to be used to instatiate the octree
  47196. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  47197. * @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.)
  47198. */
  47199. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  47200. /** 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.) */
  47201. maxDepth?: number);
  47202. /**
  47203. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  47204. * @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);
  47205. * @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);
  47206. * @param entries meshes to be added to the octree blocks
  47207. */
  47208. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  47209. /**
  47210. * Adds a mesh to the octree
  47211. * @param entry Mesh to add to the octree
  47212. */
  47213. addMesh(entry: T): void;
  47214. /**
  47215. * Remove an element from the octree
  47216. * @param entry defines the element to remove
  47217. */
  47218. removeMesh(entry: T): void;
  47219. /**
  47220. * Selects an array of meshes within the frustum
  47221. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  47222. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  47223. * @returns array of meshes within the frustum
  47224. */
  47225. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  47226. /**
  47227. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  47228. * @param sphereCenter defines the bounding sphere center
  47229. * @param sphereRadius defines the bounding sphere radius
  47230. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47231. * @returns an array of objects that intersect the sphere
  47232. */
  47233. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  47234. /**
  47235. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  47236. * @param ray defines the ray to test with
  47237. * @returns array of intersected objects
  47238. */
  47239. intersectsRay(ray: Ray): SmartArray<T>;
  47240. /**
  47241. * Adds a mesh into the octree block if it intersects the block
  47242. */
  47243. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  47244. /**
  47245. * Adds a submesh into the octree block if it intersects the block
  47246. */
  47247. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  47248. }
  47249. }
  47250. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  47251. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  47252. import { Scene } from "babylonjs/scene";
  47253. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47254. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47255. import { Ray } from "babylonjs/Culling/ray";
  47256. import { Octree } from "babylonjs/Culling/Octrees/octree";
  47257. import { Collider } from "babylonjs/Collisions/collider";
  47258. module "babylonjs/scene" {
  47259. interface Scene {
  47260. /**
  47261. * @hidden
  47262. * Backing Filed
  47263. */
  47264. _selectionOctree: Octree<AbstractMesh>;
  47265. /**
  47266. * Gets the octree used to boost mesh selection (picking)
  47267. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47268. */
  47269. selectionOctree: Octree<AbstractMesh>;
  47270. /**
  47271. * Creates or updates the octree used to boost selection (picking)
  47272. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47273. * @param maxCapacity defines the maximum capacity per leaf
  47274. * @param maxDepth defines the maximum depth of the octree
  47275. * @returns an octree of AbstractMesh
  47276. */
  47277. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  47278. }
  47279. }
  47280. module "babylonjs/Meshes/abstractMesh" {
  47281. interface AbstractMesh {
  47282. /**
  47283. * @hidden
  47284. * Backing Field
  47285. */
  47286. _submeshesOctree: Octree<SubMesh>;
  47287. /**
  47288. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  47289. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  47290. * @param maxCapacity defines the maximum size of each block (64 by default)
  47291. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  47292. * @returns the new octree
  47293. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  47294. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47295. */
  47296. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  47297. }
  47298. }
  47299. /**
  47300. * Defines the octree scene component responsible to manage any octrees
  47301. * in a given scene.
  47302. */
  47303. export class OctreeSceneComponent {
  47304. /**
  47305. * The component name help to identify the component in the list of scene components.
  47306. */
  47307. readonly name: string;
  47308. /**
  47309. * The scene the component belongs to.
  47310. */
  47311. scene: Scene;
  47312. /**
  47313. * Indicates if the meshes have been checked to make sure they are isEnabled()
  47314. */
  47315. readonly checksIsEnabled: boolean;
  47316. /**
  47317. * Creates a new instance of the component for the given scene
  47318. * @param scene Defines the scene to register the component in
  47319. */
  47320. constructor(scene: Scene);
  47321. /**
  47322. * Registers the component in a given scene
  47323. */
  47324. register(): void;
  47325. /**
  47326. * Return the list of active meshes
  47327. * @returns the list of active meshes
  47328. */
  47329. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  47330. /**
  47331. * Return the list of active sub meshes
  47332. * @param mesh The mesh to get the candidates sub meshes from
  47333. * @returns the list of active sub meshes
  47334. */
  47335. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  47336. private _tempRay;
  47337. /**
  47338. * Return the list of sub meshes intersecting with a given local ray
  47339. * @param mesh defines the mesh to find the submesh for
  47340. * @param localRay defines the ray in local space
  47341. * @returns the list of intersecting sub meshes
  47342. */
  47343. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  47344. /**
  47345. * Return the list of sub meshes colliding with a collider
  47346. * @param mesh defines the mesh to find the submesh for
  47347. * @param collider defines the collider to evaluate the collision against
  47348. * @returns the list of colliding sub meshes
  47349. */
  47350. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  47351. /**
  47352. * Rebuilds the elements related to this component in case of
  47353. * context lost for instance.
  47354. */
  47355. rebuild(): void;
  47356. /**
  47357. * Disposes the component and the associated ressources.
  47358. */
  47359. dispose(): void;
  47360. }
  47361. }
  47362. declare module "babylonjs/Culling/Octrees/index" {
  47363. export * from "babylonjs/Culling/Octrees/octree";
  47364. export * from "babylonjs/Culling/Octrees/octreeBlock";
  47365. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  47366. }
  47367. declare module "babylonjs/Culling/index" {
  47368. export * from "babylonjs/Culling/boundingBox";
  47369. export * from "babylonjs/Culling/boundingInfo";
  47370. export * from "babylonjs/Culling/boundingSphere";
  47371. export * from "babylonjs/Culling/Octrees/index";
  47372. export * from "babylonjs/Culling/ray";
  47373. }
  47374. declare module "babylonjs/Gizmos/gizmo" {
  47375. import { Nullable } from "babylonjs/types";
  47376. import { IDisposable } from "babylonjs/scene";
  47377. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47378. import { Mesh } from "babylonjs/Meshes/mesh";
  47379. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47380. /**
  47381. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  47382. */
  47383. export class Gizmo implements IDisposable {
  47384. /** The utility layer the gizmo will be added to */
  47385. gizmoLayer: UtilityLayerRenderer;
  47386. /**
  47387. * The root mesh of the gizmo
  47388. */
  47389. _rootMesh: Mesh;
  47390. private _attachedMesh;
  47391. /**
  47392. * Ratio for the scale of the gizmo (Default: 1)
  47393. */
  47394. scaleRatio: number;
  47395. /**
  47396. * If a custom mesh has been set (Default: false)
  47397. */
  47398. protected _customMeshSet: boolean;
  47399. /**
  47400. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  47401. * * When set, interactions will be enabled
  47402. */
  47403. get attachedMesh(): Nullable<AbstractMesh>;
  47404. set attachedMesh(value: Nullable<AbstractMesh>);
  47405. /**
  47406. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  47407. * @param mesh The mesh to replace the default mesh of the gizmo
  47408. */
  47409. setCustomMesh(mesh: Mesh): void;
  47410. /**
  47411. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  47412. */
  47413. updateGizmoRotationToMatchAttachedMesh: boolean;
  47414. /**
  47415. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  47416. */
  47417. updateGizmoPositionToMatchAttachedMesh: boolean;
  47418. /**
  47419. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  47420. */
  47421. updateScale: boolean;
  47422. protected _interactionsEnabled: boolean;
  47423. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47424. private _beforeRenderObserver;
  47425. private _tempVector;
  47426. /**
  47427. * Creates a gizmo
  47428. * @param gizmoLayer The utility layer the gizmo will be added to
  47429. */
  47430. constructor(
  47431. /** The utility layer the gizmo will be added to */
  47432. gizmoLayer?: UtilityLayerRenderer);
  47433. /**
  47434. * Updates the gizmo to match the attached mesh's position/rotation
  47435. */
  47436. protected _update(): void;
  47437. /**
  47438. * Disposes of the gizmo
  47439. */
  47440. dispose(): void;
  47441. }
  47442. }
  47443. declare module "babylonjs/Gizmos/planeDragGizmo" {
  47444. import { Observable } from "babylonjs/Misc/observable";
  47445. import { Nullable } from "babylonjs/types";
  47446. import { Vector3 } from "babylonjs/Maths/math.vector";
  47447. import { Color3 } from "babylonjs/Maths/math.color";
  47448. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47449. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47450. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47451. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47452. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47453. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47454. import { Scene } from "babylonjs/scene";
  47455. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47456. /**
  47457. * Single plane drag gizmo
  47458. */
  47459. export class PlaneDragGizmo extends Gizmo {
  47460. /**
  47461. * Drag behavior responsible for the gizmos dragging interactions
  47462. */
  47463. dragBehavior: PointerDragBehavior;
  47464. private _pointerObserver;
  47465. /**
  47466. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47467. */
  47468. snapDistance: number;
  47469. /**
  47470. * Event that fires each time the gizmo snaps to a new location.
  47471. * * snapDistance is the the change in distance
  47472. */
  47473. onSnapObservable: Observable<{
  47474. snapDistance: number;
  47475. }>;
  47476. private _plane;
  47477. private _coloredMaterial;
  47478. private _hoverMaterial;
  47479. private _isEnabled;
  47480. private _parent;
  47481. /** @hidden */
  47482. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  47483. /** @hidden */
  47484. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  47485. /**
  47486. * Creates a PlaneDragGizmo
  47487. * @param gizmoLayer The utility layer the gizmo will be added to
  47488. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  47489. * @param color The color of the gizmo
  47490. */
  47491. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  47492. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47493. /**
  47494. * If the gizmo is enabled
  47495. */
  47496. set isEnabled(value: boolean);
  47497. get isEnabled(): boolean;
  47498. /**
  47499. * Disposes of the gizmo
  47500. */
  47501. dispose(): void;
  47502. }
  47503. }
  47504. declare module "babylonjs/Gizmos/positionGizmo" {
  47505. import { Observable } from "babylonjs/Misc/observable";
  47506. import { Nullable } from "babylonjs/types";
  47507. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47508. import { Mesh } from "babylonjs/Meshes/mesh";
  47509. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47510. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  47511. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  47512. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47513. /**
  47514. * Gizmo that enables dragging a mesh along 3 axis
  47515. */
  47516. export class PositionGizmo extends Gizmo {
  47517. /**
  47518. * Internal gizmo used for interactions on the x axis
  47519. */
  47520. xGizmo: AxisDragGizmo;
  47521. /**
  47522. * Internal gizmo used for interactions on the y axis
  47523. */
  47524. yGizmo: AxisDragGizmo;
  47525. /**
  47526. * Internal gizmo used for interactions on the z axis
  47527. */
  47528. zGizmo: AxisDragGizmo;
  47529. /**
  47530. * Internal gizmo used for interactions on the yz plane
  47531. */
  47532. xPlaneGizmo: PlaneDragGizmo;
  47533. /**
  47534. * Internal gizmo used for interactions on the xz plane
  47535. */
  47536. yPlaneGizmo: PlaneDragGizmo;
  47537. /**
  47538. * Internal gizmo used for interactions on the xy plane
  47539. */
  47540. zPlaneGizmo: PlaneDragGizmo;
  47541. /**
  47542. * private variables
  47543. */
  47544. private _meshAttached;
  47545. private _updateGizmoRotationToMatchAttachedMesh;
  47546. private _snapDistance;
  47547. private _scaleRatio;
  47548. /** Fires an event when any of it's sub gizmos are dragged */
  47549. onDragStartObservable: Observable<unknown>;
  47550. /** Fires an event when any of it's sub gizmos are released from dragging */
  47551. onDragEndObservable: Observable<unknown>;
  47552. /**
  47553. * If set to true, planar drag is enabled
  47554. */
  47555. private _planarGizmoEnabled;
  47556. get attachedMesh(): Nullable<AbstractMesh>;
  47557. set attachedMesh(mesh: Nullable<AbstractMesh>);
  47558. /**
  47559. * Creates a PositionGizmo
  47560. * @param gizmoLayer The utility layer the gizmo will be added to
  47561. */
  47562. constructor(gizmoLayer?: UtilityLayerRenderer);
  47563. /**
  47564. * If the planar drag gizmo is enabled
  47565. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  47566. */
  47567. set planarGizmoEnabled(value: boolean);
  47568. get planarGizmoEnabled(): boolean;
  47569. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  47570. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  47571. /**
  47572. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47573. */
  47574. set snapDistance(value: number);
  47575. get snapDistance(): number;
  47576. /**
  47577. * Ratio for the scale of the gizmo (Default: 1)
  47578. */
  47579. set scaleRatio(value: number);
  47580. get scaleRatio(): number;
  47581. /**
  47582. * Disposes of the gizmo
  47583. */
  47584. dispose(): void;
  47585. /**
  47586. * CustomMeshes are not supported by this gizmo
  47587. * @param mesh The mesh to replace the default mesh of the gizmo
  47588. */
  47589. setCustomMesh(mesh: Mesh): void;
  47590. }
  47591. }
  47592. declare module "babylonjs/Gizmos/axisDragGizmo" {
  47593. import { Observable } from "babylonjs/Misc/observable";
  47594. import { Nullable } from "babylonjs/types";
  47595. import { Vector3 } from "babylonjs/Maths/math.vector";
  47596. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47597. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47598. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47599. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47600. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47601. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47602. import { Scene } from "babylonjs/scene";
  47603. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47604. import { Color3 } from "babylonjs/Maths/math.color";
  47605. /**
  47606. * Single axis drag gizmo
  47607. */
  47608. export class AxisDragGizmo extends Gizmo {
  47609. /**
  47610. * Drag behavior responsible for the gizmos dragging interactions
  47611. */
  47612. dragBehavior: PointerDragBehavior;
  47613. private _pointerObserver;
  47614. /**
  47615. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47616. */
  47617. snapDistance: number;
  47618. /**
  47619. * Event that fires each time the gizmo snaps to a new location.
  47620. * * snapDistance is the the change in distance
  47621. */
  47622. onSnapObservable: Observable<{
  47623. snapDistance: number;
  47624. }>;
  47625. private _isEnabled;
  47626. private _parent;
  47627. private _arrow;
  47628. private _coloredMaterial;
  47629. private _hoverMaterial;
  47630. /** @hidden */
  47631. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  47632. /** @hidden */
  47633. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  47634. /**
  47635. * Creates an AxisDragGizmo
  47636. * @param gizmoLayer The utility layer the gizmo will be added to
  47637. * @param dragAxis The axis which the gizmo will be able to drag on
  47638. * @param color The color of the gizmo
  47639. */
  47640. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  47641. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47642. /**
  47643. * If the gizmo is enabled
  47644. */
  47645. set isEnabled(value: boolean);
  47646. get isEnabled(): boolean;
  47647. /**
  47648. * Disposes of the gizmo
  47649. */
  47650. dispose(): void;
  47651. }
  47652. }
  47653. declare module "babylonjs/Debug/axesViewer" {
  47654. import { Vector3 } from "babylonjs/Maths/math.vector";
  47655. import { Nullable } from "babylonjs/types";
  47656. import { Scene } from "babylonjs/scene";
  47657. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47658. /**
  47659. * The Axes viewer will show 3 axes in a specific point in space
  47660. */
  47661. export class AxesViewer {
  47662. private _xAxis;
  47663. private _yAxis;
  47664. private _zAxis;
  47665. private _scaleLinesFactor;
  47666. private _instanced;
  47667. /**
  47668. * Gets the hosting scene
  47669. */
  47670. scene: Scene;
  47671. /**
  47672. * Gets or sets a number used to scale line length
  47673. */
  47674. scaleLines: number;
  47675. /** Gets the node hierarchy used to render x-axis */
  47676. get xAxis(): TransformNode;
  47677. /** Gets the node hierarchy used to render y-axis */
  47678. get yAxis(): TransformNode;
  47679. /** Gets the node hierarchy used to render z-axis */
  47680. get zAxis(): TransformNode;
  47681. /**
  47682. * Creates a new AxesViewer
  47683. * @param scene defines the hosting scene
  47684. * @param scaleLines defines a number used to scale line length (1 by default)
  47685. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  47686. * @param xAxis defines the node hierarchy used to render the x-axis
  47687. * @param yAxis defines the node hierarchy used to render the y-axis
  47688. * @param zAxis defines the node hierarchy used to render the z-axis
  47689. */
  47690. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  47691. /**
  47692. * Force the viewer to update
  47693. * @param position defines the position of the viewer
  47694. * @param xaxis defines the x axis of the viewer
  47695. * @param yaxis defines the y axis of the viewer
  47696. * @param zaxis defines the z axis of the viewer
  47697. */
  47698. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  47699. /**
  47700. * Creates an instance of this axes viewer.
  47701. * @returns a new axes viewer with instanced meshes
  47702. */
  47703. createInstance(): AxesViewer;
  47704. /** Releases resources */
  47705. dispose(): void;
  47706. private static _SetRenderingGroupId;
  47707. }
  47708. }
  47709. declare module "babylonjs/Debug/boneAxesViewer" {
  47710. import { Nullable } from "babylonjs/types";
  47711. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  47712. import { Vector3 } from "babylonjs/Maths/math.vector";
  47713. import { Mesh } from "babylonjs/Meshes/mesh";
  47714. import { Bone } from "babylonjs/Bones/bone";
  47715. import { Scene } from "babylonjs/scene";
  47716. /**
  47717. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  47718. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  47719. */
  47720. export class BoneAxesViewer extends AxesViewer {
  47721. /**
  47722. * Gets or sets the target mesh where to display the axes viewer
  47723. */
  47724. mesh: Nullable<Mesh>;
  47725. /**
  47726. * Gets or sets the target bone where to display the axes viewer
  47727. */
  47728. bone: Nullable<Bone>;
  47729. /** Gets current position */
  47730. pos: Vector3;
  47731. /** Gets direction of X axis */
  47732. xaxis: Vector3;
  47733. /** Gets direction of Y axis */
  47734. yaxis: Vector3;
  47735. /** Gets direction of Z axis */
  47736. zaxis: Vector3;
  47737. /**
  47738. * Creates a new BoneAxesViewer
  47739. * @param scene defines the hosting scene
  47740. * @param bone defines the target bone
  47741. * @param mesh defines the target mesh
  47742. * @param scaleLines defines a scaling factor for line length (1 by default)
  47743. */
  47744. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  47745. /**
  47746. * Force the viewer to update
  47747. */
  47748. update(): void;
  47749. /** Releases resources */
  47750. dispose(): void;
  47751. }
  47752. }
  47753. declare module "babylonjs/Debug/debugLayer" {
  47754. import { Scene } from "babylonjs/scene";
  47755. /**
  47756. * Interface used to define scene explorer extensibility option
  47757. */
  47758. export interface IExplorerExtensibilityOption {
  47759. /**
  47760. * Define the option label
  47761. */
  47762. label: string;
  47763. /**
  47764. * Defines the action to execute on click
  47765. */
  47766. action: (entity: any) => void;
  47767. }
  47768. /**
  47769. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  47770. */
  47771. export interface IExplorerExtensibilityGroup {
  47772. /**
  47773. * Defines a predicate to test if a given type mut be extended
  47774. */
  47775. predicate: (entity: any) => boolean;
  47776. /**
  47777. * Gets the list of options added to a type
  47778. */
  47779. entries: IExplorerExtensibilityOption[];
  47780. }
  47781. /**
  47782. * Interface used to define the options to use to create the Inspector
  47783. */
  47784. export interface IInspectorOptions {
  47785. /**
  47786. * Display in overlay mode (default: false)
  47787. */
  47788. overlay?: boolean;
  47789. /**
  47790. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  47791. */
  47792. globalRoot?: HTMLElement;
  47793. /**
  47794. * Display the Scene explorer
  47795. */
  47796. showExplorer?: boolean;
  47797. /**
  47798. * Display the property inspector
  47799. */
  47800. showInspector?: boolean;
  47801. /**
  47802. * Display in embed mode (both panes on the right)
  47803. */
  47804. embedMode?: boolean;
  47805. /**
  47806. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  47807. */
  47808. handleResize?: boolean;
  47809. /**
  47810. * Allow the panes to popup (default: true)
  47811. */
  47812. enablePopup?: boolean;
  47813. /**
  47814. * Allow the panes to be closed by users (default: true)
  47815. */
  47816. enableClose?: boolean;
  47817. /**
  47818. * Optional list of extensibility entries
  47819. */
  47820. explorerExtensibility?: IExplorerExtensibilityGroup[];
  47821. /**
  47822. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  47823. */
  47824. inspectorURL?: string;
  47825. /**
  47826. * Optional initial tab (default to DebugLayerTab.Properties)
  47827. */
  47828. initialTab?: DebugLayerTab;
  47829. }
  47830. module "babylonjs/scene" {
  47831. interface Scene {
  47832. /**
  47833. * @hidden
  47834. * Backing field
  47835. */
  47836. _debugLayer: DebugLayer;
  47837. /**
  47838. * Gets the debug layer (aka Inspector) associated with the scene
  47839. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47840. */
  47841. debugLayer: DebugLayer;
  47842. }
  47843. }
  47844. /**
  47845. * Enum of inspector action tab
  47846. */
  47847. export enum DebugLayerTab {
  47848. /**
  47849. * Properties tag (default)
  47850. */
  47851. Properties = 0,
  47852. /**
  47853. * Debug tab
  47854. */
  47855. Debug = 1,
  47856. /**
  47857. * Statistics tab
  47858. */
  47859. Statistics = 2,
  47860. /**
  47861. * Tools tab
  47862. */
  47863. Tools = 3,
  47864. /**
  47865. * Settings tab
  47866. */
  47867. Settings = 4
  47868. }
  47869. /**
  47870. * The debug layer (aka Inspector) is the go to tool in order to better understand
  47871. * what is happening in your scene
  47872. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47873. */
  47874. export class DebugLayer {
  47875. /**
  47876. * Define the url to get the inspector script from.
  47877. * By default it uses the babylonjs CDN.
  47878. * @ignoreNaming
  47879. */
  47880. static InspectorURL: string;
  47881. private _scene;
  47882. private BJSINSPECTOR;
  47883. private _onPropertyChangedObservable?;
  47884. /**
  47885. * Observable triggered when a property is changed through the inspector.
  47886. */
  47887. get onPropertyChangedObservable(): any;
  47888. /**
  47889. * Instantiates a new debug layer.
  47890. * The debug layer (aka Inspector) is the go to tool in order to better understand
  47891. * what is happening in your scene
  47892. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47893. * @param scene Defines the scene to inspect
  47894. */
  47895. constructor(scene: Scene);
  47896. /** Creates the inspector window. */
  47897. private _createInspector;
  47898. /**
  47899. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  47900. * @param entity defines the entity to select
  47901. * @param lineContainerTitle defines the specific block to highlight
  47902. */
  47903. select(entity: any, lineContainerTitle?: string): void;
  47904. /** Get the inspector from bundle or global */
  47905. private _getGlobalInspector;
  47906. /**
  47907. * Get if the inspector is visible or not.
  47908. * @returns true if visible otherwise, false
  47909. */
  47910. isVisible(): boolean;
  47911. /**
  47912. * Hide the inspector and close its window.
  47913. */
  47914. hide(): void;
  47915. /**
  47916. * Launch the debugLayer.
  47917. * @param config Define the configuration of the inspector
  47918. * @return a promise fulfilled when the debug layer is visible
  47919. */
  47920. show(config?: IInspectorOptions): Promise<DebugLayer>;
  47921. }
  47922. }
  47923. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  47924. import { Nullable } from "babylonjs/types";
  47925. import { Scene } from "babylonjs/scene";
  47926. import { Vector4 } from "babylonjs/Maths/math.vector";
  47927. import { Color4 } from "babylonjs/Maths/math.color";
  47928. import { Mesh } from "babylonjs/Meshes/mesh";
  47929. /**
  47930. * Class containing static functions to help procedurally build meshes
  47931. */
  47932. export class BoxBuilder {
  47933. /**
  47934. * Creates a box mesh
  47935. * * The parameter `size` sets the size (float) of each box side (default 1)
  47936. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  47937. * * 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)
  47938. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  47939. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47940. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47941. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47942. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  47943. * @param name defines the name of the mesh
  47944. * @param options defines the options used to create the mesh
  47945. * @param scene defines the hosting scene
  47946. * @returns the box mesh
  47947. */
  47948. static CreateBox(name: string, options: {
  47949. size?: number;
  47950. width?: number;
  47951. height?: number;
  47952. depth?: number;
  47953. faceUV?: Vector4[];
  47954. faceColors?: Color4[];
  47955. sideOrientation?: number;
  47956. frontUVs?: Vector4;
  47957. backUVs?: Vector4;
  47958. wrap?: boolean;
  47959. topBaseAt?: number;
  47960. bottomBaseAt?: number;
  47961. updatable?: boolean;
  47962. }, scene?: Nullable<Scene>): Mesh;
  47963. }
  47964. }
  47965. declare module "babylonjs/Debug/physicsViewer" {
  47966. import { Nullable } from "babylonjs/types";
  47967. import { Scene } from "babylonjs/scene";
  47968. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47969. import { Mesh } from "babylonjs/Meshes/mesh";
  47970. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  47971. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  47972. /**
  47973. * Used to show the physics impostor around the specific mesh
  47974. */
  47975. export class PhysicsViewer {
  47976. /** @hidden */
  47977. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  47978. /** @hidden */
  47979. protected _meshes: Array<Nullable<AbstractMesh>>;
  47980. /** @hidden */
  47981. protected _scene: Nullable<Scene>;
  47982. /** @hidden */
  47983. protected _numMeshes: number;
  47984. /** @hidden */
  47985. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  47986. private _renderFunction;
  47987. private _utilityLayer;
  47988. private _debugBoxMesh;
  47989. private _debugSphereMesh;
  47990. private _debugCylinderMesh;
  47991. private _debugMaterial;
  47992. private _debugMeshMeshes;
  47993. /**
  47994. * Creates a new PhysicsViewer
  47995. * @param scene defines the hosting scene
  47996. */
  47997. constructor(scene: Scene);
  47998. /** @hidden */
  47999. protected _updateDebugMeshes(): void;
  48000. /**
  48001. * Renders a specified physic impostor
  48002. * @param impostor defines the impostor to render
  48003. * @param targetMesh defines the mesh represented by the impostor
  48004. * @returns the new debug mesh used to render the impostor
  48005. */
  48006. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  48007. /**
  48008. * Hides a specified physic impostor
  48009. * @param impostor defines the impostor to hide
  48010. */
  48011. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  48012. private _getDebugMaterial;
  48013. private _getDebugBoxMesh;
  48014. private _getDebugSphereMesh;
  48015. private _getDebugCylinderMesh;
  48016. private _getDebugMeshMesh;
  48017. private _getDebugMesh;
  48018. /** Releases all resources */
  48019. dispose(): void;
  48020. }
  48021. }
  48022. declare module "babylonjs/Debug/rayHelper" {
  48023. import { Nullable } from "babylonjs/types";
  48024. import { Ray } from "babylonjs/Culling/ray";
  48025. import { Vector3 } from "babylonjs/Maths/math.vector";
  48026. import { Color3 } from "babylonjs/Maths/math.color";
  48027. import { Scene } from "babylonjs/scene";
  48028. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48029. import "babylonjs/Meshes/Builders/linesBuilder";
  48030. /**
  48031. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48032. * in order to better appreciate the issue one might have.
  48033. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48034. */
  48035. export class RayHelper {
  48036. /**
  48037. * Defines the ray we are currently tryin to visualize.
  48038. */
  48039. ray: Nullable<Ray>;
  48040. private _renderPoints;
  48041. private _renderLine;
  48042. private _renderFunction;
  48043. private _scene;
  48044. private _updateToMeshFunction;
  48045. private _attachedToMesh;
  48046. private _meshSpaceDirection;
  48047. private _meshSpaceOrigin;
  48048. /**
  48049. * Helper function to create a colored helper in a scene in one line.
  48050. * @param ray Defines the ray we are currently tryin to visualize
  48051. * @param scene Defines the scene the ray is used in
  48052. * @param color Defines the color we want to see the ray in
  48053. * @returns The newly created ray helper.
  48054. */
  48055. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  48056. /**
  48057. * Instantiate a new ray helper.
  48058. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48059. * in order to better appreciate the issue one might have.
  48060. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48061. * @param ray Defines the ray we are currently tryin to visualize
  48062. */
  48063. constructor(ray: Ray);
  48064. /**
  48065. * Shows the ray we are willing to debug.
  48066. * @param scene Defines the scene the ray needs to be rendered in
  48067. * @param color Defines the color the ray needs to be rendered in
  48068. */
  48069. show(scene: Scene, color?: Color3): void;
  48070. /**
  48071. * Hides the ray we are debugging.
  48072. */
  48073. hide(): void;
  48074. private _render;
  48075. /**
  48076. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  48077. * @param mesh Defines the mesh we want the helper attached to
  48078. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  48079. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  48080. * @param length Defines the length of the ray
  48081. */
  48082. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  48083. /**
  48084. * Detach the ray helper from the mesh it has previously been attached to.
  48085. */
  48086. detachFromMesh(): void;
  48087. private _updateToMesh;
  48088. /**
  48089. * Dispose the helper and release its associated resources.
  48090. */
  48091. dispose(): void;
  48092. }
  48093. }
  48094. declare module "babylonjs/Debug/skeletonViewer" {
  48095. import { Color3 } from "babylonjs/Maths/math.color";
  48096. import { Scene } from "babylonjs/scene";
  48097. import { Nullable } from "babylonjs/types";
  48098. import { Skeleton } from "babylonjs/Bones/skeleton";
  48099. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48100. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  48101. /**
  48102. * Class used to render a debug view of a given skeleton
  48103. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  48104. */
  48105. export class SkeletonViewer {
  48106. /** defines the skeleton to render */
  48107. skeleton: Skeleton;
  48108. /** defines the mesh attached to the skeleton */
  48109. mesh: AbstractMesh;
  48110. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48111. autoUpdateBonesMatrices: boolean;
  48112. /** defines the rendering group id to use with the viewer */
  48113. renderingGroupId: number;
  48114. /** Gets or sets the color used to render the skeleton */
  48115. color: Color3;
  48116. private _scene;
  48117. private _debugLines;
  48118. private _debugMesh;
  48119. private _isEnabled;
  48120. private _renderFunction;
  48121. private _utilityLayer;
  48122. /**
  48123. * Returns the mesh used to render the bones
  48124. */
  48125. get debugMesh(): Nullable<LinesMesh>;
  48126. /**
  48127. * Creates a new SkeletonViewer
  48128. * @param skeleton defines the skeleton to render
  48129. * @param mesh defines the mesh attached to the skeleton
  48130. * @param scene defines the hosting scene
  48131. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  48132. * @param renderingGroupId defines the rendering group id to use with the viewer
  48133. */
  48134. constructor(
  48135. /** defines the skeleton to render */
  48136. skeleton: Skeleton,
  48137. /** defines the mesh attached to the skeleton */
  48138. mesh: AbstractMesh, scene: Scene,
  48139. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48140. autoUpdateBonesMatrices?: boolean,
  48141. /** defines the rendering group id to use with the viewer */
  48142. renderingGroupId?: number);
  48143. /** Gets or sets a boolean indicating if the viewer is enabled */
  48144. set isEnabled(value: boolean);
  48145. get isEnabled(): boolean;
  48146. private _getBonePosition;
  48147. private _getLinesForBonesWithLength;
  48148. private _getLinesForBonesNoLength;
  48149. /** Update the viewer to sync with current skeleton state */
  48150. update(): void;
  48151. /** Release associated resources */
  48152. dispose(): void;
  48153. }
  48154. }
  48155. declare module "babylonjs/Debug/index" {
  48156. export * from "babylonjs/Debug/axesViewer";
  48157. export * from "babylonjs/Debug/boneAxesViewer";
  48158. export * from "babylonjs/Debug/debugLayer";
  48159. export * from "babylonjs/Debug/physicsViewer";
  48160. export * from "babylonjs/Debug/rayHelper";
  48161. export * from "babylonjs/Debug/skeletonViewer";
  48162. }
  48163. declare module "babylonjs/Engines/nullEngine" {
  48164. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  48165. import { Scene } from "babylonjs/scene";
  48166. import { Engine } from "babylonjs/Engines/engine";
  48167. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  48168. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  48169. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48170. import { Effect } from "babylonjs/Materials/effect";
  48171. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  48172. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48173. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  48174. /**
  48175. * Options to create the null engine
  48176. */
  48177. export class NullEngineOptions {
  48178. /**
  48179. * Render width (Default: 512)
  48180. */
  48181. renderWidth: number;
  48182. /**
  48183. * Render height (Default: 256)
  48184. */
  48185. renderHeight: number;
  48186. /**
  48187. * Texture size (Default: 512)
  48188. */
  48189. textureSize: number;
  48190. /**
  48191. * If delta time between frames should be constant
  48192. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48193. */
  48194. deterministicLockstep: boolean;
  48195. /**
  48196. * Maximum about of steps between frames (Default: 4)
  48197. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48198. */
  48199. lockstepMaxSteps: number;
  48200. }
  48201. /**
  48202. * The null engine class provides support for headless version of babylon.js.
  48203. * This can be used in server side scenario or for testing purposes
  48204. */
  48205. export class NullEngine extends Engine {
  48206. private _options;
  48207. /**
  48208. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  48209. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48210. * @returns true if engine is in deterministic lock step mode
  48211. */
  48212. isDeterministicLockStep(): boolean;
  48213. /**
  48214. * Gets the max steps when engine is running in deterministic lock step
  48215. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48216. * @returns the max steps
  48217. */
  48218. getLockstepMaxSteps(): number;
  48219. /**
  48220. * Gets the current hardware scaling level.
  48221. * By default the hardware scaling level is computed from the window device ratio.
  48222. * 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.
  48223. * @returns a number indicating the current hardware scaling level
  48224. */
  48225. getHardwareScalingLevel(): number;
  48226. constructor(options?: NullEngineOptions);
  48227. /**
  48228. * Creates a vertex buffer
  48229. * @param vertices the data for the vertex buffer
  48230. * @returns the new WebGL static buffer
  48231. */
  48232. createVertexBuffer(vertices: FloatArray): DataBuffer;
  48233. /**
  48234. * Creates a new index buffer
  48235. * @param indices defines the content of the index buffer
  48236. * @param updatable defines if the index buffer must be updatable
  48237. * @returns a new webGL buffer
  48238. */
  48239. createIndexBuffer(indices: IndicesArray): DataBuffer;
  48240. /**
  48241. * Clear the current render buffer or the current render target (if any is set up)
  48242. * @param color defines the color to use
  48243. * @param backBuffer defines if the back buffer must be cleared
  48244. * @param depth defines if the depth buffer must be cleared
  48245. * @param stencil defines if the stencil buffer must be cleared
  48246. */
  48247. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48248. /**
  48249. * Gets the current render width
  48250. * @param useScreen defines if screen size must be used (or the current render target if any)
  48251. * @returns a number defining the current render width
  48252. */
  48253. getRenderWidth(useScreen?: boolean): number;
  48254. /**
  48255. * Gets the current render height
  48256. * @param useScreen defines if screen size must be used (or the current render target if any)
  48257. * @returns a number defining the current render height
  48258. */
  48259. getRenderHeight(useScreen?: boolean): number;
  48260. /**
  48261. * Set the WebGL's viewport
  48262. * @param viewport defines the viewport element to be used
  48263. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  48264. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  48265. */
  48266. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  48267. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  48268. /**
  48269. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  48270. * @param pipelineContext defines the pipeline context to use
  48271. * @param uniformsNames defines the list of uniform names
  48272. * @returns an array of webGL uniform locations
  48273. */
  48274. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  48275. /**
  48276. * Gets the lsit of active attributes for a given webGL program
  48277. * @param pipelineContext defines the pipeline context to use
  48278. * @param attributesNames defines the list of attribute names to get
  48279. * @returns an array of indices indicating the offset of each attribute
  48280. */
  48281. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48282. /**
  48283. * Binds an effect to the webGL context
  48284. * @param effect defines the effect to bind
  48285. */
  48286. bindSamplers(effect: Effect): void;
  48287. /**
  48288. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  48289. * @param effect defines the effect to activate
  48290. */
  48291. enableEffect(effect: Effect): void;
  48292. /**
  48293. * Set various states to the webGL context
  48294. * @param culling defines backface culling state
  48295. * @param zOffset defines the value to apply to zOffset (0 by default)
  48296. * @param force defines if states must be applied even if cache is up to date
  48297. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  48298. */
  48299. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48300. /**
  48301. * Set the value of an uniform to an array of int32
  48302. * @param uniform defines the webGL uniform location where to store the value
  48303. * @param array defines the array of int32 to store
  48304. */
  48305. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48306. /**
  48307. * Set the value of an uniform to an array of int32 (stored as vec2)
  48308. * @param uniform defines the webGL uniform location where to store the value
  48309. * @param array defines the array of int32 to store
  48310. */
  48311. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48312. /**
  48313. * Set the value of an uniform to an array of int32 (stored as vec3)
  48314. * @param uniform defines the webGL uniform location where to store the value
  48315. * @param array defines the array of int32 to store
  48316. */
  48317. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48318. /**
  48319. * Set the value of an uniform to an array of int32 (stored as vec4)
  48320. * @param uniform defines the webGL uniform location where to store the value
  48321. * @param array defines the array of int32 to store
  48322. */
  48323. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48324. /**
  48325. * Set the value of an uniform to an array of float32
  48326. * @param uniform defines the webGL uniform location where to store the value
  48327. * @param array defines the array of float32 to store
  48328. */
  48329. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48330. /**
  48331. * Set the value of an uniform to an array of float32 (stored as vec2)
  48332. * @param uniform defines the webGL uniform location where to store the value
  48333. * @param array defines the array of float32 to store
  48334. */
  48335. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48336. /**
  48337. * Set the value of an uniform to an array of float32 (stored as vec3)
  48338. * @param uniform defines the webGL uniform location where to store the value
  48339. * @param array defines the array of float32 to store
  48340. */
  48341. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48342. /**
  48343. * Set the value of an uniform to an array of float32 (stored as vec4)
  48344. * @param uniform defines the webGL uniform location where to store the value
  48345. * @param array defines the array of float32 to store
  48346. */
  48347. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48348. /**
  48349. * Set the value of an uniform to an array of number
  48350. * @param uniform defines the webGL uniform location where to store the value
  48351. * @param array defines the array of number to store
  48352. */
  48353. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48354. /**
  48355. * Set the value of an uniform to an array of number (stored as vec2)
  48356. * @param uniform defines the webGL uniform location where to store the value
  48357. * @param array defines the array of number to store
  48358. */
  48359. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48360. /**
  48361. * Set the value of an uniform to an array of number (stored as vec3)
  48362. * @param uniform defines the webGL uniform location where to store the value
  48363. * @param array defines the array of number to store
  48364. */
  48365. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48366. /**
  48367. * Set the value of an uniform to an array of number (stored as vec4)
  48368. * @param uniform defines the webGL uniform location where to store the value
  48369. * @param array defines the array of number to store
  48370. */
  48371. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48372. /**
  48373. * Set the value of an uniform to an array of float32 (stored as matrices)
  48374. * @param uniform defines the webGL uniform location where to store the value
  48375. * @param matrices defines the array of float32 to store
  48376. */
  48377. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48378. /**
  48379. * Set the value of an uniform to a matrix (3x3)
  48380. * @param uniform defines the webGL uniform location where to store the value
  48381. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  48382. */
  48383. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48384. /**
  48385. * Set the value of an uniform to a matrix (2x2)
  48386. * @param uniform defines the webGL uniform location where to store the value
  48387. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  48388. */
  48389. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48390. /**
  48391. * Set the value of an uniform to a number (float)
  48392. * @param uniform defines the webGL uniform location where to store the value
  48393. * @param value defines the float number to store
  48394. */
  48395. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48396. /**
  48397. * Set the value of an uniform to a vec2
  48398. * @param uniform defines the webGL uniform location where to store the value
  48399. * @param x defines the 1st component of the value
  48400. * @param y defines the 2nd component of the value
  48401. */
  48402. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48403. /**
  48404. * Set the value of an uniform to a vec3
  48405. * @param uniform defines the webGL uniform location where to store the value
  48406. * @param x defines the 1st component of the value
  48407. * @param y defines the 2nd component of the value
  48408. * @param z defines the 3rd component of the value
  48409. */
  48410. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48411. /**
  48412. * Set the value of an uniform to a boolean
  48413. * @param uniform defines the webGL uniform location where to store the value
  48414. * @param bool defines the boolean to store
  48415. */
  48416. setBool(uniform: WebGLUniformLocation, bool: number): void;
  48417. /**
  48418. * Set the value of an uniform to a vec4
  48419. * @param uniform defines the webGL uniform location where to store the value
  48420. * @param x defines the 1st component of the value
  48421. * @param y defines the 2nd component of the value
  48422. * @param z defines the 3rd component of the value
  48423. * @param w defines the 4th component of the value
  48424. */
  48425. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48426. /**
  48427. * Sets the current alpha mode
  48428. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  48429. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48430. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48431. */
  48432. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48433. /**
  48434. * Bind webGl buffers directly to the webGL context
  48435. * @param vertexBuffers defines the vertex buffer to bind
  48436. * @param indexBuffer defines the index buffer to bind
  48437. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  48438. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  48439. * @param effect defines the effect associated with the vertex buffer
  48440. */
  48441. bindBuffers(vertexBuffers: {
  48442. [key: string]: VertexBuffer;
  48443. }, indexBuffer: DataBuffer, effect: Effect): void;
  48444. /**
  48445. * Force the entire cache to be cleared
  48446. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  48447. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  48448. */
  48449. wipeCaches(bruteForce?: boolean): void;
  48450. /**
  48451. * Send a draw order
  48452. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  48453. * @param indexStart defines the starting index
  48454. * @param indexCount defines the number of index to draw
  48455. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48456. */
  48457. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  48458. /**
  48459. * Draw a list of indexed primitives
  48460. * @param fillMode defines the primitive to use
  48461. * @param indexStart defines the starting index
  48462. * @param indexCount defines the number of index to draw
  48463. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48464. */
  48465. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48466. /**
  48467. * Draw a list of unindexed primitives
  48468. * @param fillMode defines the primitive to use
  48469. * @param verticesStart defines the index of first vertex to draw
  48470. * @param verticesCount defines the count of vertices to draw
  48471. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48472. */
  48473. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48474. /** @hidden */
  48475. _createTexture(): WebGLTexture;
  48476. /** @hidden */
  48477. _releaseTexture(texture: InternalTexture): void;
  48478. /**
  48479. * Usually called from Texture.ts.
  48480. * Passed information to create a WebGLTexture
  48481. * @param urlArg defines a value which contains one of the following:
  48482. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48483. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48484. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48485. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48486. * @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)
  48487. * @param scene needed for loading to the correct scene
  48488. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  48489. * @param onLoad optional callback to be called upon successful completion
  48490. * @param onError optional callback to be called upon failure
  48491. * @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
  48492. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48493. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48494. * @param forcedExtension defines the extension to use to pick the right loader
  48495. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  48496. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48497. */
  48498. createTexture(urlArg: string, noMipmap: boolean, invertY: boolean, scene: Scene, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<ArrayBuffer | HTMLImageElement>, fallBack?: InternalTexture, format?: number): InternalTexture;
  48499. /**
  48500. * Creates a new render target texture
  48501. * @param size defines the size of the texture
  48502. * @param options defines the options used to create the texture
  48503. * @returns a new render target texture stored in an InternalTexture
  48504. */
  48505. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  48506. /**
  48507. * Update the sampling mode of a given texture
  48508. * @param samplingMode defines the required sampling mode
  48509. * @param texture defines the texture to update
  48510. */
  48511. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48512. /**
  48513. * Binds the frame buffer to the specified texture.
  48514. * @param texture The texture to render to or null for the default canvas
  48515. * @param faceIndex The face of the texture to render to in case of cube texture
  48516. * @param requiredWidth The width of the target to render to
  48517. * @param requiredHeight The height of the target to render to
  48518. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  48519. * @param lodLevel defines le lod level to bind to the frame buffer
  48520. */
  48521. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48522. /**
  48523. * Unbind the current render target texture from the webGL context
  48524. * @param texture defines the render target texture to unbind
  48525. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  48526. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  48527. */
  48528. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48529. /**
  48530. * Creates a dynamic vertex buffer
  48531. * @param vertices the data for the dynamic vertex buffer
  48532. * @returns the new WebGL dynamic buffer
  48533. */
  48534. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  48535. /**
  48536. * Update the content of a dynamic texture
  48537. * @param texture defines the texture to update
  48538. * @param canvas defines the canvas containing the source
  48539. * @param invertY defines if data must be stored with Y axis inverted
  48540. * @param premulAlpha defines if alpha is stored as premultiplied
  48541. * @param format defines the format of the data
  48542. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  48543. */
  48544. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  48545. /**
  48546. * Gets a boolean indicating if all created effects are ready
  48547. * @returns true if all effects are ready
  48548. */
  48549. areAllEffectsReady(): boolean;
  48550. /**
  48551. * @hidden
  48552. * Get the current error code of the webGL context
  48553. * @returns the error code
  48554. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  48555. */
  48556. getError(): number;
  48557. /** @hidden */
  48558. _getUnpackAlignement(): number;
  48559. /** @hidden */
  48560. _unpackFlipY(value: boolean): void;
  48561. /**
  48562. * Update a dynamic index buffer
  48563. * @param indexBuffer defines the target index buffer
  48564. * @param indices defines the data to update
  48565. * @param offset defines the offset in the target index buffer where update should start
  48566. */
  48567. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  48568. /**
  48569. * Updates a dynamic vertex buffer.
  48570. * @param vertexBuffer the vertex buffer to update
  48571. * @param vertices the data used to update the vertex buffer
  48572. * @param byteOffset the byte offset of the data (optional)
  48573. * @param byteLength the byte length of the data (optional)
  48574. */
  48575. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  48576. /** @hidden */
  48577. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  48578. /** @hidden */
  48579. _bindTexture(channel: number, texture: InternalTexture): void;
  48580. protected _deleteBuffer(buffer: WebGLBuffer): void;
  48581. /**
  48582. * 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
  48583. */
  48584. releaseEffects(): void;
  48585. displayLoadingUI(): void;
  48586. hideLoadingUI(): void;
  48587. /** @hidden */
  48588. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48589. /** @hidden */
  48590. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48591. /** @hidden */
  48592. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48593. /** @hidden */
  48594. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48595. }
  48596. }
  48597. declare module "babylonjs/Instrumentation/timeToken" {
  48598. import { Nullable } from "babylonjs/types";
  48599. /**
  48600. * @hidden
  48601. **/
  48602. export class _TimeToken {
  48603. _startTimeQuery: Nullable<WebGLQuery>;
  48604. _endTimeQuery: Nullable<WebGLQuery>;
  48605. _timeElapsedQuery: Nullable<WebGLQuery>;
  48606. _timeElapsedQueryEnded: boolean;
  48607. }
  48608. }
  48609. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  48610. import { Nullable, int } from "babylonjs/types";
  48611. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  48612. /** @hidden */
  48613. export class _OcclusionDataStorage {
  48614. /** @hidden */
  48615. occlusionInternalRetryCounter: number;
  48616. /** @hidden */
  48617. isOcclusionQueryInProgress: boolean;
  48618. /** @hidden */
  48619. isOccluded: boolean;
  48620. /** @hidden */
  48621. occlusionRetryCount: number;
  48622. /** @hidden */
  48623. occlusionType: number;
  48624. /** @hidden */
  48625. occlusionQueryAlgorithmType: number;
  48626. }
  48627. module "babylonjs/Engines/engine" {
  48628. interface Engine {
  48629. /**
  48630. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  48631. * @return the new query
  48632. */
  48633. createQuery(): WebGLQuery;
  48634. /**
  48635. * Delete and release a webGL query
  48636. * @param query defines the query to delete
  48637. * @return the current engine
  48638. */
  48639. deleteQuery(query: WebGLQuery): Engine;
  48640. /**
  48641. * Check if a given query has resolved and got its value
  48642. * @param query defines the query to check
  48643. * @returns true if the query got its value
  48644. */
  48645. isQueryResultAvailable(query: WebGLQuery): boolean;
  48646. /**
  48647. * Gets the value of a given query
  48648. * @param query defines the query to check
  48649. * @returns the value of the query
  48650. */
  48651. getQueryResult(query: WebGLQuery): number;
  48652. /**
  48653. * Initiates an occlusion query
  48654. * @param algorithmType defines the algorithm to use
  48655. * @param query defines the query to use
  48656. * @returns the current engine
  48657. * @see http://doc.babylonjs.com/features/occlusionquery
  48658. */
  48659. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  48660. /**
  48661. * Ends an occlusion query
  48662. * @see http://doc.babylonjs.com/features/occlusionquery
  48663. * @param algorithmType defines the algorithm to use
  48664. * @returns the current engine
  48665. */
  48666. endOcclusionQuery(algorithmType: number): Engine;
  48667. /**
  48668. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  48669. * Please note that only one query can be issued at a time
  48670. * @returns a time token used to track the time span
  48671. */
  48672. startTimeQuery(): Nullable<_TimeToken>;
  48673. /**
  48674. * Ends a time query
  48675. * @param token defines the token used to measure the time span
  48676. * @returns the time spent (in ns)
  48677. */
  48678. endTimeQuery(token: _TimeToken): int;
  48679. /** @hidden */
  48680. _currentNonTimestampToken: Nullable<_TimeToken>;
  48681. /** @hidden */
  48682. _createTimeQuery(): WebGLQuery;
  48683. /** @hidden */
  48684. _deleteTimeQuery(query: WebGLQuery): void;
  48685. /** @hidden */
  48686. _getGlAlgorithmType(algorithmType: number): number;
  48687. /** @hidden */
  48688. _getTimeQueryResult(query: WebGLQuery): any;
  48689. /** @hidden */
  48690. _getTimeQueryAvailability(query: WebGLQuery): any;
  48691. }
  48692. }
  48693. module "babylonjs/Meshes/abstractMesh" {
  48694. interface AbstractMesh {
  48695. /**
  48696. * Backing filed
  48697. * @hidden
  48698. */
  48699. __occlusionDataStorage: _OcclusionDataStorage;
  48700. /**
  48701. * Access property
  48702. * @hidden
  48703. */
  48704. _occlusionDataStorage: _OcclusionDataStorage;
  48705. /**
  48706. * 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.
  48707. * The default value is -1 which means don't break the query and wait till the result
  48708. * @see http://doc.babylonjs.com/features/occlusionquery
  48709. */
  48710. occlusionRetryCount: number;
  48711. /**
  48712. * 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:
  48713. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  48714. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  48715. * * 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.
  48716. * @see http://doc.babylonjs.com/features/occlusionquery
  48717. */
  48718. occlusionType: number;
  48719. /**
  48720. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  48721. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  48722. * * 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.
  48723. * @see http://doc.babylonjs.com/features/occlusionquery
  48724. */
  48725. occlusionQueryAlgorithmType: number;
  48726. /**
  48727. * 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
  48728. * @see http://doc.babylonjs.com/features/occlusionquery
  48729. */
  48730. isOccluded: boolean;
  48731. /**
  48732. * Flag to check the progress status of the query
  48733. * @see http://doc.babylonjs.com/features/occlusionquery
  48734. */
  48735. isOcclusionQueryInProgress: boolean;
  48736. }
  48737. }
  48738. }
  48739. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  48740. import { Nullable } from "babylonjs/types";
  48741. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48742. /** @hidden */
  48743. export var _forceTransformFeedbackToBundle: boolean;
  48744. module "babylonjs/Engines/engine" {
  48745. interface Engine {
  48746. /**
  48747. * Creates a webGL transform feedback object
  48748. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  48749. * @returns the webGL transform feedback object
  48750. */
  48751. createTransformFeedback(): WebGLTransformFeedback;
  48752. /**
  48753. * Delete a webGL transform feedback object
  48754. * @param value defines the webGL transform feedback object to delete
  48755. */
  48756. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  48757. /**
  48758. * Bind a webGL transform feedback object to the webgl context
  48759. * @param value defines the webGL transform feedback object to bind
  48760. */
  48761. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  48762. /**
  48763. * Begins a transform feedback operation
  48764. * @param usePoints defines if points or triangles must be used
  48765. */
  48766. beginTransformFeedback(usePoints: boolean): void;
  48767. /**
  48768. * Ends a transform feedback operation
  48769. */
  48770. endTransformFeedback(): void;
  48771. /**
  48772. * Specify the varyings to use with transform feedback
  48773. * @param program defines the associated webGL program
  48774. * @param value defines the list of strings representing the varying names
  48775. */
  48776. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  48777. /**
  48778. * Bind a webGL buffer for a transform feedback operation
  48779. * @param value defines the webGL buffer to bind
  48780. */
  48781. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  48782. }
  48783. }
  48784. }
  48785. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  48786. import { Scene } from "babylonjs/scene";
  48787. import { Engine } from "babylonjs/Engines/engine";
  48788. import { Texture } from "babylonjs/Materials/Textures/texture";
  48789. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48790. import "babylonjs/Engines/Extensions/engine.multiRender";
  48791. /**
  48792. * Creation options of the multi render target texture.
  48793. */
  48794. export interface IMultiRenderTargetOptions {
  48795. /**
  48796. * Define if the texture needs to create mip maps after render.
  48797. */
  48798. generateMipMaps?: boolean;
  48799. /**
  48800. * Define the types of all the draw buffers we want to create
  48801. */
  48802. types?: number[];
  48803. /**
  48804. * Define the sampling modes of all the draw buffers we want to create
  48805. */
  48806. samplingModes?: number[];
  48807. /**
  48808. * Define if a depth buffer is required
  48809. */
  48810. generateDepthBuffer?: boolean;
  48811. /**
  48812. * Define if a stencil buffer is required
  48813. */
  48814. generateStencilBuffer?: boolean;
  48815. /**
  48816. * Define if a depth texture is required instead of a depth buffer
  48817. */
  48818. generateDepthTexture?: boolean;
  48819. /**
  48820. * Define the number of desired draw buffers
  48821. */
  48822. textureCount?: number;
  48823. /**
  48824. * Define if aspect ratio should be adapted to the texture or stay the scene one
  48825. */
  48826. doNotChangeAspectRatio?: boolean;
  48827. /**
  48828. * Define the default type of the buffers we are creating
  48829. */
  48830. defaultType?: number;
  48831. }
  48832. /**
  48833. * A multi render target, like a render target provides the ability to render to a texture.
  48834. * Unlike the render target, it can render to several draw buffers in one draw.
  48835. * This is specially interesting in deferred rendering or for any effects requiring more than
  48836. * just one color from a single pass.
  48837. */
  48838. export class MultiRenderTarget extends RenderTargetTexture {
  48839. private _internalTextures;
  48840. private _textures;
  48841. private _multiRenderTargetOptions;
  48842. /**
  48843. * Get if draw buffers are currently supported by the used hardware and browser.
  48844. */
  48845. get isSupported(): boolean;
  48846. /**
  48847. * Get the list of textures generated by the multi render target.
  48848. */
  48849. get textures(): Texture[];
  48850. /**
  48851. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  48852. */
  48853. get depthTexture(): Texture;
  48854. /**
  48855. * Set the wrapping mode on U of all the textures we are rendering to.
  48856. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  48857. */
  48858. set wrapU(wrap: number);
  48859. /**
  48860. * Set the wrapping mode on V of all the textures we are rendering to.
  48861. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  48862. */
  48863. set wrapV(wrap: number);
  48864. /**
  48865. * Instantiate a new multi render target texture.
  48866. * A multi render target, like a render target provides the ability to render to a texture.
  48867. * Unlike the render target, it can render to several draw buffers in one draw.
  48868. * This is specially interesting in deferred rendering or for any effects requiring more than
  48869. * just one color from a single pass.
  48870. * @param name Define the name of the texture
  48871. * @param size Define the size of the buffers to render to
  48872. * @param count Define the number of target we are rendering into
  48873. * @param scene Define the scene the texture belongs to
  48874. * @param options Define the options used to create the multi render target
  48875. */
  48876. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  48877. /** @hidden */
  48878. _rebuild(): void;
  48879. private _createInternalTextures;
  48880. private _createTextures;
  48881. /**
  48882. * Define the number of samples used if MSAA is enabled.
  48883. */
  48884. get samples(): number;
  48885. set samples(value: number);
  48886. /**
  48887. * Resize all the textures in the multi render target.
  48888. * Be carrefull as it will recreate all the data in the new texture.
  48889. * @param size Define the new size
  48890. */
  48891. resize(size: any): void;
  48892. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  48893. /**
  48894. * Dispose the render targets and their associated resources
  48895. */
  48896. dispose(): void;
  48897. /**
  48898. * Release all the underlying texture used as draw buffers.
  48899. */
  48900. releaseInternalTextures(): void;
  48901. }
  48902. }
  48903. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  48904. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48905. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  48906. import { Nullable } from "babylonjs/types";
  48907. module "babylonjs/Engines/thinEngine" {
  48908. interface ThinEngine {
  48909. /**
  48910. * Unbind a list of render target textures from the webGL context
  48911. * This is used only when drawBuffer extension or webGL2 are active
  48912. * @param textures defines the render target textures to unbind
  48913. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  48914. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  48915. */
  48916. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  48917. /**
  48918. * Create a multi render target texture
  48919. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  48920. * @param size defines the size of the texture
  48921. * @param options defines the creation options
  48922. * @returns the cube texture as an InternalTexture
  48923. */
  48924. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  48925. /**
  48926. * Update the sample count for a given multiple render target texture
  48927. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  48928. * @param textures defines the textures to update
  48929. * @param samples defines the sample count to set
  48930. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  48931. */
  48932. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  48933. }
  48934. }
  48935. }
  48936. declare module "babylonjs/Engines/Extensions/engine.views" {
  48937. import { Camera } from "babylonjs/Cameras/camera";
  48938. import { Nullable } from "babylonjs/types";
  48939. /**
  48940. * Class used to define an additional view for the engine
  48941. * @see https://doc.babylonjs.com/how_to/multi_canvases
  48942. */
  48943. export class EngineView {
  48944. /** Defines the canvas where to render the view */
  48945. target: HTMLCanvasElement;
  48946. /** Defines an optional camera used to render the view (will use active camera else) */
  48947. camera?: Camera;
  48948. }
  48949. module "babylonjs/Engines/engine" {
  48950. interface Engine {
  48951. /**
  48952. * Gets or sets the HTML element to use for attaching events
  48953. */
  48954. inputElement: Nullable<HTMLElement>;
  48955. /**
  48956. * Gets the current engine view
  48957. * @see https://doc.babylonjs.com/how_to/multi_canvases
  48958. */
  48959. activeView: Nullable<EngineView>;
  48960. /** Gets or sets the list of views */
  48961. views: EngineView[];
  48962. /**
  48963. * Register a new child canvas
  48964. * @param canvas defines the canvas to register
  48965. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  48966. * @returns the associated view
  48967. */
  48968. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  48969. /**
  48970. * Remove a registered child canvas
  48971. * @param canvas defines the canvas to remove
  48972. * @returns the current engine
  48973. */
  48974. unRegisterView(canvas: HTMLCanvasElement): Engine;
  48975. }
  48976. }
  48977. }
  48978. declare module "babylonjs/Engines/Extensions/index" {
  48979. export * from "babylonjs/Engines/Extensions/engine.alpha";
  48980. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  48981. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  48982. export * from "babylonjs/Engines/Extensions/engine.multiview";
  48983. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  48984. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  48985. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  48986. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  48987. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  48988. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  48989. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  48990. export * from "babylonjs/Engines/Extensions/engine.webVR";
  48991. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  48992. export * from "babylonjs/Engines/Extensions/engine.views";
  48993. }
  48994. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  48995. import { Nullable } from "babylonjs/types";
  48996. /**
  48997. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  48998. */
  48999. export interface CubeMapInfo {
  49000. /**
  49001. * The pixel array for the front face.
  49002. * This is stored in format, left to right, up to down format.
  49003. */
  49004. front: Nullable<ArrayBufferView>;
  49005. /**
  49006. * The pixel array for the back face.
  49007. * This is stored in format, left to right, up to down format.
  49008. */
  49009. back: Nullable<ArrayBufferView>;
  49010. /**
  49011. * The pixel array for the left face.
  49012. * This is stored in format, left to right, up to down format.
  49013. */
  49014. left: Nullable<ArrayBufferView>;
  49015. /**
  49016. * The pixel array for the right face.
  49017. * This is stored in format, left to right, up to down format.
  49018. */
  49019. right: Nullable<ArrayBufferView>;
  49020. /**
  49021. * The pixel array for the up face.
  49022. * This is stored in format, left to right, up to down format.
  49023. */
  49024. up: Nullable<ArrayBufferView>;
  49025. /**
  49026. * The pixel array for the down face.
  49027. * This is stored in format, left to right, up to down format.
  49028. */
  49029. down: Nullable<ArrayBufferView>;
  49030. /**
  49031. * The size of the cubemap stored.
  49032. *
  49033. * Each faces will be size * size pixels.
  49034. */
  49035. size: number;
  49036. /**
  49037. * The format of the texture.
  49038. *
  49039. * RGBA, RGB.
  49040. */
  49041. format: number;
  49042. /**
  49043. * The type of the texture data.
  49044. *
  49045. * UNSIGNED_INT, FLOAT.
  49046. */
  49047. type: number;
  49048. /**
  49049. * Specifies whether the texture is in gamma space.
  49050. */
  49051. gammaSpace: boolean;
  49052. }
  49053. /**
  49054. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  49055. */
  49056. export class PanoramaToCubeMapTools {
  49057. private static FACE_FRONT;
  49058. private static FACE_BACK;
  49059. private static FACE_RIGHT;
  49060. private static FACE_LEFT;
  49061. private static FACE_DOWN;
  49062. private static FACE_UP;
  49063. /**
  49064. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  49065. *
  49066. * @param float32Array The source data.
  49067. * @param inputWidth The width of the input panorama.
  49068. * @param inputHeight The height of the input panorama.
  49069. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  49070. * @return The cubemap data
  49071. */
  49072. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  49073. private static CreateCubemapTexture;
  49074. private static CalcProjectionSpherical;
  49075. }
  49076. }
  49077. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  49078. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49079. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49080. import { Nullable } from "babylonjs/types";
  49081. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  49082. /**
  49083. * Helper class dealing with the extraction of spherical polynomial dataArray
  49084. * from a cube map.
  49085. */
  49086. export class CubeMapToSphericalPolynomialTools {
  49087. private static FileFaces;
  49088. /**
  49089. * Converts a texture to the according Spherical Polynomial data.
  49090. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49091. *
  49092. * @param texture The texture to extract the information from.
  49093. * @return The Spherical Polynomial data.
  49094. */
  49095. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  49096. /**
  49097. * Converts a cubemap to the according Spherical Polynomial data.
  49098. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49099. *
  49100. * @param cubeInfo The Cube map to extract the information from.
  49101. * @return The Spherical Polynomial data.
  49102. */
  49103. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  49104. }
  49105. }
  49106. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  49107. import { Nullable } from "babylonjs/types";
  49108. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49109. module "babylonjs/Materials/Textures/baseTexture" {
  49110. interface BaseTexture {
  49111. /**
  49112. * Get the polynomial representation of the texture data.
  49113. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  49114. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  49115. */
  49116. sphericalPolynomial: Nullable<SphericalPolynomial>;
  49117. }
  49118. }
  49119. }
  49120. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  49121. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49122. /** @hidden */
  49123. export var rgbdEncodePixelShader: {
  49124. name: string;
  49125. shader: string;
  49126. };
  49127. }
  49128. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  49129. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49130. /** @hidden */
  49131. export var rgbdDecodePixelShader: {
  49132. name: string;
  49133. shader: string;
  49134. };
  49135. }
  49136. declare module "babylonjs/Misc/environmentTextureTools" {
  49137. import { Nullable } from "babylonjs/types";
  49138. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49139. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49140. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49141. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49142. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  49143. import "babylonjs/Shaders/rgbdEncode.fragment";
  49144. import "babylonjs/Shaders/rgbdDecode.fragment";
  49145. /**
  49146. * Raw texture data and descriptor sufficient for WebGL texture upload
  49147. */
  49148. export interface EnvironmentTextureInfo {
  49149. /**
  49150. * Version of the environment map
  49151. */
  49152. version: number;
  49153. /**
  49154. * Width of image
  49155. */
  49156. width: number;
  49157. /**
  49158. * Irradiance information stored in the file.
  49159. */
  49160. irradiance: any;
  49161. /**
  49162. * Specular information stored in the file.
  49163. */
  49164. specular: any;
  49165. }
  49166. /**
  49167. * Defines One Image in the file. It requires only the position in the file
  49168. * as well as the length.
  49169. */
  49170. interface BufferImageData {
  49171. /**
  49172. * Length of the image data.
  49173. */
  49174. length: number;
  49175. /**
  49176. * Position of the data from the null terminator delimiting the end of the JSON.
  49177. */
  49178. position: number;
  49179. }
  49180. /**
  49181. * Defines the specular data enclosed in the file.
  49182. * This corresponds to the version 1 of the data.
  49183. */
  49184. export interface EnvironmentTextureSpecularInfoV1 {
  49185. /**
  49186. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  49187. */
  49188. specularDataPosition?: number;
  49189. /**
  49190. * This contains all the images data needed to reconstruct the cubemap.
  49191. */
  49192. mipmaps: Array<BufferImageData>;
  49193. /**
  49194. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  49195. */
  49196. lodGenerationScale: number;
  49197. }
  49198. /**
  49199. * Sets of helpers addressing the serialization and deserialization of environment texture
  49200. * stored in a BabylonJS env file.
  49201. * Those files are usually stored as .env files.
  49202. */
  49203. export class EnvironmentTextureTools {
  49204. /**
  49205. * Magic number identifying the env file.
  49206. */
  49207. private static _MagicBytes;
  49208. /**
  49209. * Gets the environment info from an env file.
  49210. * @param data The array buffer containing the .env bytes.
  49211. * @returns the environment file info (the json header) if successfully parsed.
  49212. */
  49213. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  49214. /**
  49215. * Creates an environment texture from a loaded cube texture.
  49216. * @param texture defines the cube texture to convert in env file
  49217. * @return a promise containing the environment data if succesfull.
  49218. */
  49219. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  49220. /**
  49221. * Creates a JSON representation of the spherical data.
  49222. * @param texture defines the texture containing the polynomials
  49223. * @return the JSON representation of the spherical info
  49224. */
  49225. private static _CreateEnvTextureIrradiance;
  49226. /**
  49227. * Creates the ArrayBufferViews used for initializing environment texture image data.
  49228. * @param data the image data
  49229. * @param info parameters that determine what views will be created for accessing the underlying buffer
  49230. * @return the views described by info providing access to the underlying buffer
  49231. */
  49232. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  49233. /**
  49234. * Uploads the texture info contained in the env file to the GPU.
  49235. * @param texture defines the internal texture to upload to
  49236. * @param data defines the data to load
  49237. * @param info defines the texture info retrieved through the GetEnvInfo method
  49238. * @returns a promise
  49239. */
  49240. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  49241. private static _OnImageReadyAsync;
  49242. /**
  49243. * Uploads the levels of image data to the GPU.
  49244. * @param texture defines the internal texture to upload to
  49245. * @param imageData defines the array buffer views of image data [mipmap][face]
  49246. * @returns a promise
  49247. */
  49248. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  49249. /**
  49250. * Uploads spherical polynomials information to the texture.
  49251. * @param texture defines the texture we are trying to upload the information to
  49252. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  49253. */
  49254. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  49255. /** @hidden */
  49256. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49257. }
  49258. }
  49259. declare module "babylonjs/Maths/math.vertexFormat" {
  49260. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  49261. /**
  49262. * Contains position and normal vectors for a vertex
  49263. */
  49264. export class PositionNormalVertex {
  49265. /** the position of the vertex (defaut: 0,0,0) */
  49266. position: Vector3;
  49267. /** the normal of the vertex (defaut: 0,1,0) */
  49268. normal: Vector3;
  49269. /**
  49270. * Creates a PositionNormalVertex
  49271. * @param position the position of the vertex (defaut: 0,0,0)
  49272. * @param normal the normal of the vertex (defaut: 0,1,0)
  49273. */
  49274. constructor(
  49275. /** the position of the vertex (defaut: 0,0,0) */
  49276. position?: Vector3,
  49277. /** the normal of the vertex (defaut: 0,1,0) */
  49278. normal?: Vector3);
  49279. /**
  49280. * Clones the PositionNormalVertex
  49281. * @returns the cloned PositionNormalVertex
  49282. */
  49283. clone(): PositionNormalVertex;
  49284. }
  49285. /**
  49286. * Contains position, normal and uv vectors for a vertex
  49287. */
  49288. export class PositionNormalTextureVertex {
  49289. /** the position of the vertex (defaut: 0,0,0) */
  49290. position: Vector3;
  49291. /** the normal of the vertex (defaut: 0,1,0) */
  49292. normal: Vector3;
  49293. /** the uv of the vertex (default: 0,0) */
  49294. uv: Vector2;
  49295. /**
  49296. * Creates a PositionNormalTextureVertex
  49297. * @param position the position of the vertex (defaut: 0,0,0)
  49298. * @param normal the normal of the vertex (defaut: 0,1,0)
  49299. * @param uv the uv of the vertex (default: 0,0)
  49300. */
  49301. constructor(
  49302. /** the position of the vertex (defaut: 0,0,0) */
  49303. position?: Vector3,
  49304. /** the normal of the vertex (defaut: 0,1,0) */
  49305. normal?: Vector3,
  49306. /** the uv of the vertex (default: 0,0) */
  49307. uv?: Vector2);
  49308. /**
  49309. * Clones the PositionNormalTextureVertex
  49310. * @returns the cloned PositionNormalTextureVertex
  49311. */
  49312. clone(): PositionNormalTextureVertex;
  49313. }
  49314. }
  49315. declare module "babylonjs/Maths/math" {
  49316. export * from "babylonjs/Maths/math.axis";
  49317. export * from "babylonjs/Maths/math.color";
  49318. export * from "babylonjs/Maths/math.constants";
  49319. export * from "babylonjs/Maths/math.frustum";
  49320. export * from "babylonjs/Maths/math.path";
  49321. export * from "babylonjs/Maths/math.plane";
  49322. export * from "babylonjs/Maths/math.size";
  49323. export * from "babylonjs/Maths/math.vector";
  49324. export * from "babylonjs/Maths/math.vertexFormat";
  49325. export * from "babylonjs/Maths/math.viewport";
  49326. }
  49327. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  49328. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49329. /** @hidden */
  49330. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  49331. private _genericAttributeLocation;
  49332. private _varyingLocationCount;
  49333. private _varyingLocationMap;
  49334. private _replacements;
  49335. private _textureCount;
  49336. private _uniforms;
  49337. lineProcessor(line: string): string;
  49338. attributeProcessor(attribute: string): string;
  49339. varyingProcessor(varying: string, isFragment: boolean): string;
  49340. uniformProcessor(uniform: string): string;
  49341. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  49342. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  49343. }
  49344. }
  49345. declare module "babylonjs/Engines/nativeEngine" {
  49346. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  49347. import { Engine } from "babylonjs/Engines/engine";
  49348. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  49349. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49350. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49351. import { Effect } from "babylonjs/Materials/effect";
  49352. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  49353. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  49354. import { IColor4Like } from "babylonjs/Maths/math.like";
  49355. import { Scene } from "babylonjs/scene";
  49356. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  49357. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  49358. /**
  49359. * Container for accessors for natively-stored mesh data buffers.
  49360. */
  49361. class NativeDataBuffer extends DataBuffer {
  49362. /**
  49363. * Accessor value used to identify/retrieve a natively-stored index buffer.
  49364. */
  49365. nativeIndexBuffer?: any;
  49366. /**
  49367. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  49368. */
  49369. nativeVertexBuffer?: any;
  49370. }
  49371. /** @hidden */
  49372. class NativeTexture extends InternalTexture {
  49373. getInternalTexture(): InternalTexture;
  49374. getViewCount(): number;
  49375. }
  49376. /** @hidden */
  49377. export class NativeEngine extends Engine {
  49378. private readonly _native;
  49379. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  49380. private readonly INVALID_HANDLE;
  49381. getHardwareScalingLevel(): number;
  49382. constructor();
  49383. /**
  49384. * Can be used to override the current requestAnimationFrame requester.
  49385. * @hidden
  49386. */
  49387. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  49388. /**
  49389. * Override default engine behavior.
  49390. * @param color
  49391. * @param backBuffer
  49392. * @param depth
  49393. * @param stencil
  49394. */
  49395. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  49396. /**
  49397. * Gets host document
  49398. * @returns the host document object
  49399. */
  49400. getHostDocument(): Nullable<Document>;
  49401. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  49402. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  49403. createVertexBuffer(data: DataArray): NativeDataBuffer;
  49404. recordVertexArrayObject(vertexBuffers: {
  49405. [key: string]: VertexBuffer;
  49406. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  49407. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49408. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49409. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  49410. /**
  49411. * Draw a list of indexed primitives
  49412. * @param fillMode defines the primitive to use
  49413. * @param indexStart defines the starting index
  49414. * @param indexCount defines the number of index to draw
  49415. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49416. */
  49417. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  49418. /**
  49419. * Draw a list of unindexed primitives
  49420. * @param fillMode defines the primitive to use
  49421. * @param verticesStart defines the index of first vertex to draw
  49422. * @param verticesCount defines the count of vertices to draw
  49423. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49424. */
  49425. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  49426. createPipelineContext(): IPipelineContext;
  49427. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  49428. /** @hidden */
  49429. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  49430. /** @hidden */
  49431. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  49432. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49433. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49434. protected _setProgram(program: WebGLProgram): void;
  49435. _releaseEffect(effect: Effect): void;
  49436. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  49437. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  49438. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  49439. bindSamplers(effect: Effect): void;
  49440. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  49441. getRenderWidth(useScreen?: boolean): number;
  49442. getRenderHeight(useScreen?: boolean): number;
  49443. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  49444. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  49445. /**
  49446. * Set the z offset to apply to current rendering
  49447. * @param value defines the offset to apply
  49448. */
  49449. setZOffset(value: number): void;
  49450. /**
  49451. * Gets the current value of the zOffset
  49452. * @returns the current zOffset state
  49453. */
  49454. getZOffset(): number;
  49455. /**
  49456. * Enable or disable depth buffering
  49457. * @param enable defines the state to set
  49458. */
  49459. setDepthBuffer(enable: boolean): void;
  49460. /**
  49461. * Gets a boolean indicating if depth writing is enabled
  49462. * @returns the current depth writing state
  49463. */
  49464. getDepthWrite(): boolean;
  49465. /**
  49466. * Enable or disable depth writing
  49467. * @param enable defines the state to set
  49468. */
  49469. setDepthWrite(enable: boolean): void;
  49470. /**
  49471. * Enable or disable color writing
  49472. * @param enable defines the state to set
  49473. */
  49474. setColorWrite(enable: boolean): void;
  49475. /**
  49476. * Gets a boolean indicating if color writing is enabled
  49477. * @returns the current color writing state
  49478. */
  49479. getColorWrite(): boolean;
  49480. /**
  49481. * Sets alpha constants used by some alpha blending modes
  49482. * @param r defines the red component
  49483. * @param g defines the green component
  49484. * @param b defines the blue component
  49485. * @param a defines the alpha component
  49486. */
  49487. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  49488. /**
  49489. * Sets the current alpha mode
  49490. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  49491. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  49492. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49493. */
  49494. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  49495. /**
  49496. * Gets the current alpha mode
  49497. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49498. * @returns the current alpha mode
  49499. */
  49500. getAlphaMode(): number;
  49501. setInt(uniform: WebGLUniformLocation, int: number): void;
  49502. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  49503. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  49504. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  49505. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  49506. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  49507. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  49508. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  49509. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  49510. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  49511. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  49512. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  49513. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  49514. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  49515. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49516. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49517. setFloat(uniform: WebGLUniformLocation, value: number): void;
  49518. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  49519. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  49520. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  49521. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  49522. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  49523. wipeCaches(bruteForce?: boolean): void;
  49524. _createTexture(): WebGLTexture;
  49525. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  49526. /**
  49527. * Usually called from BABYLON.Texture.ts.
  49528. * Passed information to create a WebGLTexture
  49529. * @param urlArg defines a value which contains one of the following:
  49530. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  49531. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  49532. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  49533. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  49534. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  49535. * @param scene needed for loading to the correct scene
  49536. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  49537. * @param onLoad optional callback to be called upon successful completion
  49538. * @param onError optional callback to be called upon failure
  49539. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  49540. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  49541. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  49542. * @param forcedExtension defines the extension to use to pick the right loader
  49543. * @returns a InternalTexture for assignment back into BABYLON.Texture
  49544. */
  49545. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  49546. /**
  49547. * Creates a cube texture
  49548. * @param rootUrl defines the url where the files to load is located
  49549. * @param scene defines the current scene
  49550. * @param files defines the list of files to load (1 per face)
  49551. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  49552. * @param onLoad defines an optional callback raised when the texture is loaded
  49553. * @param onError defines an optional callback raised if there is an issue to load the texture
  49554. * @param format defines the format of the data
  49555. * @param forcedExtension defines the extension to use to pick the right loader
  49556. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  49557. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49558. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49559. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  49560. * @returns the cube texture as an InternalTexture
  49561. */
  49562. 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;
  49563. private _getSamplingFilter;
  49564. private static _GetNativeTextureFormat;
  49565. createRenderTargetTexture(size: number | {
  49566. width: number;
  49567. height: number;
  49568. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  49569. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  49570. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  49571. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  49572. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  49573. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  49574. /**
  49575. * Updates a dynamic vertex buffer.
  49576. * @param vertexBuffer the vertex buffer to update
  49577. * @param data the data used to update the vertex buffer
  49578. * @param byteOffset the byte offset of the data (optional)
  49579. * @param byteLength the byte length of the data (optional)
  49580. */
  49581. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  49582. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  49583. private _updateAnisotropicLevel;
  49584. private _getAddressMode;
  49585. /** @hidden */
  49586. _bindTexture(channel: number, texture: InternalTexture): void;
  49587. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  49588. releaseEffects(): void;
  49589. /** @hidden */
  49590. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49591. /** @hidden */
  49592. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49593. /** @hidden */
  49594. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49595. /** @hidden */
  49596. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  49597. }
  49598. }
  49599. declare module "babylonjs/Engines/index" {
  49600. export * from "babylonjs/Engines/constants";
  49601. export * from "babylonjs/Engines/engineCapabilities";
  49602. export * from "babylonjs/Engines/instancingAttributeInfo";
  49603. export * from "babylonjs/Engines/thinEngine";
  49604. export * from "babylonjs/Engines/engine";
  49605. export * from "babylonjs/Engines/engineStore";
  49606. export * from "babylonjs/Engines/nullEngine";
  49607. export * from "babylonjs/Engines/Extensions/index";
  49608. export * from "babylonjs/Engines/IPipelineContext";
  49609. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  49610. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49611. export * from "babylonjs/Engines/nativeEngine";
  49612. }
  49613. declare module "babylonjs/Events/clipboardEvents" {
  49614. /**
  49615. * Gather the list of clipboard event types as constants.
  49616. */
  49617. export class ClipboardEventTypes {
  49618. /**
  49619. * The clipboard event is fired when a copy command is active (pressed).
  49620. */
  49621. static readonly COPY: number;
  49622. /**
  49623. * The clipboard event is fired when a cut command is active (pressed).
  49624. */
  49625. static readonly CUT: number;
  49626. /**
  49627. * The clipboard event is fired when a paste command is active (pressed).
  49628. */
  49629. static readonly PASTE: number;
  49630. }
  49631. /**
  49632. * This class is used to store clipboard related info for the onClipboardObservable event.
  49633. */
  49634. export class ClipboardInfo {
  49635. /**
  49636. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49637. */
  49638. type: number;
  49639. /**
  49640. * Defines the related dom event
  49641. */
  49642. event: ClipboardEvent;
  49643. /**
  49644. *Creates an instance of ClipboardInfo.
  49645. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  49646. * @param event Defines the related dom event
  49647. */
  49648. constructor(
  49649. /**
  49650. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49651. */
  49652. type: number,
  49653. /**
  49654. * Defines the related dom event
  49655. */
  49656. event: ClipboardEvent);
  49657. /**
  49658. * Get the clipboard event's type from the keycode.
  49659. * @param keyCode Defines the keyCode for the current keyboard event.
  49660. * @return {number}
  49661. */
  49662. static GetTypeFromCharacter(keyCode: number): number;
  49663. }
  49664. }
  49665. declare module "babylonjs/Events/index" {
  49666. export * from "babylonjs/Events/keyboardEvents";
  49667. export * from "babylonjs/Events/pointerEvents";
  49668. export * from "babylonjs/Events/clipboardEvents";
  49669. }
  49670. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  49671. import { Scene } from "babylonjs/scene";
  49672. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49673. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49674. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49675. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49676. /**
  49677. * Google Daydream controller
  49678. */
  49679. export class DaydreamController extends WebVRController {
  49680. /**
  49681. * Base Url for the controller model.
  49682. */
  49683. static MODEL_BASE_URL: string;
  49684. /**
  49685. * File name for the controller model.
  49686. */
  49687. static MODEL_FILENAME: string;
  49688. /**
  49689. * Gamepad Id prefix used to identify Daydream Controller.
  49690. */
  49691. static readonly GAMEPAD_ID_PREFIX: string;
  49692. /**
  49693. * Creates a new DaydreamController from a gamepad
  49694. * @param vrGamepad the gamepad that the controller should be created from
  49695. */
  49696. constructor(vrGamepad: any);
  49697. /**
  49698. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49699. * @param scene scene in which to add meshes
  49700. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49701. */
  49702. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49703. /**
  49704. * Called once for each button that changed state since the last frame
  49705. * @param buttonIdx Which button index changed
  49706. * @param state New state of the button
  49707. * @param changes Which properties on the state changed since last frame
  49708. */
  49709. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49710. }
  49711. }
  49712. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  49713. import { Scene } from "babylonjs/scene";
  49714. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49715. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49716. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49717. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49718. /**
  49719. * Gear VR Controller
  49720. */
  49721. export class GearVRController extends WebVRController {
  49722. /**
  49723. * Base Url for the controller model.
  49724. */
  49725. static MODEL_BASE_URL: string;
  49726. /**
  49727. * File name for the controller model.
  49728. */
  49729. static MODEL_FILENAME: string;
  49730. /**
  49731. * Gamepad Id prefix used to identify this controller.
  49732. */
  49733. static readonly GAMEPAD_ID_PREFIX: string;
  49734. private readonly _buttonIndexToObservableNameMap;
  49735. /**
  49736. * Creates a new GearVRController from a gamepad
  49737. * @param vrGamepad the gamepad that the controller should be created from
  49738. */
  49739. constructor(vrGamepad: any);
  49740. /**
  49741. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49742. * @param scene scene in which to add meshes
  49743. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49744. */
  49745. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49746. /**
  49747. * Called once for each button that changed state since the last frame
  49748. * @param buttonIdx Which button index changed
  49749. * @param state New state of the button
  49750. * @param changes Which properties on the state changed since last frame
  49751. */
  49752. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49753. }
  49754. }
  49755. declare module "babylonjs/Gamepads/Controllers/genericController" {
  49756. import { Scene } from "babylonjs/scene";
  49757. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49758. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49759. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49760. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49761. /**
  49762. * Generic Controller
  49763. */
  49764. export class GenericController extends WebVRController {
  49765. /**
  49766. * Base Url for the controller model.
  49767. */
  49768. static readonly MODEL_BASE_URL: string;
  49769. /**
  49770. * File name for the controller model.
  49771. */
  49772. static readonly MODEL_FILENAME: string;
  49773. /**
  49774. * Creates a new GenericController from a gamepad
  49775. * @param vrGamepad the gamepad that the controller should be created from
  49776. */
  49777. constructor(vrGamepad: any);
  49778. /**
  49779. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49780. * @param scene scene in which to add meshes
  49781. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49782. */
  49783. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49784. /**
  49785. * Called once for each button that changed state since the last frame
  49786. * @param buttonIdx Which button index changed
  49787. * @param state New state of the button
  49788. * @param changes Which properties on the state changed since last frame
  49789. */
  49790. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49791. }
  49792. }
  49793. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  49794. import { Observable } from "babylonjs/Misc/observable";
  49795. import { Scene } from "babylonjs/scene";
  49796. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49797. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49798. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49799. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49800. /**
  49801. * Oculus Touch Controller
  49802. */
  49803. export class OculusTouchController extends WebVRController {
  49804. /**
  49805. * Base Url for the controller model.
  49806. */
  49807. static MODEL_BASE_URL: string;
  49808. /**
  49809. * File name for the left controller model.
  49810. */
  49811. static MODEL_LEFT_FILENAME: string;
  49812. /**
  49813. * File name for the right controller model.
  49814. */
  49815. static MODEL_RIGHT_FILENAME: string;
  49816. /**
  49817. * Base Url for the Quest controller model.
  49818. */
  49819. static QUEST_MODEL_BASE_URL: string;
  49820. /**
  49821. * @hidden
  49822. * If the controllers are running on a device that needs the updated Quest controller models
  49823. */
  49824. static _IsQuest: boolean;
  49825. /**
  49826. * Fired when the secondary trigger on this controller is modified
  49827. */
  49828. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  49829. /**
  49830. * Fired when the thumb rest on this controller is modified
  49831. */
  49832. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  49833. /**
  49834. * Creates a new OculusTouchController from a gamepad
  49835. * @param vrGamepad the gamepad that the controller should be created from
  49836. */
  49837. constructor(vrGamepad: any);
  49838. /**
  49839. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49840. * @param scene scene in which to add meshes
  49841. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49842. */
  49843. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49844. /**
  49845. * Fired when the A button on this controller is modified
  49846. */
  49847. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49848. /**
  49849. * Fired when the B button on this controller is modified
  49850. */
  49851. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49852. /**
  49853. * Fired when the X button on this controller is modified
  49854. */
  49855. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49856. /**
  49857. * Fired when the Y button on this controller is modified
  49858. */
  49859. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49860. /**
  49861. * Called once for each button that changed state since the last frame
  49862. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  49863. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  49864. * 2) secondary trigger (same)
  49865. * 3) A (right) X (left), touch, pressed = value
  49866. * 4) B / Y
  49867. * 5) thumb rest
  49868. * @param buttonIdx Which button index changed
  49869. * @param state New state of the button
  49870. * @param changes Which properties on the state changed since last frame
  49871. */
  49872. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49873. }
  49874. }
  49875. declare module "babylonjs/Gamepads/Controllers/viveController" {
  49876. import { Scene } from "babylonjs/scene";
  49877. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49878. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49879. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49880. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49881. import { Observable } from "babylonjs/Misc/observable";
  49882. /**
  49883. * Vive Controller
  49884. */
  49885. export class ViveController extends WebVRController {
  49886. /**
  49887. * Base Url for the controller model.
  49888. */
  49889. static MODEL_BASE_URL: string;
  49890. /**
  49891. * File name for the controller model.
  49892. */
  49893. static MODEL_FILENAME: string;
  49894. /**
  49895. * Creates a new ViveController from a gamepad
  49896. * @param vrGamepad the gamepad that the controller should be created from
  49897. */
  49898. constructor(vrGamepad: any);
  49899. /**
  49900. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49901. * @param scene scene in which to add meshes
  49902. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49903. */
  49904. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49905. /**
  49906. * Fired when the left button on this controller is modified
  49907. */
  49908. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49909. /**
  49910. * Fired when the right button on this controller is modified
  49911. */
  49912. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49913. /**
  49914. * Fired when the menu button on this controller is modified
  49915. */
  49916. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49917. /**
  49918. * Called once for each button that changed state since the last frame
  49919. * Vive mapping:
  49920. * 0: touchpad
  49921. * 1: trigger
  49922. * 2: left AND right buttons
  49923. * 3: menu button
  49924. * @param buttonIdx Which button index changed
  49925. * @param state New state of the button
  49926. * @param changes Which properties on the state changed since last frame
  49927. */
  49928. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49929. }
  49930. }
  49931. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  49932. import { Observable } from "babylonjs/Misc/observable";
  49933. import { Scene } from "babylonjs/scene";
  49934. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49935. import { Ray } from "babylonjs/Culling/ray";
  49936. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49937. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49938. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49939. /**
  49940. * Defines the WindowsMotionController object that the state of the windows motion controller
  49941. */
  49942. export class WindowsMotionController extends WebVRController {
  49943. /**
  49944. * The base url used to load the left and right controller models
  49945. */
  49946. static MODEL_BASE_URL: string;
  49947. /**
  49948. * The name of the left controller model file
  49949. */
  49950. static MODEL_LEFT_FILENAME: string;
  49951. /**
  49952. * The name of the right controller model file
  49953. */
  49954. static MODEL_RIGHT_FILENAME: string;
  49955. /**
  49956. * The controller name prefix for this controller type
  49957. */
  49958. static readonly GAMEPAD_ID_PREFIX: string;
  49959. /**
  49960. * The controller id pattern for this controller type
  49961. */
  49962. private static readonly GAMEPAD_ID_PATTERN;
  49963. private _loadedMeshInfo;
  49964. protected readonly _mapping: {
  49965. buttons: string[];
  49966. buttonMeshNames: {
  49967. 'trigger': string;
  49968. 'menu': string;
  49969. 'grip': string;
  49970. 'thumbstick': string;
  49971. 'trackpad': string;
  49972. };
  49973. buttonObservableNames: {
  49974. 'trigger': string;
  49975. 'menu': string;
  49976. 'grip': string;
  49977. 'thumbstick': string;
  49978. 'trackpad': string;
  49979. };
  49980. axisMeshNames: string[];
  49981. pointingPoseMeshName: string;
  49982. };
  49983. /**
  49984. * Fired when the trackpad on this controller is clicked
  49985. */
  49986. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  49987. /**
  49988. * Fired when the trackpad on this controller is modified
  49989. */
  49990. onTrackpadValuesChangedObservable: Observable<StickValues>;
  49991. /**
  49992. * The current x and y values of this controller's trackpad
  49993. */
  49994. trackpad: StickValues;
  49995. /**
  49996. * Creates a new WindowsMotionController from a gamepad
  49997. * @param vrGamepad the gamepad that the controller should be created from
  49998. */
  49999. constructor(vrGamepad: any);
  50000. /**
  50001. * Fired when the trigger on this controller is modified
  50002. */
  50003. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50004. /**
  50005. * Fired when the menu button on this controller is modified
  50006. */
  50007. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50008. /**
  50009. * Fired when the grip button on this controller is modified
  50010. */
  50011. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50012. /**
  50013. * Fired when the thumbstick button on this controller is modified
  50014. */
  50015. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50016. /**
  50017. * Fired when the touchpad button on this controller is modified
  50018. */
  50019. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50020. /**
  50021. * Fired when the touchpad values on this controller are modified
  50022. */
  50023. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  50024. protected _updateTrackpad(): void;
  50025. /**
  50026. * Called once per frame by the engine.
  50027. */
  50028. update(): void;
  50029. /**
  50030. * Called once for each button that changed state since the last frame
  50031. * @param buttonIdx Which button index changed
  50032. * @param state New state of the button
  50033. * @param changes Which properties on the state changed since last frame
  50034. */
  50035. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50036. /**
  50037. * Moves the buttons on the controller mesh based on their current state
  50038. * @param buttonName the name of the button to move
  50039. * @param buttonValue the value of the button which determines the buttons new position
  50040. */
  50041. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  50042. /**
  50043. * Moves the axis on the controller mesh based on its current state
  50044. * @param axis the index of the axis
  50045. * @param axisValue the value of the axis which determines the meshes new position
  50046. * @hidden
  50047. */
  50048. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  50049. /**
  50050. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50051. * @param scene scene in which to add meshes
  50052. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50053. */
  50054. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  50055. /**
  50056. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  50057. * can be transformed by button presses and axes values, based on this._mapping.
  50058. *
  50059. * @param scene scene in which the meshes exist
  50060. * @param meshes list of meshes that make up the controller model to process
  50061. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  50062. */
  50063. private processModel;
  50064. private createMeshInfo;
  50065. /**
  50066. * Gets the ray of the controller in the direction the controller is pointing
  50067. * @param length the length the resulting ray should be
  50068. * @returns a ray in the direction the controller is pointing
  50069. */
  50070. getForwardRay(length?: number): Ray;
  50071. /**
  50072. * Disposes of the controller
  50073. */
  50074. dispose(): void;
  50075. }
  50076. /**
  50077. * This class represents a new windows motion controller in XR.
  50078. */
  50079. export class XRWindowsMotionController extends WindowsMotionController {
  50080. /**
  50081. * Changing the original WIndowsMotionController mapping to fir the new mapping
  50082. */
  50083. protected readonly _mapping: {
  50084. buttons: string[];
  50085. buttonMeshNames: {
  50086. 'trigger': string;
  50087. 'menu': string;
  50088. 'grip': string;
  50089. 'thumbstick': string;
  50090. 'trackpad': string;
  50091. };
  50092. buttonObservableNames: {
  50093. 'trigger': string;
  50094. 'menu': string;
  50095. 'grip': string;
  50096. 'thumbstick': string;
  50097. 'trackpad': string;
  50098. };
  50099. axisMeshNames: string[];
  50100. pointingPoseMeshName: string;
  50101. };
  50102. /**
  50103. * Construct a new XR-Based windows motion controller
  50104. *
  50105. * @param gamepadInfo the gamepad object from the browser
  50106. */
  50107. constructor(gamepadInfo: any);
  50108. /**
  50109. * holds the thumbstick values (X,Y)
  50110. */
  50111. thumbstickValues: StickValues;
  50112. /**
  50113. * Fired when the thumbstick on this controller is clicked
  50114. */
  50115. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  50116. /**
  50117. * Fired when the thumbstick on this controller is modified
  50118. */
  50119. onThumbstickValuesChangedObservable: Observable<StickValues>;
  50120. /**
  50121. * Fired when the touchpad button on this controller is modified
  50122. */
  50123. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50124. /**
  50125. * Fired when the touchpad values on this controller are modified
  50126. */
  50127. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50128. /**
  50129. * Fired when the thumbstick button on this controller is modified
  50130. * here to prevent breaking changes
  50131. */
  50132. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50133. /**
  50134. * updating the thumbstick(!) and not the trackpad.
  50135. * This is named this way due to the difference between WebVR and XR and to avoid
  50136. * changing the parent class.
  50137. */
  50138. protected _updateTrackpad(): void;
  50139. /**
  50140. * Disposes the class with joy
  50141. */
  50142. dispose(): void;
  50143. }
  50144. }
  50145. declare module "babylonjs/Gamepads/Controllers/index" {
  50146. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  50147. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  50148. export * from "babylonjs/Gamepads/Controllers/genericController";
  50149. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  50150. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50151. export * from "babylonjs/Gamepads/Controllers/viveController";
  50152. export * from "babylonjs/Gamepads/Controllers/webVRController";
  50153. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  50154. }
  50155. declare module "babylonjs/Gamepads/index" {
  50156. export * from "babylonjs/Gamepads/Controllers/index";
  50157. export * from "babylonjs/Gamepads/gamepad";
  50158. export * from "babylonjs/Gamepads/gamepadManager";
  50159. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  50160. export * from "babylonjs/Gamepads/xboxGamepad";
  50161. export * from "babylonjs/Gamepads/dualShockGamepad";
  50162. }
  50163. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  50164. import { Scene } from "babylonjs/scene";
  50165. import { Vector4 } from "babylonjs/Maths/math.vector";
  50166. import { Color4 } from "babylonjs/Maths/math.color";
  50167. import { Mesh } from "babylonjs/Meshes/mesh";
  50168. import { Nullable } from "babylonjs/types";
  50169. /**
  50170. * Class containing static functions to help procedurally build meshes
  50171. */
  50172. export class PolyhedronBuilder {
  50173. /**
  50174. * Creates a polyhedron mesh
  50175. * * 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
  50176. * * The parameter `size` (positive float, default 1) sets the polygon size
  50177. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  50178. * * 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`
  50179. * * 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
  50180. * * 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)`)
  50181. * * 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
  50182. * * 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
  50183. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50184. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50185. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50186. * @param name defines the name of the mesh
  50187. * @param options defines the options used to create the mesh
  50188. * @param scene defines the hosting scene
  50189. * @returns the polyhedron mesh
  50190. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  50191. */
  50192. static CreatePolyhedron(name: string, options: {
  50193. type?: number;
  50194. size?: number;
  50195. sizeX?: number;
  50196. sizeY?: number;
  50197. sizeZ?: number;
  50198. custom?: any;
  50199. faceUV?: Vector4[];
  50200. faceColors?: Color4[];
  50201. flat?: boolean;
  50202. updatable?: boolean;
  50203. sideOrientation?: number;
  50204. frontUVs?: Vector4;
  50205. backUVs?: Vector4;
  50206. }, scene?: Nullable<Scene>): Mesh;
  50207. }
  50208. }
  50209. declare module "babylonjs/Gizmos/scaleGizmo" {
  50210. import { Observable } from "babylonjs/Misc/observable";
  50211. import { Nullable } from "babylonjs/types";
  50212. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50213. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50214. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  50215. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50216. /**
  50217. * Gizmo that enables scaling a mesh along 3 axis
  50218. */
  50219. export class ScaleGizmo extends Gizmo {
  50220. /**
  50221. * Internal gizmo used for interactions on the x axis
  50222. */
  50223. xGizmo: AxisScaleGizmo;
  50224. /**
  50225. * Internal gizmo used for interactions on the y axis
  50226. */
  50227. yGizmo: AxisScaleGizmo;
  50228. /**
  50229. * Internal gizmo used for interactions on the z axis
  50230. */
  50231. zGizmo: AxisScaleGizmo;
  50232. /**
  50233. * Internal gizmo used to scale all axis equally
  50234. */
  50235. uniformScaleGizmo: AxisScaleGizmo;
  50236. private _meshAttached;
  50237. private _updateGizmoRotationToMatchAttachedMesh;
  50238. private _snapDistance;
  50239. private _scaleRatio;
  50240. private _uniformScalingMesh;
  50241. private _octahedron;
  50242. private _sensitivity;
  50243. /** Fires an event when any of it's sub gizmos are dragged */
  50244. onDragStartObservable: Observable<unknown>;
  50245. /** Fires an event when any of it's sub gizmos are released from dragging */
  50246. onDragEndObservable: Observable<unknown>;
  50247. get attachedMesh(): Nullable<AbstractMesh>;
  50248. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50249. /**
  50250. * Creates a ScaleGizmo
  50251. * @param gizmoLayer The utility layer the gizmo will be added to
  50252. */
  50253. constructor(gizmoLayer?: UtilityLayerRenderer);
  50254. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50255. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50256. /**
  50257. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50258. */
  50259. set snapDistance(value: number);
  50260. get snapDistance(): number;
  50261. /**
  50262. * Ratio for the scale of the gizmo (Default: 1)
  50263. */
  50264. set scaleRatio(value: number);
  50265. get scaleRatio(): number;
  50266. /**
  50267. * Sensitivity factor for dragging (Default: 1)
  50268. */
  50269. set sensitivity(value: number);
  50270. get sensitivity(): number;
  50271. /**
  50272. * Disposes of the gizmo
  50273. */
  50274. dispose(): void;
  50275. }
  50276. }
  50277. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  50278. import { Observable } from "babylonjs/Misc/observable";
  50279. import { Nullable } from "babylonjs/types";
  50280. import { Vector3 } from "babylonjs/Maths/math.vector";
  50281. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50282. import { Mesh } from "babylonjs/Meshes/mesh";
  50283. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50284. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50285. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50286. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50287. import { Color3 } from "babylonjs/Maths/math.color";
  50288. /**
  50289. * Single axis scale gizmo
  50290. */
  50291. export class AxisScaleGizmo extends Gizmo {
  50292. /**
  50293. * Drag behavior responsible for the gizmos dragging interactions
  50294. */
  50295. dragBehavior: PointerDragBehavior;
  50296. private _pointerObserver;
  50297. /**
  50298. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50299. */
  50300. snapDistance: number;
  50301. /**
  50302. * Event that fires each time the gizmo snaps to a new location.
  50303. * * snapDistance is the the change in distance
  50304. */
  50305. onSnapObservable: Observable<{
  50306. snapDistance: number;
  50307. }>;
  50308. /**
  50309. * If the scaling operation should be done on all axis (default: false)
  50310. */
  50311. uniformScaling: boolean;
  50312. /**
  50313. * Custom sensitivity value for the drag strength
  50314. */
  50315. sensitivity: number;
  50316. private _isEnabled;
  50317. private _parent;
  50318. private _arrow;
  50319. private _coloredMaterial;
  50320. private _hoverMaterial;
  50321. /**
  50322. * Creates an AxisScaleGizmo
  50323. * @param gizmoLayer The utility layer the gizmo will be added to
  50324. * @param dragAxis The axis which the gizmo will be able to scale on
  50325. * @param color The color of the gizmo
  50326. */
  50327. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  50328. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50329. /**
  50330. * If the gizmo is enabled
  50331. */
  50332. set isEnabled(value: boolean);
  50333. get isEnabled(): boolean;
  50334. /**
  50335. * Disposes of the gizmo
  50336. */
  50337. dispose(): void;
  50338. /**
  50339. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50340. * @param mesh The mesh to replace the default mesh of the gizmo
  50341. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  50342. */
  50343. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  50344. }
  50345. }
  50346. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  50347. import { Observable } from "babylonjs/Misc/observable";
  50348. import { Nullable } from "babylonjs/types";
  50349. import { Vector3 } from "babylonjs/Maths/math.vector";
  50350. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50351. import { Mesh } from "babylonjs/Meshes/mesh";
  50352. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50353. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50354. import { Color3 } from "babylonjs/Maths/math.color";
  50355. import "babylonjs/Meshes/Builders/boxBuilder";
  50356. /**
  50357. * Bounding box gizmo
  50358. */
  50359. export class BoundingBoxGizmo extends Gizmo {
  50360. private _lineBoundingBox;
  50361. private _rotateSpheresParent;
  50362. private _scaleBoxesParent;
  50363. private _boundingDimensions;
  50364. private _renderObserver;
  50365. private _pointerObserver;
  50366. private _scaleDragSpeed;
  50367. private _tmpQuaternion;
  50368. private _tmpVector;
  50369. private _tmpRotationMatrix;
  50370. /**
  50371. * 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)
  50372. */
  50373. ignoreChildren: boolean;
  50374. /**
  50375. * 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)
  50376. */
  50377. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  50378. /**
  50379. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  50380. */
  50381. rotationSphereSize: number;
  50382. /**
  50383. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  50384. */
  50385. scaleBoxSize: number;
  50386. /**
  50387. * 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)
  50388. */
  50389. fixedDragMeshScreenSize: boolean;
  50390. /**
  50391. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  50392. */
  50393. fixedDragMeshScreenSizeDistanceFactor: number;
  50394. /**
  50395. * Fired when a rotation sphere or scale box is dragged
  50396. */
  50397. onDragStartObservable: Observable<{}>;
  50398. /**
  50399. * Fired when a scale box is dragged
  50400. */
  50401. onScaleBoxDragObservable: Observable<{}>;
  50402. /**
  50403. * Fired when a scale box drag is ended
  50404. */
  50405. onScaleBoxDragEndObservable: Observable<{}>;
  50406. /**
  50407. * Fired when a rotation sphere is dragged
  50408. */
  50409. onRotationSphereDragObservable: Observable<{}>;
  50410. /**
  50411. * Fired when a rotation sphere drag is ended
  50412. */
  50413. onRotationSphereDragEndObservable: Observable<{}>;
  50414. /**
  50415. * 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)
  50416. */
  50417. scalePivot: Nullable<Vector3>;
  50418. /**
  50419. * Mesh used as a pivot to rotate the attached mesh
  50420. */
  50421. private _anchorMesh;
  50422. private _existingMeshScale;
  50423. private _dragMesh;
  50424. private pointerDragBehavior;
  50425. private coloredMaterial;
  50426. private hoverColoredMaterial;
  50427. /**
  50428. * Sets the color of the bounding box gizmo
  50429. * @param color the color to set
  50430. */
  50431. setColor(color: Color3): void;
  50432. /**
  50433. * Creates an BoundingBoxGizmo
  50434. * @param gizmoLayer The utility layer the gizmo will be added to
  50435. * @param color The color of the gizmo
  50436. */
  50437. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  50438. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50439. private _selectNode;
  50440. /**
  50441. * Updates the bounding box information for the Gizmo
  50442. */
  50443. updateBoundingBox(): void;
  50444. private _updateRotationSpheres;
  50445. private _updateScaleBoxes;
  50446. /**
  50447. * Enables rotation on the specified axis and disables rotation on the others
  50448. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  50449. */
  50450. setEnabledRotationAxis(axis: string): void;
  50451. /**
  50452. * Enables/disables scaling
  50453. * @param enable if scaling should be enabled
  50454. */
  50455. setEnabledScaling(enable: boolean): void;
  50456. private _updateDummy;
  50457. /**
  50458. * Enables a pointer drag behavior on the bounding box of the gizmo
  50459. */
  50460. enableDragBehavior(): void;
  50461. /**
  50462. * Disposes of the gizmo
  50463. */
  50464. dispose(): void;
  50465. /**
  50466. * 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)
  50467. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  50468. * @returns the bounding box mesh with the passed in mesh as a child
  50469. */
  50470. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  50471. /**
  50472. * CustomMeshes are not supported by this gizmo
  50473. * @param mesh The mesh to replace the default mesh of the gizmo
  50474. */
  50475. setCustomMesh(mesh: Mesh): void;
  50476. }
  50477. }
  50478. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  50479. import { Observable } from "babylonjs/Misc/observable";
  50480. import { Nullable } from "babylonjs/types";
  50481. import { Vector3 } from "babylonjs/Maths/math.vector";
  50482. import { Color3 } from "babylonjs/Maths/math.color";
  50483. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50484. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50485. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50486. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50487. import "babylonjs/Meshes/Builders/linesBuilder";
  50488. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  50489. /**
  50490. * Single plane rotation gizmo
  50491. */
  50492. export class PlaneRotationGizmo extends Gizmo {
  50493. /**
  50494. * Drag behavior responsible for the gizmos dragging interactions
  50495. */
  50496. dragBehavior: PointerDragBehavior;
  50497. private _pointerObserver;
  50498. /**
  50499. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  50500. */
  50501. snapDistance: number;
  50502. /**
  50503. * Event that fires each time the gizmo snaps to a new location.
  50504. * * snapDistance is the the change in distance
  50505. */
  50506. onSnapObservable: Observable<{
  50507. snapDistance: number;
  50508. }>;
  50509. private _isEnabled;
  50510. private _parent;
  50511. /**
  50512. * Creates a PlaneRotationGizmo
  50513. * @param gizmoLayer The utility layer the gizmo will be added to
  50514. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  50515. * @param color The color of the gizmo
  50516. * @param tessellation Amount of tessellation to be used when creating rotation circles
  50517. * @param useEulerRotation Use and update Euler angle instead of quaternion
  50518. */
  50519. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  50520. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50521. /**
  50522. * If the gizmo is enabled
  50523. */
  50524. set isEnabled(value: boolean);
  50525. get isEnabled(): boolean;
  50526. /**
  50527. * Disposes of the gizmo
  50528. */
  50529. dispose(): void;
  50530. }
  50531. }
  50532. declare module "babylonjs/Gizmos/rotationGizmo" {
  50533. import { Observable } from "babylonjs/Misc/observable";
  50534. import { Nullable } from "babylonjs/types";
  50535. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50536. import { Mesh } from "babylonjs/Meshes/mesh";
  50537. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50538. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  50539. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50540. /**
  50541. * Gizmo that enables rotating a mesh along 3 axis
  50542. */
  50543. export class RotationGizmo extends Gizmo {
  50544. /**
  50545. * Internal gizmo used for interactions on the x axis
  50546. */
  50547. xGizmo: PlaneRotationGizmo;
  50548. /**
  50549. * Internal gizmo used for interactions on the y axis
  50550. */
  50551. yGizmo: PlaneRotationGizmo;
  50552. /**
  50553. * Internal gizmo used for interactions on the z axis
  50554. */
  50555. zGizmo: PlaneRotationGizmo;
  50556. /** Fires an event when any of it's sub gizmos are dragged */
  50557. onDragStartObservable: Observable<unknown>;
  50558. /** Fires an event when any of it's sub gizmos are released from dragging */
  50559. onDragEndObservable: Observable<unknown>;
  50560. private _meshAttached;
  50561. get attachedMesh(): Nullable<AbstractMesh>;
  50562. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50563. /**
  50564. * Creates a RotationGizmo
  50565. * @param gizmoLayer The utility layer the gizmo will be added to
  50566. * @param tessellation Amount of tessellation to be used when creating rotation circles
  50567. * @param useEulerRotation Use and update Euler angle instead of quaternion
  50568. */
  50569. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  50570. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50571. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50572. /**
  50573. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50574. */
  50575. set snapDistance(value: number);
  50576. get snapDistance(): number;
  50577. /**
  50578. * Ratio for the scale of the gizmo (Default: 1)
  50579. */
  50580. set scaleRatio(value: number);
  50581. get scaleRatio(): number;
  50582. /**
  50583. * Disposes of the gizmo
  50584. */
  50585. dispose(): void;
  50586. /**
  50587. * CustomMeshes are not supported by this gizmo
  50588. * @param mesh The mesh to replace the default mesh of the gizmo
  50589. */
  50590. setCustomMesh(mesh: Mesh): void;
  50591. }
  50592. }
  50593. declare module "babylonjs/Gizmos/gizmoManager" {
  50594. import { Observable } from "babylonjs/Misc/observable";
  50595. import { Nullable } from "babylonjs/types";
  50596. import { Scene, IDisposable } from "babylonjs/scene";
  50597. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50598. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50599. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  50600. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  50601. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  50602. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50603. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  50604. /**
  50605. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  50606. */
  50607. export class GizmoManager implements IDisposable {
  50608. private scene;
  50609. /**
  50610. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  50611. */
  50612. gizmos: {
  50613. positionGizmo: Nullable<PositionGizmo>;
  50614. rotationGizmo: Nullable<RotationGizmo>;
  50615. scaleGizmo: Nullable<ScaleGizmo>;
  50616. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  50617. };
  50618. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  50619. clearGizmoOnEmptyPointerEvent: boolean;
  50620. /** Fires an event when the manager is attached to a mesh */
  50621. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  50622. private _gizmosEnabled;
  50623. private _pointerObserver;
  50624. private _attachedMesh;
  50625. private _boundingBoxColor;
  50626. private _defaultUtilityLayer;
  50627. private _defaultKeepDepthUtilityLayer;
  50628. /**
  50629. * When bounding box gizmo is enabled, this can be used to track drag/end events
  50630. */
  50631. boundingBoxDragBehavior: SixDofDragBehavior;
  50632. /**
  50633. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  50634. */
  50635. attachableMeshes: Nullable<Array<AbstractMesh>>;
  50636. /**
  50637. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  50638. */
  50639. usePointerToAttachGizmos: boolean;
  50640. /**
  50641. * Utility layer that the bounding box gizmo belongs to
  50642. */
  50643. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  50644. /**
  50645. * Utility layer that all gizmos besides bounding box belong to
  50646. */
  50647. get utilityLayer(): UtilityLayerRenderer;
  50648. /**
  50649. * Instatiates a gizmo manager
  50650. * @param scene the scene to overlay the gizmos on top of
  50651. */
  50652. constructor(scene: Scene);
  50653. /**
  50654. * Attaches a set of gizmos to the specified mesh
  50655. * @param mesh The mesh the gizmo's should be attached to
  50656. */
  50657. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  50658. /**
  50659. * If the position gizmo is enabled
  50660. */
  50661. set positionGizmoEnabled(value: boolean);
  50662. get positionGizmoEnabled(): boolean;
  50663. /**
  50664. * If the rotation gizmo is enabled
  50665. */
  50666. set rotationGizmoEnabled(value: boolean);
  50667. get rotationGizmoEnabled(): boolean;
  50668. /**
  50669. * If the scale gizmo is enabled
  50670. */
  50671. set scaleGizmoEnabled(value: boolean);
  50672. get scaleGizmoEnabled(): boolean;
  50673. /**
  50674. * If the boundingBox gizmo is enabled
  50675. */
  50676. set boundingBoxGizmoEnabled(value: boolean);
  50677. get boundingBoxGizmoEnabled(): boolean;
  50678. /**
  50679. * Disposes of the gizmo manager
  50680. */
  50681. dispose(): void;
  50682. }
  50683. }
  50684. declare module "babylonjs/Lights/directionalLight" {
  50685. import { Camera } from "babylonjs/Cameras/camera";
  50686. import { Scene } from "babylonjs/scene";
  50687. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  50688. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50689. import { Light } from "babylonjs/Lights/light";
  50690. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50691. import { Effect } from "babylonjs/Materials/effect";
  50692. /**
  50693. * A directional light is defined by a direction (what a surprise!).
  50694. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  50695. * 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.
  50696. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50697. */
  50698. export class DirectionalLight extends ShadowLight {
  50699. private _shadowFrustumSize;
  50700. /**
  50701. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  50702. */
  50703. get shadowFrustumSize(): number;
  50704. /**
  50705. * Specifies a fix frustum size for the shadow generation.
  50706. */
  50707. set shadowFrustumSize(value: number);
  50708. private _shadowOrthoScale;
  50709. /**
  50710. * Gets the shadow projection scale against the optimal computed one.
  50711. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  50712. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  50713. */
  50714. get shadowOrthoScale(): number;
  50715. /**
  50716. * Sets the shadow projection scale against the optimal computed one.
  50717. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  50718. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  50719. */
  50720. set shadowOrthoScale(value: number);
  50721. /**
  50722. * Automatically compute the projection matrix to best fit (including all the casters)
  50723. * on each frame.
  50724. */
  50725. autoUpdateExtends: boolean;
  50726. /**
  50727. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  50728. * on each frame. autoUpdateExtends must be set to true for this to work
  50729. */
  50730. autoCalcShadowZBounds: boolean;
  50731. private _orthoLeft;
  50732. private _orthoRight;
  50733. private _orthoTop;
  50734. private _orthoBottom;
  50735. /**
  50736. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  50737. * The directional light is emitted from everywhere in the given direction.
  50738. * It can cast shadows.
  50739. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50740. * @param name The friendly name of the light
  50741. * @param direction The direction of the light
  50742. * @param scene The scene the light belongs to
  50743. */
  50744. constructor(name: string, direction: Vector3, scene: Scene);
  50745. /**
  50746. * Returns the string "DirectionalLight".
  50747. * @return The class name
  50748. */
  50749. getClassName(): string;
  50750. /**
  50751. * Returns the integer 1.
  50752. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50753. */
  50754. getTypeID(): number;
  50755. /**
  50756. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  50757. * Returns the DirectionalLight Shadow projection matrix.
  50758. */
  50759. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50760. /**
  50761. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  50762. * Returns the DirectionalLight Shadow projection matrix.
  50763. */
  50764. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  50765. /**
  50766. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  50767. * Returns the DirectionalLight Shadow projection matrix.
  50768. */
  50769. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50770. protected _buildUniformLayout(): void;
  50771. /**
  50772. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  50773. * @param effect The effect to update
  50774. * @param lightIndex The index of the light in the effect to update
  50775. * @returns The directional light
  50776. */
  50777. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  50778. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  50779. /**
  50780. * Gets the minZ used for shadow according to both the scene and the light.
  50781. *
  50782. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  50783. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  50784. * @param activeCamera The camera we are returning the min for
  50785. * @returns the depth min z
  50786. */
  50787. getDepthMinZ(activeCamera: Camera): number;
  50788. /**
  50789. * Gets the maxZ used for shadow according to both the scene and the light.
  50790. *
  50791. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  50792. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  50793. * @param activeCamera The camera we are returning the max for
  50794. * @returns the depth max z
  50795. */
  50796. getDepthMaxZ(activeCamera: Camera): number;
  50797. /**
  50798. * Prepares the list of defines specific to the light type.
  50799. * @param defines the list of defines
  50800. * @param lightIndex defines the index of the light for the effect
  50801. */
  50802. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50803. }
  50804. }
  50805. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  50806. import { Mesh } from "babylonjs/Meshes/mesh";
  50807. /**
  50808. * Class containing static functions to help procedurally build meshes
  50809. */
  50810. export class HemisphereBuilder {
  50811. /**
  50812. * Creates a hemisphere mesh
  50813. * @param name defines the name of the mesh
  50814. * @param options defines the options used to create the mesh
  50815. * @param scene defines the hosting scene
  50816. * @returns the hemisphere mesh
  50817. */
  50818. static CreateHemisphere(name: string, options: {
  50819. segments?: number;
  50820. diameter?: number;
  50821. sideOrientation?: number;
  50822. }, scene: any): Mesh;
  50823. }
  50824. }
  50825. declare module "babylonjs/Lights/spotLight" {
  50826. import { Nullable } from "babylonjs/types";
  50827. import { Scene } from "babylonjs/scene";
  50828. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  50829. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50830. import { Effect } from "babylonjs/Materials/effect";
  50831. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50832. import { Light } from "babylonjs/Lights/light";
  50833. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50834. /**
  50835. * A spot light is defined by a position, a direction, an angle, and an exponent.
  50836. * These values define a cone of light starting from the position, emitting toward the direction.
  50837. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  50838. * and the exponent defines the speed of the decay of the light with distance (reach).
  50839. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50840. */
  50841. export class SpotLight extends ShadowLight {
  50842. private _angle;
  50843. private _innerAngle;
  50844. private _cosHalfAngle;
  50845. private _lightAngleScale;
  50846. private _lightAngleOffset;
  50847. /**
  50848. * Gets the cone angle of the spot light in Radians.
  50849. */
  50850. get angle(): number;
  50851. /**
  50852. * Sets the cone angle of the spot light in Radians.
  50853. */
  50854. set angle(value: number);
  50855. /**
  50856. * Only used in gltf falloff mode, this defines the angle where
  50857. * the directional falloff will start before cutting at angle which could be seen
  50858. * as outer angle.
  50859. */
  50860. get innerAngle(): number;
  50861. /**
  50862. * Only used in gltf falloff mode, this defines the angle where
  50863. * the directional falloff will start before cutting at angle which could be seen
  50864. * as outer angle.
  50865. */
  50866. set innerAngle(value: number);
  50867. private _shadowAngleScale;
  50868. /**
  50869. * Allows scaling the angle of the light for shadow generation only.
  50870. */
  50871. get shadowAngleScale(): number;
  50872. /**
  50873. * Allows scaling the angle of the light for shadow generation only.
  50874. */
  50875. set shadowAngleScale(value: number);
  50876. /**
  50877. * The light decay speed with the distance from the emission spot.
  50878. */
  50879. exponent: number;
  50880. private _projectionTextureMatrix;
  50881. /**
  50882. * Allows reading the projecton texture
  50883. */
  50884. get projectionTextureMatrix(): Matrix;
  50885. protected _projectionTextureLightNear: number;
  50886. /**
  50887. * Gets the near clip of the Spotlight for texture projection.
  50888. */
  50889. get projectionTextureLightNear(): number;
  50890. /**
  50891. * Sets the near clip of the Spotlight for texture projection.
  50892. */
  50893. set projectionTextureLightNear(value: number);
  50894. protected _projectionTextureLightFar: number;
  50895. /**
  50896. * Gets the far clip of the Spotlight for texture projection.
  50897. */
  50898. get projectionTextureLightFar(): number;
  50899. /**
  50900. * Sets the far clip of the Spotlight for texture projection.
  50901. */
  50902. set projectionTextureLightFar(value: number);
  50903. protected _projectionTextureUpDirection: Vector3;
  50904. /**
  50905. * Gets the Up vector of the Spotlight for texture projection.
  50906. */
  50907. get projectionTextureUpDirection(): Vector3;
  50908. /**
  50909. * Sets the Up vector of the Spotlight for texture projection.
  50910. */
  50911. set projectionTextureUpDirection(value: Vector3);
  50912. private _projectionTexture;
  50913. /**
  50914. * Gets the projection texture of the light.
  50915. */
  50916. get projectionTexture(): Nullable<BaseTexture>;
  50917. /**
  50918. * Sets the projection texture of the light.
  50919. */
  50920. set projectionTexture(value: Nullable<BaseTexture>);
  50921. private _projectionTextureViewLightDirty;
  50922. private _projectionTextureProjectionLightDirty;
  50923. private _projectionTextureDirty;
  50924. private _projectionTextureViewTargetVector;
  50925. private _projectionTextureViewLightMatrix;
  50926. private _projectionTextureProjectionLightMatrix;
  50927. private _projectionTextureScalingMatrix;
  50928. /**
  50929. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  50930. * It can cast shadows.
  50931. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50932. * @param name The light friendly name
  50933. * @param position The position of the spot light in the scene
  50934. * @param direction The direction of the light in the scene
  50935. * @param angle The cone angle of the light in Radians
  50936. * @param exponent The light decay speed with the distance from the emission spot
  50937. * @param scene The scene the lights belongs to
  50938. */
  50939. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  50940. /**
  50941. * Returns the string "SpotLight".
  50942. * @returns the class name
  50943. */
  50944. getClassName(): string;
  50945. /**
  50946. * Returns the integer 2.
  50947. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50948. */
  50949. getTypeID(): number;
  50950. /**
  50951. * Overrides the direction setter to recompute the projection texture view light Matrix.
  50952. */
  50953. protected _setDirection(value: Vector3): void;
  50954. /**
  50955. * Overrides the position setter to recompute the projection texture view light Matrix.
  50956. */
  50957. protected _setPosition(value: Vector3): void;
  50958. /**
  50959. * 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.
  50960. * Returns the SpotLight.
  50961. */
  50962. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50963. protected _computeProjectionTextureViewLightMatrix(): void;
  50964. protected _computeProjectionTextureProjectionLightMatrix(): void;
  50965. /**
  50966. * Main function for light texture projection matrix computing.
  50967. */
  50968. protected _computeProjectionTextureMatrix(): void;
  50969. protected _buildUniformLayout(): void;
  50970. private _computeAngleValues;
  50971. /**
  50972. * Sets the passed Effect "effect" with the Light textures.
  50973. * @param effect The effect to update
  50974. * @param lightIndex The index of the light in the effect to update
  50975. * @returns The light
  50976. */
  50977. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  50978. /**
  50979. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  50980. * @param effect The effect to update
  50981. * @param lightIndex The index of the light in the effect to update
  50982. * @returns The spot light
  50983. */
  50984. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  50985. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  50986. /**
  50987. * Disposes the light and the associated resources.
  50988. */
  50989. dispose(): void;
  50990. /**
  50991. * Prepares the list of defines specific to the light type.
  50992. * @param defines the list of defines
  50993. * @param lightIndex defines the index of the light for the effect
  50994. */
  50995. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50996. }
  50997. }
  50998. declare module "babylonjs/Gizmos/lightGizmo" {
  50999. import { Nullable } from "babylonjs/types";
  51000. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51001. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51002. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  51003. import { Light } from "babylonjs/Lights/light";
  51004. /**
  51005. * Gizmo that enables viewing a light
  51006. */
  51007. export class LightGizmo extends Gizmo {
  51008. private _lightMesh;
  51009. private _material;
  51010. private _cachedPosition;
  51011. private _cachedForward;
  51012. private _attachedMeshParent;
  51013. /**
  51014. * Creates a LightGizmo
  51015. * @param gizmoLayer The utility layer the gizmo will be added to
  51016. */
  51017. constructor(gizmoLayer?: UtilityLayerRenderer);
  51018. private _light;
  51019. /**
  51020. * The light that the gizmo is attached to
  51021. */
  51022. set light(light: Nullable<Light>);
  51023. get light(): Nullable<Light>;
  51024. /**
  51025. * Gets the material used to render the light gizmo
  51026. */
  51027. get material(): StandardMaterial;
  51028. /**
  51029. * @hidden
  51030. * Updates the gizmo to match the attached mesh's position/rotation
  51031. */
  51032. protected _update(): void;
  51033. private static _Scale;
  51034. /**
  51035. * Creates the lines for a light mesh
  51036. */
  51037. private static _CreateLightLines;
  51038. /**
  51039. * Disposes of the light gizmo
  51040. */
  51041. dispose(): void;
  51042. private static _CreateHemisphericLightMesh;
  51043. private static _CreatePointLightMesh;
  51044. private static _CreateSpotLightMesh;
  51045. private static _CreateDirectionalLightMesh;
  51046. }
  51047. }
  51048. declare module "babylonjs/Gizmos/index" {
  51049. export * from "babylonjs/Gizmos/axisDragGizmo";
  51050. export * from "babylonjs/Gizmos/axisScaleGizmo";
  51051. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  51052. export * from "babylonjs/Gizmos/gizmo";
  51053. export * from "babylonjs/Gizmos/gizmoManager";
  51054. export * from "babylonjs/Gizmos/planeRotationGizmo";
  51055. export * from "babylonjs/Gizmos/positionGizmo";
  51056. export * from "babylonjs/Gizmos/rotationGizmo";
  51057. export * from "babylonjs/Gizmos/scaleGizmo";
  51058. export * from "babylonjs/Gizmos/lightGizmo";
  51059. export * from "babylonjs/Gizmos/planeDragGizmo";
  51060. }
  51061. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  51062. /** @hidden */
  51063. export var backgroundFragmentDeclaration: {
  51064. name: string;
  51065. shader: string;
  51066. };
  51067. }
  51068. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  51069. /** @hidden */
  51070. export var backgroundUboDeclaration: {
  51071. name: string;
  51072. shader: string;
  51073. };
  51074. }
  51075. declare module "babylonjs/Shaders/background.fragment" {
  51076. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  51077. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51078. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  51079. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51080. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51081. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51082. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51083. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  51084. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  51085. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51086. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  51087. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  51088. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51089. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  51090. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  51091. /** @hidden */
  51092. export var backgroundPixelShader: {
  51093. name: string;
  51094. shader: string;
  51095. };
  51096. }
  51097. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  51098. /** @hidden */
  51099. export var backgroundVertexDeclaration: {
  51100. name: string;
  51101. shader: string;
  51102. };
  51103. }
  51104. declare module "babylonjs/Shaders/background.vertex" {
  51105. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  51106. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51107. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51108. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51109. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51110. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  51111. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  51112. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51113. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51114. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51115. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51116. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51117. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  51118. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  51119. /** @hidden */
  51120. export var backgroundVertexShader: {
  51121. name: string;
  51122. shader: string;
  51123. };
  51124. }
  51125. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  51126. import { Nullable, int, float } from "babylonjs/types";
  51127. import { Scene } from "babylonjs/scene";
  51128. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51129. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51130. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51131. import { Mesh } from "babylonjs/Meshes/mesh";
  51132. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  51133. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  51134. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  51135. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51136. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  51137. import { Color3 } from "babylonjs/Maths/math.color";
  51138. import "babylonjs/Shaders/background.fragment";
  51139. import "babylonjs/Shaders/background.vertex";
  51140. /**
  51141. * Background material used to create an efficient environement around your scene.
  51142. */
  51143. export class BackgroundMaterial extends PushMaterial {
  51144. /**
  51145. * Standard reflectance value at parallel view angle.
  51146. */
  51147. static StandardReflectance0: number;
  51148. /**
  51149. * Standard reflectance value at grazing angle.
  51150. */
  51151. static StandardReflectance90: number;
  51152. protected _primaryColor: Color3;
  51153. /**
  51154. * Key light Color (multiply against the environement texture)
  51155. */
  51156. primaryColor: Color3;
  51157. protected __perceptualColor: Nullable<Color3>;
  51158. /**
  51159. * Experimental Internal Use Only.
  51160. *
  51161. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  51162. * This acts as a helper to set the primary color to a more "human friendly" value.
  51163. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  51164. * output color as close as possible from the chosen value.
  51165. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  51166. * part of lighting setup.)
  51167. */
  51168. get _perceptualColor(): Nullable<Color3>;
  51169. set _perceptualColor(value: Nullable<Color3>);
  51170. protected _primaryColorShadowLevel: float;
  51171. /**
  51172. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  51173. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  51174. */
  51175. get primaryColorShadowLevel(): float;
  51176. set primaryColorShadowLevel(value: float);
  51177. protected _primaryColorHighlightLevel: float;
  51178. /**
  51179. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  51180. * The primary color is used at the level chosen to define what the white area would look.
  51181. */
  51182. get primaryColorHighlightLevel(): float;
  51183. set primaryColorHighlightLevel(value: float);
  51184. protected _reflectionTexture: Nullable<BaseTexture>;
  51185. /**
  51186. * Reflection Texture used in the material.
  51187. * Should be author in a specific way for the best result (refer to the documentation).
  51188. */
  51189. reflectionTexture: Nullable<BaseTexture>;
  51190. protected _reflectionBlur: float;
  51191. /**
  51192. * Reflection Texture level of blur.
  51193. *
  51194. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  51195. * texture twice.
  51196. */
  51197. reflectionBlur: float;
  51198. protected _diffuseTexture: Nullable<BaseTexture>;
  51199. /**
  51200. * Diffuse Texture used in the material.
  51201. * Should be author in a specific way for the best result (refer to the documentation).
  51202. */
  51203. diffuseTexture: Nullable<BaseTexture>;
  51204. protected _shadowLights: Nullable<IShadowLight[]>;
  51205. /**
  51206. * Specify the list of lights casting shadow on the material.
  51207. * All scene shadow lights will be included if null.
  51208. */
  51209. shadowLights: Nullable<IShadowLight[]>;
  51210. protected _shadowLevel: float;
  51211. /**
  51212. * Helps adjusting the shadow to a softer level if required.
  51213. * 0 means black shadows and 1 means no shadows.
  51214. */
  51215. shadowLevel: float;
  51216. protected _sceneCenter: Vector3;
  51217. /**
  51218. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  51219. * It is usually zero but might be interesting to modify according to your setup.
  51220. */
  51221. sceneCenter: Vector3;
  51222. protected _opacityFresnel: boolean;
  51223. /**
  51224. * This helps specifying that the material is falling off to the sky box at grazing angle.
  51225. * This helps ensuring a nice transition when the camera goes under the ground.
  51226. */
  51227. opacityFresnel: boolean;
  51228. protected _reflectionFresnel: boolean;
  51229. /**
  51230. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  51231. * This helps adding a mirror texture on the ground.
  51232. */
  51233. reflectionFresnel: boolean;
  51234. protected _reflectionFalloffDistance: number;
  51235. /**
  51236. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  51237. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  51238. */
  51239. reflectionFalloffDistance: number;
  51240. protected _reflectionAmount: number;
  51241. /**
  51242. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  51243. */
  51244. reflectionAmount: number;
  51245. protected _reflectionReflectance0: number;
  51246. /**
  51247. * This specifies the weight of the reflection at grazing angle.
  51248. */
  51249. reflectionReflectance0: number;
  51250. protected _reflectionReflectance90: number;
  51251. /**
  51252. * This specifies the weight of the reflection at a perpendicular point of view.
  51253. */
  51254. reflectionReflectance90: number;
  51255. /**
  51256. * Sets the reflection reflectance fresnel values according to the default standard
  51257. * empirically know to work well :-)
  51258. */
  51259. set reflectionStandardFresnelWeight(value: number);
  51260. protected _useRGBColor: boolean;
  51261. /**
  51262. * Helps to directly use the maps channels instead of their level.
  51263. */
  51264. useRGBColor: boolean;
  51265. protected _enableNoise: boolean;
  51266. /**
  51267. * This helps reducing the banding effect that could occur on the background.
  51268. */
  51269. enableNoise: boolean;
  51270. /**
  51271. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51272. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  51273. * Recommended to be keep at 1.0 except for special cases.
  51274. */
  51275. get fovMultiplier(): number;
  51276. set fovMultiplier(value: number);
  51277. private _fovMultiplier;
  51278. /**
  51279. * Enable the FOV adjustment feature controlled by fovMultiplier.
  51280. */
  51281. useEquirectangularFOV: boolean;
  51282. private _maxSimultaneousLights;
  51283. /**
  51284. * Number of Simultaneous lights allowed on the material.
  51285. */
  51286. maxSimultaneousLights: int;
  51287. /**
  51288. * Default configuration related to image processing available in the Background Material.
  51289. */
  51290. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51291. /**
  51292. * Keep track of the image processing observer to allow dispose and replace.
  51293. */
  51294. private _imageProcessingObserver;
  51295. /**
  51296. * Attaches a new image processing configuration to the PBR Material.
  51297. * @param configuration (if null the scene configuration will be use)
  51298. */
  51299. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51300. /**
  51301. * Gets the image processing configuration used either in this material.
  51302. */
  51303. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  51304. /**
  51305. * Sets the Default image processing configuration used either in the this material.
  51306. *
  51307. * If sets to null, the scene one is in use.
  51308. */
  51309. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  51310. /**
  51311. * Gets wether the color curves effect is enabled.
  51312. */
  51313. get cameraColorCurvesEnabled(): boolean;
  51314. /**
  51315. * Sets wether the color curves effect is enabled.
  51316. */
  51317. set cameraColorCurvesEnabled(value: boolean);
  51318. /**
  51319. * Gets wether the color grading effect is enabled.
  51320. */
  51321. get cameraColorGradingEnabled(): boolean;
  51322. /**
  51323. * Gets wether the color grading effect is enabled.
  51324. */
  51325. set cameraColorGradingEnabled(value: boolean);
  51326. /**
  51327. * Gets wether tonemapping is enabled or not.
  51328. */
  51329. get cameraToneMappingEnabled(): boolean;
  51330. /**
  51331. * Sets wether tonemapping is enabled or not
  51332. */
  51333. set cameraToneMappingEnabled(value: boolean);
  51334. /**
  51335. * The camera exposure used on this material.
  51336. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51337. * This corresponds to a photographic exposure.
  51338. */
  51339. get cameraExposure(): float;
  51340. /**
  51341. * The camera exposure used on this material.
  51342. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51343. * This corresponds to a photographic exposure.
  51344. */
  51345. set cameraExposure(value: float);
  51346. /**
  51347. * Gets The camera contrast used on this material.
  51348. */
  51349. get cameraContrast(): float;
  51350. /**
  51351. * Sets The camera contrast used on this material.
  51352. */
  51353. set cameraContrast(value: float);
  51354. /**
  51355. * Gets the Color Grading 2D Lookup Texture.
  51356. */
  51357. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  51358. /**
  51359. * Sets the Color Grading 2D Lookup Texture.
  51360. */
  51361. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  51362. /**
  51363. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51364. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51365. * 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;
  51366. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51367. */
  51368. get cameraColorCurves(): Nullable<ColorCurves>;
  51369. /**
  51370. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51371. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51372. * 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;
  51373. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51374. */
  51375. set cameraColorCurves(value: Nullable<ColorCurves>);
  51376. /**
  51377. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  51378. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  51379. */
  51380. switchToBGR: boolean;
  51381. private _renderTargets;
  51382. private _reflectionControls;
  51383. private _white;
  51384. private _primaryShadowColor;
  51385. private _primaryHighlightColor;
  51386. /**
  51387. * Instantiates a Background Material in the given scene
  51388. * @param name The friendly name of the material
  51389. * @param scene The scene to add the material to
  51390. */
  51391. constructor(name: string, scene: Scene);
  51392. /**
  51393. * Gets a boolean indicating that current material needs to register RTT
  51394. */
  51395. get hasRenderTargetTextures(): boolean;
  51396. /**
  51397. * The entire material has been created in order to prevent overdraw.
  51398. * @returns false
  51399. */
  51400. needAlphaTesting(): boolean;
  51401. /**
  51402. * The entire material has been created in order to prevent overdraw.
  51403. * @returns true if blending is enable
  51404. */
  51405. needAlphaBlending(): boolean;
  51406. /**
  51407. * Checks wether the material is ready to be rendered for a given mesh.
  51408. * @param mesh The mesh to render
  51409. * @param subMesh The submesh to check against
  51410. * @param useInstances Specify wether or not the material is used with instances
  51411. * @returns true if all the dependencies are ready (Textures, Effects...)
  51412. */
  51413. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51414. /**
  51415. * Compute the primary color according to the chosen perceptual color.
  51416. */
  51417. private _computePrimaryColorFromPerceptualColor;
  51418. /**
  51419. * Compute the highlights and shadow colors according to their chosen levels.
  51420. */
  51421. private _computePrimaryColors;
  51422. /**
  51423. * Build the uniform buffer used in the material.
  51424. */
  51425. buildUniformLayout(): void;
  51426. /**
  51427. * Unbind the material.
  51428. */
  51429. unbind(): void;
  51430. /**
  51431. * Bind only the world matrix to the material.
  51432. * @param world The world matrix to bind.
  51433. */
  51434. bindOnlyWorldMatrix(world: Matrix): void;
  51435. /**
  51436. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  51437. * @param world The world matrix to bind.
  51438. * @param subMesh The submesh to bind for.
  51439. */
  51440. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51441. /**
  51442. * Checks to see if a texture is used in the material.
  51443. * @param texture - Base texture to use.
  51444. * @returns - Boolean specifying if a texture is used in the material.
  51445. */
  51446. hasTexture(texture: BaseTexture): boolean;
  51447. /**
  51448. * Dispose the material.
  51449. * @param forceDisposeEffect Force disposal of the associated effect.
  51450. * @param forceDisposeTextures Force disposal of the associated textures.
  51451. */
  51452. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51453. /**
  51454. * Clones the material.
  51455. * @param name The cloned name.
  51456. * @returns The cloned material.
  51457. */
  51458. clone(name: string): BackgroundMaterial;
  51459. /**
  51460. * Serializes the current material to its JSON representation.
  51461. * @returns The JSON representation.
  51462. */
  51463. serialize(): any;
  51464. /**
  51465. * Gets the class name of the material
  51466. * @returns "BackgroundMaterial"
  51467. */
  51468. getClassName(): string;
  51469. /**
  51470. * Parse a JSON input to create back a background material.
  51471. * @param source The JSON data to parse
  51472. * @param scene The scene to create the parsed material in
  51473. * @param rootUrl The root url of the assets the material depends upon
  51474. * @returns the instantiated BackgroundMaterial.
  51475. */
  51476. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  51477. }
  51478. }
  51479. declare module "babylonjs/Helpers/environmentHelper" {
  51480. import { Observable } from "babylonjs/Misc/observable";
  51481. import { Nullable } from "babylonjs/types";
  51482. import { Scene } from "babylonjs/scene";
  51483. import { Vector3 } from "babylonjs/Maths/math.vector";
  51484. import { Color3 } from "babylonjs/Maths/math.color";
  51485. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51486. import { Mesh } from "babylonjs/Meshes/mesh";
  51487. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51488. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  51489. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51490. import "babylonjs/Meshes/Builders/planeBuilder";
  51491. import "babylonjs/Meshes/Builders/boxBuilder";
  51492. /**
  51493. * Represents the different options available during the creation of
  51494. * a Environment helper.
  51495. *
  51496. * This can control the default ground, skybox and image processing setup of your scene.
  51497. */
  51498. export interface IEnvironmentHelperOptions {
  51499. /**
  51500. * Specifies whether or not to create a ground.
  51501. * True by default.
  51502. */
  51503. createGround: boolean;
  51504. /**
  51505. * Specifies the ground size.
  51506. * 15 by default.
  51507. */
  51508. groundSize: number;
  51509. /**
  51510. * The texture used on the ground for the main color.
  51511. * Comes from the BabylonJS CDN by default.
  51512. *
  51513. * Remarks: Can be either a texture or a url.
  51514. */
  51515. groundTexture: string | BaseTexture;
  51516. /**
  51517. * The color mixed in the ground texture by default.
  51518. * BabylonJS clearColor by default.
  51519. */
  51520. groundColor: Color3;
  51521. /**
  51522. * Specifies the ground opacity.
  51523. * 1 by default.
  51524. */
  51525. groundOpacity: number;
  51526. /**
  51527. * Enables the ground to receive shadows.
  51528. * True by default.
  51529. */
  51530. enableGroundShadow: boolean;
  51531. /**
  51532. * Helps preventing the shadow to be fully black on the ground.
  51533. * 0.5 by default.
  51534. */
  51535. groundShadowLevel: number;
  51536. /**
  51537. * Creates a mirror texture attach to the ground.
  51538. * false by default.
  51539. */
  51540. enableGroundMirror: boolean;
  51541. /**
  51542. * Specifies the ground mirror size ratio.
  51543. * 0.3 by default as the default kernel is 64.
  51544. */
  51545. groundMirrorSizeRatio: number;
  51546. /**
  51547. * Specifies the ground mirror blur kernel size.
  51548. * 64 by default.
  51549. */
  51550. groundMirrorBlurKernel: number;
  51551. /**
  51552. * Specifies the ground mirror visibility amount.
  51553. * 1 by default
  51554. */
  51555. groundMirrorAmount: number;
  51556. /**
  51557. * Specifies the ground mirror reflectance weight.
  51558. * This uses the standard weight of the background material to setup the fresnel effect
  51559. * of the mirror.
  51560. * 1 by default.
  51561. */
  51562. groundMirrorFresnelWeight: number;
  51563. /**
  51564. * Specifies the ground mirror Falloff distance.
  51565. * This can helps reducing the size of the reflection.
  51566. * 0 by Default.
  51567. */
  51568. groundMirrorFallOffDistance: number;
  51569. /**
  51570. * Specifies the ground mirror texture type.
  51571. * Unsigned Int by Default.
  51572. */
  51573. groundMirrorTextureType: number;
  51574. /**
  51575. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  51576. * the shown objects.
  51577. */
  51578. groundYBias: number;
  51579. /**
  51580. * Specifies whether or not to create a skybox.
  51581. * True by default.
  51582. */
  51583. createSkybox: boolean;
  51584. /**
  51585. * Specifies the skybox size.
  51586. * 20 by default.
  51587. */
  51588. skyboxSize: number;
  51589. /**
  51590. * The texture used on the skybox for the main color.
  51591. * Comes from the BabylonJS CDN by default.
  51592. *
  51593. * Remarks: Can be either a texture or a url.
  51594. */
  51595. skyboxTexture: string | BaseTexture;
  51596. /**
  51597. * The color mixed in the skybox texture by default.
  51598. * BabylonJS clearColor by default.
  51599. */
  51600. skyboxColor: Color3;
  51601. /**
  51602. * The background rotation around the Y axis of the scene.
  51603. * This helps aligning the key lights of your scene with the background.
  51604. * 0 by default.
  51605. */
  51606. backgroundYRotation: number;
  51607. /**
  51608. * Compute automatically the size of the elements to best fit with the scene.
  51609. */
  51610. sizeAuto: boolean;
  51611. /**
  51612. * Default position of the rootMesh if autoSize is not true.
  51613. */
  51614. rootPosition: Vector3;
  51615. /**
  51616. * Sets up the image processing in the scene.
  51617. * true by default.
  51618. */
  51619. setupImageProcessing: boolean;
  51620. /**
  51621. * The texture used as your environment texture in the scene.
  51622. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  51623. *
  51624. * Remarks: Can be either a texture or a url.
  51625. */
  51626. environmentTexture: string | BaseTexture;
  51627. /**
  51628. * The value of the exposure to apply to the scene.
  51629. * 0.6 by default if setupImageProcessing is true.
  51630. */
  51631. cameraExposure: number;
  51632. /**
  51633. * The value of the contrast to apply to the scene.
  51634. * 1.6 by default if setupImageProcessing is true.
  51635. */
  51636. cameraContrast: number;
  51637. /**
  51638. * Specifies whether or not tonemapping should be enabled in the scene.
  51639. * true by default if setupImageProcessing is true.
  51640. */
  51641. toneMappingEnabled: boolean;
  51642. }
  51643. /**
  51644. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  51645. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  51646. * It also helps with the default setup of your imageProcessing configuration.
  51647. */
  51648. export class EnvironmentHelper {
  51649. /**
  51650. * Default ground texture URL.
  51651. */
  51652. private static _groundTextureCDNUrl;
  51653. /**
  51654. * Default skybox texture URL.
  51655. */
  51656. private static _skyboxTextureCDNUrl;
  51657. /**
  51658. * Default environment texture URL.
  51659. */
  51660. private static _environmentTextureCDNUrl;
  51661. /**
  51662. * Creates the default options for the helper.
  51663. */
  51664. private static _getDefaultOptions;
  51665. private _rootMesh;
  51666. /**
  51667. * Gets the root mesh created by the helper.
  51668. */
  51669. get rootMesh(): Mesh;
  51670. private _skybox;
  51671. /**
  51672. * Gets the skybox created by the helper.
  51673. */
  51674. get skybox(): Nullable<Mesh>;
  51675. private _skyboxTexture;
  51676. /**
  51677. * Gets the skybox texture created by the helper.
  51678. */
  51679. get skyboxTexture(): Nullable<BaseTexture>;
  51680. private _skyboxMaterial;
  51681. /**
  51682. * Gets the skybox material created by the helper.
  51683. */
  51684. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  51685. private _ground;
  51686. /**
  51687. * Gets the ground mesh created by the helper.
  51688. */
  51689. get ground(): Nullable<Mesh>;
  51690. private _groundTexture;
  51691. /**
  51692. * Gets the ground texture created by the helper.
  51693. */
  51694. get groundTexture(): Nullable<BaseTexture>;
  51695. private _groundMirror;
  51696. /**
  51697. * Gets the ground mirror created by the helper.
  51698. */
  51699. get groundMirror(): Nullable<MirrorTexture>;
  51700. /**
  51701. * Gets the ground mirror render list to helps pushing the meshes
  51702. * you wish in the ground reflection.
  51703. */
  51704. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  51705. private _groundMaterial;
  51706. /**
  51707. * Gets the ground material created by the helper.
  51708. */
  51709. get groundMaterial(): Nullable<BackgroundMaterial>;
  51710. /**
  51711. * Stores the creation options.
  51712. */
  51713. private readonly _scene;
  51714. private _options;
  51715. /**
  51716. * This observable will be notified with any error during the creation of the environment,
  51717. * mainly texture creation errors.
  51718. */
  51719. onErrorObservable: Observable<{
  51720. message?: string;
  51721. exception?: any;
  51722. }>;
  51723. /**
  51724. * constructor
  51725. * @param options Defines the options we want to customize the helper
  51726. * @param scene The scene to add the material to
  51727. */
  51728. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  51729. /**
  51730. * Updates the background according to the new options
  51731. * @param options
  51732. */
  51733. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  51734. /**
  51735. * Sets the primary color of all the available elements.
  51736. * @param color the main color to affect to the ground and the background
  51737. */
  51738. setMainColor(color: Color3): void;
  51739. /**
  51740. * Setup the image processing according to the specified options.
  51741. */
  51742. private _setupImageProcessing;
  51743. /**
  51744. * Setup the environment texture according to the specified options.
  51745. */
  51746. private _setupEnvironmentTexture;
  51747. /**
  51748. * Setup the background according to the specified options.
  51749. */
  51750. private _setupBackground;
  51751. /**
  51752. * Get the scene sizes according to the setup.
  51753. */
  51754. private _getSceneSize;
  51755. /**
  51756. * Setup the ground according to the specified options.
  51757. */
  51758. private _setupGround;
  51759. /**
  51760. * Setup the ground material according to the specified options.
  51761. */
  51762. private _setupGroundMaterial;
  51763. /**
  51764. * Setup the ground diffuse texture according to the specified options.
  51765. */
  51766. private _setupGroundDiffuseTexture;
  51767. /**
  51768. * Setup the ground mirror texture according to the specified options.
  51769. */
  51770. private _setupGroundMirrorTexture;
  51771. /**
  51772. * Setup the ground to receive the mirror texture.
  51773. */
  51774. private _setupMirrorInGroundMaterial;
  51775. /**
  51776. * Setup the skybox according to the specified options.
  51777. */
  51778. private _setupSkybox;
  51779. /**
  51780. * Setup the skybox material according to the specified options.
  51781. */
  51782. private _setupSkyboxMaterial;
  51783. /**
  51784. * Setup the skybox reflection texture according to the specified options.
  51785. */
  51786. private _setupSkyboxReflectionTexture;
  51787. private _errorHandler;
  51788. /**
  51789. * Dispose all the elements created by the Helper.
  51790. */
  51791. dispose(): void;
  51792. }
  51793. }
  51794. declare module "babylonjs/Helpers/photoDome" {
  51795. import { Observable } from "babylonjs/Misc/observable";
  51796. import { Nullable } from "babylonjs/types";
  51797. import { Scene } from "babylonjs/scene";
  51798. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51799. import { Mesh } from "babylonjs/Meshes/mesh";
  51800. import { Texture } from "babylonjs/Materials/Textures/texture";
  51801. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51802. import "babylonjs/Meshes/Builders/sphereBuilder";
  51803. /**
  51804. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  51805. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  51806. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  51807. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  51808. */
  51809. export class PhotoDome extends TransformNode {
  51810. /**
  51811. * Define the image as a Monoscopic panoramic 360 image.
  51812. */
  51813. static readonly MODE_MONOSCOPIC: number;
  51814. /**
  51815. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  51816. */
  51817. static readonly MODE_TOPBOTTOM: number;
  51818. /**
  51819. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  51820. */
  51821. static readonly MODE_SIDEBYSIDE: number;
  51822. private _useDirectMapping;
  51823. /**
  51824. * The texture being displayed on the sphere
  51825. */
  51826. protected _photoTexture: Texture;
  51827. /**
  51828. * Gets or sets the texture being displayed on the sphere
  51829. */
  51830. get photoTexture(): Texture;
  51831. set photoTexture(value: Texture);
  51832. /**
  51833. * Observable raised when an error occured while loading the 360 image
  51834. */
  51835. onLoadErrorObservable: Observable<string>;
  51836. /**
  51837. * The skybox material
  51838. */
  51839. protected _material: BackgroundMaterial;
  51840. /**
  51841. * The surface used for the skybox
  51842. */
  51843. protected _mesh: Mesh;
  51844. /**
  51845. * Gets the mesh used for the skybox.
  51846. */
  51847. get mesh(): Mesh;
  51848. /**
  51849. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51850. * Also see the options.resolution property.
  51851. */
  51852. get fovMultiplier(): number;
  51853. set fovMultiplier(value: number);
  51854. private _imageMode;
  51855. /**
  51856. * Gets or set the current video mode for the video. It can be:
  51857. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  51858. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  51859. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  51860. */
  51861. get imageMode(): number;
  51862. set imageMode(value: number);
  51863. /**
  51864. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  51865. * @param name Element's name, child elements will append suffixes for their own names.
  51866. * @param urlsOfPhoto defines the url of the photo to display
  51867. * @param options defines an object containing optional or exposed sub element properties
  51868. * @param onError defines a callback called when an error occured while loading the texture
  51869. */
  51870. constructor(name: string, urlOfPhoto: string, options: {
  51871. resolution?: number;
  51872. size?: number;
  51873. useDirectMapping?: boolean;
  51874. faceForward?: boolean;
  51875. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  51876. private _onBeforeCameraRenderObserver;
  51877. private _changeImageMode;
  51878. /**
  51879. * Releases resources associated with this node.
  51880. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  51881. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  51882. */
  51883. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  51884. }
  51885. }
  51886. declare module "babylonjs/Misc/rgbdTextureTools" {
  51887. import "babylonjs/Shaders/rgbdDecode.fragment";
  51888. import "babylonjs/Engines/Extensions/engine.renderTarget";
  51889. import { Texture } from "babylonjs/Materials/Textures/texture";
  51890. /**
  51891. * Class used to host RGBD texture specific utilities
  51892. */
  51893. export class RGBDTextureTools {
  51894. /**
  51895. * Expand the RGBD Texture from RGBD to Half Float if possible.
  51896. * @param texture the texture to expand.
  51897. */
  51898. static ExpandRGBDTexture(texture: Texture): void;
  51899. }
  51900. }
  51901. declare module "babylonjs/Misc/brdfTextureTools" {
  51902. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51903. import { Scene } from "babylonjs/scene";
  51904. /**
  51905. * Class used to host texture specific utilities
  51906. */
  51907. export class BRDFTextureTools {
  51908. /**
  51909. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  51910. * @param scene defines the hosting scene
  51911. * @returns the environment BRDF texture
  51912. */
  51913. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  51914. private static _environmentBRDFBase64Texture;
  51915. }
  51916. }
  51917. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  51918. import { Nullable } from "babylonjs/types";
  51919. import { Color3 } from "babylonjs/Maths/math.color";
  51920. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51921. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  51922. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  51923. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  51924. import { Engine } from "babylonjs/Engines/engine";
  51925. import { Scene } from "babylonjs/scene";
  51926. /**
  51927. * @hidden
  51928. */
  51929. export interface IMaterialClearCoatDefines {
  51930. CLEARCOAT: boolean;
  51931. CLEARCOAT_DEFAULTIOR: boolean;
  51932. CLEARCOAT_TEXTURE: boolean;
  51933. CLEARCOAT_TEXTUREDIRECTUV: number;
  51934. CLEARCOAT_BUMP: boolean;
  51935. CLEARCOAT_BUMPDIRECTUV: number;
  51936. CLEARCOAT_TINT: boolean;
  51937. CLEARCOAT_TINT_TEXTURE: boolean;
  51938. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  51939. /** @hidden */
  51940. _areTexturesDirty: boolean;
  51941. }
  51942. /**
  51943. * Define the code related to the clear coat parameters of the pbr material.
  51944. */
  51945. export class PBRClearCoatConfiguration {
  51946. /**
  51947. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  51948. * The default fits with a polyurethane material.
  51949. */
  51950. private static readonly _DefaultIndexOfRefraction;
  51951. private _isEnabled;
  51952. /**
  51953. * Defines if the clear coat is enabled in the material.
  51954. */
  51955. isEnabled: boolean;
  51956. /**
  51957. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  51958. */
  51959. intensity: number;
  51960. /**
  51961. * Defines the clear coat layer roughness.
  51962. */
  51963. roughness: number;
  51964. private _indexOfRefraction;
  51965. /**
  51966. * Defines the index of refraction of the clear coat.
  51967. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  51968. * The default fits with a polyurethane material.
  51969. * Changing the default value is more performance intensive.
  51970. */
  51971. indexOfRefraction: number;
  51972. private _texture;
  51973. /**
  51974. * Stores the clear coat values in a texture.
  51975. */
  51976. texture: Nullable<BaseTexture>;
  51977. private _bumpTexture;
  51978. /**
  51979. * Define the clear coat specific bump texture.
  51980. */
  51981. bumpTexture: Nullable<BaseTexture>;
  51982. private _isTintEnabled;
  51983. /**
  51984. * Defines if the clear coat tint is enabled in the material.
  51985. */
  51986. isTintEnabled: boolean;
  51987. /**
  51988. * Defines the clear coat tint of the material.
  51989. * This is only use if tint is enabled
  51990. */
  51991. tintColor: Color3;
  51992. /**
  51993. * Defines the distance at which the tint color should be found in the
  51994. * clear coat media.
  51995. * This is only use if tint is enabled
  51996. */
  51997. tintColorAtDistance: number;
  51998. /**
  51999. * Defines the clear coat layer thickness.
  52000. * This is only use if tint is enabled
  52001. */
  52002. tintThickness: number;
  52003. private _tintTexture;
  52004. /**
  52005. * Stores the clear tint values in a texture.
  52006. * rgb is tint
  52007. * a is a thickness factor
  52008. */
  52009. tintTexture: Nullable<BaseTexture>;
  52010. /** @hidden */
  52011. private _internalMarkAllSubMeshesAsTexturesDirty;
  52012. /** @hidden */
  52013. _markAllSubMeshesAsTexturesDirty(): void;
  52014. /**
  52015. * Instantiate a new istance of clear coat configuration.
  52016. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52017. */
  52018. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52019. /**
  52020. * Gets wehter the submesh is ready to be used or not.
  52021. * @param defines the list of "defines" to update.
  52022. * @param scene defines the scene the material belongs to.
  52023. * @param engine defines the engine the material belongs to.
  52024. * @param disableBumpMap defines wether the material disables bump or not.
  52025. * @returns - boolean indicating that the submesh is ready or not.
  52026. */
  52027. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  52028. /**
  52029. * Checks to see if a texture is used in the material.
  52030. * @param defines the list of "defines" to update.
  52031. * @param scene defines the scene to the material belongs to.
  52032. */
  52033. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  52034. /**
  52035. * Binds the material data.
  52036. * @param uniformBuffer defines the Uniform buffer to fill in.
  52037. * @param scene defines the scene the material belongs to.
  52038. * @param engine defines the engine the material belongs to.
  52039. * @param disableBumpMap defines wether the material disables bump or not.
  52040. * @param isFrozen defines wether the material is frozen or not.
  52041. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  52042. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  52043. */
  52044. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  52045. /**
  52046. * Checks to see if a texture is used in the material.
  52047. * @param texture - Base texture to use.
  52048. * @returns - Boolean specifying if a texture is used in the material.
  52049. */
  52050. hasTexture(texture: BaseTexture): boolean;
  52051. /**
  52052. * Returns an array of the actively used textures.
  52053. * @param activeTextures Array of BaseTextures
  52054. */
  52055. getActiveTextures(activeTextures: BaseTexture[]): void;
  52056. /**
  52057. * Returns the animatable textures.
  52058. * @param animatables Array of animatable textures.
  52059. */
  52060. getAnimatables(animatables: IAnimatable[]): void;
  52061. /**
  52062. * Disposes the resources of the material.
  52063. * @param forceDisposeTextures - Forces the disposal of all textures.
  52064. */
  52065. dispose(forceDisposeTextures?: boolean): void;
  52066. /**
  52067. * Get the current class name of the texture useful for serialization or dynamic coding.
  52068. * @returns "PBRClearCoatConfiguration"
  52069. */
  52070. getClassName(): string;
  52071. /**
  52072. * Add fallbacks to the effect fallbacks list.
  52073. * @param defines defines the Base texture to use.
  52074. * @param fallbacks defines the current fallback list.
  52075. * @param currentRank defines the current fallback rank.
  52076. * @returns the new fallback rank.
  52077. */
  52078. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52079. /**
  52080. * Add the required uniforms to the current list.
  52081. * @param uniforms defines the current uniform list.
  52082. */
  52083. static AddUniforms(uniforms: string[]): void;
  52084. /**
  52085. * Add the required samplers to the current list.
  52086. * @param samplers defines the current sampler list.
  52087. */
  52088. static AddSamplers(samplers: string[]): void;
  52089. /**
  52090. * Add the required uniforms to the current buffer.
  52091. * @param uniformBuffer defines the current uniform buffer.
  52092. */
  52093. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52094. /**
  52095. * Makes a duplicate of the current configuration into another one.
  52096. * @param clearCoatConfiguration define the config where to copy the info
  52097. */
  52098. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  52099. /**
  52100. * Serializes this clear coat configuration.
  52101. * @returns - An object with the serialized config.
  52102. */
  52103. serialize(): any;
  52104. /**
  52105. * Parses a anisotropy Configuration from a serialized object.
  52106. * @param source - Serialized object.
  52107. * @param scene Defines the scene we are parsing for
  52108. * @param rootUrl Defines the rootUrl to load from
  52109. */
  52110. parse(source: any, scene: Scene, rootUrl: string): void;
  52111. }
  52112. }
  52113. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  52114. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52115. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52116. import { Vector2 } from "babylonjs/Maths/math.vector";
  52117. import { Scene } from "babylonjs/scene";
  52118. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52119. import { Nullable } from "babylonjs/types";
  52120. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52121. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52122. /**
  52123. * @hidden
  52124. */
  52125. export interface IMaterialAnisotropicDefines {
  52126. ANISOTROPIC: boolean;
  52127. ANISOTROPIC_TEXTURE: boolean;
  52128. ANISOTROPIC_TEXTUREDIRECTUV: number;
  52129. MAINUV1: boolean;
  52130. _areTexturesDirty: boolean;
  52131. _needUVs: boolean;
  52132. }
  52133. /**
  52134. * Define the code related to the anisotropic parameters of the pbr material.
  52135. */
  52136. export class PBRAnisotropicConfiguration {
  52137. private _isEnabled;
  52138. /**
  52139. * Defines if the anisotropy is enabled in the material.
  52140. */
  52141. isEnabled: boolean;
  52142. /**
  52143. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  52144. */
  52145. intensity: number;
  52146. /**
  52147. * Defines if the effect is along the tangents, bitangents or in between.
  52148. * By default, the effect is "strectching" the highlights along the tangents.
  52149. */
  52150. direction: Vector2;
  52151. private _texture;
  52152. /**
  52153. * Stores the anisotropy values in a texture.
  52154. * rg is direction (like normal from -1 to 1)
  52155. * b is a intensity
  52156. */
  52157. texture: Nullable<BaseTexture>;
  52158. /** @hidden */
  52159. private _internalMarkAllSubMeshesAsTexturesDirty;
  52160. /** @hidden */
  52161. _markAllSubMeshesAsTexturesDirty(): void;
  52162. /**
  52163. * Instantiate a new istance of anisotropy configuration.
  52164. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52165. */
  52166. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52167. /**
  52168. * Specifies that the submesh is ready to be used.
  52169. * @param defines the list of "defines" to update.
  52170. * @param scene defines the scene the material belongs to.
  52171. * @returns - boolean indicating that the submesh is ready or not.
  52172. */
  52173. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  52174. /**
  52175. * Checks to see if a texture is used in the material.
  52176. * @param defines the list of "defines" to update.
  52177. * @param mesh the mesh we are preparing the defines for.
  52178. * @param scene defines the scene the material belongs to.
  52179. */
  52180. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  52181. /**
  52182. * Binds the material data.
  52183. * @param uniformBuffer defines the Uniform buffer to fill in.
  52184. * @param scene defines the scene the material belongs to.
  52185. * @param isFrozen defines wether the material is frozen or not.
  52186. */
  52187. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52188. /**
  52189. * Checks to see if a texture is used in the material.
  52190. * @param texture - Base texture to use.
  52191. * @returns - Boolean specifying if a texture is used in the material.
  52192. */
  52193. hasTexture(texture: BaseTexture): boolean;
  52194. /**
  52195. * Returns an array of the actively used textures.
  52196. * @param activeTextures Array of BaseTextures
  52197. */
  52198. getActiveTextures(activeTextures: BaseTexture[]): void;
  52199. /**
  52200. * Returns the animatable textures.
  52201. * @param animatables Array of animatable textures.
  52202. */
  52203. getAnimatables(animatables: IAnimatable[]): void;
  52204. /**
  52205. * Disposes the resources of the material.
  52206. * @param forceDisposeTextures - Forces the disposal of all textures.
  52207. */
  52208. dispose(forceDisposeTextures?: boolean): void;
  52209. /**
  52210. * Get the current class name of the texture useful for serialization or dynamic coding.
  52211. * @returns "PBRAnisotropicConfiguration"
  52212. */
  52213. getClassName(): string;
  52214. /**
  52215. * Add fallbacks to the effect fallbacks list.
  52216. * @param defines defines the Base texture to use.
  52217. * @param fallbacks defines the current fallback list.
  52218. * @param currentRank defines the current fallback rank.
  52219. * @returns the new fallback rank.
  52220. */
  52221. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52222. /**
  52223. * Add the required uniforms to the current list.
  52224. * @param uniforms defines the current uniform list.
  52225. */
  52226. static AddUniforms(uniforms: string[]): void;
  52227. /**
  52228. * Add the required uniforms to the current buffer.
  52229. * @param uniformBuffer defines the current uniform buffer.
  52230. */
  52231. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52232. /**
  52233. * Add the required samplers to the current list.
  52234. * @param samplers defines the current sampler list.
  52235. */
  52236. static AddSamplers(samplers: string[]): void;
  52237. /**
  52238. * Makes a duplicate of the current configuration into another one.
  52239. * @param anisotropicConfiguration define the config where to copy the info
  52240. */
  52241. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  52242. /**
  52243. * Serializes this anisotropy configuration.
  52244. * @returns - An object with the serialized config.
  52245. */
  52246. serialize(): any;
  52247. /**
  52248. * Parses a anisotropy Configuration from a serialized object.
  52249. * @param source - Serialized object.
  52250. * @param scene Defines the scene we are parsing for
  52251. * @param rootUrl Defines the rootUrl to load from
  52252. */
  52253. parse(source: any, scene: Scene, rootUrl: string): void;
  52254. }
  52255. }
  52256. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  52257. import { Scene } from "babylonjs/scene";
  52258. /**
  52259. * @hidden
  52260. */
  52261. export interface IMaterialBRDFDefines {
  52262. BRDF_V_HEIGHT_CORRELATED: boolean;
  52263. MS_BRDF_ENERGY_CONSERVATION: boolean;
  52264. SPHERICAL_HARMONICS: boolean;
  52265. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  52266. /** @hidden */
  52267. _areMiscDirty: boolean;
  52268. }
  52269. /**
  52270. * Define the code related to the BRDF parameters of the pbr material.
  52271. */
  52272. export class PBRBRDFConfiguration {
  52273. /**
  52274. * Default value used for the energy conservation.
  52275. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52276. */
  52277. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  52278. /**
  52279. * Default value used for the Smith Visibility Height Correlated mode.
  52280. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52281. */
  52282. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  52283. /**
  52284. * Default value used for the IBL diffuse part.
  52285. * This can help switching back to the polynomials mode globally which is a tiny bit
  52286. * less GPU intensive at the drawback of a lower quality.
  52287. */
  52288. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  52289. /**
  52290. * Default value used for activating energy conservation for the specular workflow.
  52291. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52292. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52293. */
  52294. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  52295. private _useEnergyConservation;
  52296. /**
  52297. * Defines if the material uses energy conservation.
  52298. */
  52299. useEnergyConservation: boolean;
  52300. private _useSmithVisibilityHeightCorrelated;
  52301. /**
  52302. * LEGACY Mode set to false
  52303. * Defines if the material uses height smith correlated visibility term.
  52304. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  52305. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  52306. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  52307. * Not relying on height correlated will also disable energy conservation.
  52308. */
  52309. useSmithVisibilityHeightCorrelated: boolean;
  52310. private _useSphericalHarmonics;
  52311. /**
  52312. * LEGACY Mode set to false
  52313. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  52314. * diffuse part of the IBL.
  52315. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  52316. * to the ground truth.
  52317. */
  52318. useSphericalHarmonics: boolean;
  52319. private _useSpecularGlossinessInputEnergyConservation;
  52320. /**
  52321. * Defines if the material uses energy conservation, when the specular workflow is active.
  52322. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52323. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52324. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  52325. */
  52326. useSpecularGlossinessInputEnergyConservation: boolean;
  52327. /** @hidden */
  52328. private _internalMarkAllSubMeshesAsMiscDirty;
  52329. /** @hidden */
  52330. _markAllSubMeshesAsMiscDirty(): void;
  52331. /**
  52332. * Instantiate a new istance of clear coat configuration.
  52333. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  52334. */
  52335. constructor(markAllSubMeshesAsMiscDirty: () => void);
  52336. /**
  52337. * Checks to see if a texture is used in the material.
  52338. * @param defines the list of "defines" to update.
  52339. */
  52340. prepareDefines(defines: IMaterialBRDFDefines): void;
  52341. /**
  52342. * Get the current class name of the texture useful for serialization or dynamic coding.
  52343. * @returns "PBRClearCoatConfiguration"
  52344. */
  52345. getClassName(): string;
  52346. /**
  52347. * Makes a duplicate of the current configuration into another one.
  52348. * @param brdfConfiguration define the config where to copy the info
  52349. */
  52350. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  52351. /**
  52352. * Serializes this BRDF configuration.
  52353. * @returns - An object with the serialized config.
  52354. */
  52355. serialize(): any;
  52356. /**
  52357. * Parses a anisotropy Configuration from a serialized object.
  52358. * @param source - Serialized object.
  52359. * @param scene Defines the scene we are parsing for
  52360. * @param rootUrl Defines the rootUrl to load from
  52361. */
  52362. parse(source: any, scene: Scene, rootUrl: string): void;
  52363. }
  52364. }
  52365. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  52366. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52367. import { Color3 } from "babylonjs/Maths/math.color";
  52368. import { Scene } from "babylonjs/scene";
  52369. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52370. import { Nullable } from "babylonjs/types";
  52371. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52372. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52373. /**
  52374. * @hidden
  52375. */
  52376. export interface IMaterialSheenDefines {
  52377. SHEEN: boolean;
  52378. SHEEN_TEXTURE: boolean;
  52379. SHEEN_TEXTUREDIRECTUV: number;
  52380. SHEEN_LINKWITHALBEDO: boolean;
  52381. /** @hidden */
  52382. _areTexturesDirty: boolean;
  52383. }
  52384. /**
  52385. * Define the code related to the Sheen parameters of the pbr material.
  52386. */
  52387. export class PBRSheenConfiguration {
  52388. private _isEnabled;
  52389. /**
  52390. * Defines if the material uses sheen.
  52391. */
  52392. isEnabled: boolean;
  52393. private _linkSheenWithAlbedo;
  52394. /**
  52395. * Defines if the sheen is linked to the sheen color.
  52396. */
  52397. linkSheenWithAlbedo: boolean;
  52398. /**
  52399. * Defines the sheen intensity.
  52400. */
  52401. intensity: number;
  52402. /**
  52403. * Defines the sheen color.
  52404. */
  52405. color: Color3;
  52406. private _texture;
  52407. /**
  52408. * Stores the sheen tint values in a texture.
  52409. * rgb is tint
  52410. * a is a intensity
  52411. */
  52412. texture: Nullable<BaseTexture>;
  52413. /** @hidden */
  52414. private _internalMarkAllSubMeshesAsTexturesDirty;
  52415. /** @hidden */
  52416. _markAllSubMeshesAsTexturesDirty(): void;
  52417. /**
  52418. * Instantiate a new istance of clear coat configuration.
  52419. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52420. */
  52421. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52422. /**
  52423. * Specifies that the submesh is ready to be used.
  52424. * @param defines the list of "defines" to update.
  52425. * @param scene defines the scene the material belongs to.
  52426. * @returns - boolean indicating that the submesh is ready or not.
  52427. */
  52428. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  52429. /**
  52430. * Checks to see if a texture is used in the material.
  52431. * @param defines the list of "defines" to update.
  52432. * @param scene defines the scene the material belongs to.
  52433. */
  52434. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  52435. /**
  52436. * Binds the material data.
  52437. * @param uniformBuffer defines the Uniform buffer to fill in.
  52438. * @param scene defines the scene the material belongs to.
  52439. * @param isFrozen defines wether the material is frozen or not.
  52440. */
  52441. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52442. /**
  52443. * Checks to see if a texture is used in the material.
  52444. * @param texture - Base texture to use.
  52445. * @returns - Boolean specifying if a texture is used in the material.
  52446. */
  52447. hasTexture(texture: BaseTexture): boolean;
  52448. /**
  52449. * Returns an array of the actively used textures.
  52450. * @param activeTextures Array of BaseTextures
  52451. */
  52452. getActiveTextures(activeTextures: BaseTexture[]): void;
  52453. /**
  52454. * Returns the animatable textures.
  52455. * @param animatables Array of animatable textures.
  52456. */
  52457. getAnimatables(animatables: IAnimatable[]): void;
  52458. /**
  52459. * Disposes the resources of the material.
  52460. * @param forceDisposeTextures - Forces the disposal of all textures.
  52461. */
  52462. dispose(forceDisposeTextures?: boolean): void;
  52463. /**
  52464. * Get the current class name of the texture useful for serialization or dynamic coding.
  52465. * @returns "PBRSheenConfiguration"
  52466. */
  52467. getClassName(): string;
  52468. /**
  52469. * Add fallbacks to the effect fallbacks list.
  52470. * @param defines defines the Base texture to use.
  52471. * @param fallbacks defines the current fallback list.
  52472. * @param currentRank defines the current fallback rank.
  52473. * @returns the new fallback rank.
  52474. */
  52475. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52476. /**
  52477. * Add the required uniforms to the current list.
  52478. * @param uniforms defines the current uniform list.
  52479. */
  52480. static AddUniforms(uniforms: string[]): void;
  52481. /**
  52482. * Add the required uniforms to the current buffer.
  52483. * @param uniformBuffer defines the current uniform buffer.
  52484. */
  52485. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52486. /**
  52487. * Add the required samplers to the current list.
  52488. * @param samplers defines the current sampler list.
  52489. */
  52490. static AddSamplers(samplers: string[]): void;
  52491. /**
  52492. * Makes a duplicate of the current configuration into another one.
  52493. * @param sheenConfiguration define the config where to copy the info
  52494. */
  52495. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  52496. /**
  52497. * Serializes this BRDF configuration.
  52498. * @returns - An object with the serialized config.
  52499. */
  52500. serialize(): any;
  52501. /**
  52502. * Parses a anisotropy Configuration from a serialized object.
  52503. * @param source - Serialized object.
  52504. * @param scene Defines the scene we are parsing for
  52505. * @param rootUrl Defines the rootUrl to load from
  52506. */
  52507. parse(source: any, scene: Scene, rootUrl: string): void;
  52508. }
  52509. }
  52510. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  52511. import { Nullable } from "babylonjs/types";
  52512. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52513. import { Color3 } from "babylonjs/Maths/math.color";
  52514. import { SmartArray } from "babylonjs/Misc/smartArray";
  52515. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52516. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52517. import { Effect } from "babylonjs/Materials/effect";
  52518. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52519. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52520. import { Engine } from "babylonjs/Engines/engine";
  52521. import { Scene } from "babylonjs/scene";
  52522. /**
  52523. * @hidden
  52524. */
  52525. export interface IMaterialSubSurfaceDefines {
  52526. SUBSURFACE: boolean;
  52527. SS_REFRACTION: boolean;
  52528. SS_TRANSLUCENCY: boolean;
  52529. SS_SCATERRING: boolean;
  52530. SS_THICKNESSANDMASK_TEXTURE: boolean;
  52531. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  52532. SS_REFRACTIONMAP_3D: boolean;
  52533. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  52534. SS_LODINREFRACTIONALPHA: boolean;
  52535. SS_GAMMAREFRACTION: boolean;
  52536. SS_RGBDREFRACTION: boolean;
  52537. SS_LINEARSPECULARREFRACTION: boolean;
  52538. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  52539. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  52540. /** @hidden */
  52541. _areTexturesDirty: boolean;
  52542. }
  52543. /**
  52544. * Define the code related to the sub surface parameters of the pbr material.
  52545. */
  52546. export class PBRSubSurfaceConfiguration {
  52547. private _isRefractionEnabled;
  52548. /**
  52549. * Defines if the refraction is enabled in the material.
  52550. */
  52551. isRefractionEnabled: boolean;
  52552. private _isTranslucencyEnabled;
  52553. /**
  52554. * Defines if the translucency is enabled in the material.
  52555. */
  52556. isTranslucencyEnabled: boolean;
  52557. private _isScatteringEnabled;
  52558. /**
  52559. * Defines the refraction intensity of the material.
  52560. * The refraction when enabled replaces the Diffuse part of the material.
  52561. * The intensity helps transitionning between diffuse and refraction.
  52562. */
  52563. refractionIntensity: number;
  52564. /**
  52565. * Defines the translucency intensity of the material.
  52566. * When translucency has been enabled, this defines how much of the "translucency"
  52567. * is addded to the diffuse part of the material.
  52568. */
  52569. translucencyIntensity: number;
  52570. /**
  52571. * Defines the scattering intensity of the material.
  52572. * When scattering has been enabled, this defines how much of the "scattered light"
  52573. * is addded to the diffuse part of the material.
  52574. */
  52575. scatteringIntensity: number;
  52576. private _thicknessTexture;
  52577. /**
  52578. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  52579. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  52580. * 0 would mean minimumThickness
  52581. * 1 would mean maximumThickness
  52582. * The other channels might be use as a mask to vary the different effects intensity.
  52583. */
  52584. thicknessTexture: Nullable<BaseTexture>;
  52585. private _refractionTexture;
  52586. /**
  52587. * Defines the texture to use for refraction.
  52588. */
  52589. refractionTexture: Nullable<BaseTexture>;
  52590. private _indexOfRefraction;
  52591. /**
  52592. * Defines the index of refraction used in the material.
  52593. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  52594. */
  52595. indexOfRefraction: number;
  52596. private _invertRefractionY;
  52597. /**
  52598. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52599. */
  52600. invertRefractionY: boolean;
  52601. private _linkRefractionWithTransparency;
  52602. /**
  52603. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52604. * Materials half opaque for instance using refraction could benefit from this control.
  52605. */
  52606. linkRefractionWithTransparency: boolean;
  52607. /**
  52608. * Defines the minimum thickness stored in the thickness map.
  52609. * If no thickness map is defined, this value will be used to simulate thickness.
  52610. */
  52611. minimumThickness: number;
  52612. /**
  52613. * Defines the maximum thickness stored in the thickness map.
  52614. */
  52615. maximumThickness: number;
  52616. /**
  52617. * Defines the volume tint of the material.
  52618. * This is used for both translucency and scattering.
  52619. */
  52620. tintColor: Color3;
  52621. /**
  52622. * Defines the distance at which the tint color should be found in the media.
  52623. * This is used for refraction only.
  52624. */
  52625. tintColorAtDistance: number;
  52626. /**
  52627. * Defines how far each channel transmit through the media.
  52628. * It is defined as a color to simplify it selection.
  52629. */
  52630. diffusionDistance: Color3;
  52631. private _useMaskFromThicknessTexture;
  52632. /**
  52633. * Stores the intensity of the different subsurface effects in the thickness texture.
  52634. * * the green channel is the translucency intensity.
  52635. * * the blue channel is the scattering intensity.
  52636. * * the alpha channel is the refraction intensity.
  52637. */
  52638. useMaskFromThicknessTexture: boolean;
  52639. /** @hidden */
  52640. private _internalMarkAllSubMeshesAsTexturesDirty;
  52641. /** @hidden */
  52642. _markAllSubMeshesAsTexturesDirty(): void;
  52643. /**
  52644. * Instantiate a new istance of sub surface configuration.
  52645. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52646. */
  52647. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52648. /**
  52649. * Gets wehter the submesh is ready to be used or not.
  52650. * @param defines the list of "defines" to update.
  52651. * @param scene defines the scene the material belongs to.
  52652. * @returns - boolean indicating that the submesh is ready or not.
  52653. */
  52654. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  52655. /**
  52656. * Checks to see if a texture is used in the material.
  52657. * @param defines the list of "defines" to update.
  52658. * @param scene defines the scene to the material belongs to.
  52659. */
  52660. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  52661. /**
  52662. * Binds the material data.
  52663. * @param uniformBuffer defines the Uniform buffer to fill in.
  52664. * @param scene defines the scene the material belongs to.
  52665. * @param engine defines the engine the material belongs to.
  52666. * @param isFrozen defines wether the material is frozen or not.
  52667. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  52668. */
  52669. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  52670. /**
  52671. * Unbinds the material from the mesh.
  52672. * @param activeEffect defines the effect that should be unbound from.
  52673. * @returns true if unbound, otherwise false
  52674. */
  52675. unbind(activeEffect: Effect): boolean;
  52676. /**
  52677. * Returns the texture used for refraction or null if none is used.
  52678. * @param scene defines the scene the material belongs to.
  52679. * @returns - Refraction texture if present. If no refraction texture and refraction
  52680. * is linked with transparency, returns environment texture. Otherwise, returns null.
  52681. */
  52682. private _getRefractionTexture;
  52683. /**
  52684. * Returns true if alpha blending should be disabled.
  52685. */
  52686. get disableAlphaBlending(): boolean;
  52687. /**
  52688. * Fills the list of render target textures.
  52689. * @param renderTargets the list of render targets to update
  52690. */
  52691. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  52692. /**
  52693. * Checks to see if a texture is used in the material.
  52694. * @param texture - Base texture to use.
  52695. * @returns - Boolean specifying if a texture is used in the material.
  52696. */
  52697. hasTexture(texture: BaseTexture): boolean;
  52698. /**
  52699. * Gets a boolean indicating that current material needs to register RTT
  52700. * @returns true if this uses a render target otherwise false.
  52701. */
  52702. hasRenderTargetTextures(): boolean;
  52703. /**
  52704. * Returns an array of the actively used textures.
  52705. * @param activeTextures Array of BaseTextures
  52706. */
  52707. getActiveTextures(activeTextures: BaseTexture[]): void;
  52708. /**
  52709. * Returns the animatable textures.
  52710. * @param animatables Array of animatable textures.
  52711. */
  52712. getAnimatables(animatables: IAnimatable[]): void;
  52713. /**
  52714. * Disposes the resources of the material.
  52715. * @param forceDisposeTextures - Forces the disposal of all textures.
  52716. */
  52717. dispose(forceDisposeTextures?: boolean): void;
  52718. /**
  52719. * Get the current class name of the texture useful for serialization or dynamic coding.
  52720. * @returns "PBRSubSurfaceConfiguration"
  52721. */
  52722. getClassName(): string;
  52723. /**
  52724. * Add fallbacks to the effect fallbacks list.
  52725. * @param defines defines the Base texture to use.
  52726. * @param fallbacks defines the current fallback list.
  52727. * @param currentRank defines the current fallback rank.
  52728. * @returns the new fallback rank.
  52729. */
  52730. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52731. /**
  52732. * Add the required uniforms to the current list.
  52733. * @param uniforms defines the current uniform list.
  52734. */
  52735. static AddUniforms(uniforms: string[]): void;
  52736. /**
  52737. * Add the required samplers to the current list.
  52738. * @param samplers defines the current sampler list.
  52739. */
  52740. static AddSamplers(samplers: string[]): void;
  52741. /**
  52742. * Add the required uniforms to the current buffer.
  52743. * @param uniformBuffer defines the current uniform buffer.
  52744. */
  52745. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52746. /**
  52747. * Makes a duplicate of the current configuration into another one.
  52748. * @param configuration define the config where to copy the info
  52749. */
  52750. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  52751. /**
  52752. * Serializes this Sub Surface configuration.
  52753. * @returns - An object with the serialized config.
  52754. */
  52755. serialize(): any;
  52756. /**
  52757. * Parses a anisotropy Configuration from a serialized object.
  52758. * @param source - Serialized object.
  52759. * @param scene Defines the scene we are parsing for
  52760. * @param rootUrl Defines the rootUrl to load from
  52761. */
  52762. parse(source: any, scene: Scene, rootUrl: string): void;
  52763. }
  52764. }
  52765. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  52766. /** @hidden */
  52767. export var pbrFragmentDeclaration: {
  52768. name: string;
  52769. shader: string;
  52770. };
  52771. }
  52772. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  52773. /** @hidden */
  52774. export var pbrUboDeclaration: {
  52775. name: string;
  52776. shader: string;
  52777. };
  52778. }
  52779. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  52780. /** @hidden */
  52781. export var pbrFragmentExtraDeclaration: {
  52782. name: string;
  52783. shader: string;
  52784. };
  52785. }
  52786. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  52787. /** @hidden */
  52788. export var pbrFragmentSamplersDeclaration: {
  52789. name: string;
  52790. shader: string;
  52791. };
  52792. }
  52793. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  52794. /** @hidden */
  52795. export var pbrHelperFunctions: {
  52796. name: string;
  52797. shader: string;
  52798. };
  52799. }
  52800. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  52801. /** @hidden */
  52802. export var harmonicsFunctions: {
  52803. name: string;
  52804. shader: string;
  52805. };
  52806. }
  52807. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  52808. /** @hidden */
  52809. export var pbrDirectLightingSetupFunctions: {
  52810. name: string;
  52811. shader: string;
  52812. };
  52813. }
  52814. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  52815. /** @hidden */
  52816. export var pbrDirectLightingFalloffFunctions: {
  52817. name: string;
  52818. shader: string;
  52819. };
  52820. }
  52821. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  52822. /** @hidden */
  52823. export var pbrBRDFFunctions: {
  52824. name: string;
  52825. shader: string;
  52826. };
  52827. }
  52828. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  52829. /** @hidden */
  52830. export var pbrDirectLightingFunctions: {
  52831. name: string;
  52832. shader: string;
  52833. };
  52834. }
  52835. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  52836. /** @hidden */
  52837. export var pbrIBLFunctions: {
  52838. name: string;
  52839. shader: string;
  52840. };
  52841. }
  52842. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  52843. /** @hidden */
  52844. export var pbrDebug: {
  52845. name: string;
  52846. shader: string;
  52847. };
  52848. }
  52849. declare module "babylonjs/Shaders/pbr.fragment" {
  52850. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  52851. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  52852. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  52853. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  52854. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  52855. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  52856. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  52857. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  52858. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  52859. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  52860. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52861. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  52862. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  52863. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  52864. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  52865. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  52866. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  52867. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  52868. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  52869. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  52870. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  52871. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  52872. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  52873. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  52874. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  52875. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  52876. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  52877. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  52878. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  52879. /** @hidden */
  52880. export var pbrPixelShader: {
  52881. name: string;
  52882. shader: string;
  52883. };
  52884. }
  52885. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  52886. /** @hidden */
  52887. export var pbrVertexDeclaration: {
  52888. name: string;
  52889. shader: string;
  52890. };
  52891. }
  52892. declare module "babylonjs/Shaders/pbr.vertex" {
  52893. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  52894. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  52895. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52896. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  52897. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  52898. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  52899. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  52900. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  52901. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  52902. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  52903. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  52904. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  52905. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  52906. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  52907. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  52908. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  52909. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  52910. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  52911. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  52912. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  52913. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  52914. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  52915. /** @hidden */
  52916. export var pbrVertexShader: {
  52917. name: string;
  52918. shader: string;
  52919. };
  52920. }
  52921. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  52922. import { Nullable } from "babylonjs/types";
  52923. import { Scene } from "babylonjs/scene";
  52924. import { Matrix } from "babylonjs/Maths/math.vector";
  52925. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52926. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52927. import { Mesh } from "babylonjs/Meshes/mesh";
  52928. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  52929. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  52930. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  52931. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  52932. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  52933. import { Color3 } from "babylonjs/Maths/math.color";
  52934. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  52935. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  52936. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  52937. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  52938. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52939. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52940. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  52941. import "babylonjs/Shaders/pbr.fragment";
  52942. import "babylonjs/Shaders/pbr.vertex";
  52943. /**
  52944. * Manages the defines for the PBR Material.
  52945. * @hidden
  52946. */
  52947. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  52948. PBR: boolean;
  52949. MAINUV1: boolean;
  52950. MAINUV2: boolean;
  52951. UV1: boolean;
  52952. UV2: boolean;
  52953. ALBEDO: boolean;
  52954. ALBEDODIRECTUV: number;
  52955. VERTEXCOLOR: boolean;
  52956. AMBIENT: boolean;
  52957. AMBIENTDIRECTUV: number;
  52958. AMBIENTINGRAYSCALE: boolean;
  52959. OPACITY: boolean;
  52960. VERTEXALPHA: boolean;
  52961. OPACITYDIRECTUV: number;
  52962. OPACITYRGB: boolean;
  52963. ALPHATEST: boolean;
  52964. DEPTHPREPASS: boolean;
  52965. ALPHABLEND: boolean;
  52966. ALPHAFROMALBEDO: boolean;
  52967. ALPHATESTVALUE: string;
  52968. SPECULAROVERALPHA: boolean;
  52969. RADIANCEOVERALPHA: boolean;
  52970. ALPHAFRESNEL: boolean;
  52971. LINEARALPHAFRESNEL: boolean;
  52972. PREMULTIPLYALPHA: boolean;
  52973. EMISSIVE: boolean;
  52974. EMISSIVEDIRECTUV: number;
  52975. REFLECTIVITY: boolean;
  52976. REFLECTIVITYDIRECTUV: number;
  52977. SPECULARTERM: boolean;
  52978. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  52979. MICROSURFACEAUTOMATIC: boolean;
  52980. LODBASEDMICROSFURACE: boolean;
  52981. MICROSURFACEMAP: boolean;
  52982. MICROSURFACEMAPDIRECTUV: number;
  52983. METALLICWORKFLOW: boolean;
  52984. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  52985. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  52986. METALLNESSSTOREINMETALMAPBLUE: boolean;
  52987. AOSTOREINMETALMAPRED: boolean;
  52988. METALLICF0FACTORFROMMETALLICMAP: boolean;
  52989. ENVIRONMENTBRDF: boolean;
  52990. ENVIRONMENTBRDF_RGBD: boolean;
  52991. NORMAL: boolean;
  52992. TANGENT: boolean;
  52993. BUMP: boolean;
  52994. BUMPDIRECTUV: number;
  52995. OBJECTSPACE_NORMALMAP: boolean;
  52996. PARALLAX: boolean;
  52997. PARALLAXOCCLUSION: boolean;
  52998. NORMALXYSCALE: boolean;
  52999. LIGHTMAP: boolean;
  53000. LIGHTMAPDIRECTUV: number;
  53001. USELIGHTMAPASSHADOWMAP: boolean;
  53002. GAMMALIGHTMAP: boolean;
  53003. RGBDLIGHTMAP: boolean;
  53004. REFLECTION: boolean;
  53005. REFLECTIONMAP_3D: boolean;
  53006. REFLECTIONMAP_SPHERICAL: boolean;
  53007. REFLECTIONMAP_PLANAR: boolean;
  53008. REFLECTIONMAP_CUBIC: boolean;
  53009. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  53010. REFLECTIONMAP_PROJECTION: boolean;
  53011. REFLECTIONMAP_SKYBOX: boolean;
  53012. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  53013. REFLECTIONMAP_EXPLICIT: boolean;
  53014. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  53015. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  53016. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  53017. INVERTCUBICMAP: boolean;
  53018. USESPHERICALFROMREFLECTIONMAP: boolean;
  53019. USEIRRADIANCEMAP: boolean;
  53020. SPHERICAL_HARMONICS: boolean;
  53021. USESPHERICALINVERTEX: boolean;
  53022. REFLECTIONMAP_OPPOSITEZ: boolean;
  53023. LODINREFLECTIONALPHA: boolean;
  53024. GAMMAREFLECTION: boolean;
  53025. RGBDREFLECTION: boolean;
  53026. LINEARSPECULARREFLECTION: boolean;
  53027. RADIANCEOCCLUSION: boolean;
  53028. HORIZONOCCLUSION: boolean;
  53029. INSTANCES: boolean;
  53030. NUM_BONE_INFLUENCERS: number;
  53031. BonesPerMesh: number;
  53032. BONETEXTURE: boolean;
  53033. NONUNIFORMSCALING: boolean;
  53034. MORPHTARGETS: boolean;
  53035. MORPHTARGETS_NORMAL: boolean;
  53036. MORPHTARGETS_TANGENT: boolean;
  53037. MORPHTARGETS_UV: boolean;
  53038. NUM_MORPH_INFLUENCERS: number;
  53039. IMAGEPROCESSING: boolean;
  53040. VIGNETTE: boolean;
  53041. VIGNETTEBLENDMODEMULTIPLY: boolean;
  53042. VIGNETTEBLENDMODEOPAQUE: boolean;
  53043. TONEMAPPING: boolean;
  53044. TONEMAPPING_ACES: boolean;
  53045. CONTRAST: boolean;
  53046. COLORCURVES: boolean;
  53047. COLORGRADING: boolean;
  53048. COLORGRADING3D: boolean;
  53049. SAMPLER3DGREENDEPTH: boolean;
  53050. SAMPLER3DBGRMAP: boolean;
  53051. IMAGEPROCESSINGPOSTPROCESS: boolean;
  53052. EXPOSURE: boolean;
  53053. MULTIVIEW: boolean;
  53054. USEPHYSICALLIGHTFALLOFF: boolean;
  53055. USEGLTFLIGHTFALLOFF: boolean;
  53056. TWOSIDEDLIGHTING: boolean;
  53057. SHADOWFLOAT: boolean;
  53058. CLIPPLANE: boolean;
  53059. CLIPPLANE2: boolean;
  53060. CLIPPLANE3: boolean;
  53061. CLIPPLANE4: boolean;
  53062. CLIPPLANE5: boolean;
  53063. CLIPPLANE6: boolean;
  53064. POINTSIZE: boolean;
  53065. FOG: boolean;
  53066. LOGARITHMICDEPTH: boolean;
  53067. FORCENORMALFORWARD: boolean;
  53068. SPECULARAA: boolean;
  53069. CLEARCOAT: boolean;
  53070. CLEARCOAT_DEFAULTIOR: boolean;
  53071. CLEARCOAT_TEXTURE: boolean;
  53072. CLEARCOAT_TEXTUREDIRECTUV: number;
  53073. CLEARCOAT_BUMP: boolean;
  53074. CLEARCOAT_BUMPDIRECTUV: number;
  53075. CLEARCOAT_TINT: boolean;
  53076. CLEARCOAT_TINT_TEXTURE: boolean;
  53077. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  53078. ANISOTROPIC: boolean;
  53079. ANISOTROPIC_TEXTURE: boolean;
  53080. ANISOTROPIC_TEXTUREDIRECTUV: number;
  53081. BRDF_V_HEIGHT_CORRELATED: boolean;
  53082. MS_BRDF_ENERGY_CONSERVATION: boolean;
  53083. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  53084. SHEEN: boolean;
  53085. SHEEN_TEXTURE: boolean;
  53086. SHEEN_TEXTUREDIRECTUV: number;
  53087. SHEEN_LINKWITHALBEDO: boolean;
  53088. SUBSURFACE: boolean;
  53089. SS_REFRACTION: boolean;
  53090. SS_TRANSLUCENCY: boolean;
  53091. SS_SCATERRING: boolean;
  53092. SS_THICKNESSANDMASK_TEXTURE: boolean;
  53093. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  53094. SS_REFRACTIONMAP_3D: boolean;
  53095. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  53096. SS_LODINREFRACTIONALPHA: boolean;
  53097. SS_GAMMAREFRACTION: boolean;
  53098. SS_RGBDREFRACTION: boolean;
  53099. SS_LINEARSPECULARREFRACTION: boolean;
  53100. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  53101. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  53102. UNLIT: boolean;
  53103. DEBUGMODE: number;
  53104. /**
  53105. * Initializes the PBR Material defines.
  53106. */
  53107. constructor();
  53108. /**
  53109. * Resets the PBR Material defines.
  53110. */
  53111. reset(): void;
  53112. }
  53113. /**
  53114. * The Physically based material base class of BJS.
  53115. *
  53116. * This offers the main features of a standard PBR material.
  53117. * For more information, please refer to the documentation :
  53118. * https://doc.babylonjs.com/how_to/physically_based_rendering
  53119. */
  53120. export abstract class PBRBaseMaterial extends PushMaterial {
  53121. /**
  53122. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53123. */
  53124. static readonly PBRMATERIAL_OPAQUE: number;
  53125. /**
  53126. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53127. */
  53128. static readonly PBRMATERIAL_ALPHATEST: number;
  53129. /**
  53130. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53131. */
  53132. static readonly PBRMATERIAL_ALPHABLEND: number;
  53133. /**
  53134. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53135. * They are also discarded below the alpha cutoff threshold to improve performances.
  53136. */
  53137. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  53138. /**
  53139. * Defines the default value of how much AO map is occluding the analytical lights
  53140. * (point spot...).
  53141. */
  53142. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  53143. /**
  53144. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  53145. */
  53146. static readonly LIGHTFALLOFF_PHYSICAL: number;
  53147. /**
  53148. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  53149. * to enhance interoperability with other engines.
  53150. */
  53151. static readonly LIGHTFALLOFF_GLTF: number;
  53152. /**
  53153. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  53154. * to enhance interoperability with other materials.
  53155. */
  53156. static readonly LIGHTFALLOFF_STANDARD: number;
  53157. /**
  53158. * Intensity of the direct lights e.g. the four lights available in your scene.
  53159. * This impacts both the direct diffuse and specular highlights.
  53160. */
  53161. protected _directIntensity: number;
  53162. /**
  53163. * Intensity of the emissive part of the material.
  53164. * This helps controlling the emissive effect without modifying the emissive color.
  53165. */
  53166. protected _emissiveIntensity: number;
  53167. /**
  53168. * Intensity of the environment e.g. how much the environment will light the object
  53169. * either through harmonics for rough material or through the refelction for shiny ones.
  53170. */
  53171. protected _environmentIntensity: number;
  53172. /**
  53173. * This is a special control allowing the reduction of the specular highlights coming from the
  53174. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53175. */
  53176. protected _specularIntensity: number;
  53177. /**
  53178. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  53179. */
  53180. private _lightingInfos;
  53181. /**
  53182. * Debug Control allowing disabling the bump map on this material.
  53183. */
  53184. protected _disableBumpMap: boolean;
  53185. /**
  53186. * AKA Diffuse Texture in standard nomenclature.
  53187. */
  53188. protected _albedoTexture: Nullable<BaseTexture>;
  53189. /**
  53190. * AKA Occlusion Texture in other nomenclature.
  53191. */
  53192. protected _ambientTexture: Nullable<BaseTexture>;
  53193. /**
  53194. * AKA Occlusion Texture Intensity in other nomenclature.
  53195. */
  53196. protected _ambientTextureStrength: number;
  53197. /**
  53198. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53199. * 1 means it completely occludes it
  53200. * 0 mean it has no impact
  53201. */
  53202. protected _ambientTextureImpactOnAnalyticalLights: number;
  53203. /**
  53204. * Stores the alpha values in a texture.
  53205. */
  53206. protected _opacityTexture: Nullable<BaseTexture>;
  53207. /**
  53208. * Stores the reflection values in a texture.
  53209. */
  53210. protected _reflectionTexture: Nullable<BaseTexture>;
  53211. /**
  53212. * Stores the emissive values in a texture.
  53213. */
  53214. protected _emissiveTexture: Nullable<BaseTexture>;
  53215. /**
  53216. * AKA Specular texture in other nomenclature.
  53217. */
  53218. protected _reflectivityTexture: Nullable<BaseTexture>;
  53219. /**
  53220. * Used to switch from specular/glossiness to metallic/roughness workflow.
  53221. */
  53222. protected _metallicTexture: Nullable<BaseTexture>;
  53223. /**
  53224. * Specifies the metallic scalar of the metallic/roughness workflow.
  53225. * Can also be used to scale the metalness values of the metallic texture.
  53226. */
  53227. protected _metallic: Nullable<number>;
  53228. /**
  53229. * Specifies the roughness scalar of the metallic/roughness workflow.
  53230. * Can also be used to scale the roughness values of the metallic texture.
  53231. */
  53232. protected _roughness: Nullable<number>;
  53233. /**
  53234. * Specifies the an F0 factor to help configuring the material F0.
  53235. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  53236. * to 0.5 the previously hard coded value stays the same.
  53237. * Can also be used to scale the F0 values of the metallic texture.
  53238. */
  53239. protected _metallicF0Factor: number;
  53240. /**
  53241. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  53242. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  53243. * your expectation as it multiplies with the texture data.
  53244. */
  53245. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  53246. /**
  53247. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  53248. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  53249. */
  53250. protected _microSurfaceTexture: Nullable<BaseTexture>;
  53251. /**
  53252. * Stores surface normal data used to displace a mesh in a texture.
  53253. */
  53254. protected _bumpTexture: Nullable<BaseTexture>;
  53255. /**
  53256. * Stores the pre-calculated light information of a mesh in a texture.
  53257. */
  53258. protected _lightmapTexture: Nullable<BaseTexture>;
  53259. /**
  53260. * The color of a material in ambient lighting.
  53261. */
  53262. protected _ambientColor: Color3;
  53263. /**
  53264. * AKA Diffuse Color in other nomenclature.
  53265. */
  53266. protected _albedoColor: Color3;
  53267. /**
  53268. * AKA Specular Color in other nomenclature.
  53269. */
  53270. protected _reflectivityColor: Color3;
  53271. /**
  53272. * The color applied when light is reflected from a material.
  53273. */
  53274. protected _reflectionColor: Color3;
  53275. /**
  53276. * The color applied when light is emitted from a material.
  53277. */
  53278. protected _emissiveColor: Color3;
  53279. /**
  53280. * AKA Glossiness in other nomenclature.
  53281. */
  53282. protected _microSurface: number;
  53283. /**
  53284. * Specifies that the material will use the light map as a show map.
  53285. */
  53286. protected _useLightmapAsShadowmap: boolean;
  53287. /**
  53288. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  53289. * makes the reflect vector face the model (under horizon).
  53290. */
  53291. protected _useHorizonOcclusion: boolean;
  53292. /**
  53293. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  53294. * too much the area relying on ambient texture to define their ambient occlusion.
  53295. */
  53296. protected _useRadianceOcclusion: boolean;
  53297. /**
  53298. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  53299. */
  53300. protected _useAlphaFromAlbedoTexture: boolean;
  53301. /**
  53302. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  53303. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  53304. */
  53305. protected _useSpecularOverAlpha: boolean;
  53306. /**
  53307. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  53308. */
  53309. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  53310. /**
  53311. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  53312. */
  53313. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  53314. /**
  53315. * Specifies if the metallic texture contains the roughness information in its green channel.
  53316. */
  53317. protected _useRoughnessFromMetallicTextureGreen: boolean;
  53318. /**
  53319. * Specifies if the metallic texture contains the metallness information in its blue channel.
  53320. */
  53321. protected _useMetallnessFromMetallicTextureBlue: boolean;
  53322. /**
  53323. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  53324. */
  53325. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  53326. /**
  53327. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  53328. */
  53329. protected _useAmbientInGrayScale: boolean;
  53330. /**
  53331. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  53332. * The material will try to infer what glossiness each pixel should be.
  53333. */
  53334. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  53335. /**
  53336. * Defines the falloff type used in this material.
  53337. * It by default is Physical.
  53338. */
  53339. protected _lightFalloff: number;
  53340. /**
  53341. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  53342. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  53343. */
  53344. protected _useRadianceOverAlpha: boolean;
  53345. /**
  53346. * Allows using an object space normal map (instead of tangent space).
  53347. */
  53348. protected _useObjectSpaceNormalMap: boolean;
  53349. /**
  53350. * Allows using the bump map in parallax mode.
  53351. */
  53352. protected _useParallax: boolean;
  53353. /**
  53354. * Allows using the bump map in parallax occlusion mode.
  53355. */
  53356. protected _useParallaxOcclusion: boolean;
  53357. /**
  53358. * Controls the scale bias of the parallax mode.
  53359. */
  53360. protected _parallaxScaleBias: number;
  53361. /**
  53362. * If sets to true, disables all the lights affecting the material.
  53363. */
  53364. protected _disableLighting: boolean;
  53365. /**
  53366. * Number of Simultaneous lights allowed on the material.
  53367. */
  53368. protected _maxSimultaneousLights: number;
  53369. /**
  53370. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  53371. */
  53372. protected _invertNormalMapX: boolean;
  53373. /**
  53374. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  53375. */
  53376. protected _invertNormalMapY: boolean;
  53377. /**
  53378. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53379. */
  53380. protected _twoSidedLighting: boolean;
  53381. /**
  53382. * Defines the alpha limits in alpha test mode.
  53383. */
  53384. protected _alphaCutOff: number;
  53385. /**
  53386. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  53387. */
  53388. protected _forceAlphaTest: boolean;
  53389. /**
  53390. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53391. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  53392. */
  53393. protected _useAlphaFresnel: boolean;
  53394. /**
  53395. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53396. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  53397. */
  53398. protected _useLinearAlphaFresnel: boolean;
  53399. /**
  53400. * The transparency mode of the material.
  53401. */
  53402. protected _transparencyMode: Nullable<number>;
  53403. /**
  53404. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  53405. * from cos thetav and roughness:
  53406. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  53407. */
  53408. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  53409. /**
  53410. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  53411. */
  53412. protected _forceIrradianceInFragment: boolean;
  53413. /**
  53414. * Force normal to face away from face.
  53415. */
  53416. protected _forceNormalForward: boolean;
  53417. /**
  53418. * Enables specular anti aliasing in the PBR shader.
  53419. * It will both interacts on the Geometry for analytical and IBL lighting.
  53420. * It also prefilter the roughness map based on the bump values.
  53421. */
  53422. protected _enableSpecularAntiAliasing: boolean;
  53423. /**
  53424. * Default configuration related to image processing available in the PBR Material.
  53425. */
  53426. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53427. /**
  53428. * Keep track of the image processing observer to allow dispose and replace.
  53429. */
  53430. private _imageProcessingObserver;
  53431. /**
  53432. * Attaches a new image processing configuration to the PBR Material.
  53433. * @param configuration
  53434. */
  53435. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53436. /**
  53437. * Stores the available render targets.
  53438. */
  53439. private _renderTargets;
  53440. /**
  53441. * Sets the global ambient color for the material used in lighting calculations.
  53442. */
  53443. private _globalAmbientColor;
  53444. /**
  53445. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  53446. */
  53447. private _useLogarithmicDepth;
  53448. /**
  53449. * If set to true, no lighting calculations will be applied.
  53450. */
  53451. private _unlit;
  53452. private _debugMode;
  53453. /**
  53454. * @hidden
  53455. * This is reserved for the inspector.
  53456. * Defines the material debug mode.
  53457. * It helps seeing only some components of the material while troubleshooting.
  53458. */
  53459. debugMode: number;
  53460. /**
  53461. * @hidden
  53462. * This is reserved for the inspector.
  53463. * Specify from where on screen the debug mode should start.
  53464. * The value goes from -1 (full screen) to 1 (not visible)
  53465. * It helps with side by side comparison against the final render
  53466. * This defaults to -1
  53467. */
  53468. private debugLimit;
  53469. /**
  53470. * @hidden
  53471. * This is reserved for the inspector.
  53472. * As the default viewing range might not be enough (if the ambient is really small for instance)
  53473. * You can use the factor to better multiply the final value.
  53474. */
  53475. private debugFactor;
  53476. /**
  53477. * Defines the clear coat layer parameters for the material.
  53478. */
  53479. readonly clearCoat: PBRClearCoatConfiguration;
  53480. /**
  53481. * Defines the anisotropic parameters for the material.
  53482. */
  53483. readonly anisotropy: PBRAnisotropicConfiguration;
  53484. /**
  53485. * Defines the BRDF parameters for the material.
  53486. */
  53487. readonly brdf: PBRBRDFConfiguration;
  53488. /**
  53489. * Defines the Sheen parameters for the material.
  53490. */
  53491. readonly sheen: PBRSheenConfiguration;
  53492. /**
  53493. * Defines the SubSurface parameters for the material.
  53494. */
  53495. readonly subSurface: PBRSubSurfaceConfiguration;
  53496. /**
  53497. * Custom callback helping to override the default shader used in the material.
  53498. */
  53499. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  53500. protected _rebuildInParallel: boolean;
  53501. /**
  53502. * Instantiates a new PBRMaterial instance.
  53503. *
  53504. * @param name The material name
  53505. * @param scene The scene the material will be use in.
  53506. */
  53507. constructor(name: string, scene: Scene);
  53508. /**
  53509. * Gets a boolean indicating that current material needs to register RTT
  53510. */
  53511. get hasRenderTargetTextures(): boolean;
  53512. /**
  53513. * Gets the name of the material class.
  53514. */
  53515. getClassName(): string;
  53516. /**
  53517. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  53518. */
  53519. get useLogarithmicDepth(): boolean;
  53520. /**
  53521. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  53522. */
  53523. set useLogarithmicDepth(value: boolean);
  53524. /**
  53525. * Gets the current transparency mode.
  53526. */
  53527. get transparencyMode(): Nullable<number>;
  53528. /**
  53529. * Sets the transparency mode of the material.
  53530. *
  53531. * | Value | Type | Description |
  53532. * | ----- | ----------------------------------- | ----------- |
  53533. * | 0 | OPAQUE | |
  53534. * | 1 | ALPHATEST | |
  53535. * | 2 | ALPHABLEND | |
  53536. * | 3 | ALPHATESTANDBLEND | |
  53537. *
  53538. */
  53539. set transparencyMode(value: Nullable<number>);
  53540. /**
  53541. * Returns true if alpha blending should be disabled.
  53542. */
  53543. private get _disableAlphaBlending();
  53544. /**
  53545. * Specifies whether or not this material should be rendered in alpha blend mode.
  53546. */
  53547. needAlphaBlending(): boolean;
  53548. /**
  53549. * Specifies if the mesh will require alpha blending.
  53550. * @param mesh - BJS mesh.
  53551. */
  53552. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  53553. /**
  53554. * Specifies whether or not this material should be rendered in alpha test mode.
  53555. */
  53556. needAlphaTesting(): boolean;
  53557. /**
  53558. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  53559. */
  53560. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  53561. /**
  53562. * Gets the texture used for the alpha test.
  53563. */
  53564. getAlphaTestTexture(): Nullable<BaseTexture>;
  53565. /**
  53566. * Specifies that the submesh is ready to be used.
  53567. * @param mesh - BJS mesh.
  53568. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  53569. * @param useInstances - Specifies that instances should be used.
  53570. * @returns - boolean indicating that the submesh is ready or not.
  53571. */
  53572. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53573. /**
  53574. * Specifies if the material uses metallic roughness workflow.
  53575. * @returns boolean specifiying if the material uses metallic roughness workflow.
  53576. */
  53577. isMetallicWorkflow(): boolean;
  53578. private _prepareEffect;
  53579. private _prepareDefines;
  53580. /**
  53581. * Force shader compilation
  53582. */
  53583. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  53584. /**
  53585. * Initializes the uniform buffer layout for the shader.
  53586. */
  53587. buildUniformLayout(): void;
  53588. /**
  53589. * Unbinds the material from the mesh
  53590. */
  53591. unbind(): void;
  53592. /**
  53593. * Binds the submesh data.
  53594. * @param world - The world matrix.
  53595. * @param mesh - The BJS mesh.
  53596. * @param subMesh - A submesh of the BJS mesh.
  53597. */
  53598. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53599. /**
  53600. * Returns the animatable textures.
  53601. * @returns - Array of animatable textures.
  53602. */
  53603. getAnimatables(): IAnimatable[];
  53604. /**
  53605. * Returns the texture used for reflections.
  53606. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  53607. */
  53608. private _getReflectionTexture;
  53609. /**
  53610. * Returns an array of the actively used textures.
  53611. * @returns - Array of BaseTextures
  53612. */
  53613. getActiveTextures(): BaseTexture[];
  53614. /**
  53615. * Checks to see if a texture is used in the material.
  53616. * @param texture - Base texture to use.
  53617. * @returns - Boolean specifying if a texture is used in the material.
  53618. */
  53619. hasTexture(texture: BaseTexture): boolean;
  53620. /**
  53621. * Disposes the resources of the material.
  53622. * @param forceDisposeEffect - Forces the disposal of effects.
  53623. * @param forceDisposeTextures - Forces the disposal of all textures.
  53624. */
  53625. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  53626. }
  53627. }
  53628. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  53629. import { Nullable } from "babylonjs/types";
  53630. import { Scene } from "babylonjs/scene";
  53631. import { Color3 } from "babylonjs/Maths/math.color";
  53632. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  53633. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  53634. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53635. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53636. /**
  53637. * The Physically based material of BJS.
  53638. *
  53639. * This offers the main features of a standard PBR material.
  53640. * For more information, please refer to the documentation :
  53641. * https://doc.babylonjs.com/how_to/physically_based_rendering
  53642. */
  53643. export class PBRMaterial extends PBRBaseMaterial {
  53644. /**
  53645. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53646. */
  53647. static readonly PBRMATERIAL_OPAQUE: number;
  53648. /**
  53649. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53650. */
  53651. static readonly PBRMATERIAL_ALPHATEST: number;
  53652. /**
  53653. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53654. */
  53655. static readonly PBRMATERIAL_ALPHABLEND: number;
  53656. /**
  53657. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53658. * They are also discarded below the alpha cutoff threshold to improve performances.
  53659. */
  53660. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  53661. /**
  53662. * Defines the default value of how much AO map is occluding the analytical lights
  53663. * (point spot...).
  53664. */
  53665. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  53666. /**
  53667. * Intensity of the direct lights e.g. the four lights available in your scene.
  53668. * This impacts both the direct diffuse and specular highlights.
  53669. */
  53670. directIntensity: number;
  53671. /**
  53672. * Intensity of the emissive part of the material.
  53673. * This helps controlling the emissive effect without modifying the emissive color.
  53674. */
  53675. emissiveIntensity: number;
  53676. /**
  53677. * Intensity of the environment e.g. how much the environment will light the object
  53678. * either through harmonics for rough material or through the refelction for shiny ones.
  53679. */
  53680. environmentIntensity: number;
  53681. /**
  53682. * This is a special control allowing the reduction of the specular highlights coming from the
  53683. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53684. */
  53685. specularIntensity: number;
  53686. /**
  53687. * Debug Control allowing disabling the bump map on this material.
  53688. */
  53689. disableBumpMap: boolean;
  53690. /**
  53691. * AKA Diffuse Texture in standard nomenclature.
  53692. */
  53693. albedoTexture: BaseTexture;
  53694. /**
  53695. * AKA Occlusion Texture in other nomenclature.
  53696. */
  53697. ambientTexture: BaseTexture;
  53698. /**
  53699. * AKA Occlusion Texture Intensity in other nomenclature.
  53700. */
  53701. ambientTextureStrength: number;
  53702. /**
  53703. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53704. * 1 means it completely occludes it
  53705. * 0 mean it has no impact
  53706. */
  53707. ambientTextureImpactOnAnalyticalLights: number;
  53708. /**
  53709. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  53710. */
  53711. opacityTexture: BaseTexture;
  53712. /**
  53713. * Stores the reflection values in a texture.
  53714. */
  53715. reflectionTexture: Nullable<BaseTexture>;
  53716. /**
  53717. * Stores the emissive values in a texture.
  53718. */
  53719. emissiveTexture: BaseTexture;
  53720. /**
  53721. * AKA Specular texture in other nomenclature.
  53722. */
  53723. reflectivityTexture: BaseTexture;
  53724. /**
  53725. * Used to switch from specular/glossiness to metallic/roughness workflow.
  53726. */
  53727. metallicTexture: BaseTexture;
  53728. /**
  53729. * Specifies the metallic scalar of the metallic/roughness workflow.
  53730. * Can also be used to scale the metalness values of the metallic texture.
  53731. */
  53732. metallic: Nullable<number>;
  53733. /**
  53734. * Specifies the roughness scalar of the metallic/roughness workflow.
  53735. * Can also be used to scale the roughness values of the metallic texture.
  53736. */
  53737. roughness: Nullable<number>;
  53738. /**
  53739. * Specifies the an F0 factor to help configuring the material F0.
  53740. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  53741. * to 0.5 the previously hard coded value stays the same.
  53742. * Can also be used to scale the F0 values of the metallic texture.
  53743. */
  53744. metallicF0Factor: number;
  53745. /**
  53746. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  53747. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  53748. * your expectation as it multiplies with the texture data.
  53749. */
  53750. useMetallicF0FactorFromMetallicTexture: boolean;
  53751. /**
  53752. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  53753. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  53754. */
  53755. microSurfaceTexture: BaseTexture;
  53756. /**
  53757. * Stores surface normal data used to displace a mesh in a texture.
  53758. */
  53759. bumpTexture: BaseTexture;
  53760. /**
  53761. * Stores the pre-calculated light information of a mesh in a texture.
  53762. */
  53763. lightmapTexture: BaseTexture;
  53764. /**
  53765. * Stores the refracted light information in a texture.
  53766. */
  53767. get refractionTexture(): Nullable<BaseTexture>;
  53768. set refractionTexture(value: Nullable<BaseTexture>);
  53769. /**
  53770. * The color of a material in ambient lighting.
  53771. */
  53772. ambientColor: Color3;
  53773. /**
  53774. * AKA Diffuse Color in other nomenclature.
  53775. */
  53776. albedoColor: Color3;
  53777. /**
  53778. * AKA Specular Color in other nomenclature.
  53779. */
  53780. reflectivityColor: Color3;
  53781. /**
  53782. * The color reflected from the material.
  53783. */
  53784. reflectionColor: Color3;
  53785. /**
  53786. * The color emitted from the material.
  53787. */
  53788. emissiveColor: Color3;
  53789. /**
  53790. * AKA Glossiness in other nomenclature.
  53791. */
  53792. microSurface: number;
  53793. /**
  53794. * source material index of refraction (IOR)' / 'destination material IOR.
  53795. */
  53796. get indexOfRefraction(): number;
  53797. set indexOfRefraction(value: number);
  53798. /**
  53799. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  53800. */
  53801. get invertRefractionY(): boolean;
  53802. set invertRefractionY(value: boolean);
  53803. /**
  53804. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  53805. * Materials half opaque for instance using refraction could benefit from this control.
  53806. */
  53807. get linkRefractionWithTransparency(): boolean;
  53808. set linkRefractionWithTransparency(value: boolean);
  53809. /**
  53810. * If true, the light map contains occlusion information instead of lighting info.
  53811. */
  53812. useLightmapAsShadowmap: boolean;
  53813. /**
  53814. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  53815. */
  53816. useAlphaFromAlbedoTexture: boolean;
  53817. /**
  53818. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  53819. */
  53820. forceAlphaTest: boolean;
  53821. /**
  53822. * Defines the alpha limits in alpha test mode.
  53823. */
  53824. alphaCutOff: number;
  53825. /**
  53826. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  53827. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  53828. */
  53829. useSpecularOverAlpha: boolean;
  53830. /**
  53831. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  53832. */
  53833. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  53834. /**
  53835. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  53836. */
  53837. useRoughnessFromMetallicTextureAlpha: boolean;
  53838. /**
  53839. * Specifies if the metallic texture contains the roughness information in its green channel.
  53840. */
  53841. useRoughnessFromMetallicTextureGreen: boolean;
  53842. /**
  53843. * Specifies if the metallic texture contains the metallness information in its blue channel.
  53844. */
  53845. useMetallnessFromMetallicTextureBlue: boolean;
  53846. /**
  53847. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  53848. */
  53849. useAmbientOcclusionFromMetallicTextureRed: boolean;
  53850. /**
  53851. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  53852. */
  53853. useAmbientInGrayScale: boolean;
  53854. /**
  53855. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  53856. * The material will try to infer what glossiness each pixel should be.
  53857. */
  53858. useAutoMicroSurfaceFromReflectivityMap: boolean;
  53859. /**
  53860. * BJS is using an harcoded light falloff based on a manually sets up range.
  53861. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  53862. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  53863. */
  53864. get usePhysicalLightFalloff(): boolean;
  53865. /**
  53866. * BJS is using an harcoded light falloff based on a manually sets up range.
  53867. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  53868. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  53869. */
  53870. set usePhysicalLightFalloff(value: boolean);
  53871. /**
  53872. * In order to support the falloff compatibility with gltf, a special mode has been added
  53873. * to reproduce the gltf light falloff.
  53874. */
  53875. get useGLTFLightFalloff(): boolean;
  53876. /**
  53877. * In order to support the falloff compatibility with gltf, a special mode has been added
  53878. * to reproduce the gltf light falloff.
  53879. */
  53880. set useGLTFLightFalloff(value: boolean);
  53881. /**
  53882. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  53883. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  53884. */
  53885. useRadianceOverAlpha: boolean;
  53886. /**
  53887. * Allows using an object space normal map (instead of tangent space).
  53888. */
  53889. useObjectSpaceNormalMap: boolean;
  53890. /**
  53891. * Allows using the bump map in parallax mode.
  53892. */
  53893. useParallax: boolean;
  53894. /**
  53895. * Allows using the bump map in parallax occlusion mode.
  53896. */
  53897. useParallaxOcclusion: boolean;
  53898. /**
  53899. * Controls the scale bias of the parallax mode.
  53900. */
  53901. parallaxScaleBias: number;
  53902. /**
  53903. * If sets to true, disables all the lights affecting the material.
  53904. */
  53905. disableLighting: boolean;
  53906. /**
  53907. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  53908. */
  53909. forceIrradianceInFragment: boolean;
  53910. /**
  53911. * Number of Simultaneous lights allowed on the material.
  53912. */
  53913. maxSimultaneousLights: number;
  53914. /**
  53915. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  53916. */
  53917. invertNormalMapX: boolean;
  53918. /**
  53919. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  53920. */
  53921. invertNormalMapY: boolean;
  53922. /**
  53923. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53924. */
  53925. twoSidedLighting: boolean;
  53926. /**
  53927. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53928. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  53929. */
  53930. useAlphaFresnel: boolean;
  53931. /**
  53932. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53933. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  53934. */
  53935. useLinearAlphaFresnel: boolean;
  53936. /**
  53937. * Let user defines the brdf lookup texture used for IBL.
  53938. * A default 8bit version is embedded but you could point at :
  53939. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  53940. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  53941. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  53942. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  53943. */
  53944. environmentBRDFTexture: Nullable<BaseTexture>;
  53945. /**
  53946. * Force normal to face away from face.
  53947. */
  53948. forceNormalForward: boolean;
  53949. /**
  53950. * Enables specular anti aliasing in the PBR shader.
  53951. * It will both interacts on the Geometry for analytical and IBL lighting.
  53952. * It also prefilter the roughness map based on the bump values.
  53953. */
  53954. enableSpecularAntiAliasing: boolean;
  53955. /**
  53956. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  53957. * makes the reflect vector face the model (under horizon).
  53958. */
  53959. useHorizonOcclusion: boolean;
  53960. /**
  53961. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  53962. * too much the area relying on ambient texture to define their ambient occlusion.
  53963. */
  53964. useRadianceOcclusion: boolean;
  53965. /**
  53966. * If set to true, no lighting calculations will be applied.
  53967. */
  53968. unlit: boolean;
  53969. /**
  53970. * Gets the image processing configuration used either in this material.
  53971. */
  53972. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  53973. /**
  53974. * Sets the Default image processing configuration used either in the this material.
  53975. *
  53976. * If sets to null, the scene one is in use.
  53977. */
  53978. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  53979. /**
  53980. * Gets wether the color curves effect is enabled.
  53981. */
  53982. get cameraColorCurvesEnabled(): boolean;
  53983. /**
  53984. * Sets wether the color curves effect is enabled.
  53985. */
  53986. set cameraColorCurvesEnabled(value: boolean);
  53987. /**
  53988. * Gets wether the color grading effect is enabled.
  53989. */
  53990. get cameraColorGradingEnabled(): boolean;
  53991. /**
  53992. * Gets wether the color grading effect is enabled.
  53993. */
  53994. set cameraColorGradingEnabled(value: boolean);
  53995. /**
  53996. * Gets wether tonemapping is enabled or not.
  53997. */
  53998. get cameraToneMappingEnabled(): boolean;
  53999. /**
  54000. * Sets wether tonemapping is enabled or not
  54001. */
  54002. set cameraToneMappingEnabled(value: boolean);
  54003. /**
  54004. * The camera exposure used on this material.
  54005. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54006. * This corresponds to a photographic exposure.
  54007. */
  54008. get cameraExposure(): number;
  54009. /**
  54010. * The camera exposure used on this material.
  54011. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54012. * This corresponds to a photographic exposure.
  54013. */
  54014. set cameraExposure(value: number);
  54015. /**
  54016. * Gets The camera contrast used on this material.
  54017. */
  54018. get cameraContrast(): number;
  54019. /**
  54020. * Sets The camera contrast used on this material.
  54021. */
  54022. set cameraContrast(value: number);
  54023. /**
  54024. * Gets the Color Grading 2D Lookup Texture.
  54025. */
  54026. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  54027. /**
  54028. * Sets the Color Grading 2D Lookup Texture.
  54029. */
  54030. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  54031. /**
  54032. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54033. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54034. * 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;
  54035. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54036. */
  54037. get cameraColorCurves(): Nullable<ColorCurves>;
  54038. /**
  54039. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54040. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54041. * 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;
  54042. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54043. */
  54044. set cameraColorCurves(value: Nullable<ColorCurves>);
  54045. /**
  54046. * Instantiates a new PBRMaterial instance.
  54047. *
  54048. * @param name The material name
  54049. * @param scene The scene the material will be use in.
  54050. */
  54051. constructor(name: string, scene: Scene);
  54052. /**
  54053. * Returns the name of this material class.
  54054. */
  54055. getClassName(): string;
  54056. /**
  54057. * Makes a duplicate of the current material.
  54058. * @param name - name to use for the new material.
  54059. */
  54060. clone(name: string): PBRMaterial;
  54061. /**
  54062. * Serializes this PBR Material.
  54063. * @returns - An object with the serialized material.
  54064. */
  54065. serialize(): any;
  54066. /**
  54067. * Parses a PBR Material from a serialized object.
  54068. * @param source - Serialized object.
  54069. * @param scene - BJS scene instance.
  54070. * @param rootUrl - url for the scene object
  54071. * @returns - PBRMaterial
  54072. */
  54073. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  54074. }
  54075. }
  54076. declare module "babylonjs/Misc/dds" {
  54077. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54078. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54079. import { Nullable } from "babylonjs/types";
  54080. import { Scene } from "babylonjs/scene";
  54081. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  54082. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  54083. /**
  54084. * Direct draw surface info
  54085. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  54086. */
  54087. export interface DDSInfo {
  54088. /**
  54089. * Width of the texture
  54090. */
  54091. width: number;
  54092. /**
  54093. * Width of the texture
  54094. */
  54095. height: number;
  54096. /**
  54097. * Number of Mipmaps for the texture
  54098. * @see https://en.wikipedia.org/wiki/Mipmap
  54099. */
  54100. mipmapCount: number;
  54101. /**
  54102. * If the textures format is a known fourCC format
  54103. * @see https://www.fourcc.org/
  54104. */
  54105. isFourCC: boolean;
  54106. /**
  54107. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  54108. */
  54109. isRGB: boolean;
  54110. /**
  54111. * If the texture is a lumincance format
  54112. */
  54113. isLuminance: boolean;
  54114. /**
  54115. * If this is a cube texture
  54116. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  54117. */
  54118. isCube: boolean;
  54119. /**
  54120. * If the texture is a compressed format eg. FOURCC_DXT1
  54121. */
  54122. isCompressed: boolean;
  54123. /**
  54124. * The dxgiFormat of the texture
  54125. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  54126. */
  54127. dxgiFormat: number;
  54128. /**
  54129. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  54130. */
  54131. textureType: number;
  54132. /**
  54133. * Sphericle polynomial created for the dds texture
  54134. */
  54135. sphericalPolynomial?: SphericalPolynomial;
  54136. }
  54137. /**
  54138. * Class used to provide DDS decompression tools
  54139. */
  54140. export class DDSTools {
  54141. /**
  54142. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  54143. */
  54144. static StoreLODInAlphaChannel: boolean;
  54145. /**
  54146. * Gets DDS information from an array buffer
  54147. * @param data defines the array buffer view to read data from
  54148. * @returns the DDS information
  54149. */
  54150. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  54151. private static _FloatView;
  54152. private static _Int32View;
  54153. private static _ToHalfFloat;
  54154. private static _FromHalfFloat;
  54155. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  54156. private static _GetHalfFloatRGBAArrayBuffer;
  54157. private static _GetFloatRGBAArrayBuffer;
  54158. private static _GetFloatAsUIntRGBAArrayBuffer;
  54159. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  54160. private static _GetRGBAArrayBuffer;
  54161. private static _ExtractLongWordOrder;
  54162. private static _GetRGBArrayBuffer;
  54163. private static _GetLuminanceArrayBuffer;
  54164. /**
  54165. * Uploads DDS Levels to a Babylon Texture
  54166. * @hidden
  54167. */
  54168. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  54169. }
  54170. module "babylonjs/Engines/thinEngine" {
  54171. interface ThinEngine {
  54172. /**
  54173. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  54174. * @param rootUrl defines the url where the file to load is located
  54175. * @param scene defines the current scene
  54176. * @param lodScale defines scale to apply to the mip map selection
  54177. * @param lodOffset defines offset to apply to the mip map selection
  54178. * @param onLoad defines an optional callback raised when the texture is loaded
  54179. * @param onError defines an optional callback raised if there is an issue to load the texture
  54180. * @param format defines the format of the data
  54181. * @param forcedExtension defines the extension to use to pick the right loader
  54182. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  54183. * @returns the cube texture as an InternalTexture
  54184. */
  54185. 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;
  54186. }
  54187. }
  54188. }
  54189. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  54190. import { Nullable } from "babylonjs/types";
  54191. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54192. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54193. /**
  54194. * Implementation of the DDS Texture Loader.
  54195. * @hidden
  54196. */
  54197. export class _DDSTextureLoader implements IInternalTextureLoader {
  54198. /**
  54199. * Defines wether the loader supports cascade loading the different faces.
  54200. */
  54201. readonly supportCascades: boolean;
  54202. /**
  54203. * This returns if the loader support the current file information.
  54204. * @param extension defines the file extension of the file being loaded
  54205. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54206. * @param fallback defines the fallback internal texture if any
  54207. * @param isBase64 defines whether the texture is encoded as a base64
  54208. * @param isBuffer defines whether the texture data are stored as a buffer
  54209. * @returns true if the loader can load the specified file
  54210. */
  54211. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54212. /**
  54213. * Transform the url before loading if required.
  54214. * @param rootUrl the url of the texture
  54215. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54216. * @returns the transformed texture
  54217. */
  54218. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54219. /**
  54220. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54221. * @param rootUrl the url of the texture
  54222. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54223. * @returns the fallback texture
  54224. */
  54225. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54226. /**
  54227. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54228. * @param data contains the texture data
  54229. * @param texture defines the BabylonJS internal texture
  54230. * @param createPolynomials will be true if polynomials have been requested
  54231. * @param onLoad defines the callback to trigger once the texture is ready
  54232. * @param onError defines the callback to trigger in case of error
  54233. */
  54234. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54235. /**
  54236. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54237. * @param data contains the texture data
  54238. * @param texture defines the BabylonJS internal texture
  54239. * @param callback defines the method to call once ready to upload
  54240. */
  54241. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54242. }
  54243. }
  54244. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  54245. import { Nullable } from "babylonjs/types";
  54246. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54247. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54248. /**
  54249. * Implementation of the ENV Texture Loader.
  54250. * @hidden
  54251. */
  54252. export class _ENVTextureLoader implements IInternalTextureLoader {
  54253. /**
  54254. * Defines wether the loader supports cascade loading the different faces.
  54255. */
  54256. readonly supportCascades: boolean;
  54257. /**
  54258. * This returns if the loader support the current file information.
  54259. * @param extension defines the file extension of the file being loaded
  54260. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54261. * @param fallback defines the fallback internal texture if any
  54262. * @param isBase64 defines whether the texture is encoded as a base64
  54263. * @param isBuffer defines whether the texture data are stored as a buffer
  54264. * @returns true if the loader can load the specified file
  54265. */
  54266. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54267. /**
  54268. * Transform the url before loading if required.
  54269. * @param rootUrl the url of the texture
  54270. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54271. * @returns the transformed texture
  54272. */
  54273. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54274. /**
  54275. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54276. * @param rootUrl the url of the texture
  54277. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54278. * @returns the fallback texture
  54279. */
  54280. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54281. /**
  54282. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54283. * @param data contains the texture data
  54284. * @param texture defines the BabylonJS internal texture
  54285. * @param createPolynomials will be true if polynomials have been requested
  54286. * @param onLoad defines the callback to trigger once the texture is ready
  54287. * @param onError defines the callback to trigger in case of error
  54288. */
  54289. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54290. /**
  54291. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54292. * @param data contains the texture data
  54293. * @param texture defines the BabylonJS internal texture
  54294. * @param callback defines the method to call once ready to upload
  54295. */
  54296. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54297. }
  54298. }
  54299. declare module "babylonjs/Misc/khronosTextureContainer" {
  54300. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54301. /**
  54302. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  54303. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  54304. */
  54305. export class KhronosTextureContainer {
  54306. /** contents of the KTX container file */
  54307. data: ArrayBufferView;
  54308. private static HEADER_LEN;
  54309. private static COMPRESSED_2D;
  54310. private static COMPRESSED_3D;
  54311. private static TEX_2D;
  54312. private static TEX_3D;
  54313. /**
  54314. * Gets the openGL type
  54315. */
  54316. glType: number;
  54317. /**
  54318. * Gets the openGL type size
  54319. */
  54320. glTypeSize: number;
  54321. /**
  54322. * Gets the openGL format
  54323. */
  54324. glFormat: number;
  54325. /**
  54326. * Gets the openGL internal format
  54327. */
  54328. glInternalFormat: number;
  54329. /**
  54330. * Gets the base internal format
  54331. */
  54332. glBaseInternalFormat: number;
  54333. /**
  54334. * Gets image width in pixel
  54335. */
  54336. pixelWidth: number;
  54337. /**
  54338. * Gets image height in pixel
  54339. */
  54340. pixelHeight: number;
  54341. /**
  54342. * Gets image depth in pixels
  54343. */
  54344. pixelDepth: number;
  54345. /**
  54346. * Gets the number of array elements
  54347. */
  54348. numberOfArrayElements: number;
  54349. /**
  54350. * Gets the number of faces
  54351. */
  54352. numberOfFaces: number;
  54353. /**
  54354. * Gets the number of mipmap levels
  54355. */
  54356. numberOfMipmapLevels: number;
  54357. /**
  54358. * Gets the bytes of key value data
  54359. */
  54360. bytesOfKeyValueData: number;
  54361. /**
  54362. * Gets the load type
  54363. */
  54364. loadType: number;
  54365. /**
  54366. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  54367. */
  54368. isInvalid: boolean;
  54369. /**
  54370. * Creates a new KhronosTextureContainer
  54371. * @param data contents of the KTX container file
  54372. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  54373. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  54374. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  54375. */
  54376. constructor(
  54377. /** contents of the KTX container file */
  54378. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  54379. /**
  54380. * Uploads KTX content to a Babylon Texture.
  54381. * It is assumed that the texture has already been created & is currently bound
  54382. * @hidden
  54383. */
  54384. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  54385. private _upload2DCompressedLevels;
  54386. }
  54387. }
  54388. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  54389. import { Nullable } from "babylonjs/types";
  54390. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54391. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54392. /**
  54393. * Implementation of the KTX Texture Loader.
  54394. * @hidden
  54395. */
  54396. export class _KTXTextureLoader implements IInternalTextureLoader {
  54397. /**
  54398. * Defines wether the loader supports cascade loading the different faces.
  54399. */
  54400. readonly supportCascades: boolean;
  54401. /**
  54402. * This returns if the loader support the current file information.
  54403. * @param extension defines the file extension of the file being loaded
  54404. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54405. * @param fallback defines the fallback internal texture if any
  54406. * @param isBase64 defines whether the texture is encoded as a base64
  54407. * @param isBuffer defines whether the texture data are stored as a buffer
  54408. * @returns true if the loader can load the specified file
  54409. */
  54410. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54411. /**
  54412. * Transform the url before loading if required.
  54413. * @param rootUrl the url of the texture
  54414. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54415. * @returns the transformed texture
  54416. */
  54417. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54418. /**
  54419. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54420. * @param rootUrl the url of the texture
  54421. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54422. * @returns the fallback texture
  54423. */
  54424. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54425. /**
  54426. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54427. * @param data contains the texture data
  54428. * @param texture defines the BabylonJS internal texture
  54429. * @param createPolynomials will be true if polynomials have been requested
  54430. * @param onLoad defines the callback to trigger once the texture is ready
  54431. * @param onError defines the callback to trigger in case of error
  54432. */
  54433. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54434. /**
  54435. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54436. * @param data contains the texture data
  54437. * @param texture defines the BabylonJS internal texture
  54438. * @param callback defines the method to call once ready to upload
  54439. */
  54440. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  54441. }
  54442. }
  54443. declare module "babylonjs/Helpers/sceneHelpers" {
  54444. import { Nullable } from "babylonjs/types";
  54445. import { Mesh } from "babylonjs/Meshes/mesh";
  54446. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54447. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  54448. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  54449. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54450. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54451. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54452. import "babylonjs/Meshes/Builders/boxBuilder";
  54453. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  54454. /** @hidden */
  54455. export var _forceSceneHelpersToBundle: boolean;
  54456. module "babylonjs/scene" {
  54457. interface Scene {
  54458. /**
  54459. * Creates a default light for the scene.
  54460. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  54461. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  54462. */
  54463. createDefaultLight(replace?: boolean): void;
  54464. /**
  54465. * Creates a default camera for the scene.
  54466. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  54467. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  54468. * @param replace has default false, when true replaces the active camera in the scene
  54469. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  54470. */
  54471. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  54472. /**
  54473. * Creates a default camera and a default light.
  54474. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  54475. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  54476. * @param replace has the default false, when true replaces the active camera/light in the scene
  54477. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  54478. */
  54479. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  54480. /**
  54481. * Creates a new sky box
  54482. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  54483. * @param environmentTexture defines the texture to use as environment texture
  54484. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  54485. * @param scale defines the overall scale of the skybox
  54486. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  54487. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  54488. * @returns a new mesh holding the sky box
  54489. */
  54490. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  54491. /**
  54492. * Creates a new environment
  54493. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  54494. * @param options defines the options you can use to configure the environment
  54495. * @returns the new EnvironmentHelper
  54496. */
  54497. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  54498. /**
  54499. * Creates a new VREXperienceHelper
  54500. * @see http://doc.babylonjs.com/how_to/webvr_helper
  54501. * @param webVROptions defines the options used to create the new VREXperienceHelper
  54502. * @returns a new VREXperienceHelper
  54503. */
  54504. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  54505. /**
  54506. * Creates a new WebXRDefaultExperience
  54507. * @see http://doc.babylonjs.com/how_to/webxr
  54508. * @param options experience options
  54509. * @returns a promise for a new WebXRDefaultExperience
  54510. */
  54511. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  54512. }
  54513. }
  54514. }
  54515. declare module "babylonjs/Helpers/videoDome" {
  54516. import { Scene } from "babylonjs/scene";
  54517. import { TransformNode } from "babylonjs/Meshes/transformNode";
  54518. import { Mesh } from "babylonjs/Meshes/mesh";
  54519. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  54520. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  54521. import "babylonjs/Meshes/Builders/sphereBuilder";
  54522. /**
  54523. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  54524. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  54525. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  54526. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  54527. */
  54528. export class VideoDome extends TransformNode {
  54529. /**
  54530. * Define the video source as a Monoscopic panoramic 360 video.
  54531. */
  54532. static readonly MODE_MONOSCOPIC: number;
  54533. /**
  54534. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  54535. */
  54536. static readonly MODE_TOPBOTTOM: number;
  54537. /**
  54538. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  54539. */
  54540. static readonly MODE_SIDEBYSIDE: number;
  54541. private _halfDome;
  54542. private _useDirectMapping;
  54543. /**
  54544. * The video texture being displayed on the sphere
  54545. */
  54546. protected _videoTexture: VideoTexture;
  54547. /**
  54548. * Gets the video texture being displayed on the sphere
  54549. */
  54550. get videoTexture(): VideoTexture;
  54551. /**
  54552. * The skybox material
  54553. */
  54554. protected _material: BackgroundMaterial;
  54555. /**
  54556. * The surface used for the skybox
  54557. */
  54558. protected _mesh: Mesh;
  54559. /**
  54560. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  54561. */
  54562. private _halfDomeMask;
  54563. /**
  54564. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54565. * Also see the options.resolution property.
  54566. */
  54567. get fovMultiplier(): number;
  54568. set fovMultiplier(value: number);
  54569. private _videoMode;
  54570. /**
  54571. * Gets or set the current video mode for the video. It can be:
  54572. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  54573. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  54574. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  54575. */
  54576. get videoMode(): number;
  54577. set videoMode(value: number);
  54578. /**
  54579. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  54580. *
  54581. */
  54582. get halfDome(): boolean;
  54583. /**
  54584. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  54585. */
  54586. set halfDome(enabled: boolean);
  54587. /**
  54588. * Oberserver used in Stereoscopic VR Mode.
  54589. */
  54590. private _onBeforeCameraRenderObserver;
  54591. /**
  54592. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  54593. * @param name Element's name, child elements will append suffixes for their own names.
  54594. * @param urlsOrVideo defines the url(s) or the video element to use
  54595. * @param options An object containing optional or exposed sub element properties
  54596. */
  54597. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  54598. resolution?: number;
  54599. clickToPlay?: boolean;
  54600. autoPlay?: boolean;
  54601. loop?: boolean;
  54602. size?: number;
  54603. poster?: string;
  54604. faceForward?: boolean;
  54605. useDirectMapping?: boolean;
  54606. halfDomeMode?: boolean;
  54607. }, scene: Scene);
  54608. private _changeVideoMode;
  54609. /**
  54610. * Releases resources associated with this node.
  54611. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  54612. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  54613. */
  54614. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  54615. }
  54616. }
  54617. declare module "babylonjs/Helpers/index" {
  54618. export * from "babylonjs/Helpers/environmentHelper";
  54619. export * from "babylonjs/Helpers/photoDome";
  54620. export * from "babylonjs/Helpers/sceneHelpers";
  54621. export * from "babylonjs/Helpers/videoDome";
  54622. }
  54623. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  54624. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  54625. import { IDisposable } from "babylonjs/scene";
  54626. import { Engine } from "babylonjs/Engines/engine";
  54627. /**
  54628. * This class can be used to get instrumentation data from a Babylon engine
  54629. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  54630. */
  54631. export class EngineInstrumentation implements IDisposable {
  54632. /**
  54633. * Define the instrumented engine.
  54634. */
  54635. engine: Engine;
  54636. private _captureGPUFrameTime;
  54637. private _gpuFrameTimeToken;
  54638. private _gpuFrameTime;
  54639. private _captureShaderCompilationTime;
  54640. private _shaderCompilationTime;
  54641. private _onBeginFrameObserver;
  54642. private _onEndFrameObserver;
  54643. private _onBeforeShaderCompilationObserver;
  54644. private _onAfterShaderCompilationObserver;
  54645. /**
  54646. * Gets the perf counter used for GPU frame time
  54647. */
  54648. get gpuFrameTimeCounter(): PerfCounter;
  54649. /**
  54650. * Gets the GPU frame time capture status
  54651. */
  54652. get captureGPUFrameTime(): boolean;
  54653. /**
  54654. * Enable or disable the GPU frame time capture
  54655. */
  54656. set captureGPUFrameTime(value: boolean);
  54657. /**
  54658. * Gets the perf counter used for shader compilation time
  54659. */
  54660. get shaderCompilationTimeCounter(): PerfCounter;
  54661. /**
  54662. * Gets the shader compilation time capture status
  54663. */
  54664. get captureShaderCompilationTime(): boolean;
  54665. /**
  54666. * Enable or disable the shader compilation time capture
  54667. */
  54668. set captureShaderCompilationTime(value: boolean);
  54669. /**
  54670. * Instantiates a new engine instrumentation.
  54671. * This class can be used to get instrumentation data from a Babylon engine
  54672. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  54673. * @param engine Defines the engine to instrument
  54674. */
  54675. constructor(
  54676. /**
  54677. * Define the instrumented engine.
  54678. */
  54679. engine: Engine);
  54680. /**
  54681. * Dispose and release associated resources.
  54682. */
  54683. dispose(): void;
  54684. }
  54685. }
  54686. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  54687. import { Scene, IDisposable } from "babylonjs/scene";
  54688. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  54689. /**
  54690. * This class can be used to get instrumentation data from a Babylon engine
  54691. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  54692. */
  54693. export class SceneInstrumentation implements IDisposable {
  54694. /**
  54695. * Defines the scene to instrument
  54696. */
  54697. scene: Scene;
  54698. private _captureActiveMeshesEvaluationTime;
  54699. private _activeMeshesEvaluationTime;
  54700. private _captureRenderTargetsRenderTime;
  54701. private _renderTargetsRenderTime;
  54702. private _captureFrameTime;
  54703. private _frameTime;
  54704. private _captureRenderTime;
  54705. private _renderTime;
  54706. private _captureInterFrameTime;
  54707. private _interFrameTime;
  54708. private _captureParticlesRenderTime;
  54709. private _particlesRenderTime;
  54710. private _captureSpritesRenderTime;
  54711. private _spritesRenderTime;
  54712. private _capturePhysicsTime;
  54713. private _physicsTime;
  54714. private _captureAnimationsTime;
  54715. private _animationsTime;
  54716. private _captureCameraRenderTime;
  54717. private _cameraRenderTime;
  54718. private _onBeforeActiveMeshesEvaluationObserver;
  54719. private _onAfterActiveMeshesEvaluationObserver;
  54720. private _onBeforeRenderTargetsRenderObserver;
  54721. private _onAfterRenderTargetsRenderObserver;
  54722. private _onAfterRenderObserver;
  54723. private _onBeforeDrawPhaseObserver;
  54724. private _onAfterDrawPhaseObserver;
  54725. private _onBeforeAnimationsObserver;
  54726. private _onBeforeParticlesRenderingObserver;
  54727. private _onAfterParticlesRenderingObserver;
  54728. private _onBeforeSpritesRenderingObserver;
  54729. private _onAfterSpritesRenderingObserver;
  54730. private _onBeforePhysicsObserver;
  54731. private _onAfterPhysicsObserver;
  54732. private _onAfterAnimationsObserver;
  54733. private _onBeforeCameraRenderObserver;
  54734. private _onAfterCameraRenderObserver;
  54735. /**
  54736. * Gets the perf counter used for active meshes evaluation time
  54737. */
  54738. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  54739. /**
  54740. * Gets the active meshes evaluation time capture status
  54741. */
  54742. get captureActiveMeshesEvaluationTime(): boolean;
  54743. /**
  54744. * Enable or disable the active meshes evaluation time capture
  54745. */
  54746. set captureActiveMeshesEvaluationTime(value: boolean);
  54747. /**
  54748. * Gets the perf counter used for render targets render time
  54749. */
  54750. get renderTargetsRenderTimeCounter(): PerfCounter;
  54751. /**
  54752. * Gets the render targets render time capture status
  54753. */
  54754. get captureRenderTargetsRenderTime(): boolean;
  54755. /**
  54756. * Enable or disable the render targets render time capture
  54757. */
  54758. set captureRenderTargetsRenderTime(value: boolean);
  54759. /**
  54760. * Gets the perf counter used for particles render time
  54761. */
  54762. get particlesRenderTimeCounter(): PerfCounter;
  54763. /**
  54764. * Gets the particles render time capture status
  54765. */
  54766. get captureParticlesRenderTime(): boolean;
  54767. /**
  54768. * Enable or disable the particles render time capture
  54769. */
  54770. set captureParticlesRenderTime(value: boolean);
  54771. /**
  54772. * Gets the perf counter used for sprites render time
  54773. */
  54774. get spritesRenderTimeCounter(): PerfCounter;
  54775. /**
  54776. * Gets the sprites render time capture status
  54777. */
  54778. get captureSpritesRenderTime(): boolean;
  54779. /**
  54780. * Enable or disable the sprites render time capture
  54781. */
  54782. set captureSpritesRenderTime(value: boolean);
  54783. /**
  54784. * Gets the perf counter used for physics time
  54785. */
  54786. get physicsTimeCounter(): PerfCounter;
  54787. /**
  54788. * Gets the physics time capture status
  54789. */
  54790. get capturePhysicsTime(): boolean;
  54791. /**
  54792. * Enable or disable the physics time capture
  54793. */
  54794. set capturePhysicsTime(value: boolean);
  54795. /**
  54796. * Gets the perf counter used for animations time
  54797. */
  54798. get animationsTimeCounter(): PerfCounter;
  54799. /**
  54800. * Gets the animations time capture status
  54801. */
  54802. get captureAnimationsTime(): boolean;
  54803. /**
  54804. * Enable or disable the animations time capture
  54805. */
  54806. set captureAnimationsTime(value: boolean);
  54807. /**
  54808. * Gets the perf counter used for frame time capture
  54809. */
  54810. get frameTimeCounter(): PerfCounter;
  54811. /**
  54812. * Gets the frame time capture status
  54813. */
  54814. get captureFrameTime(): boolean;
  54815. /**
  54816. * Enable or disable the frame time capture
  54817. */
  54818. set captureFrameTime(value: boolean);
  54819. /**
  54820. * Gets the perf counter used for inter-frames time capture
  54821. */
  54822. get interFrameTimeCounter(): PerfCounter;
  54823. /**
  54824. * Gets the inter-frames time capture status
  54825. */
  54826. get captureInterFrameTime(): boolean;
  54827. /**
  54828. * Enable or disable the inter-frames time capture
  54829. */
  54830. set captureInterFrameTime(value: boolean);
  54831. /**
  54832. * Gets the perf counter used for render time capture
  54833. */
  54834. get renderTimeCounter(): PerfCounter;
  54835. /**
  54836. * Gets the render time capture status
  54837. */
  54838. get captureRenderTime(): boolean;
  54839. /**
  54840. * Enable or disable the render time capture
  54841. */
  54842. set captureRenderTime(value: boolean);
  54843. /**
  54844. * Gets the perf counter used for camera render time capture
  54845. */
  54846. get cameraRenderTimeCounter(): PerfCounter;
  54847. /**
  54848. * Gets the camera render time capture status
  54849. */
  54850. get captureCameraRenderTime(): boolean;
  54851. /**
  54852. * Enable or disable the camera render time capture
  54853. */
  54854. set captureCameraRenderTime(value: boolean);
  54855. /**
  54856. * Gets the perf counter used for draw calls
  54857. */
  54858. get drawCallsCounter(): PerfCounter;
  54859. /**
  54860. * Instantiates a new scene instrumentation.
  54861. * This class can be used to get instrumentation data from a Babylon engine
  54862. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  54863. * @param scene Defines the scene to instrument
  54864. */
  54865. constructor(
  54866. /**
  54867. * Defines the scene to instrument
  54868. */
  54869. scene: Scene);
  54870. /**
  54871. * Dispose and release associated resources.
  54872. */
  54873. dispose(): void;
  54874. }
  54875. }
  54876. declare module "babylonjs/Instrumentation/index" {
  54877. export * from "babylonjs/Instrumentation/engineInstrumentation";
  54878. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  54879. export * from "babylonjs/Instrumentation/timeToken";
  54880. }
  54881. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  54882. /** @hidden */
  54883. export var glowMapGenerationPixelShader: {
  54884. name: string;
  54885. shader: string;
  54886. };
  54887. }
  54888. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  54889. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  54890. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  54891. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  54892. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  54893. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  54894. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  54895. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  54896. /** @hidden */
  54897. export var glowMapGenerationVertexShader: {
  54898. name: string;
  54899. shader: string;
  54900. };
  54901. }
  54902. declare module "babylonjs/Layers/effectLayer" {
  54903. import { Observable } from "babylonjs/Misc/observable";
  54904. import { Nullable } from "babylonjs/types";
  54905. import { Camera } from "babylonjs/Cameras/camera";
  54906. import { Scene } from "babylonjs/scene";
  54907. import { ISize } from "babylonjs/Maths/math.size";
  54908. import { Color4 } from "babylonjs/Maths/math.color";
  54909. import { Engine } from "babylonjs/Engines/engine";
  54910. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54911. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54912. import { Mesh } from "babylonjs/Meshes/mesh";
  54913. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54914. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54915. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54916. import { Effect } from "babylonjs/Materials/effect";
  54917. import { Material } from "babylonjs/Materials/material";
  54918. import "babylonjs/Shaders/glowMapGeneration.fragment";
  54919. import "babylonjs/Shaders/glowMapGeneration.vertex";
  54920. /**
  54921. * Effect layer options. This helps customizing the behaviour
  54922. * of the effect layer.
  54923. */
  54924. export interface IEffectLayerOptions {
  54925. /**
  54926. * Multiplication factor apply to the canvas size to compute the render target size
  54927. * used to generated the objects (the smaller the faster).
  54928. */
  54929. mainTextureRatio: number;
  54930. /**
  54931. * Enforces a fixed size texture to ensure effect stability across devices.
  54932. */
  54933. mainTextureFixedSize?: number;
  54934. /**
  54935. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  54936. */
  54937. alphaBlendingMode: number;
  54938. /**
  54939. * The camera attached to the layer.
  54940. */
  54941. camera: Nullable<Camera>;
  54942. /**
  54943. * The rendering group to draw the layer in.
  54944. */
  54945. renderingGroupId: number;
  54946. }
  54947. /**
  54948. * The effect layer Helps adding post process effect blended with the main pass.
  54949. *
  54950. * This can be for instance use to generate glow or higlight effects on the scene.
  54951. *
  54952. * The effect layer class can not be used directly and is intented to inherited from to be
  54953. * customized per effects.
  54954. */
  54955. export abstract class EffectLayer {
  54956. private _vertexBuffers;
  54957. private _indexBuffer;
  54958. private _cachedDefines;
  54959. private _effectLayerMapGenerationEffect;
  54960. private _effectLayerOptions;
  54961. private _mergeEffect;
  54962. protected _scene: Scene;
  54963. protected _engine: Engine;
  54964. protected _maxSize: number;
  54965. protected _mainTextureDesiredSize: ISize;
  54966. protected _mainTexture: RenderTargetTexture;
  54967. protected _shouldRender: boolean;
  54968. protected _postProcesses: PostProcess[];
  54969. protected _textures: BaseTexture[];
  54970. protected _emissiveTextureAndColor: {
  54971. texture: Nullable<BaseTexture>;
  54972. color: Color4;
  54973. };
  54974. /**
  54975. * The name of the layer
  54976. */
  54977. name: string;
  54978. /**
  54979. * The clear color of the texture used to generate the glow map.
  54980. */
  54981. neutralColor: Color4;
  54982. /**
  54983. * Specifies whether the highlight layer is enabled or not.
  54984. */
  54985. isEnabled: boolean;
  54986. /**
  54987. * Gets the camera attached to the layer.
  54988. */
  54989. get camera(): Nullable<Camera>;
  54990. /**
  54991. * Gets the rendering group id the layer should render in.
  54992. */
  54993. get renderingGroupId(): number;
  54994. set renderingGroupId(renderingGroupId: number);
  54995. /**
  54996. * An event triggered when the effect layer has been disposed.
  54997. */
  54998. onDisposeObservable: Observable<EffectLayer>;
  54999. /**
  55000. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  55001. */
  55002. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  55003. /**
  55004. * An event triggered when the generated texture is being merged in the scene.
  55005. */
  55006. onBeforeComposeObservable: Observable<EffectLayer>;
  55007. /**
  55008. * An event triggered when the mesh is rendered into the effect render target.
  55009. */
  55010. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  55011. /**
  55012. * An event triggered after the mesh has been rendered into the effect render target.
  55013. */
  55014. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  55015. /**
  55016. * An event triggered when the generated texture has been merged in the scene.
  55017. */
  55018. onAfterComposeObservable: Observable<EffectLayer>;
  55019. /**
  55020. * An event triggered when the efffect layer changes its size.
  55021. */
  55022. onSizeChangedObservable: Observable<EffectLayer>;
  55023. /** @hidden */
  55024. static _SceneComponentInitialization: (scene: Scene) => void;
  55025. /**
  55026. * Instantiates a new effect Layer and references it in the scene.
  55027. * @param name The name of the layer
  55028. * @param scene The scene to use the layer in
  55029. */
  55030. constructor(
  55031. /** The Friendly of the effect in the scene */
  55032. name: string, scene: Scene);
  55033. /**
  55034. * Get the effect name of the layer.
  55035. * @return The effect name
  55036. */
  55037. abstract getEffectName(): string;
  55038. /**
  55039. * Checks for the readiness of the element composing the layer.
  55040. * @param subMesh the mesh to check for
  55041. * @param useInstances specify whether or not to use instances to render the mesh
  55042. * @return true if ready otherwise, false
  55043. */
  55044. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55045. /**
  55046. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  55047. * @returns true if the effect requires stencil during the main canvas render pass.
  55048. */
  55049. abstract needStencil(): boolean;
  55050. /**
  55051. * Create the merge effect. This is the shader use to blit the information back
  55052. * to the main canvas at the end of the scene rendering.
  55053. * @returns The effect containing the shader used to merge the effect on the main canvas
  55054. */
  55055. protected abstract _createMergeEffect(): Effect;
  55056. /**
  55057. * Creates the render target textures and post processes used in the effect layer.
  55058. */
  55059. protected abstract _createTextureAndPostProcesses(): void;
  55060. /**
  55061. * Implementation specific of rendering the generating effect on the main canvas.
  55062. * @param effect The effect used to render through
  55063. */
  55064. protected abstract _internalRender(effect: Effect): void;
  55065. /**
  55066. * Sets the required values for both the emissive texture and and the main color.
  55067. */
  55068. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55069. /**
  55070. * Free any resources and references associated to a mesh.
  55071. * Internal use
  55072. * @param mesh The mesh to free.
  55073. */
  55074. abstract _disposeMesh(mesh: Mesh): void;
  55075. /**
  55076. * Serializes this layer (Glow or Highlight for example)
  55077. * @returns a serialized layer object
  55078. */
  55079. abstract serialize?(): any;
  55080. /**
  55081. * Initializes the effect layer with the required options.
  55082. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  55083. */
  55084. protected _init(options: Partial<IEffectLayerOptions>): void;
  55085. /**
  55086. * Generates the index buffer of the full screen quad blending to the main canvas.
  55087. */
  55088. private _generateIndexBuffer;
  55089. /**
  55090. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  55091. */
  55092. private _generateVertexBuffer;
  55093. /**
  55094. * Sets the main texture desired size which is the closest power of two
  55095. * of the engine canvas size.
  55096. */
  55097. private _setMainTextureSize;
  55098. /**
  55099. * Creates the main texture for the effect layer.
  55100. */
  55101. protected _createMainTexture(): void;
  55102. /**
  55103. * Adds specific effects defines.
  55104. * @param defines The defines to add specifics to.
  55105. */
  55106. protected _addCustomEffectDefines(defines: string[]): void;
  55107. /**
  55108. * Checks for the readiness of the element composing the layer.
  55109. * @param subMesh the mesh to check for
  55110. * @param useInstances specify whether or not to use instances to render the mesh
  55111. * @param emissiveTexture the associated emissive texture used to generate the glow
  55112. * @return true if ready otherwise, false
  55113. */
  55114. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  55115. /**
  55116. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  55117. */
  55118. render(): void;
  55119. /**
  55120. * Determine if a given mesh will be used in the current effect.
  55121. * @param mesh mesh to test
  55122. * @returns true if the mesh will be used
  55123. */
  55124. hasMesh(mesh: AbstractMesh): boolean;
  55125. /**
  55126. * Returns true if the layer contains information to display, otherwise false.
  55127. * @returns true if the glow layer should be rendered
  55128. */
  55129. shouldRender(): boolean;
  55130. /**
  55131. * Returns true if the mesh should render, otherwise false.
  55132. * @param mesh The mesh to render
  55133. * @returns true if it should render otherwise false
  55134. */
  55135. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  55136. /**
  55137. * Returns true if the mesh can be rendered, otherwise false.
  55138. * @param mesh The mesh to render
  55139. * @param material The material used on the mesh
  55140. * @returns true if it can be rendered otherwise false
  55141. */
  55142. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  55143. /**
  55144. * Returns true if the mesh should render, otherwise false.
  55145. * @param mesh The mesh to render
  55146. * @returns true if it should render otherwise false
  55147. */
  55148. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  55149. /**
  55150. * Renders the submesh passed in parameter to the generation map.
  55151. */
  55152. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  55153. /**
  55154. * Defines whether the current material of the mesh should be use to render the effect.
  55155. * @param mesh defines the current mesh to render
  55156. */
  55157. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  55158. /**
  55159. * Rebuild the required buffers.
  55160. * @hidden Internal use only.
  55161. */
  55162. _rebuild(): void;
  55163. /**
  55164. * Dispose only the render target textures and post process.
  55165. */
  55166. private _disposeTextureAndPostProcesses;
  55167. /**
  55168. * Dispose the highlight layer and free resources.
  55169. */
  55170. dispose(): void;
  55171. /**
  55172. * Gets the class name of the effect layer
  55173. * @returns the string with the class name of the effect layer
  55174. */
  55175. getClassName(): string;
  55176. /**
  55177. * Creates an effect layer from parsed effect layer data
  55178. * @param parsedEffectLayer defines effect layer data
  55179. * @param scene defines the current scene
  55180. * @param rootUrl defines the root URL containing the effect layer information
  55181. * @returns a parsed effect Layer
  55182. */
  55183. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  55184. }
  55185. }
  55186. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  55187. import { Scene } from "babylonjs/scene";
  55188. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  55189. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55190. import { AbstractScene } from "babylonjs/abstractScene";
  55191. module "babylonjs/abstractScene" {
  55192. interface AbstractScene {
  55193. /**
  55194. * The list of effect layers (highlights/glow) added to the scene
  55195. * @see http://doc.babylonjs.com/how_to/highlight_layer
  55196. * @see http://doc.babylonjs.com/how_to/glow_layer
  55197. */
  55198. effectLayers: Array<EffectLayer>;
  55199. /**
  55200. * Removes the given effect layer from this scene.
  55201. * @param toRemove defines the effect layer to remove
  55202. * @returns the index of the removed effect layer
  55203. */
  55204. removeEffectLayer(toRemove: EffectLayer): number;
  55205. /**
  55206. * Adds the given effect layer to this scene
  55207. * @param newEffectLayer defines the effect layer to add
  55208. */
  55209. addEffectLayer(newEffectLayer: EffectLayer): void;
  55210. }
  55211. }
  55212. /**
  55213. * Defines the layer scene component responsible to manage any effect layers
  55214. * in a given scene.
  55215. */
  55216. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  55217. /**
  55218. * The component name helpfull to identify the component in the list of scene components.
  55219. */
  55220. readonly name: string;
  55221. /**
  55222. * The scene the component belongs to.
  55223. */
  55224. scene: Scene;
  55225. private _engine;
  55226. private _renderEffects;
  55227. private _needStencil;
  55228. private _previousStencilState;
  55229. /**
  55230. * Creates a new instance of the component for the given scene
  55231. * @param scene Defines the scene to register the component in
  55232. */
  55233. constructor(scene: Scene);
  55234. /**
  55235. * Registers the component in a given scene
  55236. */
  55237. register(): void;
  55238. /**
  55239. * Rebuilds the elements related to this component in case of
  55240. * context lost for instance.
  55241. */
  55242. rebuild(): void;
  55243. /**
  55244. * Serializes the component data to the specified json object
  55245. * @param serializationObject The object to serialize to
  55246. */
  55247. serialize(serializationObject: any): void;
  55248. /**
  55249. * Adds all the elements from the container to the scene
  55250. * @param container the container holding the elements
  55251. */
  55252. addFromContainer(container: AbstractScene): void;
  55253. /**
  55254. * Removes all the elements in the container from the scene
  55255. * @param container contains the elements to remove
  55256. * @param dispose if the removed element should be disposed (default: false)
  55257. */
  55258. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55259. /**
  55260. * Disposes the component and the associated ressources.
  55261. */
  55262. dispose(): void;
  55263. private _isReadyForMesh;
  55264. private _renderMainTexture;
  55265. private _setStencil;
  55266. private _setStencilBack;
  55267. private _draw;
  55268. private _drawCamera;
  55269. private _drawRenderingGroup;
  55270. }
  55271. }
  55272. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  55273. /** @hidden */
  55274. export var glowMapMergePixelShader: {
  55275. name: string;
  55276. shader: string;
  55277. };
  55278. }
  55279. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  55280. /** @hidden */
  55281. export var glowMapMergeVertexShader: {
  55282. name: string;
  55283. shader: string;
  55284. };
  55285. }
  55286. declare module "babylonjs/Layers/glowLayer" {
  55287. import { Nullable } from "babylonjs/types";
  55288. import { Camera } from "babylonjs/Cameras/camera";
  55289. import { Scene } from "babylonjs/scene";
  55290. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55291. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55292. import { Mesh } from "babylonjs/Meshes/mesh";
  55293. import { Texture } from "babylonjs/Materials/Textures/texture";
  55294. import { Effect } from "babylonjs/Materials/effect";
  55295. import { Material } from "babylonjs/Materials/material";
  55296. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55297. import { Color4 } from "babylonjs/Maths/math.color";
  55298. import "babylonjs/Shaders/glowMapMerge.fragment";
  55299. import "babylonjs/Shaders/glowMapMerge.vertex";
  55300. import "babylonjs/Layers/effectLayerSceneComponent";
  55301. module "babylonjs/abstractScene" {
  55302. interface AbstractScene {
  55303. /**
  55304. * Return a the first highlight layer of the scene with a given name.
  55305. * @param name The name of the highlight layer to look for.
  55306. * @return The highlight layer if found otherwise null.
  55307. */
  55308. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  55309. }
  55310. }
  55311. /**
  55312. * Glow layer options. This helps customizing the behaviour
  55313. * of the glow layer.
  55314. */
  55315. export interface IGlowLayerOptions {
  55316. /**
  55317. * Multiplication factor apply to the canvas size to compute the render target size
  55318. * used to generated the glowing objects (the smaller the faster).
  55319. */
  55320. mainTextureRatio: number;
  55321. /**
  55322. * Enforces a fixed size texture to ensure resize independant blur.
  55323. */
  55324. mainTextureFixedSize?: number;
  55325. /**
  55326. * How big is the kernel of the blur texture.
  55327. */
  55328. blurKernelSize: number;
  55329. /**
  55330. * The camera attached to the layer.
  55331. */
  55332. camera: Nullable<Camera>;
  55333. /**
  55334. * Enable MSAA by chosing the number of samples.
  55335. */
  55336. mainTextureSamples?: number;
  55337. /**
  55338. * The rendering group to draw the layer in.
  55339. */
  55340. renderingGroupId: number;
  55341. }
  55342. /**
  55343. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  55344. *
  55345. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  55346. *
  55347. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  55348. */
  55349. export class GlowLayer extends EffectLayer {
  55350. /**
  55351. * Effect Name of the layer.
  55352. */
  55353. static readonly EffectName: string;
  55354. /**
  55355. * The default blur kernel size used for the glow.
  55356. */
  55357. static DefaultBlurKernelSize: number;
  55358. /**
  55359. * The default texture size ratio used for the glow.
  55360. */
  55361. static DefaultTextureRatio: number;
  55362. /**
  55363. * Sets the kernel size of the blur.
  55364. */
  55365. set blurKernelSize(value: number);
  55366. /**
  55367. * Gets the kernel size of the blur.
  55368. */
  55369. get blurKernelSize(): number;
  55370. /**
  55371. * Sets the glow intensity.
  55372. */
  55373. set intensity(value: number);
  55374. /**
  55375. * Gets the glow intensity.
  55376. */
  55377. get intensity(): number;
  55378. private _options;
  55379. private _intensity;
  55380. private _horizontalBlurPostprocess1;
  55381. private _verticalBlurPostprocess1;
  55382. private _horizontalBlurPostprocess2;
  55383. private _verticalBlurPostprocess2;
  55384. private _blurTexture1;
  55385. private _blurTexture2;
  55386. private _postProcesses1;
  55387. private _postProcesses2;
  55388. private _includedOnlyMeshes;
  55389. private _excludedMeshes;
  55390. private _meshesUsingTheirOwnMaterials;
  55391. /**
  55392. * Callback used to let the user override the color selection on a per mesh basis
  55393. */
  55394. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  55395. /**
  55396. * Callback used to let the user override the texture selection on a per mesh basis
  55397. */
  55398. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  55399. /**
  55400. * Instantiates a new glow Layer and references it to the scene.
  55401. * @param name The name of the layer
  55402. * @param scene The scene to use the layer in
  55403. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  55404. */
  55405. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  55406. /**
  55407. * Get the effect name of the layer.
  55408. * @return The effect name
  55409. */
  55410. getEffectName(): string;
  55411. /**
  55412. * Create the merge effect. This is the shader use to blit the information back
  55413. * to the main canvas at the end of the scene rendering.
  55414. */
  55415. protected _createMergeEffect(): Effect;
  55416. /**
  55417. * Creates the render target textures and post processes used in the glow layer.
  55418. */
  55419. protected _createTextureAndPostProcesses(): void;
  55420. /**
  55421. * Checks for the readiness of the element composing the layer.
  55422. * @param subMesh the mesh to check for
  55423. * @param useInstances specify wether or not to use instances to render the mesh
  55424. * @param emissiveTexture the associated emissive texture used to generate the glow
  55425. * @return true if ready otherwise, false
  55426. */
  55427. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55428. /**
  55429. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  55430. */
  55431. needStencil(): boolean;
  55432. /**
  55433. * Returns true if the mesh can be rendered, otherwise false.
  55434. * @param mesh The mesh to render
  55435. * @param material The material used on the mesh
  55436. * @returns true if it can be rendered otherwise false
  55437. */
  55438. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  55439. /**
  55440. * Implementation specific of rendering the generating effect on the main canvas.
  55441. * @param effect The effect used to render through
  55442. */
  55443. protected _internalRender(effect: Effect): void;
  55444. /**
  55445. * Sets the required values for both the emissive texture and and the main color.
  55446. */
  55447. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55448. /**
  55449. * Returns true if the mesh should render, otherwise false.
  55450. * @param mesh The mesh to render
  55451. * @returns true if it should render otherwise false
  55452. */
  55453. protected _shouldRenderMesh(mesh: Mesh): boolean;
  55454. /**
  55455. * Adds specific effects defines.
  55456. * @param defines The defines to add specifics to.
  55457. */
  55458. protected _addCustomEffectDefines(defines: string[]): void;
  55459. /**
  55460. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  55461. * @param mesh The mesh to exclude from the glow layer
  55462. */
  55463. addExcludedMesh(mesh: Mesh): void;
  55464. /**
  55465. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  55466. * @param mesh The mesh to remove
  55467. */
  55468. removeExcludedMesh(mesh: Mesh): void;
  55469. /**
  55470. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  55471. * @param mesh The mesh to include in the glow layer
  55472. */
  55473. addIncludedOnlyMesh(mesh: Mesh): void;
  55474. /**
  55475. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  55476. * @param mesh The mesh to remove
  55477. */
  55478. removeIncludedOnlyMesh(mesh: Mesh): void;
  55479. /**
  55480. * Determine if a given mesh will be used in the glow layer
  55481. * @param mesh The mesh to test
  55482. * @returns true if the mesh will be highlighted by the current glow layer
  55483. */
  55484. hasMesh(mesh: AbstractMesh): boolean;
  55485. /**
  55486. * Defines whether the current material of the mesh should be use to render the effect.
  55487. * @param mesh defines the current mesh to render
  55488. */
  55489. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  55490. /**
  55491. * Add a mesh to be rendered through its own material and not with emissive only.
  55492. * @param mesh The mesh for which we need to use its material
  55493. */
  55494. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  55495. /**
  55496. * Remove a mesh from being rendered through its own material and not with emissive only.
  55497. * @param mesh The mesh for which we need to not use its material
  55498. */
  55499. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  55500. /**
  55501. * Free any resources and references associated to a mesh.
  55502. * Internal use
  55503. * @param mesh The mesh to free.
  55504. * @hidden
  55505. */
  55506. _disposeMesh(mesh: Mesh): void;
  55507. /**
  55508. * Gets the class name of the effect layer
  55509. * @returns the string with the class name of the effect layer
  55510. */
  55511. getClassName(): string;
  55512. /**
  55513. * Serializes this glow layer
  55514. * @returns a serialized glow layer object
  55515. */
  55516. serialize(): any;
  55517. /**
  55518. * Creates a Glow Layer from parsed glow layer data
  55519. * @param parsedGlowLayer defines glow layer data
  55520. * @param scene defines the current scene
  55521. * @param rootUrl defines the root URL containing the glow layer information
  55522. * @returns a parsed Glow Layer
  55523. */
  55524. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  55525. }
  55526. }
  55527. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  55528. /** @hidden */
  55529. export var glowBlurPostProcessPixelShader: {
  55530. name: string;
  55531. shader: string;
  55532. };
  55533. }
  55534. declare module "babylonjs/Layers/highlightLayer" {
  55535. import { Observable } from "babylonjs/Misc/observable";
  55536. import { Nullable } from "babylonjs/types";
  55537. import { Camera } from "babylonjs/Cameras/camera";
  55538. import { Scene } from "babylonjs/scene";
  55539. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55540. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55541. import { Mesh } from "babylonjs/Meshes/mesh";
  55542. import { Effect } from "babylonjs/Materials/effect";
  55543. import { Material } from "babylonjs/Materials/material";
  55544. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55545. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  55546. import "babylonjs/Shaders/glowMapMerge.fragment";
  55547. import "babylonjs/Shaders/glowMapMerge.vertex";
  55548. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  55549. module "babylonjs/abstractScene" {
  55550. interface AbstractScene {
  55551. /**
  55552. * Return a the first highlight layer of the scene with a given name.
  55553. * @param name The name of the highlight layer to look for.
  55554. * @return The highlight layer if found otherwise null.
  55555. */
  55556. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  55557. }
  55558. }
  55559. /**
  55560. * Highlight layer options. This helps customizing the behaviour
  55561. * of the highlight layer.
  55562. */
  55563. export interface IHighlightLayerOptions {
  55564. /**
  55565. * Multiplication factor apply to the canvas size to compute the render target size
  55566. * used to generated the glowing objects (the smaller the faster).
  55567. */
  55568. mainTextureRatio: number;
  55569. /**
  55570. * Enforces a fixed size texture to ensure resize independant blur.
  55571. */
  55572. mainTextureFixedSize?: number;
  55573. /**
  55574. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  55575. * of the picture to blur (the smaller the faster).
  55576. */
  55577. blurTextureSizeRatio: number;
  55578. /**
  55579. * How big in texel of the blur texture is the vertical blur.
  55580. */
  55581. blurVerticalSize: number;
  55582. /**
  55583. * How big in texel of the blur texture is the horizontal blur.
  55584. */
  55585. blurHorizontalSize: number;
  55586. /**
  55587. * Alpha blending mode used to apply the blur. Default is combine.
  55588. */
  55589. alphaBlendingMode: number;
  55590. /**
  55591. * The camera attached to the layer.
  55592. */
  55593. camera: Nullable<Camera>;
  55594. /**
  55595. * Should we display highlight as a solid stroke?
  55596. */
  55597. isStroke?: boolean;
  55598. /**
  55599. * The rendering group to draw the layer in.
  55600. */
  55601. renderingGroupId: number;
  55602. }
  55603. /**
  55604. * The highlight layer Helps adding a glow effect around a mesh.
  55605. *
  55606. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  55607. * glowy meshes to your scene.
  55608. *
  55609. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  55610. */
  55611. export class HighlightLayer extends EffectLayer {
  55612. name: string;
  55613. /**
  55614. * Effect Name of the highlight layer.
  55615. */
  55616. static readonly EffectName: string;
  55617. /**
  55618. * The neutral color used during the preparation of the glow effect.
  55619. * This is black by default as the blend operation is a blend operation.
  55620. */
  55621. static NeutralColor: Color4;
  55622. /**
  55623. * Stencil value used for glowing meshes.
  55624. */
  55625. static GlowingMeshStencilReference: number;
  55626. /**
  55627. * Stencil value used for the other meshes in the scene.
  55628. */
  55629. static NormalMeshStencilReference: number;
  55630. /**
  55631. * Specifies whether or not the inner glow is ACTIVE in the layer.
  55632. */
  55633. innerGlow: boolean;
  55634. /**
  55635. * Specifies whether or not the outer glow is ACTIVE in the layer.
  55636. */
  55637. outerGlow: boolean;
  55638. /**
  55639. * Specifies the horizontal size of the blur.
  55640. */
  55641. set blurHorizontalSize(value: number);
  55642. /**
  55643. * Specifies the vertical size of the blur.
  55644. */
  55645. set blurVerticalSize(value: number);
  55646. /**
  55647. * Gets the horizontal size of the blur.
  55648. */
  55649. get blurHorizontalSize(): number;
  55650. /**
  55651. * Gets the vertical size of the blur.
  55652. */
  55653. get blurVerticalSize(): number;
  55654. /**
  55655. * An event triggered when the highlight layer is being blurred.
  55656. */
  55657. onBeforeBlurObservable: Observable<HighlightLayer>;
  55658. /**
  55659. * An event triggered when the highlight layer has been blurred.
  55660. */
  55661. onAfterBlurObservable: Observable<HighlightLayer>;
  55662. private _instanceGlowingMeshStencilReference;
  55663. private _options;
  55664. private _downSamplePostprocess;
  55665. private _horizontalBlurPostprocess;
  55666. private _verticalBlurPostprocess;
  55667. private _blurTexture;
  55668. private _meshes;
  55669. private _excludedMeshes;
  55670. /**
  55671. * Instantiates a new highlight Layer and references it to the scene..
  55672. * @param name The name of the layer
  55673. * @param scene The scene to use the layer in
  55674. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  55675. */
  55676. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  55677. /**
  55678. * Get the effect name of the layer.
  55679. * @return The effect name
  55680. */
  55681. getEffectName(): string;
  55682. /**
  55683. * Create the merge effect. This is the shader use to blit the information back
  55684. * to the main canvas at the end of the scene rendering.
  55685. */
  55686. protected _createMergeEffect(): Effect;
  55687. /**
  55688. * Creates the render target textures and post processes used in the highlight layer.
  55689. */
  55690. protected _createTextureAndPostProcesses(): void;
  55691. /**
  55692. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  55693. */
  55694. needStencil(): boolean;
  55695. /**
  55696. * Checks for the readiness of the element composing the layer.
  55697. * @param subMesh the mesh to check for
  55698. * @param useInstances specify wether or not to use instances to render the mesh
  55699. * @param emissiveTexture the associated emissive texture used to generate the glow
  55700. * @return true if ready otherwise, false
  55701. */
  55702. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55703. /**
  55704. * Implementation specific of rendering the generating effect on the main canvas.
  55705. * @param effect The effect used to render through
  55706. */
  55707. protected _internalRender(effect: Effect): void;
  55708. /**
  55709. * Returns true if the layer contains information to display, otherwise false.
  55710. */
  55711. shouldRender(): boolean;
  55712. /**
  55713. * Returns true if the mesh should render, otherwise false.
  55714. * @param mesh The mesh to render
  55715. * @returns true if it should render otherwise false
  55716. */
  55717. protected _shouldRenderMesh(mesh: Mesh): boolean;
  55718. /**
  55719. * Sets the required values for both the emissive texture and and the main color.
  55720. */
  55721. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55722. /**
  55723. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  55724. * @param mesh The mesh to exclude from the highlight layer
  55725. */
  55726. addExcludedMesh(mesh: Mesh): void;
  55727. /**
  55728. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  55729. * @param mesh The mesh to highlight
  55730. */
  55731. removeExcludedMesh(mesh: Mesh): void;
  55732. /**
  55733. * Determine if a given mesh will be highlighted by the current HighlightLayer
  55734. * @param mesh mesh to test
  55735. * @returns true if the mesh will be highlighted by the current HighlightLayer
  55736. */
  55737. hasMesh(mesh: AbstractMesh): boolean;
  55738. /**
  55739. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  55740. * @param mesh The mesh to highlight
  55741. * @param color The color of the highlight
  55742. * @param glowEmissiveOnly Extract the glow from the emissive texture
  55743. */
  55744. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  55745. /**
  55746. * Remove a mesh from the highlight layer in order to make it stop glowing.
  55747. * @param mesh The mesh to highlight
  55748. */
  55749. removeMesh(mesh: Mesh): void;
  55750. /**
  55751. * Force the stencil to the normal expected value for none glowing parts
  55752. */
  55753. private _defaultStencilReference;
  55754. /**
  55755. * Free any resources and references associated to a mesh.
  55756. * Internal use
  55757. * @param mesh The mesh to free.
  55758. * @hidden
  55759. */
  55760. _disposeMesh(mesh: Mesh): void;
  55761. /**
  55762. * Dispose the highlight layer and free resources.
  55763. */
  55764. dispose(): void;
  55765. /**
  55766. * Gets the class name of the effect layer
  55767. * @returns the string with the class name of the effect layer
  55768. */
  55769. getClassName(): string;
  55770. /**
  55771. * Serializes this Highlight layer
  55772. * @returns a serialized Highlight layer object
  55773. */
  55774. serialize(): any;
  55775. /**
  55776. * Creates a Highlight layer from parsed Highlight layer data
  55777. * @param parsedHightlightLayer defines the Highlight layer data
  55778. * @param scene defines the current scene
  55779. * @param rootUrl defines the root URL containing the Highlight layer information
  55780. * @returns a parsed Highlight layer
  55781. */
  55782. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  55783. }
  55784. }
  55785. declare module "babylonjs/Layers/layerSceneComponent" {
  55786. import { Scene } from "babylonjs/scene";
  55787. import { ISceneComponent } from "babylonjs/sceneComponent";
  55788. import { Layer } from "babylonjs/Layers/layer";
  55789. import { AbstractScene } from "babylonjs/abstractScene";
  55790. module "babylonjs/abstractScene" {
  55791. interface AbstractScene {
  55792. /**
  55793. * The list of layers (background and foreground) of the scene
  55794. */
  55795. layers: Array<Layer>;
  55796. }
  55797. }
  55798. /**
  55799. * Defines the layer scene component responsible to manage any layers
  55800. * in a given scene.
  55801. */
  55802. export class LayerSceneComponent implements ISceneComponent {
  55803. /**
  55804. * The component name helpfull to identify the component in the list of scene components.
  55805. */
  55806. readonly name: string;
  55807. /**
  55808. * The scene the component belongs to.
  55809. */
  55810. scene: Scene;
  55811. private _engine;
  55812. /**
  55813. * Creates a new instance of the component for the given scene
  55814. * @param scene Defines the scene to register the component in
  55815. */
  55816. constructor(scene: Scene);
  55817. /**
  55818. * Registers the component in a given scene
  55819. */
  55820. register(): void;
  55821. /**
  55822. * Rebuilds the elements related to this component in case of
  55823. * context lost for instance.
  55824. */
  55825. rebuild(): void;
  55826. /**
  55827. * Disposes the component and the associated ressources.
  55828. */
  55829. dispose(): void;
  55830. private _draw;
  55831. private _drawCameraPredicate;
  55832. private _drawCameraBackground;
  55833. private _drawCameraForeground;
  55834. private _drawRenderTargetPredicate;
  55835. private _drawRenderTargetBackground;
  55836. private _drawRenderTargetForeground;
  55837. /**
  55838. * Adds all the elements from the container to the scene
  55839. * @param container the container holding the elements
  55840. */
  55841. addFromContainer(container: AbstractScene): void;
  55842. /**
  55843. * Removes all the elements in the container from the scene
  55844. * @param container contains the elements to remove
  55845. * @param dispose if the removed element should be disposed (default: false)
  55846. */
  55847. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55848. }
  55849. }
  55850. declare module "babylonjs/Shaders/layer.fragment" {
  55851. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55852. /** @hidden */
  55853. export var layerPixelShader: {
  55854. name: string;
  55855. shader: string;
  55856. };
  55857. }
  55858. declare module "babylonjs/Shaders/layer.vertex" {
  55859. /** @hidden */
  55860. export var layerVertexShader: {
  55861. name: string;
  55862. shader: string;
  55863. };
  55864. }
  55865. declare module "babylonjs/Layers/layer" {
  55866. import { Observable } from "babylonjs/Misc/observable";
  55867. import { Nullable } from "babylonjs/types";
  55868. import { Scene } from "babylonjs/scene";
  55869. import { Vector2 } from "babylonjs/Maths/math.vector";
  55870. import { Color4 } from "babylonjs/Maths/math.color";
  55871. import { Texture } from "babylonjs/Materials/Textures/texture";
  55872. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55873. import "babylonjs/Shaders/layer.fragment";
  55874. import "babylonjs/Shaders/layer.vertex";
  55875. /**
  55876. * This represents a full screen 2d layer.
  55877. * This can be useful to display a picture in the background of your scene for instance.
  55878. * @see https://www.babylonjs-playground.com/#08A2BS#1
  55879. */
  55880. export class Layer {
  55881. /**
  55882. * Define the name of the layer.
  55883. */
  55884. name: string;
  55885. /**
  55886. * Define the texture the layer should display.
  55887. */
  55888. texture: Nullable<Texture>;
  55889. /**
  55890. * Is the layer in background or foreground.
  55891. */
  55892. isBackground: boolean;
  55893. /**
  55894. * Define the color of the layer (instead of texture).
  55895. */
  55896. color: Color4;
  55897. /**
  55898. * Define the scale of the layer in order to zoom in out of the texture.
  55899. */
  55900. scale: Vector2;
  55901. /**
  55902. * Define an offset for the layer in order to shift the texture.
  55903. */
  55904. offset: Vector2;
  55905. /**
  55906. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  55907. */
  55908. alphaBlendingMode: number;
  55909. /**
  55910. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  55911. * Alpha test will not mix with the background color in case of transparency.
  55912. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  55913. */
  55914. alphaTest: boolean;
  55915. /**
  55916. * Define a mask to restrict the layer to only some of the scene cameras.
  55917. */
  55918. layerMask: number;
  55919. /**
  55920. * Define the list of render target the layer is visible into.
  55921. */
  55922. renderTargetTextures: RenderTargetTexture[];
  55923. /**
  55924. * Define if the layer is only used in renderTarget or if it also
  55925. * renders in the main frame buffer of the canvas.
  55926. */
  55927. renderOnlyInRenderTargetTextures: boolean;
  55928. private _scene;
  55929. private _vertexBuffers;
  55930. private _indexBuffer;
  55931. private _effect;
  55932. private _previousDefines;
  55933. /**
  55934. * An event triggered when the layer is disposed.
  55935. */
  55936. onDisposeObservable: Observable<Layer>;
  55937. private _onDisposeObserver;
  55938. /**
  55939. * Back compatibility with callback before the onDisposeObservable existed.
  55940. * The set callback will be triggered when the layer has been disposed.
  55941. */
  55942. set onDispose(callback: () => void);
  55943. /**
  55944. * An event triggered before rendering the scene
  55945. */
  55946. onBeforeRenderObservable: Observable<Layer>;
  55947. private _onBeforeRenderObserver;
  55948. /**
  55949. * Back compatibility with callback before the onBeforeRenderObservable existed.
  55950. * The set callback will be triggered just before rendering the layer.
  55951. */
  55952. set onBeforeRender(callback: () => void);
  55953. /**
  55954. * An event triggered after rendering the scene
  55955. */
  55956. onAfterRenderObservable: Observable<Layer>;
  55957. private _onAfterRenderObserver;
  55958. /**
  55959. * Back compatibility with callback before the onAfterRenderObservable existed.
  55960. * The set callback will be triggered just after rendering the layer.
  55961. */
  55962. set onAfterRender(callback: () => void);
  55963. /**
  55964. * Instantiates a new layer.
  55965. * This represents a full screen 2d layer.
  55966. * This can be useful to display a picture in the background of your scene for instance.
  55967. * @see https://www.babylonjs-playground.com/#08A2BS#1
  55968. * @param name Define the name of the layer in the scene
  55969. * @param imgUrl Define the url of the texture to display in the layer
  55970. * @param scene Define the scene the layer belongs to
  55971. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  55972. * @param color Defines a color for the layer
  55973. */
  55974. constructor(
  55975. /**
  55976. * Define the name of the layer.
  55977. */
  55978. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  55979. private _createIndexBuffer;
  55980. /** @hidden */
  55981. _rebuild(): void;
  55982. /**
  55983. * Renders the layer in the scene.
  55984. */
  55985. render(): void;
  55986. /**
  55987. * Disposes and releases the associated ressources.
  55988. */
  55989. dispose(): void;
  55990. }
  55991. }
  55992. declare module "babylonjs/Layers/index" {
  55993. export * from "babylonjs/Layers/effectLayer";
  55994. export * from "babylonjs/Layers/effectLayerSceneComponent";
  55995. export * from "babylonjs/Layers/glowLayer";
  55996. export * from "babylonjs/Layers/highlightLayer";
  55997. export * from "babylonjs/Layers/layer";
  55998. export * from "babylonjs/Layers/layerSceneComponent";
  55999. }
  56000. declare module "babylonjs/Shaders/lensFlare.fragment" {
  56001. /** @hidden */
  56002. export var lensFlarePixelShader: {
  56003. name: string;
  56004. shader: string;
  56005. };
  56006. }
  56007. declare module "babylonjs/Shaders/lensFlare.vertex" {
  56008. /** @hidden */
  56009. export var lensFlareVertexShader: {
  56010. name: string;
  56011. shader: string;
  56012. };
  56013. }
  56014. declare module "babylonjs/LensFlares/lensFlareSystem" {
  56015. import { Scene } from "babylonjs/scene";
  56016. import { Vector3 } from "babylonjs/Maths/math.vector";
  56017. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56018. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  56019. import "babylonjs/Shaders/lensFlare.fragment";
  56020. import "babylonjs/Shaders/lensFlare.vertex";
  56021. import { Viewport } from "babylonjs/Maths/math.viewport";
  56022. /**
  56023. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56024. * It is usually composed of several `lensFlare`.
  56025. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56026. */
  56027. export class LensFlareSystem {
  56028. /**
  56029. * Define the name of the lens flare system
  56030. */
  56031. name: string;
  56032. /**
  56033. * List of lens flares used in this system.
  56034. */
  56035. lensFlares: LensFlare[];
  56036. /**
  56037. * Define a limit from the border the lens flare can be visible.
  56038. */
  56039. borderLimit: number;
  56040. /**
  56041. * Define a viewport border we do not want to see the lens flare in.
  56042. */
  56043. viewportBorder: number;
  56044. /**
  56045. * Define a predicate which could limit the list of meshes able to occlude the effect.
  56046. */
  56047. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  56048. /**
  56049. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  56050. */
  56051. layerMask: number;
  56052. /**
  56053. * Define the id of the lens flare system in the scene.
  56054. * (equal to name by default)
  56055. */
  56056. id: string;
  56057. private _scene;
  56058. private _emitter;
  56059. private _vertexBuffers;
  56060. private _indexBuffer;
  56061. private _effect;
  56062. private _positionX;
  56063. private _positionY;
  56064. private _isEnabled;
  56065. /** @hidden */
  56066. static _SceneComponentInitialization: (scene: Scene) => void;
  56067. /**
  56068. * Instantiates a lens flare system.
  56069. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56070. * It is usually composed of several `lensFlare`.
  56071. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56072. * @param name Define the name of the lens flare system in the scene
  56073. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  56074. * @param scene Define the scene the lens flare system belongs to
  56075. */
  56076. constructor(
  56077. /**
  56078. * Define the name of the lens flare system
  56079. */
  56080. name: string, emitter: any, scene: Scene);
  56081. /**
  56082. * Define if the lens flare system is enabled.
  56083. */
  56084. get isEnabled(): boolean;
  56085. set isEnabled(value: boolean);
  56086. /**
  56087. * Get the scene the effects belongs to.
  56088. * @returns the scene holding the lens flare system
  56089. */
  56090. getScene(): Scene;
  56091. /**
  56092. * Get the emitter of the lens flare system.
  56093. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  56094. * @returns the emitter of the lens flare system
  56095. */
  56096. getEmitter(): any;
  56097. /**
  56098. * Set the emitter of the lens flare system.
  56099. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  56100. * @param newEmitter Define the new emitter of the system
  56101. */
  56102. setEmitter(newEmitter: any): void;
  56103. /**
  56104. * Get the lens flare system emitter position.
  56105. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  56106. * @returns the position
  56107. */
  56108. getEmitterPosition(): Vector3;
  56109. /**
  56110. * @hidden
  56111. */
  56112. computeEffectivePosition(globalViewport: Viewport): boolean;
  56113. /** @hidden */
  56114. _isVisible(): boolean;
  56115. /**
  56116. * @hidden
  56117. */
  56118. render(): boolean;
  56119. /**
  56120. * Dispose and release the lens flare with its associated resources.
  56121. */
  56122. dispose(): void;
  56123. /**
  56124. * Parse a lens flare system from a JSON repressentation
  56125. * @param parsedLensFlareSystem Define the JSON to parse
  56126. * @param scene Define the scene the parsed system should be instantiated in
  56127. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  56128. * @returns the parsed system
  56129. */
  56130. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  56131. /**
  56132. * Serialize the current Lens Flare System into a JSON representation.
  56133. * @returns the serialized JSON
  56134. */
  56135. serialize(): any;
  56136. }
  56137. }
  56138. declare module "babylonjs/LensFlares/lensFlare" {
  56139. import { Nullable } from "babylonjs/types";
  56140. import { Color3 } from "babylonjs/Maths/math.color";
  56141. import { Texture } from "babylonjs/Materials/Textures/texture";
  56142. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56143. /**
  56144. * This represents one of the lens effect in a `lensFlareSystem`.
  56145. * It controls one of the indiviual texture used in the effect.
  56146. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56147. */
  56148. export class LensFlare {
  56149. /**
  56150. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56151. */
  56152. size: number;
  56153. /**
  56154. * 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.
  56155. */
  56156. position: number;
  56157. /**
  56158. * Define the lens color.
  56159. */
  56160. color: Color3;
  56161. /**
  56162. * Define the lens texture.
  56163. */
  56164. texture: Nullable<Texture>;
  56165. /**
  56166. * Define the alpha mode to render this particular lens.
  56167. */
  56168. alphaMode: number;
  56169. private _system;
  56170. /**
  56171. * Creates a new Lens Flare.
  56172. * This represents one of the lens effect in a `lensFlareSystem`.
  56173. * It controls one of the indiviual texture used in the effect.
  56174. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56175. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  56176. * @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.
  56177. * @param color Define the lens color
  56178. * @param imgUrl Define the lens texture url
  56179. * @param system Define the `lensFlareSystem` this flare is part of
  56180. * @returns The newly created Lens Flare
  56181. */
  56182. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  56183. /**
  56184. * Instantiates a new Lens Flare.
  56185. * This represents one of the lens effect in a `lensFlareSystem`.
  56186. * It controls one of the indiviual texture used in the effect.
  56187. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56188. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  56189. * @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.
  56190. * @param color Define the lens color
  56191. * @param imgUrl Define the lens texture url
  56192. * @param system Define the `lensFlareSystem` this flare is part of
  56193. */
  56194. constructor(
  56195. /**
  56196. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56197. */
  56198. size: number,
  56199. /**
  56200. * Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  56201. */
  56202. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  56203. /**
  56204. * Dispose and release the lens flare with its associated resources.
  56205. */
  56206. dispose(): void;
  56207. }
  56208. }
  56209. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  56210. import { Nullable } from "babylonjs/types";
  56211. import { Scene } from "babylonjs/scene";
  56212. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  56213. import { AbstractScene } from "babylonjs/abstractScene";
  56214. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56215. module "babylonjs/abstractScene" {
  56216. interface AbstractScene {
  56217. /**
  56218. * The list of lens flare system added to the scene
  56219. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56220. */
  56221. lensFlareSystems: Array<LensFlareSystem>;
  56222. /**
  56223. * Removes the given lens flare system from this scene.
  56224. * @param toRemove The lens flare system to remove
  56225. * @returns The index of the removed lens flare system
  56226. */
  56227. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  56228. /**
  56229. * Adds the given lens flare system to this scene
  56230. * @param newLensFlareSystem The lens flare system to add
  56231. */
  56232. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  56233. /**
  56234. * Gets a lens flare system using its name
  56235. * @param name defines the name to look for
  56236. * @returns the lens flare system or null if not found
  56237. */
  56238. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  56239. /**
  56240. * Gets a lens flare system using its id
  56241. * @param id defines the id to look for
  56242. * @returns the lens flare system or null if not found
  56243. */
  56244. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  56245. }
  56246. }
  56247. /**
  56248. * Defines the lens flare scene component responsible to manage any lens flares
  56249. * in a given scene.
  56250. */
  56251. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  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. /**
  56261. * Creates a new instance of the component for the given scene
  56262. * @param scene Defines the scene to register the component in
  56263. */
  56264. constructor(scene: Scene);
  56265. /**
  56266. * Registers the component in a given scene
  56267. */
  56268. register(): void;
  56269. /**
  56270. * Rebuilds the elements related to this component in case of
  56271. * context lost for instance.
  56272. */
  56273. rebuild(): void;
  56274. /**
  56275. * Adds all the elements from the container to the scene
  56276. * @param container the container holding the elements
  56277. */
  56278. addFromContainer(container: AbstractScene): void;
  56279. /**
  56280. * Removes all the elements in the container from the scene
  56281. * @param container contains the elements to remove
  56282. * @param dispose if the removed element should be disposed (default: false)
  56283. */
  56284. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56285. /**
  56286. * Serializes the component data to the specified json object
  56287. * @param serializationObject The object to serialize to
  56288. */
  56289. serialize(serializationObject: any): void;
  56290. /**
  56291. * Disposes the component and the associated ressources.
  56292. */
  56293. dispose(): void;
  56294. private _draw;
  56295. }
  56296. }
  56297. declare module "babylonjs/LensFlares/index" {
  56298. export * from "babylonjs/LensFlares/lensFlare";
  56299. export * from "babylonjs/LensFlares/lensFlareSystem";
  56300. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  56301. }
  56302. declare module "babylonjs/Shaders/depth.fragment" {
  56303. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  56304. /** @hidden */
  56305. export var depthPixelShader: {
  56306. name: string;
  56307. shader: string;
  56308. };
  56309. }
  56310. declare module "babylonjs/Shaders/depth.vertex" {
  56311. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56312. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  56313. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  56314. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56315. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  56316. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56317. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56318. /** @hidden */
  56319. export var depthVertexShader: {
  56320. name: string;
  56321. shader: string;
  56322. };
  56323. }
  56324. declare module "babylonjs/Rendering/depthRenderer" {
  56325. import { Nullable } from "babylonjs/types";
  56326. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56327. import { Scene } from "babylonjs/scene";
  56328. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56329. import { Camera } from "babylonjs/Cameras/camera";
  56330. import "babylonjs/Shaders/depth.fragment";
  56331. import "babylonjs/Shaders/depth.vertex";
  56332. /**
  56333. * This represents a depth renderer in Babylon.
  56334. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  56335. */
  56336. export class DepthRenderer {
  56337. private _scene;
  56338. private _depthMap;
  56339. private _effect;
  56340. private readonly _storeNonLinearDepth;
  56341. private readonly _clearColor;
  56342. /** Get if the depth renderer is using packed depth or not */
  56343. readonly isPacked: boolean;
  56344. private _cachedDefines;
  56345. private _camera;
  56346. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  56347. enabled: boolean;
  56348. /**
  56349. * Specifiess that the depth renderer will only be used within
  56350. * the camera it is created for.
  56351. * This can help forcing its rendering during the camera processing.
  56352. */
  56353. useOnlyInActiveCamera: boolean;
  56354. /** @hidden */
  56355. static _SceneComponentInitialization: (scene: Scene) => void;
  56356. /**
  56357. * Instantiates a depth renderer
  56358. * @param scene The scene the renderer belongs to
  56359. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  56360. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  56361. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  56362. */
  56363. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  56364. /**
  56365. * Creates the depth rendering effect and checks if the effect is ready.
  56366. * @param subMesh The submesh to be used to render the depth map of
  56367. * @param useInstances If multiple world instances should be used
  56368. * @returns if the depth renderer is ready to render the depth map
  56369. */
  56370. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56371. /**
  56372. * Gets the texture which the depth map will be written to.
  56373. * @returns The depth map texture
  56374. */
  56375. getDepthMap(): RenderTargetTexture;
  56376. /**
  56377. * Disposes of the depth renderer.
  56378. */
  56379. dispose(): void;
  56380. }
  56381. }
  56382. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  56383. /** @hidden */
  56384. export var minmaxReduxPixelShader: {
  56385. name: string;
  56386. shader: string;
  56387. };
  56388. }
  56389. declare module "babylonjs/Misc/minMaxReducer" {
  56390. import { Nullable } from "babylonjs/types";
  56391. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56392. import { Camera } from "babylonjs/Cameras/camera";
  56393. import { Observer } from "babylonjs/Misc/observable";
  56394. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56395. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  56396. import { Observable } from "babylonjs/Misc/observable";
  56397. import "babylonjs/Shaders/minmaxRedux.fragment";
  56398. /**
  56399. * This class computes a min/max reduction from a texture: it means it computes the minimum
  56400. * and maximum values from all values of the texture.
  56401. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  56402. * The source values are read from the red channel of the texture.
  56403. */
  56404. export class MinMaxReducer {
  56405. /**
  56406. * Observable triggered when the computation has been performed
  56407. */
  56408. onAfterReductionPerformed: Observable<{
  56409. min: number;
  56410. max: number;
  56411. }>;
  56412. protected _camera: Camera;
  56413. protected _sourceTexture: Nullable<RenderTargetTexture>;
  56414. protected _reductionSteps: Nullable<Array<PostProcess>>;
  56415. protected _postProcessManager: PostProcessManager;
  56416. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  56417. protected _forceFullscreenViewport: boolean;
  56418. /**
  56419. * Creates a min/max reducer
  56420. * @param camera The camera to use for the post processes
  56421. */
  56422. constructor(camera: Camera);
  56423. /**
  56424. * Gets the texture used to read the values from.
  56425. */
  56426. get sourceTexture(): Nullable<RenderTargetTexture>;
  56427. /**
  56428. * Sets the source texture to read the values from.
  56429. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  56430. * because in such textures '1' value must not be taken into account to compute the maximum
  56431. * as this value is used to clear the texture.
  56432. * Note that the computation is not activated by calling this function, you must call activate() for that!
  56433. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  56434. * @param depthRedux Indicates if the texture is a depth texture or not
  56435. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  56436. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  56437. */
  56438. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  56439. /**
  56440. * Defines the refresh rate of the computation.
  56441. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  56442. */
  56443. get refreshRate(): number;
  56444. set refreshRate(value: number);
  56445. protected _activated: boolean;
  56446. /**
  56447. * Gets the activation status of the reducer
  56448. */
  56449. get activated(): boolean;
  56450. /**
  56451. * Activates the reduction computation.
  56452. * When activated, the observers registered in onAfterReductionPerformed are
  56453. * called after the compuation is performed
  56454. */
  56455. activate(): void;
  56456. /**
  56457. * Deactivates the reduction computation.
  56458. */
  56459. deactivate(): void;
  56460. /**
  56461. * Disposes the min/max reducer
  56462. * @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.
  56463. */
  56464. dispose(disposeAll?: boolean): void;
  56465. }
  56466. }
  56467. declare module "babylonjs/Misc/depthReducer" {
  56468. import { Nullable } from "babylonjs/types";
  56469. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56470. import { Camera } from "babylonjs/Cameras/camera";
  56471. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56472. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  56473. /**
  56474. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  56475. */
  56476. export class DepthReducer extends MinMaxReducer {
  56477. private _depthRenderer;
  56478. private _depthRendererId;
  56479. /**
  56480. * Gets the depth renderer used for the computation.
  56481. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  56482. */
  56483. get depthRenderer(): Nullable<DepthRenderer>;
  56484. /**
  56485. * Creates a depth reducer
  56486. * @param camera The camera used to render the depth texture
  56487. */
  56488. constructor(camera: Camera);
  56489. /**
  56490. * Sets the depth renderer to use to generate the depth map
  56491. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  56492. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  56493. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  56494. */
  56495. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  56496. /** @hidden */
  56497. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  56498. /**
  56499. * Activates the reduction computation.
  56500. * When activated, the observers registered in onAfterReductionPerformed are
  56501. * called after the compuation is performed
  56502. */
  56503. activate(): void;
  56504. /**
  56505. * Deactivates the reduction computation.
  56506. */
  56507. deactivate(): void;
  56508. /**
  56509. * Disposes the depth reducer
  56510. * @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.
  56511. */
  56512. dispose(disposeAll?: boolean): void;
  56513. }
  56514. }
  56515. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  56516. import { Nullable } from "babylonjs/types";
  56517. import { Scene } from "babylonjs/scene";
  56518. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56519. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56520. import { Effect } from "babylonjs/Materials/effect";
  56521. import "babylonjs/Shaders/shadowMap.fragment";
  56522. import "babylonjs/Shaders/shadowMap.vertex";
  56523. import "babylonjs/Shaders/depthBoxBlur.fragment";
  56524. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  56525. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  56526. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  56527. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56528. /**
  56529. * A CSM implementation allowing casting shadows on large scenes.
  56530. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  56531. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  56532. */
  56533. export class CascadedShadowGenerator extends ShadowGenerator {
  56534. private static readonly frustumCornersNDCSpace;
  56535. /**
  56536. * Name of the CSM class
  56537. */
  56538. static CLASSNAME: string;
  56539. /**
  56540. * Defines the default number of cascades used by the CSM.
  56541. */
  56542. static readonly DEFAULT_CASCADES_COUNT: number;
  56543. /**
  56544. * Defines the minimum number of cascades used by the CSM.
  56545. */
  56546. static readonly MIN_CASCADES_COUNT: number;
  56547. /**
  56548. * Defines the maximum number of cascades used by the CSM.
  56549. */
  56550. static readonly MAX_CASCADES_COUNT: number;
  56551. protected _validateFilter(filter: number): number;
  56552. /**
  56553. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  56554. */
  56555. penumbraDarkness: number;
  56556. private _numCascades;
  56557. /**
  56558. * Gets or set the number of cascades used by the CSM.
  56559. */
  56560. get numCascades(): number;
  56561. set numCascades(value: number);
  56562. /**
  56563. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  56564. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  56565. */
  56566. stabilizeCascades: boolean;
  56567. private _freezeShadowCastersBoundingInfo;
  56568. private _freezeShadowCastersBoundingInfoObservable;
  56569. /**
  56570. * Enables or disables the shadow casters bounding info computation.
  56571. * If your shadow casters don't move, you can disable this feature.
  56572. * If it is enabled, the bounding box computation is done every frame.
  56573. */
  56574. get freezeShadowCastersBoundingInfo(): boolean;
  56575. set freezeShadowCastersBoundingInfo(freeze: boolean);
  56576. private _scbiMin;
  56577. private _scbiMax;
  56578. protected _computeShadowCastersBoundingInfo(): void;
  56579. protected _shadowCastersBoundingInfo: BoundingInfo;
  56580. /**
  56581. * Gets or sets the shadow casters bounding info.
  56582. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  56583. * so that the system won't overwrite the bounds you provide
  56584. */
  56585. get shadowCastersBoundingInfo(): BoundingInfo;
  56586. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  56587. protected _breaksAreDirty: boolean;
  56588. protected _minDistance: number;
  56589. protected _maxDistance: number;
  56590. /**
  56591. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  56592. *
  56593. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  56594. * If you don't know these values, simply leave them to their defaults and don't call this function.
  56595. * @param min minimal distance for the breaks (default to 0.)
  56596. * @param max maximal distance for the breaks (default to 1.)
  56597. */
  56598. setMinMaxDistance(min: number, max: number): void;
  56599. /** Gets the minimal distance used in the cascade break computation */
  56600. get minDistance(): number;
  56601. /** Gets the maximal distance used in the cascade break computation */
  56602. get maxDistance(): number;
  56603. /**
  56604. * Gets the class name of that object
  56605. * @returns "CascadedShadowGenerator"
  56606. */
  56607. getClassName(): string;
  56608. private _cascadeMinExtents;
  56609. private _cascadeMaxExtents;
  56610. /**
  56611. * Gets a cascade minimum extents
  56612. * @param cascadeIndex index of the cascade
  56613. * @returns the minimum cascade extents
  56614. */
  56615. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  56616. /**
  56617. * Gets a cascade maximum extents
  56618. * @param cascadeIndex index of the cascade
  56619. * @returns the maximum cascade extents
  56620. */
  56621. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  56622. private _cascades;
  56623. private _currentLayer;
  56624. private _viewSpaceFrustumsZ;
  56625. private _viewMatrices;
  56626. private _projectionMatrices;
  56627. private _transformMatrices;
  56628. private _transformMatricesAsArray;
  56629. private _frustumLengths;
  56630. private _lightSizeUVCorrection;
  56631. private _depthCorrection;
  56632. private _frustumCornersWorldSpace;
  56633. private _frustumCenter;
  56634. private _shadowCameraPos;
  56635. private _shadowMaxZ;
  56636. /**
  56637. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  56638. * It defaults to camera.maxZ
  56639. */
  56640. get shadowMaxZ(): number;
  56641. /**
  56642. * Sets the shadow max z distance.
  56643. */
  56644. set shadowMaxZ(value: number);
  56645. protected _debug: boolean;
  56646. /**
  56647. * Gets or sets the debug flag.
  56648. * When enabled, the cascades are materialized by different colors on the screen.
  56649. */
  56650. get debug(): boolean;
  56651. set debug(dbg: boolean);
  56652. private _depthClamp;
  56653. /**
  56654. * Gets or sets the depth clamping value.
  56655. *
  56656. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  56657. * to account for the shadow casters far away.
  56658. *
  56659. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  56660. */
  56661. get depthClamp(): boolean;
  56662. set depthClamp(value: boolean);
  56663. private _cascadeBlendPercentage;
  56664. /**
  56665. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  56666. * It defaults to 0.1 (10% blending).
  56667. */
  56668. get cascadeBlendPercentage(): number;
  56669. set cascadeBlendPercentage(value: number);
  56670. private _lambda;
  56671. /**
  56672. * Gets or set the lambda parameter.
  56673. * This parameter is used to split the camera frustum and create the cascades.
  56674. * 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.
  56675. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  56676. */
  56677. get lambda(): number;
  56678. set lambda(value: number);
  56679. /**
  56680. * Gets the view matrix corresponding to a given cascade
  56681. * @param cascadeNum cascade to retrieve the view matrix from
  56682. * @returns the cascade view matrix
  56683. */
  56684. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  56685. /**
  56686. * Gets the projection matrix corresponding to a given cascade
  56687. * @param cascadeNum cascade to retrieve the projection matrix from
  56688. * @returns the cascade projection matrix
  56689. */
  56690. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  56691. /**
  56692. * Gets the transformation matrix corresponding to a given cascade
  56693. * @param cascadeNum cascade to retrieve the transformation matrix from
  56694. * @returns the cascade transformation matrix
  56695. */
  56696. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  56697. private _depthRenderer;
  56698. /**
  56699. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  56700. *
  56701. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  56702. *
  56703. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  56704. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  56705. * @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
  56706. */
  56707. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  56708. private _depthReducer;
  56709. private _autoCalcDepthBounds;
  56710. /**
  56711. * Gets or sets the autoCalcDepthBounds property.
  56712. *
  56713. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  56714. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  56715. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  56716. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  56717. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  56718. */
  56719. get autoCalcDepthBounds(): boolean;
  56720. set autoCalcDepthBounds(value: boolean);
  56721. /**
  56722. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  56723. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  56724. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  56725. * for setting the refresh rate on the renderer yourself!
  56726. */
  56727. get autoCalcDepthBoundsRefreshRate(): number;
  56728. set autoCalcDepthBoundsRefreshRate(value: number);
  56729. /**
  56730. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  56731. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  56732. * you change the camera near/far planes!
  56733. */
  56734. splitFrustum(): void;
  56735. private _splitFrustum;
  56736. private _computeMatrices;
  56737. private _computeFrustumInWorldSpace;
  56738. private _computeCascadeFrustum;
  56739. /** @hidden */
  56740. static _SceneComponentInitialization: (scene: Scene) => void;
  56741. /**
  56742. * Creates a Cascaded Shadow Generator object.
  56743. * A ShadowGenerator is the required tool to use the shadows.
  56744. * Each directional light casting shadows needs to use its own ShadowGenerator.
  56745. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  56746. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  56747. * @param light The directional light object generating the shadows.
  56748. * @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.
  56749. */
  56750. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  56751. protected _initializeGenerator(): void;
  56752. protected _createTargetRenderTexture(): void;
  56753. protected _initializeShadowMap(): void;
  56754. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  56755. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  56756. /**
  56757. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  56758. * @param defines Defines of the material we want to update
  56759. * @param lightIndex Index of the light in the enabled light list of the material
  56760. */
  56761. prepareDefines(defines: any, lightIndex: number): void;
  56762. /**
  56763. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  56764. * defined in the generator but impacting the effect).
  56765. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  56766. * @param effect The effect we are binfing the information for
  56767. */
  56768. bindShadowLight(lightIndex: string, effect: Effect): void;
  56769. /**
  56770. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  56771. * (eq to view projection * shadow projection matrices)
  56772. * @returns The transform matrix used to create the shadow map
  56773. */
  56774. getTransformMatrix(): Matrix;
  56775. /**
  56776. * Disposes the ShadowGenerator.
  56777. * Returns nothing.
  56778. */
  56779. dispose(): void;
  56780. /**
  56781. * Serializes the shadow generator setup to a json object.
  56782. * @returns The serialized JSON object
  56783. */
  56784. serialize(): any;
  56785. /**
  56786. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  56787. * @param parsedShadowGenerator The JSON object to parse
  56788. * @param scene The scene to create the shadow map for
  56789. * @returns The parsed shadow generator
  56790. */
  56791. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  56792. }
  56793. }
  56794. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  56795. import { Scene } from "babylonjs/scene";
  56796. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  56797. import { AbstractScene } from "babylonjs/abstractScene";
  56798. /**
  56799. * Defines the shadow generator component responsible to manage any shadow generators
  56800. * in a given scene.
  56801. */
  56802. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  56803. /**
  56804. * The component name helpfull to identify the component in the list of scene components.
  56805. */
  56806. readonly name: string;
  56807. /**
  56808. * The scene the component belongs to.
  56809. */
  56810. scene: Scene;
  56811. /**
  56812. * Creates a new instance of the component for the given scene
  56813. * @param scene Defines the scene to register the component in
  56814. */
  56815. constructor(scene: Scene);
  56816. /**
  56817. * Registers the component in a given scene
  56818. */
  56819. register(): void;
  56820. /**
  56821. * Rebuilds the elements related to this component in case of
  56822. * context lost for instance.
  56823. */
  56824. rebuild(): void;
  56825. /**
  56826. * Serializes the component data to the specified json object
  56827. * @param serializationObject The object to serialize to
  56828. */
  56829. serialize(serializationObject: any): void;
  56830. /**
  56831. * Adds all the elements from the container to the scene
  56832. * @param container the container holding the elements
  56833. */
  56834. addFromContainer(container: AbstractScene): void;
  56835. /**
  56836. * Removes all the elements in the container from the scene
  56837. * @param container contains the elements to remove
  56838. * @param dispose if the removed element should be disposed (default: false)
  56839. */
  56840. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56841. /**
  56842. * Rebuilds the elements related to this component in case of
  56843. * context lost for instance.
  56844. */
  56845. dispose(): void;
  56846. private _gatherRenderTargets;
  56847. }
  56848. }
  56849. declare module "babylonjs/Lights/Shadows/index" {
  56850. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  56851. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  56852. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  56853. }
  56854. declare module "babylonjs/Lights/pointLight" {
  56855. import { Scene } from "babylonjs/scene";
  56856. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56857. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56858. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  56859. import { Effect } from "babylonjs/Materials/effect";
  56860. /**
  56861. * A point light is a light defined by an unique point in world space.
  56862. * The light is emitted in every direction from this point.
  56863. * A good example of a point light is a standard light bulb.
  56864. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56865. */
  56866. export class PointLight extends ShadowLight {
  56867. private _shadowAngle;
  56868. /**
  56869. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56870. * This specifies what angle the shadow will use to be created.
  56871. *
  56872. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  56873. */
  56874. get shadowAngle(): number;
  56875. /**
  56876. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56877. * This specifies what angle the shadow will use to be created.
  56878. *
  56879. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  56880. */
  56881. set shadowAngle(value: number);
  56882. /**
  56883. * Gets the direction if it has been set.
  56884. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56885. */
  56886. get direction(): Vector3;
  56887. /**
  56888. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56889. */
  56890. set direction(value: Vector3);
  56891. /**
  56892. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  56893. * A PointLight emits the light in every direction.
  56894. * It can cast shadows.
  56895. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  56896. * ```javascript
  56897. * var pointLight = new PointLight("pl", camera.position, scene);
  56898. * ```
  56899. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56900. * @param name The light friendly name
  56901. * @param position The position of the point light in the scene
  56902. * @param scene The scene the lights belongs to
  56903. */
  56904. constructor(name: string, position: Vector3, scene: Scene);
  56905. /**
  56906. * Returns the string "PointLight"
  56907. * @returns the class name
  56908. */
  56909. getClassName(): string;
  56910. /**
  56911. * Returns the integer 0.
  56912. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56913. */
  56914. getTypeID(): number;
  56915. /**
  56916. * Specifies wether or not the shadowmap should be a cube texture.
  56917. * @returns true if the shadowmap needs to be a cube texture.
  56918. */
  56919. needCube(): boolean;
  56920. /**
  56921. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  56922. * @param faceIndex The index of the face we are computed the direction to generate shadow
  56923. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  56924. */
  56925. getShadowDirection(faceIndex?: number): Vector3;
  56926. /**
  56927. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  56928. * - fov = PI / 2
  56929. * - aspect ratio : 1.0
  56930. * - z-near and far equal to the active camera minZ and maxZ.
  56931. * Returns the PointLight.
  56932. */
  56933. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56934. protected _buildUniformLayout(): void;
  56935. /**
  56936. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  56937. * @param effect The effect to update
  56938. * @param lightIndex The index of the light in the effect to update
  56939. * @returns The point light
  56940. */
  56941. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  56942. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  56943. /**
  56944. * Prepares the list of defines specific to the light type.
  56945. * @param defines the list of defines
  56946. * @param lightIndex defines the index of the light for the effect
  56947. */
  56948. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  56949. }
  56950. }
  56951. declare module "babylonjs/Lights/index" {
  56952. export * from "babylonjs/Lights/light";
  56953. export * from "babylonjs/Lights/shadowLight";
  56954. export * from "babylonjs/Lights/Shadows/index";
  56955. export * from "babylonjs/Lights/directionalLight";
  56956. export * from "babylonjs/Lights/hemisphericLight";
  56957. export * from "babylonjs/Lights/pointLight";
  56958. export * from "babylonjs/Lights/spotLight";
  56959. }
  56960. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  56961. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  56962. /**
  56963. * Header information of HDR texture files.
  56964. */
  56965. export interface HDRInfo {
  56966. /**
  56967. * The height of the texture in pixels.
  56968. */
  56969. height: number;
  56970. /**
  56971. * The width of the texture in pixels.
  56972. */
  56973. width: number;
  56974. /**
  56975. * The index of the beginning of the data in the binary file.
  56976. */
  56977. dataPosition: number;
  56978. }
  56979. /**
  56980. * This groups tools to convert HDR texture to native colors array.
  56981. */
  56982. export class HDRTools {
  56983. private static Ldexp;
  56984. private static Rgbe2float;
  56985. private static readStringLine;
  56986. /**
  56987. * Reads header information from an RGBE texture stored in a native array.
  56988. * More information on this format are available here:
  56989. * https://en.wikipedia.org/wiki/RGBE_image_format
  56990. *
  56991. * @param uint8array The binary file stored in native array.
  56992. * @return The header information.
  56993. */
  56994. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  56995. /**
  56996. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  56997. * This RGBE texture needs to store the information as a panorama.
  56998. *
  56999. * More information on this format are available here:
  57000. * https://en.wikipedia.org/wiki/RGBE_image_format
  57001. *
  57002. * @param buffer The binary file stored in an array buffer.
  57003. * @param size The expected size of the extracted cubemap.
  57004. * @return The Cube Map information.
  57005. */
  57006. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  57007. /**
  57008. * Returns the pixels data extracted from an RGBE texture.
  57009. * This pixels will be stored left to right up to down in the R G B order in one array.
  57010. *
  57011. * More information on this format are available here:
  57012. * https://en.wikipedia.org/wiki/RGBE_image_format
  57013. *
  57014. * @param uint8array The binary file stored in an array buffer.
  57015. * @param hdrInfo The header information of the file.
  57016. * @return The pixels data in RGB right to left up to down order.
  57017. */
  57018. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  57019. private static RGBE_ReadPixels_RLE;
  57020. }
  57021. }
  57022. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  57023. import { Nullable } from "babylonjs/types";
  57024. import { Scene } from "babylonjs/scene";
  57025. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57026. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57027. import "babylonjs/Engines/Extensions/engine.rawTexture";
  57028. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  57029. /**
  57030. * This represents a texture coming from an HDR input.
  57031. *
  57032. * The only supported format is currently panorama picture stored in RGBE format.
  57033. * Example of such files can be found on HDRLib: http://hdrlib.com/
  57034. */
  57035. export class HDRCubeTexture extends BaseTexture {
  57036. private static _facesMapping;
  57037. private _generateHarmonics;
  57038. private _noMipmap;
  57039. private _textureMatrix;
  57040. private _size;
  57041. private _onLoad;
  57042. private _onError;
  57043. /**
  57044. * The texture URL.
  57045. */
  57046. url: string;
  57047. /**
  57048. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  57049. */
  57050. coordinatesMode: number;
  57051. protected _isBlocking: boolean;
  57052. /**
  57053. * Sets wether or not the texture is blocking during loading.
  57054. */
  57055. set isBlocking(value: boolean);
  57056. /**
  57057. * Gets wether or not the texture is blocking during loading.
  57058. */
  57059. get isBlocking(): boolean;
  57060. protected _rotationY: number;
  57061. /**
  57062. * Sets texture matrix rotation angle around Y axis in radians.
  57063. */
  57064. set rotationY(value: number);
  57065. /**
  57066. * Gets texture matrix rotation angle around Y axis radians.
  57067. */
  57068. get rotationY(): number;
  57069. /**
  57070. * Gets or sets the center of the bounding box associated with the cube texture
  57071. * It must define where the camera used to render the texture was set
  57072. */
  57073. boundingBoxPosition: Vector3;
  57074. private _boundingBoxSize;
  57075. /**
  57076. * Gets or sets the size of the bounding box associated with the cube texture
  57077. * When defined, the cubemap will switch to local mode
  57078. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  57079. * @example https://www.babylonjs-playground.com/#RNASML
  57080. */
  57081. set boundingBoxSize(value: Vector3);
  57082. get boundingBoxSize(): Vector3;
  57083. /**
  57084. * Instantiates an HDRTexture from the following parameters.
  57085. *
  57086. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  57087. * @param scene The scene the texture will be used in
  57088. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  57089. * @param noMipmap Forces to not generate the mipmap if true
  57090. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  57091. * @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)
  57092. * @param reserved Reserved flag for internal use.
  57093. */
  57094. 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>);
  57095. /**
  57096. * Get the current class name of the texture useful for serialization or dynamic coding.
  57097. * @returns "HDRCubeTexture"
  57098. */
  57099. getClassName(): string;
  57100. /**
  57101. * Occurs when the file is raw .hdr file.
  57102. */
  57103. private loadTexture;
  57104. clone(): HDRCubeTexture;
  57105. delayLoad(): void;
  57106. /**
  57107. * Get the texture reflection matrix used to rotate/transform the reflection.
  57108. * @returns the reflection matrix
  57109. */
  57110. getReflectionTextureMatrix(): Matrix;
  57111. /**
  57112. * Set the texture reflection matrix used to rotate/transform the reflection.
  57113. * @param value Define the reflection matrix to set
  57114. */
  57115. setReflectionTextureMatrix(value: Matrix): void;
  57116. /**
  57117. * Parses a JSON representation of an HDR Texture in order to create the texture
  57118. * @param parsedTexture Define the JSON representation
  57119. * @param scene Define the scene the texture should be created in
  57120. * @param rootUrl Define the root url in case we need to load relative dependencies
  57121. * @returns the newly created texture after parsing
  57122. */
  57123. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  57124. serialize(): any;
  57125. }
  57126. }
  57127. declare module "babylonjs/Physics/physicsEngine" {
  57128. import { Nullable } from "babylonjs/types";
  57129. import { Vector3 } from "babylonjs/Maths/math.vector";
  57130. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  57131. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  57132. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  57133. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57134. /**
  57135. * Class used to control physics engine
  57136. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  57137. */
  57138. export class PhysicsEngine implements IPhysicsEngine {
  57139. private _physicsPlugin;
  57140. /**
  57141. * Global value used to control the smallest number supported by the simulation
  57142. */
  57143. static Epsilon: number;
  57144. private _impostors;
  57145. private _joints;
  57146. private _subTimeStep;
  57147. /**
  57148. * Gets the gravity vector used by the simulation
  57149. */
  57150. gravity: Vector3;
  57151. /**
  57152. * Factory used to create the default physics plugin.
  57153. * @returns The default physics plugin
  57154. */
  57155. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  57156. /**
  57157. * Creates a new Physics Engine
  57158. * @param gravity defines the gravity vector used by the simulation
  57159. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  57160. */
  57161. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  57162. /**
  57163. * Sets the gravity vector used by the simulation
  57164. * @param gravity defines the gravity vector to use
  57165. */
  57166. setGravity(gravity: Vector3): void;
  57167. /**
  57168. * Set the time step of the physics engine.
  57169. * Default is 1/60.
  57170. * To slow it down, enter 1/600 for example.
  57171. * To speed it up, 1/30
  57172. * @param newTimeStep defines the new timestep to apply to this world.
  57173. */
  57174. setTimeStep(newTimeStep?: number): void;
  57175. /**
  57176. * Get the time step of the physics engine.
  57177. * @returns the current time step
  57178. */
  57179. getTimeStep(): number;
  57180. /**
  57181. * Set the sub time step of the physics engine.
  57182. * Default is 0 meaning there is no sub steps
  57183. * To increase physics resolution precision, set a small value (like 1 ms)
  57184. * @param subTimeStep defines the new sub timestep used for physics resolution.
  57185. */
  57186. setSubTimeStep(subTimeStep?: number): void;
  57187. /**
  57188. * Get the sub time step of the physics engine.
  57189. * @returns the current sub time step
  57190. */
  57191. getSubTimeStep(): number;
  57192. /**
  57193. * Release all resources
  57194. */
  57195. dispose(): void;
  57196. /**
  57197. * Gets the name of the current physics plugin
  57198. * @returns the name of the plugin
  57199. */
  57200. getPhysicsPluginName(): string;
  57201. /**
  57202. * Adding a new impostor for the impostor tracking.
  57203. * This will be done by the impostor itself.
  57204. * @param impostor the impostor to add
  57205. */
  57206. addImpostor(impostor: PhysicsImpostor): void;
  57207. /**
  57208. * Remove an impostor from the engine.
  57209. * This impostor and its mesh will not longer be updated by the physics engine.
  57210. * @param impostor the impostor to remove
  57211. */
  57212. removeImpostor(impostor: PhysicsImpostor): void;
  57213. /**
  57214. * Add a joint to the physics engine
  57215. * @param mainImpostor defines the main impostor to which the joint is added.
  57216. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  57217. * @param joint defines the joint that will connect both impostors.
  57218. */
  57219. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  57220. /**
  57221. * Removes a joint from the simulation
  57222. * @param mainImpostor defines the impostor used with the joint
  57223. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  57224. * @param joint defines the joint to remove
  57225. */
  57226. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  57227. /**
  57228. * Called by the scene. No need to call it.
  57229. * @param delta defines the timespam between frames
  57230. */
  57231. _step(delta: number): void;
  57232. /**
  57233. * Gets the current plugin used to run the simulation
  57234. * @returns current plugin
  57235. */
  57236. getPhysicsPlugin(): IPhysicsEnginePlugin;
  57237. /**
  57238. * Gets the list of physic impostors
  57239. * @returns an array of PhysicsImpostor
  57240. */
  57241. getImpostors(): Array<PhysicsImpostor>;
  57242. /**
  57243. * Gets the impostor for a physics enabled object
  57244. * @param object defines the object impersonated by the impostor
  57245. * @returns the PhysicsImpostor or null if not found
  57246. */
  57247. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  57248. /**
  57249. * Gets the impostor for a physics body object
  57250. * @param body defines physics body used by the impostor
  57251. * @returns the PhysicsImpostor or null if not found
  57252. */
  57253. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  57254. /**
  57255. * Does a raycast in the physics world
  57256. * @param from when should the ray start?
  57257. * @param to when should the ray end?
  57258. * @returns PhysicsRaycastResult
  57259. */
  57260. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57261. }
  57262. }
  57263. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  57264. import { Nullable } from "babylonjs/types";
  57265. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  57266. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57267. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57268. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57269. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57270. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57271. /** @hidden */
  57272. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  57273. private _useDeltaForWorldStep;
  57274. world: any;
  57275. name: string;
  57276. private _physicsMaterials;
  57277. private _fixedTimeStep;
  57278. private _cannonRaycastResult;
  57279. private _raycastResult;
  57280. private _physicsBodysToRemoveAfterStep;
  57281. BJSCANNON: any;
  57282. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  57283. setGravity(gravity: Vector3): void;
  57284. setTimeStep(timeStep: number): void;
  57285. getTimeStep(): number;
  57286. executeStep(delta: number): void;
  57287. private _removeMarkedPhysicsBodiesFromWorld;
  57288. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57289. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57290. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57291. private _processChildMeshes;
  57292. removePhysicsBody(impostor: PhysicsImpostor): void;
  57293. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57294. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57295. private _addMaterial;
  57296. private _checkWithEpsilon;
  57297. private _createShape;
  57298. private _createHeightmap;
  57299. private _minus90X;
  57300. private _plus90X;
  57301. private _tmpPosition;
  57302. private _tmpDeltaPosition;
  57303. private _tmpUnityRotation;
  57304. private _updatePhysicsBodyTransformation;
  57305. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57306. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57307. isSupported(): boolean;
  57308. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57309. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57310. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57311. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57312. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57313. getBodyMass(impostor: PhysicsImpostor): number;
  57314. getBodyFriction(impostor: PhysicsImpostor): number;
  57315. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57316. getBodyRestitution(impostor: PhysicsImpostor): number;
  57317. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57318. sleepBody(impostor: PhysicsImpostor): void;
  57319. wakeUpBody(impostor: PhysicsImpostor): void;
  57320. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  57321. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  57322. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  57323. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57324. getRadius(impostor: PhysicsImpostor): number;
  57325. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57326. dispose(): void;
  57327. private _extendNamespace;
  57328. /**
  57329. * Does a raycast in the physics world
  57330. * @param from when should the ray start?
  57331. * @param to when should the ray end?
  57332. * @returns PhysicsRaycastResult
  57333. */
  57334. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57335. }
  57336. }
  57337. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  57338. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57339. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57340. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57341. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57342. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  57343. import { Nullable } from "babylonjs/types";
  57344. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57345. /** @hidden */
  57346. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  57347. world: any;
  57348. name: string;
  57349. BJSOIMO: any;
  57350. private _raycastResult;
  57351. constructor(iterations?: number, oimoInjection?: any);
  57352. setGravity(gravity: Vector3): void;
  57353. setTimeStep(timeStep: number): void;
  57354. getTimeStep(): number;
  57355. private _tmpImpostorsArray;
  57356. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  57357. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57358. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57359. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57360. private _tmpPositionVector;
  57361. removePhysicsBody(impostor: PhysicsImpostor): void;
  57362. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57363. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57364. isSupported(): boolean;
  57365. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57366. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57367. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57368. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57369. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57370. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57371. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57372. getBodyMass(impostor: PhysicsImpostor): number;
  57373. getBodyFriction(impostor: PhysicsImpostor): number;
  57374. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57375. getBodyRestitution(impostor: PhysicsImpostor): number;
  57376. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57377. sleepBody(impostor: PhysicsImpostor): void;
  57378. wakeUpBody(impostor: PhysicsImpostor): void;
  57379. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  57380. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  57381. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  57382. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57383. getRadius(impostor: PhysicsImpostor): number;
  57384. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57385. dispose(): void;
  57386. /**
  57387. * Does a raycast in the physics world
  57388. * @param from when should the ray start?
  57389. * @param to when should the ray end?
  57390. * @returns PhysicsRaycastResult
  57391. */
  57392. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57393. }
  57394. }
  57395. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  57396. import { Nullable } from "babylonjs/types";
  57397. import { Scene } from "babylonjs/scene";
  57398. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  57399. import { Color4 } from "babylonjs/Maths/math.color";
  57400. import { Mesh } from "babylonjs/Meshes/mesh";
  57401. /**
  57402. * Class containing static functions to help procedurally build meshes
  57403. */
  57404. export class RibbonBuilder {
  57405. /**
  57406. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57407. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  57408. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  57409. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  57410. * * 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
  57411. * * 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
  57412. * * 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
  57413. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57414. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57415. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57416. * * 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
  57417. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  57418. * * 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
  57419. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  57420. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57421. * @param name defines the name of the mesh
  57422. * @param options defines the options used to create the mesh
  57423. * @param scene defines the hosting scene
  57424. * @returns the ribbon mesh
  57425. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  57426. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57427. */
  57428. static CreateRibbon(name: string, options: {
  57429. pathArray: Vector3[][];
  57430. closeArray?: boolean;
  57431. closePath?: boolean;
  57432. offset?: number;
  57433. updatable?: boolean;
  57434. sideOrientation?: number;
  57435. frontUVs?: Vector4;
  57436. backUVs?: Vector4;
  57437. instance?: Mesh;
  57438. invertUV?: boolean;
  57439. uvs?: Vector2[];
  57440. colors?: Color4[];
  57441. }, scene?: Nullable<Scene>): Mesh;
  57442. }
  57443. }
  57444. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  57445. import { Nullable } from "babylonjs/types";
  57446. import { Scene } from "babylonjs/scene";
  57447. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  57448. import { Mesh } from "babylonjs/Meshes/mesh";
  57449. /**
  57450. * Class containing static functions to help procedurally build meshes
  57451. */
  57452. export class ShapeBuilder {
  57453. /**
  57454. * 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.
  57455. * * 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.
  57456. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57457. * * 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.
  57458. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  57459. * * 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
  57460. * * 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
  57461. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  57462. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57463. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57464. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  57465. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57466. * @param name defines the name of the mesh
  57467. * @param options defines the options used to create the mesh
  57468. * @param scene defines the hosting scene
  57469. * @returns the extruded shape mesh
  57470. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57471. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57472. */
  57473. static ExtrudeShape(name: string, options: {
  57474. shape: Vector3[];
  57475. path: Vector3[];
  57476. scale?: number;
  57477. rotation?: number;
  57478. cap?: number;
  57479. updatable?: boolean;
  57480. sideOrientation?: number;
  57481. frontUVs?: Vector4;
  57482. backUVs?: Vector4;
  57483. instance?: Mesh;
  57484. invertUV?: boolean;
  57485. }, scene?: Nullable<Scene>): Mesh;
  57486. /**
  57487. * Creates an custom extruded shape mesh.
  57488. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  57489. * * 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.
  57490. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57491. * * 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
  57492. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  57493. * * 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
  57494. * * It must returns a float value that will be the scale value applied to the shape on each path point
  57495. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  57496. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  57497. * * 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
  57498. * * 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
  57499. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  57500. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57501. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57502. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57503. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57504. * @param name defines the name of the mesh
  57505. * @param options defines the options used to create the mesh
  57506. * @param scene defines the hosting scene
  57507. * @returns the custom extruded shape mesh
  57508. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  57509. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57510. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57511. */
  57512. static ExtrudeShapeCustom(name: string, options: {
  57513. shape: Vector3[];
  57514. path: Vector3[];
  57515. scaleFunction?: any;
  57516. rotationFunction?: any;
  57517. ribbonCloseArray?: boolean;
  57518. ribbonClosePath?: boolean;
  57519. cap?: number;
  57520. updatable?: boolean;
  57521. sideOrientation?: number;
  57522. frontUVs?: Vector4;
  57523. backUVs?: Vector4;
  57524. instance?: Mesh;
  57525. invertUV?: boolean;
  57526. }, scene?: Nullable<Scene>): Mesh;
  57527. private static _ExtrudeShapeGeneric;
  57528. }
  57529. }
  57530. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  57531. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  57532. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57533. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57534. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57535. import { Nullable } from "babylonjs/types";
  57536. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57537. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57538. /**
  57539. * AmmoJS Physics plugin
  57540. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  57541. * @see https://github.com/kripken/ammo.js/
  57542. */
  57543. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  57544. private _useDeltaForWorldStep;
  57545. /**
  57546. * Reference to the Ammo library
  57547. */
  57548. bjsAMMO: any;
  57549. /**
  57550. * Created ammoJS world which physics bodies are added to
  57551. */
  57552. world: any;
  57553. /**
  57554. * Name of the plugin
  57555. */
  57556. name: string;
  57557. private _timeStep;
  57558. private _fixedTimeStep;
  57559. private _maxSteps;
  57560. private _tmpQuaternion;
  57561. private _tmpAmmoTransform;
  57562. private _tmpAmmoQuaternion;
  57563. private _tmpAmmoConcreteContactResultCallback;
  57564. private _collisionConfiguration;
  57565. private _dispatcher;
  57566. private _overlappingPairCache;
  57567. private _solver;
  57568. private _softBodySolver;
  57569. private _tmpAmmoVectorA;
  57570. private _tmpAmmoVectorB;
  57571. private _tmpAmmoVectorC;
  57572. private _tmpAmmoVectorD;
  57573. private _tmpContactCallbackResult;
  57574. private _tmpAmmoVectorRCA;
  57575. private _tmpAmmoVectorRCB;
  57576. private _raycastResult;
  57577. private static readonly DISABLE_COLLISION_FLAG;
  57578. private static readonly KINEMATIC_FLAG;
  57579. private static readonly DISABLE_DEACTIVATION_FLAG;
  57580. /**
  57581. * Initializes the ammoJS plugin
  57582. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  57583. * @param ammoInjection can be used to inject your own ammo reference
  57584. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  57585. */
  57586. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  57587. /**
  57588. * Sets the gravity of the physics world (m/(s^2))
  57589. * @param gravity Gravity to set
  57590. */
  57591. setGravity(gravity: Vector3): void;
  57592. /**
  57593. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  57594. * @param timeStep timestep to use in seconds
  57595. */
  57596. setTimeStep(timeStep: number): void;
  57597. /**
  57598. * 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)
  57599. * @param fixedTimeStep fixedTimeStep to use in seconds
  57600. */
  57601. setFixedTimeStep(fixedTimeStep: number): void;
  57602. /**
  57603. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  57604. * @param maxSteps the maximum number of steps by the physics engine per frame
  57605. */
  57606. setMaxSteps(maxSteps: number): void;
  57607. /**
  57608. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  57609. * @returns the current timestep in seconds
  57610. */
  57611. getTimeStep(): number;
  57612. /**
  57613. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  57614. */
  57615. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  57616. private _isImpostorInContact;
  57617. private _isImpostorPairInContact;
  57618. private _stepSimulation;
  57619. /**
  57620. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  57621. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  57622. * After the step the babylon meshes are set to the position of the physics imposters
  57623. * @param delta amount of time to step forward
  57624. * @param impostors array of imposters to update before/after the step
  57625. */
  57626. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  57627. /**
  57628. * Update babylon mesh to match physics world object
  57629. * @param impostor imposter to match
  57630. */
  57631. private _afterSoftStep;
  57632. /**
  57633. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  57634. * @param impostor imposter to match
  57635. */
  57636. private _ropeStep;
  57637. /**
  57638. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  57639. * @param impostor imposter to match
  57640. */
  57641. private _softbodyOrClothStep;
  57642. private _tmpVector;
  57643. private _tmpMatrix;
  57644. /**
  57645. * Applies an impulse on the imposter
  57646. * @param impostor imposter to apply impulse to
  57647. * @param force amount of force to be applied to the imposter
  57648. * @param contactPoint the location to apply the impulse on the imposter
  57649. */
  57650. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57651. /**
  57652. * Applies a force on the imposter
  57653. * @param impostor imposter to apply force
  57654. * @param force amount of force to be applied to the imposter
  57655. * @param contactPoint the location to apply the force on the imposter
  57656. */
  57657. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57658. /**
  57659. * Creates a physics body using the plugin
  57660. * @param impostor the imposter to create the physics body on
  57661. */
  57662. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57663. /**
  57664. * Removes the physics body from the imposter and disposes of the body's memory
  57665. * @param impostor imposter to remove the physics body from
  57666. */
  57667. removePhysicsBody(impostor: PhysicsImpostor): void;
  57668. /**
  57669. * Generates a joint
  57670. * @param impostorJoint the imposter joint to create the joint with
  57671. */
  57672. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57673. /**
  57674. * Removes a joint
  57675. * @param impostorJoint the imposter joint to remove the joint from
  57676. */
  57677. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57678. private _addMeshVerts;
  57679. /**
  57680. * Initialise the soft body vertices to match its object's (mesh) vertices
  57681. * Softbody vertices (nodes) are in world space and to match this
  57682. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  57683. * @param impostor to create the softbody for
  57684. */
  57685. private _softVertexData;
  57686. /**
  57687. * Create an impostor's soft body
  57688. * @param impostor to create the softbody for
  57689. */
  57690. private _createSoftbody;
  57691. /**
  57692. * Create cloth for an impostor
  57693. * @param impostor to create the softbody for
  57694. */
  57695. private _createCloth;
  57696. /**
  57697. * Create rope for an impostor
  57698. * @param impostor to create the softbody for
  57699. */
  57700. private _createRope;
  57701. /**
  57702. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  57703. * @param impostor to create the custom physics shape for
  57704. */
  57705. private _createCustom;
  57706. private _addHullVerts;
  57707. private _createShape;
  57708. /**
  57709. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  57710. * @param impostor imposter containing the physics body and babylon object
  57711. */
  57712. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57713. /**
  57714. * Sets the babylon object's position/rotation from the physics body's position/rotation
  57715. * @param impostor imposter containing the physics body and babylon object
  57716. * @param newPosition new position
  57717. * @param newRotation new rotation
  57718. */
  57719. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57720. /**
  57721. * If this plugin is supported
  57722. * @returns true if its supported
  57723. */
  57724. isSupported(): boolean;
  57725. /**
  57726. * Sets the linear velocity of the physics body
  57727. * @param impostor imposter to set the velocity on
  57728. * @param velocity velocity to set
  57729. */
  57730. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57731. /**
  57732. * Sets the angular velocity of the physics body
  57733. * @param impostor imposter to set the velocity on
  57734. * @param velocity velocity to set
  57735. */
  57736. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57737. /**
  57738. * gets the linear velocity
  57739. * @param impostor imposter to get linear velocity from
  57740. * @returns linear velocity
  57741. */
  57742. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57743. /**
  57744. * gets the angular velocity
  57745. * @param impostor imposter to get angular velocity from
  57746. * @returns angular velocity
  57747. */
  57748. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57749. /**
  57750. * Sets the mass of physics body
  57751. * @param impostor imposter to set the mass on
  57752. * @param mass mass to set
  57753. */
  57754. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57755. /**
  57756. * Gets the mass of the physics body
  57757. * @param impostor imposter to get the mass from
  57758. * @returns mass
  57759. */
  57760. getBodyMass(impostor: PhysicsImpostor): number;
  57761. /**
  57762. * Gets friction of the impostor
  57763. * @param impostor impostor to get friction from
  57764. * @returns friction value
  57765. */
  57766. getBodyFriction(impostor: PhysicsImpostor): number;
  57767. /**
  57768. * Sets friction of the impostor
  57769. * @param impostor impostor to set friction on
  57770. * @param friction friction value
  57771. */
  57772. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57773. /**
  57774. * Gets restitution of the impostor
  57775. * @param impostor impostor to get restitution from
  57776. * @returns restitution value
  57777. */
  57778. getBodyRestitution(impostor: PhysicsImpostor): number;
  57779. /**
  57780. * Sets resitution of the impostor
  57781. * @param impostor impostor to set resitution on
  57782. * @param restitution resitution value
  57783. */
  57784. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57785. /**
  57786. * Gets pressure inside the impostor
  57787. * @param impostor impostor to get pressure from
  57788. * @returns pressure value
  57789. */
  57790. getBodyPressure(impostor: PhysicsImpostor): number;
  57791. /**
  57792. * Sets pressure inside a soft body impostor
  57793. * Cloth and rope must remain 0 pressure
  57794. * @param impostor impostor to set pressure on
  57795. * @param pressure pressure value
  57796. */
  57797. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  57798. /**
  57799. * Gets stiffness of the impostor
  57800. * @param impostor impostor to get stiffness from
  57801. * @returns pressure value
  57802. */
  57803. getBodyStiffness(impostor: PhysicsImpostor): number;
  57804. /**
  57805. * Sets stiffness of the impostor
  57806. * @param impostor impostor to set stiffness on
  57807. * @param stiffness stiffness value from 0 to 1
  57808. */
  57809. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  57810. /**
  57811. * Gets velocityIterations of the impostor
  57812. * @param impostor impostor to get velocity iterations from
  57813. * @returns velocityIterations value
  57814. */
  57815. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  57816. /**
  57817. * Sets velocityIterations of the impostor
  57818. * @param impostor impostor to set velocity iterations on
  57819. * @param velocityIterations velocityIterations value
  57820. */
  57821. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  57822. /**
  57823. * Gets positionIterations of the impostor
  57824. * @param impostor impostor to get position iterations from
  57825. * @returns positionIterations value
  57826. */
  57827. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  57828. /**
  57829. * Sets positionIterations of the impostor
  57830. * @param impostor impostor to set position on
  57831. * @param positionIterations positionIterations value
  57832. */
  57833. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  57834. /**
  57835. * Append an anchor to a cloth object
  57836. * @param impostor is the cloth impostor to add anchor to
  57837. * @param otherImpostor is the rigid impostor to anchor to
  57838. * @param width ratio across width from 0 to 1
  57839. * @param height ratio up height from 0 to 1
  57840. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  57841. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  57842. */
  57843. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  57844. /**
  57845. * Append an hook to a rope object
  57846. * @param impostor is the rope impostor to add hook to
  57847. * @param otherImpostor is the rigid impostor to hook to
  57848. * @param length ratio along the rope from 0 to 1
  57849. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  57850. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  57851. */
  57852. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  57853. /**
  57854. * Sleeps the physics body and stops it from being active
  57855. * @param impostor impostor to sleep
  57856. */
  57857. sleepBody(impostor: PhysicsImpostor): void;
  57858. /**
  57859. * Activates the physics body
  57860. * @param impostor impostor to activate
  57861. */
  57862. wakeUpBody(impostor: PhysicsImpostor): void;
  57863. /**
  57864. * Updates the distance parameters of the joint
  57865. * @param joint joint to update
  57866. * @param maxDistance maximum distance of the joint
  57867. * @param minDistance minimum distance of the joint
  57868. */
  57869. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  57870. /**
  57871. * Sets a motor on the joint
  57872. * @param joint joint to set motor on
  57873. * @param speed speed of the motor
  57874. * @param maxForce maximum force of the motor
  57875. * @param motorIndex index of the motor
  57876. */
  57877. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  57878. /**
  57879. * Sets the motors limit
  57880. * @param joint joint to set limit on
  57881. * @param upperLimit upper limit
  57882. * @param lowerLimit lower limit
  57883. */
  57884. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  57885. /**
  57886. * Syncs the position and rotation of a mesh with the impostor
  57887. * @param mesh mesh to sync
  57888. * @param impostor impostor to update the mesh with
  57889. */
  57890. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57891. /**
  57892. * Gets the radius of the impostor
  57893. * @param impostor impostor to get radius from
  57894. * @returns the radius
  57895. */
  57896. getRadius(impostor: PhysicsImpostor): number;
  57897. /**
  57898. * Gets the box size of the impostor
  57899. * @param impostor impostor to get box size from
  57900. * @param result the resulting box size
  57901. */
  57902. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57903. /**
  57904. * Disposes of the impostor
  57905. */
  57906. dispose(): void;
  57907. /**
  57908. * Does a raycast in the physics world
  57909. * @param from when should the ray start?
  57910. * @param to when should the ray end?
  57911. * @returns PhysicsRaycastResult
  57912. */
  57913. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57914. }
  57915. }
  57916. declare module "babylonjs/Probes/reflectionProbe" {
  57917. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57918. import { Vector3 } from "babylonjs/Maths/math.vector";
  57919. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57920. import { Nullable } from "babylonjs/types";
  57921. import { Scene } from "babylonjs/scene";
  57922. module "babylonjs/abstractScene" {
  57923. interface AbstractScene {
  57924. /**
  57925. * The list of reflection probes added to the scene
  57926. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  57927. */
  57928. reflectionProbes: Array<ReflectionProbe>;
  57929. /**
  57930. * Removes the given reflection probe from this scene.
  57931. * @param toRemove The reflection probe to remove
  57932. * @returns The index of the removed reflection probe
  57933. */
  57934. removeReflectionProbe(toRemove: ReflectionProbe): number;
  57935. /**
  57936. * Adds the given reflection probe to this scene.
  57937. * @param newReflectionProbe The reflection probe to add
  57938. */
  57939. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  57940. }
  57941. }
  57942. /**
  57943. * Class used to generate realtime reflection / refraction cube textures
  57944. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  57945. */
  57946. export class ReflectionProbe {
  57947. /** defines the name of the probe */
  57948. name: string;
  57949. private _scene;
  57950. private _renderTargetTexture;
  57951. private _projectionMatrix;
  57952. private _viewMatrix;
  57953. private _target;
  57954. private _add;
  57955. private _attachedMesh;
  57956. private _invertYAxis;
  57957. /** Gets or sets probe position (center of the cube map) */
  57958. position: Vector3;
  57959. /**
  57960. * Creates a new reflection probe
  57961. * @param name defines the name of the probe
  57962. * @param size defines the texture resolution (for each face)
  57963. * @param scene defines the hosting scene
  57964. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  57965. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  57966. */
  57967. constructor(
  57968. /** defines the name of the probe */
  57969. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  57970. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  57971. get samples(): number;
  57972. set samples(value: number);
  57973. /** Gets or sets the refresh rate to use (on every frame by default) */
  57974. get refreshRate(): number;
  57975. set refreshRate(value: number);
  57976. /**
  57977. * Gets the hosting scene
  57978. * @returns a Scene
  57979. */
  57980. getScene(): Scene;
  57981. /** Gets the internal CubeTexture used to render to */
  57982. get cubeTexture(): RenderTargetTexture;
  57983. /** Gets the list of meshes to render */
  57984. get renderList(): Nullable<AbstractMesh[]>;
  57985. /**
  57986. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  57987. * @param mesh defines the mesh to attach to
  57988. */
  57989. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  57990. /**
  57991. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  57992. * @param renderingGroupId The rendering group id corresponding to its index
  57993. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  57994. */
  57995. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  57996. /**
  57997. * Clean all associated resources
  57998. */
  57999. dispose(): void;
  58000. /**
  58001. * Converts the reflection probe information to a readable string for debug purpose.
  58002. * @param fullDetails Supports for multiple levels of logging within scene loading
  58003. * @returns the human readable reflection probe info
  58004. */
  58005. toString(fullDetails?: boolean): string;
  58006. /**
  58007. * Get the class name of the relfection probe.
  58008. * @returns "ReflectionProbe"
  58009. */
  58010. getClassName(): string;
  58011. /**
  58012. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  58013. * @returns The JSON representation of the texture
  58014. */
  58015. serialize(): any;
  58016. /**
  58017. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  58018. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  58019. * @param scene Define the scene the parsed reflection probe should be instantiated in
  58020. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  58021. * @returns The parsed reflection probe if successful
  58022. */
  58023. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  58024. }
  58025. }
  58026. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  58027. /** @hidden */
  58028. export var _BabylonLoaderRegistered: boolean;
  58029. /**
  58030. * Helps setting up some configuration for the babylon file loader.
  58031. */
  58032. export class BabylonFileLoaderConfiguration {
  58033. /**
  58034. * The loader does not allow injecting custom physix engine into the plugins.
  58035. * Unfortunately in ES6, we need to manually inject them into the plugin.
  58036. * So you could set this variable to your engine import to make it work.
  58037. */
  58038. static LoaderInjectedPhysicsEngine: any;
  58039. }
  58040. }
  58041. declare module "babylonjs/Loading/Plugins/index" {
  58042. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  58043. }
  58044. declare module "babylonjs/Loading/index" {
  58045. export * from "babylonjs/Loading/loadingScreen";
  58046. export * from "babylonjs/Loading/Plugins/index";
  58047. export * from "babylonjs/Loading/sceneLoader";
  58048. export * from "babylonjs/Loading/sceneLoaderFlags";
  58049. }
  58050. declare module "babylonjs/Materials/Background/index" {
  58051. export * from "babylonjs/Materials/Background/backgroundMaterial";
  58052. }
  58053. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  58054. import { Scene } from "babylonjs/scene";
  58055. import { Color3 } from "babylonjs/Maths/math.color";
  58056. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58057. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58058. /**
  58059. * The Physically based simple base material of BJS.
  58060. *
  58061. * This enables better naming and convention enforcements on top of the pbrMaterial.
  58062. * It is used as the base class for both the specGloss and metalRough conventions.
  58063. */
  58064. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  58065. /**
  58066. * Number of Simultaneous lights allowed on the material.
  58067. */
  58068. maxSimultaneousLights: number;
  58069. /**
  58070. * If sets to true, disables all the lights affecting the material.
  58071. */
  58072. disableLighting: boolean;
  58073. /**
  58074. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  58075. */
  58076. environmentTexture: BaseTexture;
  58077. /**
  58078. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  58079. */
  58080. invertNormalMapX: boolean;
  58081. /**
  58082. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  58083. */
  58084. invertNormalMapY: boolean;
  58085. /**
  58086. * Normal map used in the model.
  58087. */
  58088. normalTexture: BaseTexture;
  58089. /**
  58090. * Emissivie color used to self-illuminate the model.
  58091. */
  58092. emissiveColor: Color3;
  58093. /**
  58094. * Emissivie texture used to self-illuminate the model.
  58095. */
  58096. emissiveTexture: BaseTexture;
  58097. /**
  58098. * Occlusion Channel Strenght.
  58099. */
  58100. occlusionStrength: number;
  58101. /**
  58102. * Occlusion Texture of the material (adding extra occlusion effects).
  58103. */
  58104. occlusionTexture: BaseTexture;
  58105. /**
  58106. * Defines the alpha limits in alpha test mode.
  58107. */
  58108. alphaCutOff: number;
  58109. /**
  58110. * Gets the current double sided mode.
  58111. */
  58112. get doubleSided(): boolean;
  58113. /**
  58114. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  58115. */
  58116. set doubleSided(value: boolean);
  58117. /**
  58118. * Stores the pre-calculated light information of a mesh in a texture.
  58119. */
  58120. lightmapTexture: BaseTexture;
  58121. /**
  58122. * If true, the light map contains occlusion information instead of lighting info.
  58123. */
  58124. useLightmapAsShadowmap: boolean;
  58125. /**
  58126. * Instantiates a new PBRMaterial instance.
  58127. *
  58128. * @param name The material name
  58129. * @param scene The scene the material will be use in.
  58130. */
  58131. constructor(name: string, scene: Scene);
  58132. getClassName(): string;
  58133. }
  58134. }
  58135. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  58136. import { Scene } from "babylonjs/scene";
  58137. import { Color3 } from "babylonjs/Maths/math.color";
  58138. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58139. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58140. /**
  58141. * The PBR material of BJS following the metal roughness convention.
  58142. *
  58143. * This fits to the PBR convention in the GLTF definition:
  58144. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  58145. */
  58146. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  58147. /**
  58148. * The base color has two different interpretations depending on the value of metalness.
  58149. * When the material is a metal, the base color is the specific measured reflectance value
  58150. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  58151. * of the material.
  58152. */
  58153. baseColor: Color3;
  58154. /**
  58155. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  58156. * well as opacity information in the alpha channel.
  58157. */
  58158. baseTexture: BaseTexture;
  58159. /**
  58160. * Specifies the metallic scalar value of the material.
  58161. * Can also be used to scale the metalness values of the metallic texture.
  58162. */
  58163. metallic: number;
  58164. /**
  58165. * Specifies the roughness scalar value of the material.
  58166. * Can also be used to scale the roughness values of the metallic texture.
  58167. */
  58168. roughness: number;
  58169. /**
  58170. * Texture containing both the metallic value in the B channel and the
  58171. * roughness value in the G channel to keep better precision.
  58172. */
  58173. metallicRoughnessTexture: BaseTexture;
  58174. /**
  58175. * Instantiates a new PBRMetalRoughnessMaterial instance.
  58176. *
  58177. * @param name The material name
  58178. * @param scene The scene the material will be use in.
  58179. */
  58180. constructor(name: string, scene: Scene);
  58181. /**
  58182. * Return the currrent class name of the material.
  58183. */
  58184. getClassName(): string;
  58185. /**
  58186. * Makes a duplicate of the current material.
  58187. * @param name - name to use for the new material.
  58188. */
  58189. clone(name: string): PBRMetallicRoughnessMaterial;
  58190. /**
  58191. * Serialize the material to a parsable JSON object.
  58192. */
  58193. serialize(): any;
  58194. /**
  58195. * Parses a JSON object correponding to the serialize function.
  58196. */
  58197. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  58198. }
  58199. }
  58200. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  58201. import { Scene } from "babylonjs/scene";
  58202. import { Color3 } from "babylonjs/Maths/math.color";
  58203. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58204. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58205. /**
  58206. * The PBR material of BJS following the specular glossiness convention.
  58207. *
  58208. * This fits to the PBR convention in the GLTF definition:
  58209. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  58210. */
  58211. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  58212. /**
  58213. * Specifies the diffuse color of the material.
  58214. */
  58215. diffuseColor: Color3;
  58216. /**
  58217. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  58218. * channel.
  58219. */
  58220. diffuseTexture: BaseTexture;
  58221. /**
  58222. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  58223. */
  58224. specularColor: Color3;
  58225. /**
  58226. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  58227. */
  58228. glossiness: number;
  58229. /**
  58230. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  58231. */
  58232. specularGlossinessTexture: BaseTexture;
  58233. /**
  58234. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  58235. *
  58236. * @param name The material name
  58237. * @param scene The scene the material will be use in.
  58238. */
  58239. constructor(name: string, scene: Scene);
  58240. /**
  58241. * Return the currrent class name of the material.
  58242. */
  58243. getClassName(): string;
  58244. /**
  58245. * Makes a duplicate of the current material.
  58246. * @param name - name to use for the new material.
  58247. */
  58248. clone(name: string): PBRSpecularGlossinessMaterial;
  58249. /**
  58250. * Serialize the material to a parsable JSON object.
  58251. */
  58252. serialize(): any;
  58253. /**
  58254. * Parses a JSON object correponding to the serialize function.
  58255. */
  58256. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  58257. }
  58258. }
  58259. declare module "babylonjs/Materials/PBR/index" {
  58260. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58261. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58262. export * from "babylonjs/Materials/PBR/pbrMaterial";
  58263. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  58264. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  58265. }
  58266. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  58267. import { Nullable } from "babylonjs/types";
  58268. import { Scene } from "babylonjs/scene";
  58269. import { Matrix } from "babylonjs/Maths/math.vector";
  58270. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58271. /**
  58272. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  58273. * It can help converting any input color in a desired output one. This can then be used to create effects
  58274. * from sepia, black and white to sixties or futuristic rendering...
  58275. *
  58276. * The only supported format is currently 3dl.
  58277. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  58278. */
  58279. export class ColorGradingTexture extends BaseTexture {
  58280. /**
  58281. * The current texture matrix. (will always be identity in color grading texture)
  58282. */
  58283. private _textureMatrix;
  58284. /**
  58285. * The texture URL.
  58286. */
  58287. url: string;
  58288. /**
  58289. * Empty line regex stored for GC.
  58290. */
  58291. private static _noneEmptyLineRegex;
  58292. private _engine;
  58293. /**
  58294. * Instantiates a ColorGradingTexture from the following parameters.
  58295. *
  58296. * @param url The location of the color gradind data (currently only supporting 3dl)
  58297. * @param scene The scene the texture will be used in
  58298. */
  58299. constructor(url: string, scene: Scene);
  58300. /**
  58301. * Returns the texture matrix used in most of the material.
  58302. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  58303. */
  58304. getTextureMatrix(): Matrix;
  58305. /**
  58306. * Occurs when the file being loaded is a .3dl LUT file.
  58307. */
  58308. private load3dlTexture;
  58309. /**
  58310. * Starts the loading process of the texture.
  58311. */
  58312. private loadTexture;
  58313. /**
  58314. * Clones the color gradind texture.
  58315. */
  58316. clone(): ColorGradingTexture;
  58317. /**
  58318. * Called during delayed load for textures.
  58319. */
  58320. delayLoad(): void;
  58321. /**
  58322. * Parses a color grading texture serialized by Babylon.
  58323. * @param parsedTexture The texture information being parsedTexture
  58324. * @param scene The scene to load the texture in
  58325. * @param rootUrl The root url of the data assets to load
  58326. * @return A color gradind texture
  58327. */
  58328. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  58329. /**
  58330. * Serializes the LUT texture to json format.
  58331. */
  58332. serialize(): any;
  58333. }
  58334. }
  58335. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  58336. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58337. import { Scene } from "babylonjs/scene";
  58338. import { Nullable } from "babylonjs/types";
  58339. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58340. /**
  58341. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  58342. */
  58343. export class EquiRectangularCubeTexture extends BaseTexture {
  58344. /** The six faces of the cube. */
  58345. private static _FacesMapping;
  58346. private _noMipmap;
  58347. private _onLoad;
  58348. private _onError;
  58349. /** The size of the cubemap. */
  58350. private _size;
  58351. /** The buffer of the image. */
  58352. private _buffer;
  58353. /** The width of the input image. */
  58354. private _width;
  58355. /** The height of the input image. */
  58356. private _height;
  58357. /** The URL to the image. */
  58358. url: string;
  58359. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  58360. coordinatesMode: number;
  58361. /**
  58362. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  58363. * @param url The location of the image
  58364. * @param scene The scene the texture will be used in
  58365. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  58366. * @param noMipmap Forces to not generate the mipmap if true
  58367. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  58368. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  58369. * @param onLoad — defines a callback called when texture is loaded
  58370. * @param onError — defines a callback called if there is an error
  58371. */
  58372. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  58373. /**
  58374. * Load the image data, by putting the image on a canvas and extracting its buffer.
  58375. */
  58376. private loadImage;
  58377. /**
  58378. * Convert the image buffer into a cubemap and create a CubeTexture.
  58379. */
  58380. private loadTexture;
  58381. /**
  58382. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  58383. * @param buffer The ArrayBuffer that should be converted.
  58384. * @returns The buffer as Float32Array.
  58385. */
  58386. private getFloat32ArrayFromArrayBuffer;
  58387. /**
  58388. * Get the current class name of the texture useful for serialization or dynamic coding.
  58389. * @returns "EquiRectangularCubeTexture"
  58390. */
  58391. getClassName(): string;
  58392. /**
  58393. * Create a clone of the current EquiRectangularCubeTexture and return it.
  58394. * @returns A clone of the current EquiRectangularCubeTexture.
  58395. */
  58396. clone(): EquiRectangularCubeTexture;
  58397. }
  58398. }
  58399. declare module "babylonjs/Misc/tga" {
  58400. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58401. /**
  58402. * Based on jsTGALoader - Javascript loader for TGA file
  58403. * By Vincent Thibault
  58404. * @see http://blog.robrowser.com/javascript-tga-loader.html
  58405. */
  58406. export class TGATools {
  58407. private static _TYPE_INDEXED;
  58408. private static _TYPE_RGB;
  58409. private static _TYPE_GREY;
  58410. private static _TYPE_RLE_INDEXED;
  58411. private static _TYPE_RLE_RGB;
  58412. private static _TYPE_RLE_GREY;
  58413. private static _ORIGIN_MASK;
  58414. private static _ORIGIN_SHIFT;
  58415. private static _ORIGIN_BL;
  58416. private static _ORIGIN_BR;
  58417. private static _ORIGIN_UL;
  58418. private static _ORIGIN_UR;
  58419. /**
  58420. * Gets the header of a TGA file
  58421. * @param data defines the TGA data
  58422. * @returns the header
  58423. */
  58424. static GetTGAHeader(data: Uint8Array): any;
  58425. /**
  58426. * Uploads TGA content to a Babylon Texture
  58427. * @hidden
  58428. */
  58429. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  58430. /** @hidden */
  58431. 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;
  58432. /** @hidden */
  58433. 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;
  58434. /** @hidden */
  58435. 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;
  58436. /** @hidden */
  58437. 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;
  58438. /** @hidden */
  58439. 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;
  58440. /** @hidden */
  58441. 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;
  58442. }
  58443. }
  58444. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  58445. import { Nullable } from "babylonjs/types";
  58446. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58447. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58448. /**
  58449. * Implementation of the TGA Texture Loader.
  58450. * @hidden
  58451. */
  58452. export class _TGATextureLoader implements IInternalTextureLoader {
  58453. /**
  58454. * Defines wether the loader supports cascade loading the different faces.
  58455. */
  58456. readonly supportCascades: boolean;
  58457. /**
  58458. * This returns if the loader support the current file information.
  58459. * @param extension defines the file extension of the file being loaded
  58460. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58461. * @param fallback defines the fallback internal texture if any
  58462. * @param isBase64 defines whether the texture is encoded as a base64
  58463. * @param isBuffer defines whether the texture data are stored as a buffer
  58464. * @returns true if the loader can load the specified file
  58465. */
  58466. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  58467. /**
  58468. * Transform the url before loading if required.
  58469. * @param rootUrl the url of the texture
  58470. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58471. * @returns the transformed texture
  58472. */
  58473. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  58474. /**
  58475. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  58476. * @param rootUrl the url of the texture
  58477. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58478. * @returns the fallback texture
  58479. */
  58480. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  58481. /**
  58482. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  58483. * @param data contains the texture data
  58484. * @param texture defines the BabylonJS internal texture
  58485. * @param createPolynomials will be true if polynomials have been requested
  58486. * @param onLoad defines the callback to trigger once the texture is ready
  58487. * @param onError defines the callback to trigger in case of error
  58488. */
  58489. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58490. /**
  58491. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  58492. * @param data contains the texture data
  58493. * @param texture defines the BabylonJS internal texture
  58494. * @param callback defines the method to call once ready to upload
  58495. */
  58496. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58497. }
  58498. }
  58499. declare module "babylonjs/Misc/basis" {
  58500. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58501. /**
  58502. * Info about the .basis files
  58503. */
  58504. class BasisFileInfo {
  58505. /**
  58506. * If the file has alpha
  58507. */
  58508. hasAlpha: boolean;
  58509. /**
  58510. * Info about each image of the basis file
  58511. */
  58512. images: Array<{
  58513. levels: Array<{
  58514. width: number;
  58515. height: number;
  58516. transcodedPixels: ArrayBufferView;
  58517. }>;
  58518. }>;
  58519. }
  58520. /**
  58521. * Result of transcoding a basis file
  58522. */
  58523. class TranscodeResult {
  58524. /**
  58525. * Info about the .basis file
  58526. */
  58527. fileInfo: BasisFileInfo;
  58528. /**
  58529. * Format to use when loading the file
  58530. */
  58531. format: number;
  58532. }
  58533. /**
  58534. * Configuration options for the Basis transcoder
  58535. */
  58536. export class BasisTranscodeConfiguration {
  58537. /**
  58538. * Supported compression formats used to determine the supported output format of the transcoder
  58539. */
  58540. supportedCompressionFormats?: {
  58541. /**
  58542. * etc1 compression format
  58543. */
  58544. etc1?: boolean;
  58545. /**
  58546. * s3tc compression format
  58547. */
  58548. s3tc?: boolean;
  58549. /**
  58550. * pvrtc compression format
  58551. */
  58552. pvrtc?: boolean;
  58553. /**
  58554. * etc2 compression format
  58555. */
  58556. etc2?: boolean;
  58557. };
  58558. /**
  58559. * If mipmap levels should be loaded for transcoded images (Default: true)
  58560. */
  58561. loadMipmapLevels?: boolean;
  58562. /**
  58563. * Index of a single image to load (Default: all images)
  58564. */
  58565. loadSingleImage?: number;
  58566. }
  58567. /**
  58568. * Used to load .Basis files
  58569. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  58570. */
  58571. export class BasisTools {
  58572. private static _IgnoreSupportedFormats;
  58573. /**
  58574. * URL to use when loading the basis transcoder
  58575. */
  58576. static JSModuleURL: string;
  58577. /**
  58578. * URL to use when loading the wasm module for the transcoder
  58579. */
  58580. static WasmModuleURL: string;
  58581. /**
  58582. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  58583. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  58584. * @returns internal format corresponding to the Basis format
  58585. */
  58586. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  58587. private static _WorkerPromise;
  58588. private static _Worker;
  58589. private static _actionId;
  58590. private static _CreateWorkerAsync;
  58591. /**
  58592. * Transcodes a loaded image file to compressed pixel data
  58593. * @param data image data to transcode
  58594. * @param config configuration options for the transcoding
  58595. * @returns a promise resulting in the transcoded image
  58596. */
  58597. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  58598. /**
  58599. * Loads a texture from the transcode result
  58600. * @param texture texture load to
  58601. * @param transcodeResult the result of transcoding the basis file to load from
  58602. */
  58603. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  58604. }
  58605. }
  58606. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  58607. import { Nullable } from "babylonjs/types";
  58608. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58609. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58610. /**
  58611. * Loader for .basis file format
  58612. */
  58613. export class _BasisTextureLoader implements IInternalTextureLoader {
  58614. /**
  58615. * Defines whether the loader supports cascade loading the different faces.
  58616. */
  58617. readonly supportCascades: boolean;
  58618. /**
  58619. * This returns if the loader support the current file information.
  58620. * @param extension defines the file extension of the file being loaded
  58621. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58622. * @param fallback defines the fallback internal texture if any
  58623. * @param isBase64 defines whether the texture is encoded as a base64
  58624. * @param isBuffer defines whether the texture data are stored as a buffer
  58625. * @returns true if the loader can load the specified file
  58626. */
  58627. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  58628. /**
  58629. * Transform the url before loading if required.
  58630. * @param rootUrl the url of the texture
  58631. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58632. * @returns the transformed texture
  58633. */
  58634. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  58635. /**
  58636. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  58637. * @param rootUrl the url of the texture
  58638. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58639. * @returns the fallback texture
  58640. */
  58641. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  58642. /**
  58643. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  58644. * @param data contains the texture data
  58645. * @param texture defines the BabylonJS internal texture
  58646. * @param createPolynomials will be true if polynomials have been requested
  58647. * @param onLoad defines the callback to trigger once the texture is ready
  58648. * @param onError defines the callback to trigger in case of error
  58649. */
  58650. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58651. /**
  58652. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  58653. * @param data contains the texture data
  58654. * @param texture defines the BabylonJS internal texture
  58655. * @param callback defines the method to call once ready to upload
  58656. */
  58657. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58658. }
  58659. }
  58660. declare module "babylonjs/Materials/Textures/Loaders/index" {
  58661. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  58662. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  58663. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  58664. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  58665. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  58666. }
  58667. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  58668. import { Scene } from "babylonjs/scene";
  58669. import { Texture } from "babylonjs/Materials/Textures/texture";
  58670. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58671. /**
  58672. * 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.
  58673. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  58674. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  58675. */
  58676. export class CustomProceduralTexture extends ProceduralTexture {
  58677. private _animate;
  58678. private _time;
  58679. private _config;
  58680. private _texturePath;
  58681. /**
  58682. * Instantiates a new Custom Procedural Texture.
  58683. * 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.
  58684. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  58685. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  58686. * @param name Define the name of the texture
  58687. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  58688. * @param size Define the size of the texture to create
  58689. * @param scene Define the scene the texture belongs to
  58690. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  58691. * @param generateMipMaps Define if the texture should creates mip maps or not
  58692. */
  58693. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  58694. private _loadJson;
  58695. /**
  58696. * Is the texture ready to be used ? (rendered at least once)
  58697. * @returns true if ready, otherwise, false.
  58698. */
  58699. isReady(): boolean;
  58700. /**
  58701. * Render the texture to its associated render target.
  58702. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  58703. */
  58704. render(useCameraPostProcess?: boolean): void;
  58705. /**
  58706. * Update the list of dependant textures samplers in the shader.
  58707. */
  58708. updateTextures(): void;
  58709. /**
  58710. * Update the uniform values of the procedural texture in the shader.
  58711. */
  58712. updateShaderUniforms(): void;
  58713. /**
  58714. * Define if the texture animates or not.
  58715. */
  58716. get animate(): boolean;
  58717. set animate(value: boolean);
  58718. }
  58719. }
  58720. declare module "babylonjs/Shaders/noise.fragment" {
  58721. /** @hidden */
  58722. export var noisePixelShader: {
  58723. name: string;
  58724. shader: string;
  58725. };
  58726. }
  58727. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  58728. import { Nullable } from "babylonjs/types";
  58729. import { Scene } from "babylonjs/scene";
  58730. import { Texture } from "babylonjs/Materials/Textures/texture";
  58731. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58732. import "babylonjs/Shaders/noise.fragment";
  58733. /**
  58734. * Class used to generate noise procedural textures
  58735. */
  58736. export class NoiseProceduralTexture extends ProceduralTexture {
  58737. private _time;
  58738. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  58739. brightness: number;
  58740. /** Defines the number of octaves to process */
  58741. octaves: number;
  58742. /** Defines the level of persistence (0.8 by default) */
  58743. persistence: number;
  58744. /** Gets or sets animation speed factor (default is 1) */
  58745. animationSpeedFactor: number;
  58746. /**
  58747. * Creates a new NoiseProceduralTexture
  58748. * @param name defines the name fo the texture
  58749. * @param size defines the size of the texture (default is 256)
  58750. * @param scene defines the hosting scene
  58751. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  58752. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  58753. */
  58754. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  58755. private _updateShaderUniforms;
  58756. protected _getDefines(): string;
  58757. /** Generate the current state of the procedural texture */
  58758. render(useCameraPostProcess?: boolean): void;
  58759. /**
  58760. * Serializes this noise procedural texture
  58761. * @returns a serialized noise procedural texture object
  58762. */
  58763. serialize(): any;
  58764. /**
  58765. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  58766. * @param parsedTexture defines parsed texture data
  58767. * @param scene defines the current scene
  58768. * @param rootUrl defines the root URL containing noise procedural texture information
  58769. * @returns a parsed NoiseProceduralTexture
  58770. */
  58771. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  58772. }
  58773. }
  58774. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  58775. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  58776. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  58777. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58778. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  58779. }
  58780. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  58781. import { Nullable } from "babylonjs/types";
  58782. import { Scene } from "babylonjs/scene";
  58783. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  58784. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58785. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  58786. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58787. /**
  58788. * Raw cube texture where the raw buffers are passed in
  58789. */
  58790. export class RawCubeTexture extends CubeTexture {
  58791. /**
  58792. * Creates a cube texture where the raw buffers are passed in.
  58793. * @param scene defines the scene the texture is attached to
  58794. * @param data defines the array of data to use to create each face
  58795. * @param size defines the size of the textures
  58796. * @param format defines the format of the data
  58797. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  58798. * @param generateMipMaps defines if the engine should generate the mip levels
  58799. * @param invertY defines if data must be stored with Y axis inverted
  58800. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  58801. * @param compression defines the compression used (null by default)
  58802. */
  58803. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  58804. /**
  58805. * Updates the raw cube texture.
  58806. * @param data defines the data to store
  58807. * @param format defines the data format
  58808. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  58809. * @param invertY defines if data must be stored with Y axis inverted
  58810. * @param compression defines the compression used (null by default)
  58811. * @param level defines which level of the texture to update
  58812. */
  58813. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  58814. /**
  58815. * Updates a raw cube texture with RGBD encoded data.
  58816. * @param data defines the array of data [mipmap][face] to use to create each face
  58817. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  58818. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  58819. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  58820. * @returns a promsie that resolves when the operation is complete
  58821. */
  58822. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  58823. /**
  58824. * Clones the raw cube texture.
  58825. * @return a new cube texture
  58826. */
  58827. clone(): CubeTexture;
  58828. /** @hidden */
  58829. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  58830. }
  58831. }
  58832. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  58833. import { Scene } from "babylonjs/scene";
  58834. import { Texture } from "babylonjs/Materials/Textures/texture";
  58835. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58836. /**
  58837. * Class used to store 3D textures containing user data
  58838. */
  58839. export class RawTexture3D extends Texture {
  58840. /** Gets or sets the texture format to use */
  58841. format: number;
  58842. private _engine;
  58843. /**
  58844. * Create a new RawTexture3D
  58845. * @param data defines the data of the texture
  58846. * @param width defines the width of the texture
  58847. * @param height defines the height of the texture
  58848. * @param depth defines the depth of the texture
  58849. * @param format defines the texture format to use
  58850. * @param scene defines the hosting scene
  58851. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  58852. * @param invertY defines if texture must be stored with Y axis inverted
  58853. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58854. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  58855. */
  58856. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  58857. /** Gets or sets the texture format to use */
  58858. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  58859. /**
  58860. * Update the texture with new data
  58861. * @param data defines the data to store in the texture
  58862. */
  58863. update(data: ArrayBufferView): void;
  58864. }
  58865. }
  58866. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  58867. import { Scene } from "babylonjs/scene";
  58868. import { Texture } from "babylonjs/Materials/Textures/texture";
  58869. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58870. /**
  58871. * Class used to store 2D array textures containing user data
  58872. */
  58873. export class RawTexture2DArray extends Texture {
  58874. /** Gets or sets the texture format to use */
  58875. format: number;
  58876. private _engine;
  58877. /**
  58878. * Create a new RawTexture2DArray
  58879. * @param data defines the data of the texture
  58880. * @param width defines the width of the texture
  58881. * @param height defines the height of the texture
  58882. * @param depth defines the number of layers of the texture
  58883. * @param format defines the texture format to use
  58884. * @param scene defines the hosting scene
  58885. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  58886. * @param invertY defines if texture must be stored with Y axis inverted
  58887. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58888. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  58889. */
  58890. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  58891. /** Gets or sets the texture format to use */
  58892. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  58893. /**
  58894. * Update the texture with new data
  58895. * @param data defines the data to store in the texture
  58896. */
  58897. update(data: ArrayBufferView): void;
  58898. }
  58899. }
  58900. declare module "babylonjs/Materials/Textures/refractionTexture" {
  58901. import { Scene } from "babylonjs/scene";
  58902. import { Plane } from "babylonjs/Maths/math.plane";
  58903. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58904. /**
  58905. * Creates a refraction texture used by refraction channel of the standard material.
  58906. * It is like a mirror but to see through a material.
  58907. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58908. */
  58909. export class RefractionTexture extends RenderTargetTexture {
  58910. /**
  58911. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  58912. * 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.
  58913. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58914. */
  58915. refractionPlane: Plane;
  58916. /**
  58917. * Define how deep under the surface we should see.
  58918. */
  58919. depth: number;
  58920. /**
  58921. * Creates a refraction texture used by refraction channel of the standard material.
  58922. * It is like a mirror but to see through a material.
  58923. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58924. * @param name Define the texture name
  58925. * @param size Define the size of the underlying texture
  58926. * @param scene Define the scene the refraction belongs to
  58927. * @param generateMipMaps Define if we need to generate mips level for the refraction
  58928. */
  58929. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  58930. /**
  58931. * Clone the refraction texture.
  58932. * @returns the cloned texture
  58933. */
  58934. clone(): RefractionTexture;
  58935. /**
  58936. * Serialize the texture to a JSON representation you could use in Parse later on
  58937. * @returns the serialized JSON representation
  58938. */
  58939. serialize(): any;
  58940. }
  58941. }
  58942. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  58943. import { Nullable } from "babylonjs/types";
  58944. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58945. import { Matrix } from "babylonjs/Maths/math.vector";
  58946. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  58947. import "babylonjs/Engines/Extensions/engine.videoTexture";
  58948. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58949. import { Scene } from "babylonjs/scene";
  58950. /**
  58951. * Defines the options related to the creation of an HtmlElementTexture
  58952. */
  58953. export interface IHtmlElementTextureOptions {
  58954. /**
  58955. * Defines wether mip maps should be created or not.
  58956. */
  58957. generateMipMaps?: boolean;
  58958. /**
  58959. * Defines the sampling mode of the texture.
  58960. */
  58961. samplingMode?: number;
  58962. /**
  58963. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  58964. */
  58965. engine: Nullable<ThinEngine>;
  58966. /**
  58967. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  58968. */
  58969. scene: Nullable<Scene>;
  58970. }
  58971. /**
  58972. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  58973. * To be as efficient as possible depending on your constraints nothing aside the first upload
  58974. * is automatically managed.
  58975. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  58976. * in your application.
  58977. *
  58978. * As the update is not automatic, you need to call them manually.
  58979. */
  58980. export class HtmlElementTexture extends BaseTexture {
  58981. /**
  58982. * The texture URL.
  58983. */
  58984. element: HTMLVideoElement | HTMLCanvasElement;
  58985. private static readonly DefaultOptions;
  58986. private _textureMatrix;
  58987. private _engine;
  58988. private _isVideo;
  58989. private _generateMipMaps;
  58990. private _samplingMode;
  58991. /**
  58992. * Instantiates a HtmlElementTexture from the following parameters.
  58993. *
  58994. * @param name Defines the name of the texture
  58995. * @param element Defines the video or canvas the texture is filled with
  58996. * @param options Defines the other none mandatory texture creation options
  58997. */
  58998. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  58999. private _createInternalTexture;
  59000. /**
  59001. * Returns the texture matrix used in most of the material.
  59002. */
  59003. getTextureMatrix(): Matrix;
  59004. /**
  59005. * Updates the content of the texture.
  59006. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  59007. */
  59008. update(invertY?: Nullable<boolean>): void;
  59009. }
  59010. }
  59011. declare module "babylonjs/Materials/Textures/Packer/frame" {
  59012. import { Vector2 } from "babylonjs/Maths/math.vector";
  59013. /**
  59014. * Defines the basic options interface of a TexturePacker Frame
  59015. */
  59016. export interface ITexturePackerFrame {
  59017. /**
  59018. * The frame ID
  59019. */
  59020. id: number;
  59021. /**
  59022. * The frames Scale
  59023. */
  59024. scale: Vector2;
  59025. /**
  59026. * The Frames offset
  59027. */
  59028. offset: Vector2;
  59029. }
  59030. /**
  59031. * This is a support class for frame Data on texture packer sets.
  59032. */
  59033. export class TexturePackerFrame implements ITexturePackerFrame {
  59034. /**
  59035. * The frame ID
  59036. */
  59037. id: number;
  59038. /**
  59039. * The frames Scale
  59040. */
  59041. scale: Vector2;
  59042. /**
  59043. * The Frames offset
  59044. */
  59045. offset: Vector2;
  59046. /**
  59047. * Initializes a texture package frame.
  59048. * @param id The numerical frame identifier
  59049. * @param scale Scalar Vector2 for UV frame
  59050. * @param offset Vector2 for the frame position in UV units.
  59051. * @returns TexturePackerFrame
  59052. */
  59053. constructor(id: number, scale: Vector2, offset: Vector2);
  59054. }
  59055. }
  59056. declare module "babylonjs/Materials/Textures/Packer/packer" {
  59057. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59058. import { Scene } from "babylonjs/scene";
  59059. import { Nullable } from "babylonjs/types";
  59060. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  59061. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  59062. /**
  59063. * Defines the basic options interface of a TexturePacker
  59064. */
  59065. export interface ITexturePackerOptions {
  59066. /**
  59067. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  59068. */
  59069. map?: string[];
  59070. /**
  59071. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  59072. */
  59073. uvsIn?: string;
  59074. /**
  59075. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  59076. */
  59077. uvsOut?: string;
  59078. /**
  59079. * number representing the layout style. Defaults to LAYOUT_STRIP
  59080. */
  59081. layout?: number;
  59082. /**
  59083. * number of columns if using custom column count layout(2). This defaults to 4.
  59084. */
  59085. colnum?: number;
  59086. /**
  59087. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  59088. */
  59089. updateInputMeshes?: boolean;
  59090. /**
  59091. * boolean flag to dispose all the source textures. Defaults to true.
  59092. */
  59093. disposeSources?: boolean;
  59094. /**
  59095. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  59096. */
  59097. fillBlanks?: boolean;
  59098. /**
  59099. * string value representing the context fill style color. Defaults to 'black'.
  59100. */
  59101. customFillColor?: string;
  59102. /**
  59103. * Width and Height Value of each Frame in the TexturePacker Sets
  59104. */
  59105. frameSize?: number;
  59106. /**
  59107. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  59108. */
  59109. paddingRatio?: number;
  59110. /**
  59111. * Number that declares the fill method for the padding gutter.
  59112. */
  59113. paddingMode?: number;
  59114. /**
  59115. * If in SUBUV_COLOR padding mode what color to use.
  59116. */
  59117. paddingColor?: Color3 | Color4;
  59118. }
  59119. /**
  59120. * Defines the basic interface of a TexturePacker JSON File
  59121. */
  59122. export interface ITexturePackerJSON {
  59123. /**
  59124. * The frame ID
  59125. */
  59126. name: string;
  59127. /**
  59128. * The base64 channel data
  59129. */
  59130. sets: any;
  59131. /**
  59132. * The options of the Packer
  59133. */
  59134. options: ITexturePackerOptions;
  59135. /**
  59136. * The frame data of the Packer
  59137. */
  59138. frames: Array<number>;
  59139. }
  59140. /**
  59141. * This is a support class that generates a series of packed texture sets.
  59142. * @see https://doc.babylonjs.com/babylon101/materials
  59143. */
  59144. export class TexturePacker {
  59145. /** Packer Layout Constant 0 */
  59146. static readonly LAYOUT_STRIP: number;
  59147. /** Packer Layout Constant 1 */
  59148. static readonly LAYOUT_POWER2: number;
  59149. /** Packer Layout Constant 2 */
  59150. static readonly LAYOUT_COLNUM: number;
  59151. /** Packer Layout Constant 0 */
  59152. static readonly SUBUV_WRAP: number;
  59153. /** Packer Layout Constant 1 */
  59154. static readonly SUBUV_EXTEND: number;
  59155. /** Packer Layout Constant 2 */
  59156. static readonly SUBUV_COLOR: number;
  59157. /** The Name of the Texture Package */
  59158. name: string;
  59159. /** The scene scope of the TexturePacker */
  59160. scene: Scene;
  59161. /** The Meshes to target */
  59162. meshes: AbstractMesh[];
  59163. /** Arguments passed with the Constructor */
  59164. options: ITexturePackerOptions;
  59165. /** The promise that is started upon initialization */
  59166. promise: Nullable<Promise<TexturePacker | string>>;
  59167. /** The Container object for the channel sets that are generated */
  59168. sets: object;
  59169. /** The Container array for the frames that are generated */
  59170. frames: TexturePackerFrame[];
  59171. /** The expected number of textures the system is parsing. */
  59172. private _expecting;
  59173. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  59174. private _paddingValue;
  59175. /**
  59176. * Initializes a texture package series from an array of meshes or a single mesh.
  59177. * @param name The name of the package
  59178. * @param meshes The target meshes to compose the package from
  59179. * @param options The arguments that texture packer should follow while building.
  59180. * @param scene The scene which the textures are scoped to.
  59181. * @returns TexturePacker
  59182. */
  59183. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  59184. /**
  59185. * Starts the package process
  59186. * @param resolve The promises resolution function
  59187. * @returns TexturePacker
  59188. */
  59189. private _createFrames;
  59190. /**
  59191. * Calculates the Size of the Channel Sets
  59192. * @returns Vector2
  59193. */
  59194. private _calculateSize;
  59195. /**
  59196. * Calculates the UV data for the frames.
  59197. * @param baseSize the base frameSize
  59198. * @param padding the base frame padding
  59199. * @param dtSize size of the Dynamic Texture for that channel
  59200. * @param dtUnits is 1/dtSize
  59201. * @param update flag to update the input meshes
  59202. */
  59203. private _calculateMeshUVFrames;
  59204. /**
  59205. * Calculates the frames Offset.
  59206. * @param index of the frame
  59207. * @returns Vector2
  59208. */
  59209. private _getFrameOffset;
  59210. /**
  59211. * Updates a Mesh to the frame data
  59212. * @param mesh that is the target
  59213. * @param frameID or the frame index
  59214. */
  59215. private _updateMeshUV;
  59216. /**
  59217. * Updates a Meshes materials to use the texture packer channels
  59218. * @param m is the mesh to target
  59219. * @param force all channels on the packer to be set.
  59220. */
  59221. private _updateTextureReferences;
  59222. /**
  59223. * Public method to set a Mesh to a frame
  59224. * @param m that is the target
  59225. * @param frameID or the frame index
  59226. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  59227. */
  59228. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  59229. /**
  59230. * Starts the async promise to compile the texture packer.
  59231. * @returns Promise<void>
  59232. */
  59233. processAsync(): Promise<void>;
  59234. /**
  59235. * Disposes all textures associated with this packer
  59236. */
  59237. dispose(): void;
  59238. /**
  59239. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  59240. * @param imageType is the image type to use.
  59241. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  59242. */
  59243. download(imageType?: string, quality?: number): void;
  59244. /**
  59245. * Public method to load a texturePacker JSON file.
  59246. * @param data of the JSON file in string format.
  59247. */
  59248. updateFromJSON(data: string): void;
  59249. }
  59250. }
  59251. declare module "babylonjs/Materials/Textures/Packer/index" {
  59252. export * from "babylonjs/Materials/Textures/Packer/packer";
  59253. export * from "babylonjs/Materials/Textures/Packer/frame";
  59254. }
  59255. declare module "babylonjs/Materials/Textures/index" {
  59256. export * from "babylonjs/Materials/Textures/baseTexture";
  59257. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  59258. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  59259. export * from "babylonjs/Materials/Textures/cubeTexture";
  59260. export * from "babylonjs/Materials/Textures/dynamicTexture";
  59261. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  59262. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  59263. export * from "babylonjs/Materials/Textures/internalTexture";
  59264. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  59265. export * from "babylonjs/Materials/Textures/Loaders/index";
  59266. export * from "babylonjs/Materials/Textures/mirrorTexture";
  59267. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  59268. export * from "babylonjs/Materials/Textures/Procedurals/index";
  59269. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  59270. export * from "babylonjs/Materials/Textures/rawTexture";
  59271. export * from "babylonjs/Materials/Textures/rawTexture3D";
  59272. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  59273. export * from "babylonjs/Materials/Textures/refractionTexture";
  59274. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  59275. export * from "babylonjs/Materials/Textures/texture";
  59276. export * from "babylonjs/Materials/Textures/videoTexture";
  59277. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  59278. export * from "babylonjs/Materials/Textures/Packer/index";
  59279. }
  59280. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  59281. /**
  59282. * Enum used to define the target of a block
  59283. */
  59284. export enum NodeMaterialBlockTargets {
  59285. /** Vertex shader */
  59286. Vertex = 1,
  59287. /** Fragment shader */
  59288. Fragment = 2,
  59289. /** Neutral */
  59290. Neutral = 4,
  59291. /** Vertex and Fragment */
  59292. VertexAndFragment = 3
  59293. }
  59294. }
  59295. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  59296. /**
  59297. * Defines the kind of connection point for node based material
  59298. */
  59299. export enum NodeMaterialBlockConnectionPointTypes {
  59300. /** Float */
  59301. Float = 1,
  59302. /** Int */
  59303. Int = 2,
  59304. /** Vector2 */
  59305. Vector2 = 4,
  59306. /** Vector3 */
  59307. Vector3 = 8,
  59308. /** Vector4 */
  59309. Vector4 = 16,
  59310. /** Color3 */
  59311. Color3 = 32,
  59312. /** Color4 */
  59313. Color4 = 64,
  59314. /** Matrix */
  59315. Matrix = 128,
  59316. /** Detect type based on connection */
  59317. AutoDetect = 1024,
  59318. /** Output type that will be defined by input type */
  59319. BasedOnInput = 2048
  59320. }
  59321. }
  59322. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  59323. /**
  59324. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  59325. */
  59326. export enum NodeMaterialBlockConnectionPointMode {
  59327. /** Value is an uniform */
  59328. Uniform = 0,
  59329. /** Value is a mesh attribute */
  59330. Attribute = 1,
  59331. /** Value is a varying between vertex and fragment shaders */
  59332. Varying = 2,
  59333. /** Mode is undefined */
  59334. Undefined = 3
  59335. }
  59336. }
  59337. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  59338. /**
  59339. * Enum used to define system values e.g. values automatically provided by the system
  59340. */
  59341. export enum NodeMaterialSystemValues {
  59342. /** World */
  59343. World = 1,
  59344. /** View */
  59345. View = 2,
  59346. /** Projection */
  59347. Projection = 3,
  59348. /** ViewProjection */
  59349. ViewProjection = 4,
  59350. /** WorldView */
  59351. WorldView = 5,
  59352. /** WorldViewProjection */
  59353. WorldViewProjection = 6,
  59354. /** CameraPosition */
  59355. CameraPosition = 7,
  59356. /** Fog Color */
  59357. FogColor = 8,
  59358. /** Delta time */
  59359. DeltaTime = 9
  59360. }
  59361. }
  59362. declare module "babylonjs/Materials/Node/Enums/index" {
  59363. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  59364. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  59365. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  59366. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  59367. }
  59368. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  59369. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59370. /**
  59371. * Root class for all node material optimizers
  59372. */
  59373. export class NodeMaterialOptimizer {
  59374. /**
  59375. * Function used to optimize a NodeMaterial graph
  59376. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  59377. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  59378. */
  59379. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  59380. }
  59381. }
  59382. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  59383. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59384. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59385. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59386. import { Scene } from "babylonjs/scene";
  59387. /**
  59388. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  59389. */
  59390. export class TransformBlock extends NodeMaterialBlock {
  59391. /**
  59392. * Defines the value to use to complement W value to transform it to a Vector4
  59393. */
  59394. complementW: number;
  59395. /**
  59396. * Defines the value to use to complement z value to transform it to a Vector4
  59397. */
  59398. complementZ: number;
  59399. /**
  59400. * Creates a new TransformBlock
  59401. * @param name defines the block name
  59402. */
  59403. constructor(name: string);
  59404. /**
  59405. * Gets the current class name
  59406. * @returns the class name
  59407. */
  59408. getClassName(): string;
  59409. /**
  59410. * Gets the vector input
  59411. */
  59412. get vector(): NodeMaterialConnectionPoint;
  59413. /**
  59414. * Gets the output component
  59415. */
  59416. get output(): NodeMaterialConnectionPoint;
  59417. /**
  59418. * Gets the matrix transform input
  59419. */
  59420. get transform(): NodeMaterialConnectionPoint;
  59421. protected _buildBlock(state: NodeMaterialBuildState): this;
  59422. serialize(): any;
  59423. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59424. protected _dumpPropertiesCode(): string;
  59425. }
  59426. }
  59427. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  59428. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59429. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59430. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59431. /**
  59432. * Block used to output the vertex position
  59433. */
  59434. export class VertexOutputBlock extends NodeMaterialBlock {
  59435. /**
  59436. * Creates a new VertexOutputBlock
  59437. * @param name defines the block name
  59438. */
  59439. constructor(name: string);
  59440. /**
  59441. * Gets the current class name
  59442. * @returns the class name
  59443. */
  59444. getClassName(): string;
  59445. /**
  59446. * Gets the vector input component
  59447. */
  59448. get vector(): NodeMaterialConnectionPoint;
  59449. protected _buildBlock(state: NodeMaterialBuildState): this;
  59450. }
  59451. }
  59452. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  59453. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59454. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59455. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59456. /**
  59457. * Block used to output the final color
  59458. */
  59459. export class FragmentOutputBlock extends NodeMaterialBlock {
  59460. /**
  59461. * Create a new FragmentOutputBlock
  59462. * @param name defines the block name
  59463. */
  59464. constructor(name: string);
  59465. /**
  59466. * Gets the current class name
  59467. * @returns the class name
  59468. */
  59469. getClassName(): string;
  59470. /**
  59471. * Gets the rgba input component
  59472. */
  59473. get rgba(): NodeMaterialConnectionPoint;
  59474. /**
  59475. * Gets the rgb input component
  59476. */
  59477. get rgb(): NodeMaterialConnectionPoint;
  59478. /**
  59479. * Gets the a input component
  59480. */
  59481. get a(): NodeMaterialConnectionPoint;
  59482. protected _buildBlock(state: NodeMaterialBuildState): this;
  59483. }
  59484. }
  59485. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  59486. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59487. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59488. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59489. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59490. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59491. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59492. import { Effect } from "babylonjs/Materials/effect";
  59493. import { Mesh } from "babylonjs/Meshes/mesh";
  59494. import { Nullable } from "babylonjs/types";
  59495. import { Scene } from "babylonjs/scene";
  59496. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  59497. /**
  59498. * Block used to read a reflection texture from a sampler
  59499. */
  59500. export class ReflectionTextureBlock extends NodeMaterialBlock {
  59501. private _define3DName;
  59502. private _defineCubicName;
  59503. private _defineExplicitName;
  59504. private _defineProjectionName;
  59505. private _defineLocalCubicName;
  59506. private _defineSphericalName;
  59507. private _definePlanarName;
  59508. private _defineEquirectangularName;
  59509. private _defineMirroredEquirectangularFixedName;
  59510. private _defineEquirectangularFixedName;
  59511. private _defineSkyboxName;
  59512. private _cubeSamplerName;
  59513. private _2DSamplerName;
  59514. private _positionUVWName;
  59515. private _directionWName;
  59516. private _reflectionCoordsName;
  59517. private _reflection2DCoordsName;
  59518. private _reflectionColorName;
  59519. private _reflectionMatrixName;
  59520. /**
  59521. * Gets or sets the texture associated with the node
  59522. */
  59523. texture: Nullable<BaseTexture>;
  59524. /**
  59525. * Create a new TextureBlock
  59526. * @param name defines the block name
  59527. */
  59528. constructor(name: string);
  59529. /**
  59530. * Gets the current class name
  59531. * @returns the class name
  59532. */
  59533. getClassName(): string;
  59534. /**
  59535. * Gets the world position input component
  59536. */
  59537. get position(): NodeMaterialConnectionPoint;
  59538. /**
  59539. * Gets the world position input component
  59540. */
  59541. get worldPosition(): NodeMaterialConnectionPoint;
  59542. /**
  59543. * Gets the world normal input component
  59544. */
  59545. get worldNormal(): NodeMaterialConnectionPoint;
  59546. /**
  59547. * Gets the world input component
  59548. */
  59549. get world(): NodeMaterialConnectionPoint;
  59550. /**
  59551. * Gets the camera (or eye) position component
  59552. */
  59553. get cameraPosition(): NodeMaterialConnectionPoint;
  59554. /**
  59555. * Gets the view input component
  59556. */
  59557. get view(): NodeMaterialConnectionPoint;
  59558. /**
  59559. * Gets the rgb output component
  59560. */
  59561. get rgb(): NodeMaterialConnectionPoint;
  59562. /**
  59563. * Gets the r output component
  59564. */
  59565. get r(): NodeMaterialConnectionPoint;
  59566. /**
  59567. * Gets the g output component
  59568. */
  59569. get g(): NodeMaterialConnectionPoint;
  59570. /**
  59571. * Gets the b output component
  59572. */
  59573. get b(): NodeMaterialConnectionPoint;
  59574. autoConfigure(material: NodeMaterial): void;
  59575. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59576. isReady(): boolean;
  59577. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59578. private _injectVertexCode;
  59579. private _writeOutput;
  59580. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59581. protected _dumpPropertiesCode(): string;
  59582. serialize(): any;
  59583. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59584. }
  59585. }
  59586. declare module "babylonjs/Materials/Node/nodeMaterial" {
  59587. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59588. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  59589. import { Scene } from "babylonjs/scene";
  59590. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59591. import { Matrix } from "babylonjs/Maths/math.vector";
  59592. import { Mesh } from "babylonjs/Meshes/mesh";
  59593. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59594. import { Observable } from "babylonjs/Misc/observable";
  59595. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59596. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  59597. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  59598. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  59599. import { Nullable } from "babylonjs/types";
  59600. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  59601. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  59602. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  59603. /**
  59604. * Interface used to configure the node material editor
  59605. */
  59606. export interface INodeMaterialEditorOptions {
  59607. /** Define the URl to load node editor script */
  59608. editorURL?: string;
  59609. }
  59610. /** @hidden */
  59611. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  59612. NORMAL: boolean;
  59613. TANGENT: boolean;
  59614. UV1: boolean;
  59615. /** BONES */
  59616. NUM_BONE_INFLUENCERS: number;
  59617. BonesPerMesh: number;
  59618. BONETEXTURE: boolean;
  59619. /** MORPH TARGETS */
  59620. MORPHTARGETS: boolean;
  59621. MORPHTARGETS_NORMAL: boolean;
  59622. MORPHTARGETS_TANGENT: boolean;
  59623. MORPHTARGETS_UV: boolean;
  59624. NUM_MORPH_INFLUENCERS: number;
  59625. /** IMAGE PROCESSING */
  59626. IMAGEPROCESSING: boolean;
  59627. VIGNETTE: boolean;
  59628. VIGNETTEBLENDMODEMULTIPLY: boolean;
  59629. VIGNETTEBLENDMODEOPAQUE: boolean;
  59630. TONEMAPPING: boolean;
  59631. TONEMAPPING_ACES: boolean;
  59632. CONTRAST: boolean;
  59633. EXPOSURE: boolean;
  59634. COLORCURVES: boolean;
  59635. COLORGRADING: boolean;
  59636. COLORGRADING3D: boolean;
  59637. SAMPLER3DGREENDEPTH: boolean;
  59638. SAMPLER3DBGRMAP: boolean;
  59639. IMAGEPROCESSINGPOSTPROCESS: boolean;
  59640. /** MISC. */
  59641. BUMPDIRECTUV: number;
  59642. constructor();
  59643. setValue(name: string, value: boolean): void;
  59644. }
  59645. /**
  59646. * Class used to configure NodeMaterial
  59647. */
  59648. export interface INodeMaterialOptions {
  59649. /**
  59650. * Defines if blocks should emit comments
  59651. */
  59652. emitComments: boolean;
  59653. }
  59654. /**
  59655. * Class used to create a node based material built by assembling shader blocks
  59656. */
  59657. export class NodeMaterial extends PushMaterial {
  59658. private static _BuildIdGenerator;
  59659. private _options;
  59660. private _vertexCompilationState;
  59661. private _fragmentCompilationState;
  59662. private _sharedData;
  59663. private _buildId;
  59664. private _buildWasSuccessful;
  59665. private _cachedWorldViewMatrix;
  59666. private _cachedWorldViewProjectionMatrix;
  59667. private _optimizers;
  59668. private _animationFrame;
  59669. /** Define the Url to load node editor script */
  59670. static EditorURL: string;
  59671. /** Define the Url to load snippets */
  59672. static SnippetUrl: string;
  59673. private BJSNODEMATERIALEDITOR;
  59674. /** Get the inspector from bundle or global */
  59675. private _getGlobalNodeMaterialEditor;
  59676. /**
  59677. * Gets or sets data used by visual editor
  59678. * @see https://nme.babylonjs.com
  59679. */
  59680. editorData: any;
  59681. /**
  59682. * 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)
  59683. */
  59684. ignoreAlpha: boolean;
  59685. /**
  59686. * Defines the maximum number of lights that can be used in the material
  59687. */
  59688. maxSimultaneousLights: number;
  59689. /**
  59690. * Observable raised when the material is built
  59691. */
  59692. onBuildObservable: Observable<NodeMaterial>;
  59693. /**
  59694. * Gets or sets the root nodes of the material vertex shader
  59695. */
  59696. _vertexOutputNodes: NodeMaterialBlock[];
  59697. /**
  59698. * Gets or sets the root nodes of the material fragment (pixel) shader
  59699. */
  59700. _fragmentOutputNodes: NodeMaterialBlock[];
  59701. /** Gets or sets options to control the node material overall behavior */
  59702. get options(): INodeMaterialOptions;
  59703. set options(options: INodeMaterialOptions);
  59704. /**
  59705. * Default configuration related to image processing available in the standard Material.
  59706. */
  59707. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  59708. /**
  59709. * Gets the image processing configuration used either in this material.
  59710. */
  59711. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  59712. /**
  59713. * Sets the Default image processing configuration used either in the this material.
  59714. *
  59715. * If sets to null, the scene one is in use.
  59716. */
  59717. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  59718. /**
  59719. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  59720. */
  59721. attachedBlocks: NodeMaterialBlock[];
  59722. /**
  59723. * Create a new node based material
  59724. * @param name defines the material name
  59725. * @param scene defines the hosting scene
  59726. * @param options defines creation option
  59727. */
  59728. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  59729. /**
  59730. * Gets the current class name of the material e.g. "NodeMaterial"
  59731. * @returns the class name
  59732. */
  59733. getClassName(): string;
  59734. /**
  59735. * Keep track of the image processing observer to allow dispose and replace.
  59736. */
  59737. private _imageProcessingObserver;
  59738. /**
  59739. * Attaches a new image processing configuration to the Standard Material.
  59740. * @param configuration
  59741. */
  59742. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  59743. /**
  59744. * Get a block by its name
  59745. * @param name defines the name of the block to retrieve
  59746. * @returns the required block or null if not found
  59747. */
  59748. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  59749. /**
  59750. * Get a block by its name
  59751. * @param predicate defines the predicate used to find the good candidate
  59752. * @returns the required block or null if not found
  59753. */
  59754. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  59755. /**
  59756. * Get an input block by its name
  59757. * @param predicate defines the predicate used to find the good candidate
  59758. * @returns the required input block or null if not found
  59759. */
  59760. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  59761. /**
  59762. * Gets the list of input blocks attached to this material
  59763. * @returns an array of InputBlocks
  59764. */
  59765. getInputBlocks(): InputBlock[];
  59766. /**
  59767. * Adds a new optimizer to the list of optimizers
  59768. * @param optimizer defines the optimizers to add
  59769. * @returns the current material
  59770. */
  59771. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  59772. /**
  59773. * Remove an optimizer from the list of optimizers
  59774. * @param optimizer defines the optimizers to remove
  59775. * @returns the current material
  59776. */
  59777. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  59778. /**
  59779. * Add a new block to the list of output nodes
  59780. * @param node defines the node to add
  59781. * @returns the current material
  59782. */
  59783. addOutputNode(node: NodeMaterialBlock): this;
  59784. /**
  59785. * Remove a block from the list of root nodes
  59786. * @param node defines the node to remove
  59787. * @returns the current material
  59788. */
  59789. removeOutputNode(node: NodeMaterialBlock): this;
  59790. private _addVertexOutputNode;
  59791. private _removeVertexOutputNode;
  59792. private _addFragmentOutputNode;
  59793. private _removeFragmentOutputNode;
  59794. /**
  59795. * Specifies if the material will require alpha blending
  59796. * @returns a boolean specifying if alpha blending is needed
  59797. */
  59798. needAlphaBlending(): boolean;
  59799. /**
  59800. * Specifies if this material should be rendered in alpha test mode
  59801. * @returns a boolean specifying if an alpha test is needed.
  59802. */
  59803. needAlphaTesting(): boolean;
  59804. private _initializeBlock;
  59805. private _resetDualBlocks;
  59806. /**
  59807. * Remove a block from the current node material
  59808. * @param block defines the block to remove
  59809. */
  59810. removeBlock(block: NodeMaterialBlock): void;
  59811. /**
  59812. * Build the material and generates the inner effect
  59813. * @param verbose defines if the build should log activity
  59814. */
  59815. build(verbose?: boolean): void;
  59816. /**
  59817. * Runs an otpimization phase to try to improve the shader code
  59818. */
  59819. optimize(): void;
  59820. private _prepareDefinesForAttributes;
  59821. /**
  59822. * Get if the submesh is ready to be used and all its information available.
  59823. * Child classes can use it to update shaders
  59824. * @param mesh defines the mesh to check
  59825. * @param subMesh defines which submesh to check
  59826. * @param useInstances specifies that instances should be used
  59827. * @returns a boolean indicating that the submesh is ready or not
  59828. */
  59829. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  59830. /**
  59831. * Get a string representing the shaders built by the current node graph
  59832. */
  59833. get compiledShaders(): string;
  59834. /**
  59835. * Binds the world matrix to the material
  59836. * @param world defines the world transformation matrix
  59837. */
  59838. bindOnlyWorldMatrix(world: Matrix): void;
  59839. /**
  59840. * Binds the submesh to this material by preparing the effect and shader to draw
  59841. * @param world defines the world transformation matrix
  59842. * @param mesh defines the mesh containing the submesh
  59843. * @param subMesh defines the submesh to bind the material to
  59844. */
  59845. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  59846. /**
  59847. * Gets the active textures from the material
  59848. * @returns an array of textures
  59849. */
  59850. getActiveTextures(): BaseTexture[];
  59851. /**
  59852. * Gets the list of texture blocks
  59853. * @returns an array of texture blocks
  59854. */
  59855. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  59856. /**
  59857. * Specifies if the material uses a texture
  59858. * @param texture defines the texture to check against the material
  59859. * @returns a boolean specifying if the material uses the texture
  59860. */
  59861. hasTexture(texture: BaseTexture): boolean;
  59862. /**
  59863. * Disposes the material
  59864. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  59865. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  59866. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  59867. */
  59868. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  59869. /** Creates the node editor window. */
  59870. private _createNodeEditor;
  59871. /**
  59872. * Launch the node material editor
  59873. * @param config Define the configuration of the editor
  59874. * @return a promise fulfilled when the node editor is visible
  59875. */
  59876. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  59877. /**
  59878. * Clear the current material
  59879. */
  59880. clear(): void;
  59881. /**
  59882. * Clear the current material and set it to a default state
  59883. */
  59884. setToDefault(): void;
  59885. /**
  59886. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  59887. * @param url defines the url to load from
  59888. * @returns a promise that will fullfil when the material is fully loaded
  59889. */
  59890. loadAsync(url: string): Promise<void>;
  59891. private _gatherBlocks;
  59892. /**
  59893. * Generate a string containing the code declaration required to create an equivalent of this material
  59894. * @returns a string
  59895. */
  59896. generateCode(): string;
  59897. /**
  59898. * Serializes this material in a JSON representation
  59899. * @returns the serialized material object
  59900. */
  59901. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  59902. private _restoreConnections;
  59903. /**
  59904. * Clear the current graph and load a new one from a serialization object
  59905. * @param source defines the JSON representation of the material
  59906. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59907. */
  59908. loadFromSerialization(source: any, rootUrl?: string): void;
  59909. /**
  59910. * Creates a node material from parsed material data
  59911. * @param source defines the JSON representation of the material
  59912. * @param scene defines the hosting scene
  59913. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59914. * @returns a new node material
  59915. */
  59916. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  59917. /**
  59918. * Creates a node material from a snippet saved in a remote file
  59919. * @param name defines the name of the material to create
  59920. * @param url defines the url to load from
  59921. * @param scene defines the hosting scene
  59922. * @returns a promise that will resolve to the new node material
  59923. */
  59924. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  59925. /**
  59926. * Creates a node material from a snippet saved by the node material editor
  59927. * @param snippetId defines the snippet to load
  59928. * @param scene defines the hosting scene
  59929. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59930. * @returns a promise that will resolve to the new node material
  59931. */
  59932. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  59933. /**
  59934. * Creates a new node material set to default basic configuration
  59935. * @param name defines the name of the material
  59936. * @param scene defines the hosting scene
  59937. * @returns a new NodeMaterial
  59938. */
  59939. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  59940. }
  59941. }
  59942. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  59943. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59944. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59945. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  59946. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59947. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59948. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59949. import { Effect } from "babylonjs/Materials/effect";
  59950. import { Mesh } from "babylonjs/Meshes/mesh";
  59951. import { Nullable } from "babylonjs/types";
  59952. import { Texture } from "babylonjs/Materials/Textures/texture";
  59953. import { Scene } from "babylonjs/scene";
  59954. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59955. /**
  59956. * Block used to read a texture from a sampler
  59957. */
  59958. export class TextureBlock extends NodeMaterialBlock {
  59959. private _defineName;
  59960. private _linearDefineName;
  59961. private _tempTextureRead;
  59962. private _samplerName;
  59963. private _transformedUVName;
  59964. private _textureTransformName;
  59965. private _textureInfoName;
  59966. private _mainUVName;
  59967. private _mainUVDefineName;
  59968. /**
  59969. * Gets or sets the texture associated with the node
  59970. */
  59971. texture: Nullable<Texture>;
  59972. /**
  59973. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  59974. */
  59975. convertToGammaSpace: boolean;
  59976. /**
  59977. * Create a new TextureBlock
  59978. * @param name defines the block name
  59979. */
  59980. constructor(name: string);
  59981. /**
  59982. * Gets the current class name
  59983. * @returns the class name
  59984. */
  59985. getClassName(): string;
  59986. /**
  59987. * Gets the uv input component
  59988. */
  59989. get uv(): NodeMaterialConnectionPoint;
  59990. /**
  59991. * Gets the rgba output component
  59992. */
  59993. get rgba(): NodeMaterialConnectionPoint;
  59994. /**
  59995. * Gets the rgb output component
  59996. */
  59997. get rgb(): NodeMaterialConnectionPoint;
  59998. /**
  59999. * Gets the r output component
  60000. */
  60001. get r(): NodeMaterialConnectionPoint;
  60002. /**
  60003. * Gets the g output component
  60004. */
  60005. get g(): NodeMaterialConnectionPoint;
  60006. /**
  60007. * Gets the b output component
  60008. */
  60009. get b(): NodeMaterialConnectionPoint;
  60010. /**
  60011. * Gets the a output component
  60012. */
  60013. get a(): NodeMaterialConnectionPoint;
  60014. get target(): NodeMaterialBlockTargets;
  60015. autoConfigure(material: NodeMaterial): void;
  60016. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60017. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60018. isReady(): boolean;
  60019. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60020. private get _isMixed();
  60021. private _injectVertexCode;
  60022. private _writeTextureRead;
  60023. private _writeOutput;
  60024. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60025. protected _dumpPropertiesCode(): string;
  60026. serialize(): any;
  60027. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60028. }
  60029. }
  60030. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  60031. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60032. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60033. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60034. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  60035. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  60036. import { Scene } from "babylonjs/scene";
  60037. /**
  60038. * Class used to store shared data between 2 NodeMaterialBuildState
  60039. */
  60040. export class NodeMaterialBuildStateSharedData {
  60041. /**
  60042. * Gets the list of emitted varyings
  60043. */
  60044. temps: string[];
  60045. /**
  60046. * Gets the list of emitted varyings
  60047. */
  60048. varyings: string[];
  60049. /**
  60050. * Gets the varying declaration string
  60051. */
  60052. varyingDeclaration: string;
  60053. /**
  60054. * Input blocks
  60055. */
  60056. inputBlocks: InputBlock[];
  60057. /**
  60058. * Input blocks
  60059. */
  60060. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  60061. /**
  60062. * Bindable blocks (Blocks that need to set data to the effect)
  60063. */
  60064. bindableBlocks: NodeMaterialBlock[];
  60065. /**
  60066. * List of blocks that can provide a compilation fallback
  60067. */
  60068. blocksWithFallbacks: NodeMaterialBlock[];
  60069. /**
  60070. * List of blocks that can provide a define update
  60071. */
  60072. blocksWithDefines: NodeMaterialBlock[];
  60073. /**
  60074. * List of blocks that can provide a repeatable content
  60075. */
  60076. repeatableContentBlocks: NodeMaterialBlock[];
  60077. /**
  60078. * List of blocks that can provide a dynamic list of uniforms
  60079. */
  60080. dynamicUniformBlocks: NodeMaterialBlock[];
  60081. /**
  60082. * List of blocks that can block the isReady function for the material
  60083. */
  60084. blockingBlocks: NodeMaterialBlock[];
  60085. /**
  60086. * Gets the list of animated inputs
  60087. */
  60088. animatedInputs: InputBlock[];
  60089. /**
  60090. * Build Id used to avoid multiple recompilations
  60091. */
  60092. buildId: number;
  60093. /** List of emitted variables */
  60094. variableNames: {
  60095. [key: string]: number;
  60096. };
  60097. /** List of emitted defines */
  60098. defineNames: {
  60099. [key: string]: number;
  60100. };
  60101. /** Should emit comments? */
  60102. emitComments: boolean;
  60103. /** Emit build activity */
  60104. verbose: boolean;
  60105. /** Gets or sets the hosting scene */
  60106. scene: Scene;
  60107. /**
  60108. * Gets the compilation hints emitted at compilation time
  60109. */
  60110. hints: {
  60111. needWorldViewMatrix: boolean;
  60112. needWorldViewProjectionMatrix: boolean;
  60113. needAlphaBlending: boolean;
  60114. needAlphaTesting: boolean;
  60115. };
  60116. /**
  60117. * List of compilation checks
  60118. */
  60119. checks: {
  60120. emitVertex: boolean;
  60121. emitFragment: boolean;
  60122. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  60123. };
  60124. /** Creates a new shared data */
  60125. constructor();
  60126. /**
  60127. * Emits console errors and exceptions if there is a failing check
  60128. */
  60129. emitErrors(): void;
  60130. }
  60131. }
  60132. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  60133. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60134. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60135. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  60136. /**
  60137. * Class used to store node based material build state
  60138. */
  60139. export class NodeMaterialBuildState {
  60140. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  60141. supportUniformBuffers: boolean;
  60142. /**
  60143. * Gets the list of emitted attributes
  60144. */
  60145. attributes: string[];
  60146. /**
  60147. * Gets the list of emitted uniforms
  60148. */
  60149. uniforms: string[];
  60150. /**
  60151. * Gets the list of emitted constants
  60152. */
  60153. constants: string[];
  60154. /**
  60155. * Gets the list of emitted samplers
  60156. */
  60157. samplers: string[];
  60158. /**
  60159. * Gets the list of emitted functions
  60160. */
  60161. functions: {
  60162. [key: string]: string;
  60163. };
  60164. /**
  60165. * Gets the list of emitted extensions
  60166. */
  60167. extensions: {
  60168. [key: string]: string;
  60169. };
  60170. /**
  60171. * Gets the target of the compilation state
  60172. */
  60173. target: NodeMaterialBlockTargets;
  60174. /**
  60175. * Gets the list of emitted counters
  60176. */
  60177. counters: {
  60178. [key: string]: number;
  60179. };
  60180. /**
  60181. * Shared data between multiple NodeMaterialBuildState instances
  60182. */
  60183. sharedData: NodeMaterialBuildStateSharedData;
  60184. /** @hidden */
  60185. _vertexState: NodeMaterialBuildState;
  60186. /** @hidden */
  60187. _attributeDeclaration: string;
  60188. /** @hidden */
  60189. _uniformDeclaration: string;
  60190. /** @hidden */
  60191. _constantDeclaration: string;
  60192. /** @hidden */
  60193. _samplerDeclaration: string;
  60194. /** @hidden */
  60195. _varyingTransfer: string;
  60196. private _repeatableContentAnchorIndex;
  60197. /** @hidden */
  60198. _builtCompilationString: string;
  60199. /**
  60200. * Gets the emitted compilation strings
  60201. */
  60202. compilationString: string;
  60203. /**
  60204. * Finalize the compilation strings
  60205. * @param state defines the current compilation state
  60206. */
  60207. finalize(state: NodeMaterialBuildState): void;
  60208. /** @hidden */
  60209. get _repeatableContentAnchor(): string;
  60210. /** @hidden */
  60211. _getFreeVariableName(prefix: string): string;
  60212. /** @hidden */
  60213. _getFreeDefineName(prefix: string): string;
  60214. /** @hidden */
  60215. _excludeVariableName(name: string): void;
  60216. /** @hidden */
  60217. _emit2DSampler(name: string): void;
  60218. /** @hidden */
  60219. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  60220. /** @hidden */
  60221. _emitExtension(name: string, extension: string): void;
  60222. /** @hidden */
  60223. _emitFunction(name: string, code: string, comments: string): void;
  60224. /** @hidden */
  60225. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  60226. replaceStrings?: {
  60227. search: RegExp;
  60228. replace: string;
  60229. }[];
  60230. repeatKey?: string;
  60231. }): string;
  60232. /** @hidden */
  60233. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  60234. repeatKey?: string;
  60235. removeAttributes?: boolean;
  60236. removeUniforms?: boolean;
  60237. removeVaryings?: boolean;
  60238. removeIfDef?: boolean;
  60239. replaceStrings?: {
  60240. search: RegExp;
  60241. replace: string;
  60242. }[];
  60243. }, storeKey?: string): void;
  60244. /** @hidden */
  60245. _registerTempVariable(name: string): boolean;
  60246. /** @hidden */
  60247. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  60248. /** @hidden */
  60249. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  60250. /** @hidden */
  60251. _emitFloat(value: number): string;
  60252. }
  60253. }
  60254. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  60255. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60256. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60257. import { Nullable } from "babylonjs/types";
  60258. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60259. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60260. import { Effect } from "babylonjs/Materials/effect";
  60261. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60262. import { Mesh } from "babylonjs/Meshes/mesh";
  60263. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60264. import { Scene } from "babylonjs/scene";
  60265. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  60266. /**
  60267. * Defines a block that can be used inside a node based material
  60268. */
  60269. export class NodeMaterialBlock {
  60270. private _buildId;
  60271. private _buildTarget;
  60272. private _target;
  60273. private _isFinalMerger;
  60274. private _isInput;
  60275. protected _isUnique: boolean;
  60276. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  60277. inputsAreExclusive: boolean;
  60278. /** @hidden */
  60279. _codeVariableName: string;
  60280. /** @hidden */
  60281. _inputs: NodeMaterialConnectionPoint[];
  60282. /** @hidden */
  60283. _outputs: NodeMaterialConnectionPoint[];
  60284. /** @hidden */
  60285. _preparationId: number;
  60286. /**
  60287. * Gets or sets the name of the block
  60288. */
  60289. name: string;
  60290. /**
  60291. * Gets or sets the unique id of the node
  60292. */
  60293. uniqueId: number;
  60294. /**
  60295. * Gets or sets the comments associated with this block
  60296. */
  60297. comments: string;
  60298. /**
  60299. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  60300. */
  60301. get isUnique(): boolean;
  60302. /**
  60303. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  60304. */
  60305. get isFinalMerger(): boolean;
  60306. /**
  60307. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  60308. */
  60309. get isInput(): boolean;
  60310. /**
  60311. * Gets or sets the build Id
  60312. */
  60313. get buildId(): number;
  60314. set buildId(value: number);
  60315. /**
  60316. * Gets or sets the target of the block
  60317. */
  60318. get target(): NodeMaterialBlockTargets;
  60319. set target(value: NodeMaterialBlockTargets);
  60320. /**
  60321. * Gets the list of input points
  60322. */
  60323. get inputs(): NodeMaterialConnectionPoint[];
  60324. /** Gets the list of output points */
  60325. get outputs(): NodeMaterialConnectionPoint[];
  60326. /**
  60327. * Find an input by its name
  60328. * @param name defines the name of the input to look for
  60329. * @returns the input or null if not found
  60330. */
  60331. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  60332. /**
  60333. * Find an output by its name
  60334. * @param name defines the name of the outputto look for
  60335. * @returns the output or null if not found
  60336. */
  60337. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  60338. /**
  60339. * Creates a new NodeMaterialBlock
  60340. * @param name defines the block name
  60341. * @param target defines the target of that block (Vertex by default)
  60342. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  60343. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  60344. */
  60345. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  60346. /**
  60347. * Initialize the block and prepare the context for build
  60348. * @param state defines the state that will be used for the build
  60349. */
  60350. initialize(state: NodeMaterialBuildState): void;
  60351. /**
  60352. * Bind data to effect. Will only be called for blocks with isBindable === true
  60353. * @param effect defines the effect to bind data to
  60354. * @param nodeMaterial defines the hosting NodeMaterial
  60355. * @param mesh defines the mesh that will be rendered
  60356. */
  60357. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60358. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  60359. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  60360. protected _writeFloat(value: number): string;
  60361. /**
  60362. * Gets the current class name e.g. "NodeMaterialBlock"
  60363. * @returns the class name
  60364. */
  60365. getClassName(): string;
  60366. /**
  60367. * Register a new input. Must be called inside a block constructor
  60368. * @param name defines the connection point name
  60369. * @param type defines the connection point type
  60370. * @param isOptional defines a boolean indicating that this input can be omitted
  60371. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  60372. * @returns the current block
  60373. */
  60374. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  60375. /**
  60376. * Register a new output. Must be called inside a block constructor
  60377. * @param name defines the connection point name
  60378. * @param type defines the connection point type
  60379. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  60380. * @returns the current block
  60381. */
  60382. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  60383. /**
  60384. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  60385. * @param forOutput defines an optional connection point to check compatibility with
  60386. * @returns the first available input or null
  60387. */
  60388. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  60389. /**
  60390. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  60391. * @param forBlock defines an optional block to check compatibility with
  60392. * @returns the first available input or null
  60393. */
  60394. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  60395. /**
  60396. * Gets the sibling of the given output
  60397. * @param current defines the current output
  60398. * @returns the next output in the list or null
  60399. */
  60400. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  60401. /**
  60402. * Connect current block with another block
  60403. * @param other defines the block to connect with
  60404. * @param options define the various options to help pick the right connections
  60405. * @returns the current block
  60406. */
  60407. connectTo(other: NodeMaterialBlock, options?: {
  60408. input?: string;
  60409. output?: string;
  60410. outputSwizzle?: string;
  60411. }): this | undefined;
  60412. protected _buildBlock(state: NodeMaterialBuildState): void;
  60413. /**
  60414. * Add uniforms, samplers and uniform buffers at compilation time
  60415. * @param state defines the state to update
  60416. * @param nodeMaterial defines the node material requesting the update
  60417. * @param defines defines the material defines to update
  60418. * @param uniformBuffers defines the list of uniform buffer names
  60419. */
  60420. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  60421. /**
  60422. * Add potential fallbacks if shader compilation fails
  60423. * @param mesh defines the mesh to be rendered
  60424. * @param fallbacks defines the current prioritized list of fallbacks
  60425. */
  60426. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  60427. /**
  60428. * Initialize defines for shader compilation
  60429. * @param mesh defines the mesh to be rendered
  60430. * @param nodeMaterial defines the node material requesting the update
  60431. * @param defines defines the material defines to update
  60432. * @param useInstances specifies that instances should be used
  60433. */
  60434. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60435. /**
  60436. * Update defines for shader compilation
  60437. * @param mesh defines the mesh to be rendered
  60438. * @param nodeMaterial defines the node material requesting the update
  60439. * @param defines defines the material defines to update
  60440. * @param useInstances specifies that instances should be used
  60441. */
  60442. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60443. /**
  60444. * Lets the block try to connect some inputs automatically
  60445. * @param material defines the hosting NodeMaterial
  60446. */
  60447. autoConfigure(material: NodeMaterial): void;
  60448. /**
  60449. * Function called when a block is declared as repeatable content generator
  60450. * @param vertexShaderState defines the current compilation state for the vertex shader
  60451. * @param fragmentShaderState defines the current compilation state for the fragment shader
  60452. * @param mesh defines the mesh to be rendered
  60453. * @param defines defines the material defines to update
  60454. */
  60455. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  60456. /**
  60457. * Checks if the block is ready
  60458. * @param mesh defines the mesh to be rendered
  60459. * @param nodeMaterial defines the node material requesting the update
  60460. * @param defines defines the material defines to update
  60461. * @param useInstances specifies that instances should be used
  60462. * @returns true if the block is ready
  60463. */
  60464. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  60465. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  60466. private _processBuild;
  60467. /**
  60468. * Compile the current node and generate the shader code
  60469. * @param state defines the current compilation state (uniforms, samplers, current string)
  60470. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  60471. * @returns true if already built
  60472. */
  60473. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  60474. protected _inputRename(name: string): string;
  60475. protected _outputRename(name: string): string;
  60476. protected _dumpPropertiesCode(): string;
  60477. /** @hidden */
  60478. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  60479. /** @hidden */
  60480. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  60481. /**
  60482. * Clone the current block to a new identical block
  60483. * @param scene defines the hosting scene
  60484. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60485. * @returns a copy of the current block
  60486. */
  60487. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  60488. /**
  60489. * Serializes this block in a JSON representation
  60490. * @returns the serialized block object
  60491. */
  60492. serialize(): any;
  60493. /** @hidden */
  60494. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60495. /**
  60496. * Release resources
  60497. */
  60498. dispose(): void;
  60499. }
  60500. }
  60501. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  60502. /**
  60503. * Enum defining the type of animations supported by InputBlock
  60504. */
  60505. export enum AnimatedInputBlockTypes {
  60506. /** No animation */
  60507. None = 0,
  60508. /** Time based animation. Will only work for floats */
  60509. Time = 1
  60510. }
  60511. }
  60512. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  60513. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60514. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60515. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  60516. import { Nullable } from "babylonjs/types";
  60517. import { Effect } from "babylonjs/Materials/effect";
  60518. import { Matrix } from "babylonjs/Maths/math.vector";
  60519. import { Scene } from "babylonjs/scene";
  60520. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60521. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60522. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60523. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  60524. /**
  60525. * Block used to expose an input value
  60526. */
  60527. export class InputBlock extends NodeMaterialBlock {
  60528. private _mode;
  60529. private _associatedVariableName;
  60530. private _storedValue;
  60531. private _valueCallback;
  60532. private _type;
  60533. private _animationType;
  60534. /** Gets or set a value used to limit the range of float values */
  60535. min: number;
  60536. /** Gets or set a value used to limit the range of float values */
  60537. max: number;
  60538. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  60539. isBoolean: boolean;
  60540. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  60541. matrixMode: number;
  60542. /** @hidden */
  60543. _systemValue: Nullable<NodeMaterialSystemValues>;
  60544. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  60545. visibleInInspector: boolean;
  60546. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  60547. isConstant: boolean;
  60548. /** Gets or sets the group to use to display this block in the Inspector */
  60549. groupInInspector: string;
  60550. /**
  60551. * Gets or sets the connection point type (default is float)
  60552. */
  60553. get type(): NodeMaterialBlockConnectionPointTypes;
  60554. /**
  60555. * Creates a new InputBlock
  60556. * @param name defines the block name
  60557. * @param target defines the target of that block (Vertex by default)
  60558. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  60559. */
  60560. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  60561. /**
  60562. * Gets the output component
  60563. */
  60564. get output(): NodeMaterialConnectionPoint;
  60565. /**
  60566. * Set the source of this connection point to a vertex attribute
  60567. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  60568. * @returns the current connection point
  60569. */
  60570. setAsAttribute(attributeName?: string): InputBlock;
  60571. /**
  60572. * Set the source of this connection point to a system value
  60573. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  60574. * @returns the current connection point
  60575. */
  60576. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  60577. /**
  60578. * Gets or sets the value of that point.
  60579. * Please note that this value will be ignored if valueCallback is defined
  60580. */
  60581. get value(): any;
  60582. set value(value: any);
  60583. /**
  60584. * Gets or sets a callback used to get the value of that point.
  60585. * Please note that setting this value will force the connection point to ignore the value property
  60586. */
  60587. get valueCallback(): () => any;
  60588. set valueCallback(value: () => any);
  60589. /**
  60590. * Gets or sets the associated variable name in the shader
  60591. */
  60592. get associatedVariableName(): string;
  60593. set associatedVariableName(value: string);
  60594. /** Gets or sets the type of animation applied to the input */
  60595. get animationType(): AnimatedInputBlockTypes;
  60596. set animationType(value: AnimatedInputBlockTypes);
  60597. /**
  60598. * Gets a boolean indicating that this connection point not defined yet
  60599. */
  60600. get isUndefined(): boolean;
  60601. /**
  60602. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  60603. * In this case the connection point name must be the name of the uniform to use.
  60604. * Can only be set on inputs
  60605. */
  60606. get isUniform(): boolean;
  60607. set isUniform(value: boolean);
  60608. /**
  60609. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  60610. * In this case the connection point name must be the name of the attribute to use
  60611. * Can only be set on inputs
  60612. */
  60613. get isAttribute(): boolean;
  60614. set isAttribute(value: boolean);
  60615. /**
  60616. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  60617. * Can only be set on exit points
  60618. */
  60619. get isVarying(): boolean;
  60620. set isVarying(value: boolean);
  60621. /**
  60622. * Gets a boolean indicating that the current connection point is a system value
  60623. */
  60624. get isSystemValue(): boolean;
  60625. /**
  60626. * Gets or sets the current well known value or null if not defined as a system value
  60627. */
  60628. get systemValue(): Nullable<NodeMaterialSystemValues>;
  60629. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  60630. /**
  60631. * Gets the current class name
  60632. * @returns the class name
  60633. */
  60634. getClassName(): string;
  60635. /**
  60636. * Animate the input if animationType !== None
  60637. * @param scene defines the rendering scene
  60638. */
  60639. animate(scene: Scene): void;
  60640. private _emitDefine;
  60641. initialize(state: NodeMaterialBuildState): void;
  60642. /**
  60643. * Set the input block to its default value (based on its type)
  60644. */
  60645. setDefaultValue(): void;
  60646. private _emitConstant;
  60647. private _emit;
  60648. /** @hidden */
  60649. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  60650. /** @hidden */
  60651. _transmit(effect: Effect, scene: Scene): void;
  60652. protected _buildBlock(state: NodeMaterialBuildState): void;
  60653. protected _dumpPropertiesCode(): string;
  60654. serialize(): any;
  60655. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60656. }
  60657. }
  60658. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  60659. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60660. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60661. import { Nullable } from "babylonjs/types";
  60662. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60663. import { Observable } from "babylonjs/Misc/observable";
  60664. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60665. /**
  60666. * Enum used to define the compatibility state between two connection points
  60667. */
  60668. export enum NodeMaterialConnectionPointCompatibilityStates {
  60669. /** Points are compatibles */
  60670. Compatible = 0,
  60671. /** Points are incompatible because of their types */
  60672. TypeIncompatible = 1,
  60673. /** Points are incompatible because of their targets (vertex vs fragment) */
  60674. TargetIncompatible = 2
  60675. }
  60676. /**
  60677. * Defines the direction of a connection point
  60678. */
  60679. export enum NodeMaterialConnectionPointDirection {
  60680. /** Input */
  60681. Input = 0,
  60682. /** Output */
  60683. Output = 1
  60684. }
  60685. /**
  60686. * Defines a connection point for a block
  60687. */
  60688. export class NodeMaterialConnectionPoint {
  60689. /** @hidden */
  60690. _ownerBlock: NodeMaterialBlock;
  60691. /** @hidden */
  60692. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  60693. private _endpoints;
  60694. private _associatedVariableName;
  60695. private _direction;
  60696. /** @hidden */
  60697. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  60698. /** @hidden */
  60699. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  60700. private _type;
  60701. /** @hidden */
  60702. _enforceAssociatedVariableName: boolean;
  60703. /** Gets the direction of the point */
  60704. get direction(): NodeMaterialConnectionPointDirection;
  60705. /**
  60706. * Gets or sets the additional types supported by this connection point
  60707. */
  60708. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  60709. /**
  60710. * Gets or sets the additional types excluded by this connection point
  60711. */
  60712. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  60713. /**
  60714. * Observable triggered when this point is connected
  60715. */
  60716. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  60717. /**
  60718. * Gets or sets the associated variable name in the shader
  60719. */
  60720. get associatedVariableName(): string;
  60721. set associatedVariableName(value: string);
  60722. /** Get the inner type (ie AutoDetect for isntance instead of the inferred one) */
  60723. get innerType(): NodeMaterialBlockConnectionPointTypes;
  60724. /**
  60725. * Gets or sets the connection point type (default is float)
  60726. */
  60727. get type(): NodeMaterialBlockConnectionPointTypes;
  60728. set type(value: NodeMaterialBlockConnectionPointTypes);
  60729. /**
  60730. * Gets or sets the connection point name
  60731. */
  60732. name: string;
  60733. /**
  60734. * Gets or sets a boolean indicating that this connection point can be omitted
  60735. */
  60736. isOptional: boolean;
  60737. /**
  60738. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  60739. */
  60740. define: string;
  60741. /** @hidden */
  60742. _prioritizeVertex: boolean;
  60743. private _target;
  60744. /** Gets or sets the target of that connection point */
  60745. get target(): NodeMaterialBlockTargets;
  60746. set target(value: NodeMaterialBlockTargets);
  60747. /**
  60748. * Gets a boolean indicating that the current point is connected
  60749. */
  60750. get isConnected(): boolean;
  60751. /**
  60752. * Gets a boolean indicating that the current point is connected to an input block
  60753. */
  60754. get isConnectedToInputBlock(): boolean;
  60755. /**
  60756. * Gets a the connected input block (if any)
  60757. */
  60758. get connectInputBlock(): Nullable<InputBlock>;
  60759. /** Get the other side of the connection (if any) */
  60760. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  60761. /** Get the block that owns this connection point */
  60762. get ownerBlock(): NodeMaterialBlock;
  60763. /** Get the block connected on the other side of this connection (if any) */
  60764. get sourceBlock(): Nullable<NodeMaterialBlock>;
  60765. /** Get the block connected on the endpoints of this connection (if any) */
  60766. get connectedBlocks(): Array<NodeMaterialBlock>;
  60767. /** Gets the list of connected endpoints */
  60768. get endpoints(): NodeMaterialConnectionPoint[];
  60769. /** Gets a boolean indicating if that output point is connected to at least one input */
  60770. get hasEndpoints(): boolean;
  60771. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  60772. get isConnectedInVertexShader(): boolean;
  60773. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  60774. get isConnectedInFragmentShader(): boolean;
  60775. /**
  60776. * Creates a new connection point
  60777. * @param name defines the connection point name
  60778. * @param ownerBlock defines the block hosting this connection point
  60779. * @param direction defines the direction of the connection point
  60780. */
  60781. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  60782. /**
  60783. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  60784. * @returns the class name
  60785. */
  60786. getClassName(): string;
  60787. /**
  60788. * Gets a boolean indicating if the current point can be connected to another point
  60789. * @param connectionPoint defines the other connection point
  60790. * @returns a boolean
  60791. */
  60792. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  60793. /**
  60794. * Gets a number indicating if the current point can be connected to another point
  60795. * @param connectionPoint defines the other connection point
  60796. * @returns a number defining the compatibility state
  60797. */
  60798. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  60799. /**
  60800. * Connect this point to another connection point
  60801. * @param connectionPoint defines the other connection point
  60802. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  60803. * @returns the current connection point
  60804. */
  60805. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  60806. /**
  60807. * Disconnect this point from one of his endpoint
  60808. * @param endpoint defines the other connection point
  60809. * @returns the current connection point
  60810. */
  60811. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  60812. /**
  60813. * Serializes this point in a JSON representation
  60814. * @returns the serialized point object
  60815. */
  60816. serialize(): any;
  60817. /**
  60818. * Release resources
  60819. */
  60820. dispose(): void;
  60821. }
  60822. }
  60823. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  60824. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60825. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60826. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60827. import { Mesh } from "babylonjs/Meshes/mesh";
  60828. import { Effect } from "babylonjs/Materials/effect";
  60829. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60830. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60831. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60832. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60833. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  60834. /**
  60835. * Block used to add support for vertex skinning (bones)
  60836. */
  60837. export class BonesBlock extends NodeMaterialBlock {
  60838. /**
  60839. * Creates a new BonesBlock
  60840. * @param name defines the block name
  60841. */
  60842. constructor(name: string);
  60843. /**
  60844. * Initialize the block and prepare the context for build
  60845. * @param state defines the state that will be used for the build
  60846. */
  60847. initialize(state: NodeMaterialBuildState): void;
  60848. /**
  60849. * Gets the current class name
  60850. * @returns the class name
  60851. */
  60852. getClassName(): string;
  60853. /**
  60854. * Gets the matrix indices input component
  60855. */
  60856. get matricesIndices(): NodeMaterialConnectionPoint;
  60857. /**
  60858. * Gets the matrix weights input component
  60859. */
  60860. get matricesWeights(): NodeMaterialConnectionPoint;
  60861. /**
  60862. * Gets the extra matrix indices input component
  60863. */
  60864. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  60865. /**
  60866. * Gets the extra matrix weights input component
  60867. */
  60868. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  60869. /**
  60870. * Gets the world input component
  60871. */
  60872. get world(): NodeMaterialConnectionPoint;
  60873. /**
  60874. * Gets the output component
  60875. */
  60876. get output(): NodeMaterialConnectionPoint;
  60877. autoConfigure(material: NodeMaterial): void;
  60878. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  60879. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60880. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60881. protected _buildBlock(state: NodeMaterialBuildState): this;
  60882. }
  60883. }
  60884. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  60885. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60886. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60887. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60888. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60889. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60890. /**
  60891. * Block used to add support for instances
  60892. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  60893. */
  60894. export class InstancesBlock extends NodeMaterialBlock {
  60895. /**
  60896. * Creates a new InstancesBlock
  60897. * @param name defines the block name
  60898. */
  60899. constructor(name: string);
  60900. /**
  60901. * Gets the current class name
  60902. * @returns the class name
  60903. */
  60904. getClassName(): string;
  60905. /**
  60906. * Gets the first world row input component
  60907. */
  60908. get world0(): NodeMaterialConnectionPoint;
  60909. /**
  60910. * Gets the second world row input component
  60911. */
  60912. get world1(): NodeMaterialConnectionPoint;
  60913. /**
  60914. * Gets the third world row input component
  60915. */
  60916. get world2(): NodeMaterialConnectionPoint;
  60917. /**
  60918. * Gets the forth world row input component
  60919. */
  60920. get world3(): NodeMaterialConnectionPoint;
  60921. /**
  60922. * Gets the world input component
  60923. */
  60924. get world(): NodeMaterialConnectionPoint;
  60925. /**
  60926. * Gets the output component
  60927. */
  60928. get output(): NodeMaterialConnectionPoint;
  60929. /**
  60930. * Gets the isntanceID component
  60931. */
  60932. get instanceID(): NodeMaterialConnectionPoint;
  60933. autoConfigure(material: NodeMaterial): void;
  60934. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60935. protected _buildBlock(state: NodeMaterialBuildState): this;
  60936. }
  60937. }
  60938. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  60939. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60940. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60941. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60942. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60943. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60944. import { Effect } from "babylonjs/Materials/effect";
  60945. import { Mesh } from "babylonjs/Meshes/mesh";
  60946. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60947. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60948. /**
  60949. * Block used to add morph targets support to vertex shader
  60950. */
  60951. export class MorphTargetsBlock extends NodeMaterialBlock {
  60952. private _repeatableContentAnchor;
  60953. /**
  60954. * Create a new MorphTargetsBlock
  60955. * @param name defines the block name
  60956. */
  60957. constructor(name: string);
  60958. /**
  60959. * Gets the current class name
  60960. * @returns the class name
  60961. */
  60962. getClassName(): string;
  60963. /**
  60964. * Gets the position input component
  60965. */
  60966. get position(): NodeMaterialConnectionPoint;
  60967. /**
  60968. * Gets the normal input component
  60969. */
  60970. get normal(): NodeMaterialConnectionPoint;
  60971. /**
  60972. * Gets the tangent input component
  60973. */
  60974. get tangent(): NodeMaterialConnectionPoint;
  60975. /**
  60976. * Gets the tangent input component
  60977. */
  60978. get uv(): NodeMaterialConnectionPoint;
  60979. /**
  60980. * Gets the position output component
  60981. */
  60982. get positionOutput(): NodeMaterialConnectionPoint;
  60983. /**
  60984. * Gets the normal output component
  60985. */
  60986. get normalOutput(): NodeMaterialConnectionPoint;
  60987. /**
  60988. * Gets the tangent output component
  60989. */
  60990. get tangentOutput(): NodeMaterialConnectionPoint;
  60991. /**
  60992. * Gets the tangent output component
  60993. */
  60994. get uvOutput(): NodeMaterialConnectionPoint;
  60995. initialize(state: NodeMaterialBuildState): void;
  60996. autoConfigure(material: NodeMaterial): void;
  60997. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60998. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60999. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  61000. protected _buildBlock(state: NodeMaterialBuildState): this;
  61001. }
  61002. }
  61003. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  61004. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61005. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61006. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61007. import { Nullable } from "babylonjs/types";
  61008. import { Scene } from "babylonjs/scene";
  61009. import { Effect } from "babylonjs/Materials/effect";
  61010. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61011. import { Mesh } from "babylonjs/Meshes/mesh";
  61012. import { Light } from "babylonjs/Lights/light";
  61013. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61014. /**
  61015. * Block used to get data information from a light
  61016. */
  61017. export class LightInformationBlock extends NodeMaterialBlock {
  61018. private _lightDataUniformName;
  61019. private _lightColorUniformName;
  61020. private _lightTypeDefineName;
  61021. /**
  61022. * Gets or sets the light associated with this block
  61023. */
  61024. light: Nullable<Light>;
  61025. /**
  61026. * Creates a new LightInformationBlock
  61027. * @param name defines the block name
  61028. */
  61029. constructor(name: string);
  61030. /**
  61031. * Gets the current class name
  61032. * @returns the class name
  61033. */
  61034. getClassName(): string;
  61035. /**
  61036. * Gets the world position input component
  61037. */
  61038. get worldPosition(): NodeMaterialConnectionPoint;
  61039. /**
  61040. * Gets the direction output component
  61041. */
  61042. get direction(): NodeMaterialConnectionPoint;
  61043. /**
  61044. * Gets the direction output component
  61045. */
  61046. get color(): NodeMaterialConnectionPoint;
  61047. /**
  61048. * Gets the direction output component
  61049. */
  61050. get intensity(): NodeMaterialConnectionPoint;
  61051. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61052. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61053. protected _buildBlock(state: NodeMaterialBuildState): this;
  61054. serialize(): any;
  61055. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61056. }
  61057. }
  61058. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  61059. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  61060. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  61061. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  61062. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  61063. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  61064. }
  61065. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  61066. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61067. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61068. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61069. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61070. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61071. import { Effect } from "babylonjs/Materials/effect";
  61072. import { Mesh } from "babylonjs/Meshes/mesh";
  61073. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61074. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  61075. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  61076. /**
  61077. * Block used to add image processing support to fragment shader
  61078. */
  61079. export class ImageProcessingBlock extends NodeMaterialBlock {
  61080. /**
  61081. * Create a new ImageProcessingBlock
  61082. * @param name defines the block name
  61083. */
  61084. constructor(name: string);
  61085. /**
  61086. * Gets the current class name
  61087. * @returns the class name
  61088. */
  61089. getClassName(): string;
  61090. /**
  61091. * Gets the color input component
  61092. */
  61093. get color(): NodeMaterialConnectionPoint;
  61094. /**
  61095. * Gets the output component
  61096. */
  61097. get output(): NodeMaterialConnectionPoint;
  61098. /**
  61099. * Initialize the block and prepare the context for build
  61100. * @param state defines the state that will be used for the build
  61101. */
  61102. initialize(state: NodeMaterialBuildState): void;
  61103. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  61104. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61105. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61106. protected _buildBlock(state: NodeMaterialBuildState): this;
  61107. }
  61108. }
  61109. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  61110. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61111. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61112. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61113. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61114. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61115. import { Effect } from "babylonjs/Materials/effect";
  61116. import { Mesh } from "babylonjs/Meshes/mesh";
  61117. import { Scene } from "babylonjs/scene";
  61118. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  61119. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  61120. /**
  61121. * Block used to pertub normals based on a normal map
  61122. */
  61123. export class PerturbNormalBlock extends NodeMaterialBlock {
  61124. private _tangentSpaceParameterName;
  61125. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  61126. invertX: boolean;
  61127. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  61128. invertY: boolean;
  61129. /**
  61130. * Create a new PerturbNormalBlock
  61131. * @param name defines the block name
  61132. */
  61133. constructor(name: string);
  61134. /**
  61135. * Gets the current class name
  61136. * @returns the class name
  61137. */
  61138. getClassName(): string;
  61139. /**
  61140. * Gets the world position input component
  61141. */
  61142. get worldPosition(): NodeMaterialConnectionPoint;
  61143. /**
  61144. * Gets the world normal input component
  61145. */
  61146. get worldNormal(): NodeMaterialConnectionPoint;
  61147. /**
  61148. * Gets the world tangent input component
  61149. */
  61150. get worldTangent(): NodeMaterialConnectionPoint;
  61151. /**
  61152. * Gets the uv input component
  61153. */
  61154. get uv(): NodeMaterialConnectionPoint;
  61155. /**
  61156. * Gets the normal map color input component
  61157. */
  61158. get normalMapColor(): NodeMaterialConnectionPoint;
  61159. /**
  61160. * Gets the strength input component
  61161. */
  61162. get strength(): NodeMaterialConnectionPoint;
  61163. /**
  61164. * Gets the output component
  61165. */
  61166. get output(): NodeMaterialConnectionPoint;
  61167. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61168. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61169. autoConfigure(material: NodeMaterial): void;
  61170. protected _buildBlock(state: NodeMaterialBuildState): this;
  61171. protected _dumpPropertiesCode(): string;
  61172. serialize(): any;
  61173. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61174. }
  61175. }
  61176. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  61177. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61178. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61179. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61180. /**
  61181. * Block used to discard a pixel if a value is smaller than a cutoff
  61182. */
  61183. export class DiscardBlock extends NodeMaterialBlock {
  61184. /**
  61185. * Create a new DiscardBlock
  61186. * @param name defines the block name
  61187. */
  61188. constructor(name: string);
  61189. /**
  61190. * Gets the current class name
  61191. * @returns the class name
  61192. */
  61193. getClassName(): string;
  61194. /**
  61195. * Gets the color input component
  61196. */
  61197. get value(): NodeMaterialConnectionPoint;
  61198. /**
  61199. * Gets the cutoff input component
  61200. */
  61201. get cutoff(): NodeMaterialConnectionPoint;
  61202. protected _buildBlock(state: NodeMaterialBuildState): this;
  61203. }
  61204. }
  61205. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  61206. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61207. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61208. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61209. /**
  61210. * Block used to test if the fragment shader is front facing
  61211. */
  61212. export class FrontFacingBlock extends NodeMaterialBlock {
  61213. /**
  61214. * Creates a new FrontFacingBlock
  61215. * @param name defines the block name
  61216. */
  61217. constructor(name: string);
  61218. /**
  61219. * Gets the current class name
  61220. * @returns the class name
  61221. */
  61222. getClassName(): string;
  61223. /**
  61224. * Gets the output component
  61225. */
  61226. get output(): NodeMaterialConnectionPoint;
  61227. protected _buildBlock(state: NodeMaterialBuildState): this;
  61228. }
  61229. }
  61230. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  61231. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61232. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61233. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61234. /**
  61235. * Block used to get the derivative value on x and y of a given input
  61236. */
  61237. export class DerivativeBlock extends NodeMaterialBlock {
  61238. /**
  61239. * Create a new DerivativeBlock
  61240. * @param name defines the block name
  61241. */
  61242. constructor(name: string);
  61243. /**
  61244. * Gets the current class name
  61245. * @returns the class name
  61246. */
  61247. getClassName(): string;
  61248. /**
  61249. * Gets the input component
  61250. */
  61251. get input(): NodeMaterialConnectionPoint;
  61252. /**
  61253. * Gets the derivative output on x
  61254. */
  61255. get dx(): NodeMaterialConnectionPoint;
  61256. /**
  61257. * Gets the derivative output on y
  61258. */
  61259. get dy(): NodeMaterialConnectionPoint;
  61260. protected _buildBlock(state: NodeMaterialBuildState): this;
  61261. }
  61262. }
  61263. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  61264. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  61265. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  61266. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  61267. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  61268. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  61269. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  61270. }
  61271. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  61272. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61273. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61274. import { Mesh } from "babylonjs/Meshes/mesh";
  61275. import { Effect } from "babylonjs/Materials/effect";
  61276. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61277. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61278. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61279. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  61280. /**
  61281. * Block used to add support for scene fog
  61282. */
  61283. export class FogBlock extends NodeMaterialBlock {
  61284. private _fogDistanceName;
  61285. private _fogParameters;
  61286. /**
  61287. * Create a new FogBlock
  61288. * @param name defines the block name
  61289. */
  61290. constructor(name: string);
  61291. /**
  61292. * Gets the current class name
  61293. * @returns the class name
  61294. */
  61295. getClassName(): string;
  61296. /**
  61297. * Gets the world position input component
  61298. */
  61299. get worldPosition(): NodeMaterialConnectionPoint;
  61300. /**
  61301. * Gets the view input component
  61302. */
  61303. get view(): NodeMaterialConnectionPoint;
  61304. /**
  61305. * Gets the color input component
  61306. */
  61307. get input(): NodeMaterialConnectionPoint;
  61308. /**
  61309. * Gets the fog color input component
  61310. */
  61311. get fogColor(): NodeMaterialConnectionPoint;
  61312. /**
  61313. * Gets the output component
  61314. */
  61315. get output(): NodeMaterialConnectionPoint;
  61316. autoConfigure(material: NodeMaterial): void;
  61317. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61318. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61319. protected _buildBlock(state: NodeMaterialBuildState): this;
  61320. }
  61321. }
  61322. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  61323. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61324. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61325. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61326. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61327. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61328. import { Effect } from "babylonjs/Materials/effect";
  61329. import { Mesh } from "babylonjs/Meshes/mesh";
  61330. import { Light } from "babylonjs/Lights/light";
  61331. import { Nullable } from "babylonjs/types";
  61332. import { Scene } from "babylonjs/scene";
  61333. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  61334. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  61335. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  61336. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61337. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  61338. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  61339. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  61340. /**
  61341. * Block used to add light in the fragment shader
  61342. */
  61343. export class LightBlock extends NodeMaterialBlock {
  61344. private _lightId;
  61345. /**
  61346. * Gets or sets the light associated with this block
  61347. */
  61348. light: Nullable<Light>;
  61349. /**
  61350. * Create a new LightBlock
  61351. * @param name defines the block name
  61352. */
  61353. constructor(name: string);
  61354. /**
  61355. * Gets the current class name
  61356. * @returns the class name
  61357. */
  61358. getClassName(): string;
  61359. /**
  61360. * Gets the world position input component
  61361. */
  61362. get worldPosition(): NodeMaterialConnectionPoint;
  61363. /**
  61364. * Gets the world normal input component
  61365. */
  61366. get worldNormal(): NodeMaterialConnectionPoint;
  61367. /**
  61368. * Gets the camera (or eye) position component
  61369. */
  61370. get cameraPosition(): NodeMaterialConnectionPoint;
  61371. /**
  61372. * Gets the glossiness component
  61373. */
  61374. get glossiness(): NodeMaterialConnectionPoint;
  61375. /**
  61376. * Gets the glossinness power component
  61377. */
  61378. get glossPower(): NodeMaterialConnectionPoint;
  61379. /**
  61380. * Gets the diffuse color component
  61381. */
  61382. get diffuseColor(): NodeMaterialConnectionPoint;
  61383. /**
  61384. * Gets the specular color component
  61385. */
  61386. get specularColor(): NodeMaterialConnectionPoint;
  61387. /**
  61388. * Gets the diffuse output component
  61389. */
  61390. get diffuseOutput(): NodeMaterialConnectionPoint;
  61391. /**
  61392. * Gets the specular output component
  61393. */
  61394. get specularOutput(): NodeMaterialConnectionPoint;
  61395. /**
  61396. * Gets the shadow output component
  61397. */
  61398. get shadow(): NodeMaterialConnectionPoint;
  61399. autoConfigure(material: NodeMaterial): void;
  61400. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61401. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  61402. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61403. private _injectVertexCode;
  61404. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61405. serialize(): any;
  61406. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61407. }
  61408. }
  61409. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  61410. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  61411. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  61412. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  61413. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  61414. }
  61415. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  61416. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  61417. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  61418. }
  61419. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  61420. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61421. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61422. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61423. /**
  61424. * Block used to multiply 2 values
  61425. */
  61426. export class MultiplyBlock extends NodeMaterialBlock {
  61427. /**
  61428. * Creates a new MultiplyBlock
  61429. * @param name defines the block name
  61430. */
  61431. constructor(name: string);
  61432. /**
  61433. * Gets the current class name
  61434. * @returns the class name
  61435. */
  61436. getClassName(): string;
  61437. /**
  61438. * Gets the left operand input component
  61439. */
  61440. get left(): NodeMaterialConnectionPoint;
  61441. /**
  61442. * Gets the right operand input component
  61443. */
  61444. get right(): NodeMaterialConnectionPoint;
  61445. /**
  61446. * Gets the output component
  61447. */
  61448. get output(): NodeMaterialConnectionPoint;
  61449. protected _buildBlock(state: NodeMaterialBuildState): this;
  61450. }
  61451. }
  61452. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  61453. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61454. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61455. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61456. /**
  61457. * Block used to add 2 vectors
  61458. */
  61459. export class AddBlock extends NodeMaterialBlock {
  61460. /**
  61461. * Creates a new AddBlock
  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 left operand input component
  61472. */
  61473. get left(): NodeMaterialConnectionPoint;
  61474. /**
  61475. * Gets the right operand input component
  61476. */
  61477. get right(): NodeMaterialConnectionPoint;
  61478. /**
  61479. * Gets the output component
  61480. */
  61481. get output(): NodeMaterialConnectionPoint;
  61482. protected _buildBlock(state: NodeMaterialBuildState): this;
  61483. }
  61484. }
  61485. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  61486. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61487. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61488. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61489. /**
  61490. * Block used to scale a vector by a float
  61491. */
  61492. export class ScaleBlock extends NodeMaterialBlock {
  61493. /**
  61494. * Creates a new ScaleBlock
  61495. * @param name defines the block name
  61496. */
  61497. constructor(name: string);
  61498. /**
  61499. * Gets the current class name
  61500. * @returns the class name
  61501. */
  61502. getClassName(): string;
  61503. /**
  61504. * Gets the input component
  61505. */
  61506. get input(): NodeMaterialConnectionPoint;
  61507. /**
  61508. * Gets the factor input component
  61509. */
  61510. get factor(): NodeMaterialConnectionPoint;
  61511. /**
  61512. * Gets the output component
  61513. */
  61514. get output(): NodeMaterialConnectionPoint;
  61515. protected _buildBlock(state: NodeMaterialBuildState): this;
  61516. }
  61517. }
  61518. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  61519. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61520. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61521. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61522. import { Scene } from "babylonjs/scene";
  61523. /**
  61524. * Block used to clamp a float
  61525. */
  61526. export class ClampBlock extends NodeMaterialBlock {
  61527. /** Gets or sets the minimum range */
  61528. minimum: number;
  61529. /** Gets or sets the maximum range */
  61530. maximum: number;
  61531. /**
  61532. * Creates a new ClampBlock
  61533. * @param name defines the block name
  61534. */
  61535. constructor(name: string);
  61536. /**
  61537. * Gets the current class name
  61538. * @returns the class name
  61539. */
  61540. getClassName(): string;
  61541. /**
  61542. * Gets the value input component
  61543. */
  61544. get value(): NodeMaterialConnectionPoint;
  61545. /**
  61546. * Gets the output component
  61547. */
  61548. get output(): NodeMaterialConnectionPoint;
  61549. protected _buildBlock(state: NodeMaterialBuildState): this;
  61550. protected _dumpPropertiesCode(): string;
  61551. serialize(): any;
  61552. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61553. }
  61554. }
  61555. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  61556. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61557. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61558. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61559. /**
  61560. * Block used to apply a cross product between 2 vectors
  61561. */
  61562. export class CrossBlock extends NodeMaterialBlock {
  61563. /**
  61564. * Creates a new CrossBlock
  61565. * @param name defines the block name
  61566. */
  61567. constructor(name: string);
  61568. /**
  61569. * Gets the current class name
  61570. * @returns the class name
  61571. */
  61572. getClassName(): string;
  61573. /**
  61574. * Gets the left operand input component
  61575. */
  61576. get left(): NodeMaterialConnectionPoint;
  61577. /**
  61578. * Gets the right operand input component
  61579. */
  61580. get right(): NodeMaterialConnectionPoint;
  61581. /**
  61582. * Gets the output component
  61583. */
  61584. get output(): NodeMaterialConnectionPoint;
  61585. protected _buildBlock(state: NodeMaterialBuildState): this;
  61586. }
  61587. }
  61588. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  61589. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61590. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61591. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61592. /**
  61593. * Block used to apply a dot product between 2 vectors
  61594. */
  61595. export class DotBlock extends NodeMaterialBlock {
  61596. /**
  61597. * Creates a new DotBlock
  61598. * @param name defines the block name
  61599. */
  61600. constructor(name: string);
  61601. /**
  61602. * Gets the current class name
  61603. * @returns the class name
  61604. */
  61605. getClassName(): string;
  61606. /**
  61607. * Gets the left operand input component
  61608. */
  61609. get left(): NodeMaterialConnectionPoint;
  61610. /**
  61611. * Gets the right operand input component
  61612. */
  61613. get right(): NodeMaterialConnectionPoint;
  61614. /**
  61615. * Gets the output component
  61616. */
  61617. get output(): NodeMaterialConnectionPoint;
  61618. protected _buildBlock(state: NodeMaterialBuildState): this;
  61619. }
  61620. }
  61621. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  61622. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61623. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61624. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61625. import { Vector2 } from "babylonjs/Maths/math.vector";
  61626. import { Scene } from "babylonjs/scene";
  61627. /**
  61628. * Block used to remap a float from a range to a new one
  61629. */
  61630. export class RemapBlock extends NodeMaterialBlock {
  61631. /**
  61632. * Gets or sets the source range
  61633. */
  61634. sourceRange: Vector2;
  61635. /**
  61636. * Gets or sets the target range
  61637. */
  61638. targetRange: Vector2;
  61639. /**
  61640. * Creates a new RemapBlock
  61641. * @param name defines the block name
  61642. */
  61643. constructor(name: string);
  61644. /**
  61645. * Gets the current class name
  61646. * @returns the class name
  61647. */
  61648. getClassName(): string;
  61649. /**
  61650. * Gets the input component
  61651. */
  61652. get input(): NodeMaterialConnectionPoint;
  61653. /**
  61654. * Gets the source min input component
  61655. */
  61656. get sourceMin(): NodeMaterialConnectionPoint;
  61657. /**
  61658. * Gets the source max input component
  61659. */
  61660. get sourceMax(): NodeMaterialConnectionPoint;
  61661. /**
  61662. * Gets the target min input component
  61663. */
  61664. get targetMin(): NodeMaterialConnectionPoint;
  61665. /**
  61666. * Gets the target max input component
  61667. */
  61668. get targetMax(): NodeMaterialConnectionPoint;
  61669. /**
  61670. * Gets the output component
  61671. */
  61672. get output(): NodeMaterialConnectionPoint;
  61673. protected _buildBlock(state: NodeMaterialBuildState): this;
  61674. protected _dumpPropertiesCode(): string;
  61675. serialize(): any;
  61676. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61677. }
  61678. }
  61679. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  61680. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61681. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61682. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61683. /**
  61684. * Block used to normalize a vector
  61685. */
  61686. export class NormalizeBlock extends NodeMaterialBlock {
  61687. /**
  61688. * Creates a new NormalizeBlock
  61689. * @param name defines the block name
  61690. */
  61691. constructor(name: string);
  61692. /**
  61693. * Gets the current class name
  61694. * @returns the class name
  61695. */
  61696. getClassName(): string;
  61697. /**
  61698. * Gets the input component
  61699. */
  61700. get input(): NodeMaterialConnectionPoint;
  61701. /**
  61702. * Gets the output component
  61703. */
  61704. get output(): NodeMaterialConnectionPoint;
  61705. protected _buildBlock(state: NodeMaterialBuildState): this;
  61706. }
  61707. }
  61708. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  61709. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61710. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61711. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61712. import { Scene } from "babylonjs/scene";
  61713. /**
  61714. * Operations supported by the Trigonometry block
  61715. */
  61716. export enum TrigonometryBlockOperations {
  61717. /** Cos */
  61718. Cos = 0,
  61719. /** Sin */
  61720. Sin = 1,
  61721. /** Abs */
  61722. Abs = 2,
  61723. /** Exp */
  61724. Exp = 3,
  61725. /** Exp2 */
  61726. Exp2 = 4,
  61727. /** Round */
  61728. Round = 5,
  61729. /** Floor */
  61730. Floor = 6,
  61731. /** Ceiling */
  61732. Ceiling = 7,
  61733. /** Square root */
  61734. Sqrt = 8,
  61735. /** Log */
  61736. Log = 9,
  61737. /** Tangent */
  61738. Tan = 10,
  61739. /** Arc tangent */
  61740. ArcTan = 11,
  61741. /** Arc cosinus */
  61742. ArcCos = 12,
  61743. /** Arc sinus */
  61744. ArcSin = 13,
  61745. /** Fraction */
  61746. Fract = 14,
  61747. /** Sign */
  61748. Sign = 15,
  61749. /** To radians (from degrees) */
  61750. Radians = 16,
  61751. /** To degrees (from radians) */
  61752. Degrees = 17
  61753. }
  61754. /**
  61755. * Block used to apply trigonometry operation to floats
  61756. */
  61757. export class TrigonometryBlock extends NodeMaterialBlock {
  61758. /**
  61759. * Gets or sets the operation applied by the block
  61760. */
  61761. operation: TrigonometryBlockOperations;
  61762. /**
  61763. * Creates a new TrigonometryBlock
  61764. * @param name defines the block name
  61765. */
  61766. constructor(name: string);
  61767. /**
  61768. * Gets the current class name
  61769. * @returns the class name
  61770. */
  61771. getClassName(): string;
  61772. /**
  61773. * Gets the input component
  61774. */
  61775. get input(): NodeMaterialConnectionPoint;
  61776. /**
  61777. * Gets the output component
  61778. */
  61779. get output(): NodeMaterialConnectionPoint;
  61780. protected _buildBlock(state: NodeMaterialBuildState): this;
  61781. serialize(): any;
  61782. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61783. protected _dumpPropertiesCode(): string;
  61784. }
  61785. }
  61786. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  61787. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61788. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61789. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61790. /**
  61791. * Block used to create a Color3/4 out of individual inputs (one for each component)
  61792. */
  61793. export class ColorMergerBlock extends NodeMaterialBlock {
  61794. /**
  61795. * Create a new ColorMergerBlock
  61796. * @param name defines the block name
  61797. */
  61798. constructor(name: string);
  61799. /**
  61800. * Gets the current class name
  61801. * @returns the class name
  61802. */
  61803. getClassName(): string;
  61804. /**
  61805. * Gets the rgb component (input)
  61806. */
  61807. get rgbIn(): NodeMaterialConnectionPoint;
  61808. /**
  61809. * Gets the r component (input)
  61810. */
  61811. get r(): NodeMaterialConnectionPoint;
  61812. /**
  61813. * Gets the g component (input)
  61814. */
  61815. get g(): NodeMaterialConnectionPoint;
  61816. /**
  61817. * Gets the b component (input)
  61818. */
  61819. get b(): NodeMaterialConnectionPoint;
  61820. /**
  61821. * Gets the a component (input)
  61822. */
  61823. get a(): NodeMaterialConnectionPoint;
  61824. /**
  61825. * Gets the rgba component (output)
  61826. */
  61827. get rgba(): NodeMaterialConnectionPoint;
  61828. /**
  61829. * Gets the rgb component (output)
  61830. */
  61831. get rgbOut(): NodeMaterialConnectionPoint;
  61832. /**
  61833. * Gets the rgb component (output)
  61834. * @deprecated Please use rgbOut instead.
  61835. */
  61836. get rgb(): NodeMaterialConnectionPoint;
  61837. protected _buildBlock(state: NodeMaterialBuildState): this;
  61838. }
  61839. }
  61840. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  61841. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61842. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61843. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61844. /**
  61845. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  61846. */
  61847. export class VectorMergerBlock extends NodeMaterialBlock {
  61848. /**
  61849. * Create a new VectorMergerBlock
  61850. * @param name defines the block name
  61851. */
  61852. constructor(name: string);
  61853. /**
  61854. * Gets the current class name
  61855. * @returns the class name
  61856. */
  61857. getClassName(): string;
  61858. /**
  61859. * Gets the xyz component (input)
  61860. */
  61861. get xyzIn(): NodeMaterialConnectionPoint;
  61862. /**
  61863. * Gets the xy component (input)
  61864. */
  61865. get xyIn(): NodeMaterialConnectionPoint;
  61866. /**
  61867. * Gets the x component (input)
  61868. */
  61869. get x(): NodeMaterialConnectionPoint;
  61870. /**
  61871. * Gets the y component (input)
  61872. */
  61873. get y(): NodeMaterialConnectionPoint;
  61874. /**
  61875. * Gets the z component (input)
  61876. */
  61877. get z(): NodeMaterialConnectionPoint;
  61878. /**
  61879. * Gets the w component (input)
  61880. */
  61881. get w(): NodeMaterialConnectionPoint;
  61882. /**
  61883. * Gets the xyzw component (output)
  61884. */
  61885. get xyzw(): NodeMaterialConnectionPoint;
  61886. /**
  61887. * Gets the xyz component (output)
  61888. */
  61889. get xyzOut(): NodeMaterialConnectionPoint;
  61890. /**
  61891. * Gets the xy component (output)
  61892. */
  61893. get xyOut(): NodeMaterialConnectionPoint;
  61894. /**
  61895. * Gets the xy component (output)
  61896. * @deprecated Please use xyOut instead.
  61897. */
  61898. get xy(): NodeMaterialConnectionPoint;
  61899. /**
  61900. * Gets the xyz component (output)
  61901. * @deprecated Please use xyzOut instead.
  61902. */
  61903. get xyz(): NodeMaterialConnectionPoint;
  61904. protected _buildBlock(state: NodeMaterialBuildState): this;
  61905. }
  61906. }
  61907. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  61908. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61909. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61910. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61911. /**
  61912. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  61913. */
  61914. export class ColorSplitterBlock extends NodeMaterialBlock {
  61915. /**
  61916. * Create a new ColorSplitterBlock
  61917. * @param name defines the block name
  61918. */
  61919. constructor(name: string);
  61920. /**
  61921. * Gets the current class name
  61922. * @returns the class name
  61923. */
  61924. getClassName(): string;
  61925. /**
  61926. * Gets the rgba component (input)
  61927. */
  61928. get rgba(): NodeMaterialConnectionPoint;
  61929. /**
  61930. * Gets the rgb component (input)
  61931. */
  61932. get rgbIn(): NodeMaterialConnectionPoint;
  61933. /**
  61934. * Gets the rgb component (output)
  61935. */
  61936. get rgbOut(): NodeMaterialConnectionPoint;
  61937. /**
  61938. * Gets the r component (output)
  61939. */
  61940. get r(): NodeMaterialConnectionPoint;
  61941. /**
  61942. * Gets the g component (output)
  61943. */
  61944. get g(): NodeMaterialConnectionPoint;
  61945. /**
  61946. * Gets the b component (output)
  61947. */
  61948. get b(): NodeMaterialConnectionPoint;
  61949. /**
  61950. * Gets the a component (output)
  61951. */
  61952. get a(): NodeMaterialConnectionPoint;
  61953. protected _inputRename(name: string): string;
  61954. protected _outputRename(name: string): string;
  61955. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61956. }
  61957. }
  61958. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  61959. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61960. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61961. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61962. /**
  61963. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  61964. */
  61965. export class VectorSplitterBlock extends NodeMaterialBlock {
  61966. /**
  61967. * Create a new VectorSplitterBlock
  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 xyzw component (input)
  61978. */
  61979. get xyzw(): NodeMaterialConnectionPoint;
  61980. /**
  61981. * Gets the xyz component (input)
  61982. */
  61983. get xyzIn(): NodeMaterialConnectionPoint;
  61984. /**
  61985. * Gets the xy component (input)
  61986. */
  61987. get xyIn(): NodeMaterialConnectionPoint;
  61988. /**
  61989. * Gets the xyz component (output)
  61990. */
  61991. get xyzOut(): NodeMaterialConnectionPoint;
  61992. /**
  61993. * Gets the xy component (output)
  61994. */
  61995. get xyOut(): NodeMaterialConnectionPoint;
  61996. /**
  61997. * Gets the x component (output)
  61998. */
  61999. get x(): NodeMaterialConnectionPoint;
  62000. /**
  62001. * Gets the y component (output)
  62002. */
  62003. get y(): NodeMaterialConnectionPoint;
  62004. /**
  62005. * Gets the z component (output)
  62006. */
  62007. get z(): NodeMaterialConnectionPoint;
  62008. /**
  62009. * Gets the w component (output)
  62010. */
  62011. get w(): NodeMaterialConnectionPoint;
  62012. protected _inputRename(name: string): string;
  62013. protected _outputRename(name: string): string;
  62014. protected _buildBlock(state: NodeMaterialBuildState): this;
  62015. }
  62016. }
  62017. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  62018. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62019. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62020. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62021. /**
  62022. * Block used to lerp between 2 values
  62023. */
  62024. export class LerpBlock extends NodeMaterialBlock {
  62025. /**
  62026. * Creates a new LerpBlock
  62027. * @param name defines the block name
  62028. */
  62029. constructor(name: string);
  62030. /**
  62031. * Gets the current class name
  62032. * @returns the class name
  62033. */
  62034. getClassName(): string;
  62035. /**
  62036. * Gets the left operand input component
  62037. */
  62038. get left(): NodeMaterialConnectionPoint;
  62039. /**
  62040. * Gets the right operand input component
  62041. */
  62042. get right(): NodeMaterialConnectionPoint;
  62043. /**
  62044. * Gets the gradient operand input component
  62045. */
  62046. get gradient(): NodeMaterialConnectionPoint;
  62047. /**
  62048. * Gets the output component
  62049. */
  62050. get output(): NodeMaterialConnectionPoint;
  62051. protected _buildBlock(state: NodeMaterialBuildState): this;
  62052. }
  62053. }
  62054. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  62055. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62056. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62057. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62058. /**
  62059. * Block used to divide 2 vectors
  62060. */
  62061. export class DivideBlock extends NodeMaterialBlock {
  62062. /**
  62063. * Creates a new DivideBlock
  62064. * @param name defines the block name
  62065. */
  62066. constructor(name: string);
  62067. /**
  62068. * Gets the current class name
  62069. * @returns the class name
  62070. */
  62071. getClassName(): string;
  62072. /**
  62073. * Gets the left operand input component
  62074. */
  62075. get left(): NodeMaterialConnectionPoint;
  62076. /**
  62077. * Gets the right operand input component
  62078. */
  62079. get right(): NodeMaterialConnectionPoint;
  62080. /**
  62081. * Gets the output component
  62082. */
  62083. get output(): NodeMaterialConnectionPoint;
  62084. protected _buildBlock(state: NodeMaterialBuildState): this;
  62085. }
  62086. }
  62087. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  62088. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62089. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62090. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62091. /**
  62092. * Block used to subtract 2 vectors
  62093. */
  62094. export class SubtractBlock extends NodeMaterialBlock {
  62095. /**
  62096. * Creates a new SubtractBlock
  62097. * @param name defines the block name
  62098. */
  62099. constructor(name: string);
  62100. /**
  62101. * Gets the current class name
  62102. * @returns the class name
  62103. */
  62104. getClassName(): string;
  62105. /**
  62106. * Gets the left operand input component
  62107. */
  62108. get left(): NodeMaterialConnectionPoint;
  62109. /**
  62110. * Gets the right operand input component
  62111. */
  62112. get right(): NodeMaterialConnectionPoint;
  62113. /**
  62114. * Gets the output component
  62115. */
  62116. get output(): NodeMaterialConnectionPoint;
  62117. protected _buildBlock(state: NodeMaterialBuildState): this;
  62118. }
  62119. }
  62120. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  62121. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62122. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62123. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62124. /**
  62125. * Block used to step a value
  62126. */
  62127. export class StepBlock extends NodeMaterialBlock {
  62128. /**
  62129. * Creates a new StepBlock
  62130. * @param name defines the block name
  62131. */
  62132. constructor(name: string);
  62133. /**
  62134. * Gets the current class name
  62135. * @returns the class name
  62136. */
  62137. getClassName(): string;
  62138. /**
  62139. * Gets the value operand input component
  62140. */
  62141. get value(): NodeMaterialConnectionPoint;
  62142. /**
  62143. * Gets the edge operand input component
  62144. */
  62145. get edge(): NodeMaterialConnectionPoint;
  62146. /**
  62147. * Gets the output component
  62148. */
  62149. get output(): NodeMaterialConnectionPoint;
  62150. protected _buildBlock(state: NodeMaterialBuildState): this;
  62151. }
  62152. }
  62153. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  62154. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62155. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62156. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62157. /**
  62158. * Block used to get the opposite (1 - x) of a value
  62159. */
  62160. export class OneMinusBlock extends NodeMaterialBlock {
  62161. /**
  62162. * Creates a new OneMinusBlock
  62163. * @param name defines the block name
  62164. */
  62165. constructor(name: string);
  62166. /**
  62167. * Gets the current class name
  62168. * @returns the class name
  62169. */
  62170. getClassName(): string;
  62171. /**
  62172. * Gets the input component
  62173. */
  62174. get input(): NodeMaterialConnectionPoint;
  62175. /**
  62176. * Gets the output component
  62177. */
  62178. get output(): NodeMaterialConnectionPoint;
  62179. protected _buildBlock(state: NodeMaterialBuildState): this;
  62180. }
  62181. }
  62182. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  62183. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62184. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62185. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62186. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62187. /**
  62188. * Block used to get the view direction
  62189. */
  62190. export class ViewDirectionBlock extends NodeMaterialBlock {
  62191. /**
  62192. * Creates a new ViewDirectionBlock
  62193. * @param name defines the block name
  62194. */
  62195. constructor(name: string);
  62196. /**
  62197. * Gets the current class name
  62198. * @returns the class name
  62199. */
  62200. getClassName(): string;
  62201. /**
  62202. * Gets the world position component
  62203. */
  62204. get worldPosition(): NodeMaterialConnectionPoint;
  62205. /**
  62206. * Gets the camera position component
  62207. */
  62208. get cameraPosition(): NodeMaterialConnectionPoint;
  62209. /**
  62210. * Gets the output component
  62211. */
  62212. get output(): NodeMaterialConnectionPoint;
  62213. autoConfigure(material: NodeMaterial): void;
  62214. protected _buildBlock(state: NodeMaterialBuildState): this;
  62215. }
  62216. }
  62217. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  62218. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62219. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62220. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62221. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62222. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  62223. /**
  62224. * Block used to compute fresnel value
  62225. */
  62226. export class FresnelBlock extends NodeMaterialBlock {
  62227. /**
  62228. * Create a new FresnelBlock
  62229. * @param name defines the block name
  62230. */
  62231. constructor(name: string);
  62232. /**
  62233. * Gets the current class name
  62234. * @returns the class name
  62235. */
  62236. getClassName(): string;
  62237. /**
  62238. * Gets the world normal input component
  62239. */
  62240. get worldNormal(): NodeMaterialConnectionPoint;
  62241. /**
  62242. * Gets the view direction input component
  62243. */
  62244. get viewDirection(): NodeMaterialConnectionPoint;
  62245. /**
  62246. * Gets the bias input component
  62247. */
  62248. get bias(): NodeMaterialConnectionPoint;
  62249. /**
  62250. * Gets the camera (or eye) position component
  62251. */
  62252. get power(): NodeMaterialConnectionPoint;
  62253. /**
  62254. * Gets the fresnel output component
  62255. */
  62256. get fresnel(): NodeMaterialConnectionPoint;
  62257. autoConfigure(material: NodeMaterial): void;
  62258. protected _buildBlock(state: NodeMaterialBuildState): this;
  62259. }
  62260. }
  62261. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  62262. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62263. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62264. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62265. /**
  62266. * Block used to get the max of 2 values
  62267. */
  62268. export class MaxBlock extends NodeMaterialBlock {
  62269. /**
  62270. * Creates a new MaxBlock
  62271. * @param name defines the block name
  62272. */
  62273. constructor(name: string);
  62274. /**
  62275. * Gets the current class name
  62276. * @returns the class name
  62277. */
  62278. getClassName(): string;
  62279. /**
  62280. * Gets the left operand input component
  62281. */
  62282. get left(): NodeMaterialConnectionPoint;
  62283. /**
  62284. * Gets the right operand input component
  62285. */
  62286. get right(): NodeMaterialConnectionPoint;
  62287. /**
  62288. * Gets the output component
  62289. */
  62290. get output(): NodeMaterialConnectionPoint;
  62291. protected _buildBlock(state: NodeMaterialBuildState): this;
  62292. }
  62293. }
  62294. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  62295. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62296. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62297. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62298. /**
  62299. * Block used to get the min of 2 values
  62300. */
  62301. export class MinBlock extends NodeMaterialBlock {
  62302. /**
  62303. * Creates a new MinBlock
  62304. * @param name defines the block name
  62305. */
  62306. constructor(name: string);
  62307. /**
  62308. * Gets the current class name
  62309. * @returns the class name
  62310. */
  62311. getClassName(): string;
  62312. /**
  62313. * Gets the left operand input component
  62314. */
  62315. get left(): NodeMaterialConnectionPoint;
  62316. /**
  62317. * Gets the right operand input component
  62318. */
  62319. get right(): NodeMaterialConnectionPoint;
  62320. /**
  62321. * Gets the output component
  62322. */
  62323. get output(): NodeMaterialConnectionPoint;
  62324. protected _buildBlock(state: NodeMaterialBuildState): this;
  62325. }
  62326. }
  62327. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  62328. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62329. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62330. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62331. /**
  62332. * Block used to get the distance between 2 values
  62333. */
  62334. export class DistanceBlock extends NodeMaterialBlock {
  62335. /**
  62336. * Creates a new DistanceBlock
  62337. * @param name defines the block name
  62338. */
  62339. constructor(name: string);
  62340. /**
  62341. * Gets the current class name
  62342. * @returns the class name
  62343. */
  62344. getClassName(): string;
  62345. /**
  62346. * Gets the left operand input component
  62347. */
  62348. get left(): NodeMaterialConnectionPoint;
  62349. /**
  62350. * Gets the right operand input component
  62351. */
  62352. get right(): NodeMaterialConnectionPoint;
  62353. /**
  62354. * Gets the output component
  62355. */
  62356. get output(): NodeMaterialConnectionPoint;
  62357. protected _buildBlock(state: NodeMaterialBuildState): this;
  62358. }
  62359. }
  62360. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  62361. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62362. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62363. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62364. /**
  62365. * Block used to get the length of a vector
  62366. */
  62367. export class LengthBlock extends NodeMaterialBlock {
  62368. /**
  62369. * Creates a new LengthBlock
  62370. * @param name defines the block name
  62371. */
  62372. constructor(name: string);
  62373. /**
  62374. * Gets the current class name
  62375. * @returns the class name
  62376. */
  62377. getClassName(): string;
  62378. /**
  62379. * Gets the value input component
  62380. */
  62381. get value(): NodeMaterialConnectionPoint;
  62382. /**
  62383. * Gets the output component
  62384. */
  62385. get output(): NodeMaterialConnectionPoint;
  62386. protected _buildBlock(state: NodeMaterialBuildState): this;
  62387. }
  62388. }
  62389. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  62390. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62391. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62392. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62393. /**
  62394. * Block used to get negative version of a value (i.e. x * -1)
  62395. */
  62396. export class NegateBlock extends NodeMaterialBlock {
  62397. /**
  62398. * Creates a new NegateBlock
  62399. * @param name defines the block name
  62400. */
  62401. constructor(name: string);
  62402. /**
  62403. * Gets the current class name
  62404. * @returns the class name
  62405. */
  62406. getClassName(): string;
  62407. /**
  62408. * Gets the value input component
  62409. */
  62410. get value(): NodeMaterialConnectionPoint;
  62411. /**
  62412. * Gets the output component
  62413. */
  62414. get output(): NodeMaterialConnectionPoint;
  62415. protected _buildBlock(state: NodeMaterialBuildState): this;
  62416. }
  62417. }
  62418. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  62419. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62420. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62421. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62422. /**
  62423. * Block used to get the value of the first parameter raised to the power of the second
  62424. */
  62425. export class PowBlock extends NodeMaterialBlock {
  62426. /**
  62427. * Creates a new PowBlock
  62428. * @param name defines the block name
  62429. */
  62430. constructor(name: string);
  62431. /**
  62432. * Gets the current class name
  62433. * @returns the class name
  62434. */
  62435. getClassName(): string;
  62436. /**
  62437. * Gets the value operand input component
  62438. */
  62439. get value(): NodeMaterialConnectionPoint;
  62440. /**
  62441. * Gets the power operand input component
  62442. */
  62443. get power(): NodeMaterialConnectionPoint;
  62444. /**
  62445. * Gets the output component
  62446. */
  62447. get output(): NodeMaterialConnectionPoint;
  62448. protected _buildBlock(state: NodeMaterialBuildState): this;
  62449. }
  62450. }
  62451. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  62452. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62453. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62454. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62455. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62456. /**
  62457. * Block used to get a random number
  62458. */
  62459. export class RandomNumberBlock extends NodeMaterialBlock {
  62460. /**
  62461. * Creates a new RandomNumberBlock
  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 seed input component
  62472. */
  62473. get seed(): NodeMaterialConnectionPoint;
  62474. /**
  62475. * Gets the output component
  62476. */
  62477. get output(): NodeMaterialConnectionPoint;
  62478. protected _buildBlock(state: NodeMaterialBuildState): this;
  62479. }
  62480. }
  62481. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  62482. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62483. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62484. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62485. /**
  62486. * Block used to compute arc tangent of 2 values
  62487. */
  62488. export class ArcTan2Block extends NodeMaterialBlock {
  62489. /**
  62490. * Creates a new ArcTan2Block
  62491. * @param name defines the block name
  62492. */
  62493. constructor(name: string);
  62494. /**
  62495. * Gets the current class name
  62496. * @returns the class name
  62497. */
  62498. getClassName(): string;
  62499. /**
  62500. * Gets the x operand input component
  62501. */
  62502. get x(): NodeMaterialConnectionPoint;
  62503. /**
  62504. * Gets the y operand input component
  62505. */
  62506. get y(): NodeMaterialConnectionPoint;
  62507. /**
  62508. * Gets the output component
  62509. */
  62510. get output(): NodeMaterialConnectionPoint;
  62511. protected _buildBlock(state: NodeMaterialBuildState): this;
  62512. }
  62513. }
  62514. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  62515. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62516. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62517. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62518. /**
  62519. * Block used to smooth step a value
  62520. */
  62521. export class SmoothStepBlock extends NodeMaterialBlock {
  62522. /**
  62523. * Creates a new SmoothStepBlock
  62524. * @param name defines the block name
  62525. */
  62526. constructor(name: string);
  62527. /**
  62528. * Gets the current class name
  62529. * @returns the class name
  62530. */
  62531. getClassName(): string;
  62532. /**
  62533. * Gets the value operand input component
  62534. */
  62535. get value(): NodeMaterialConnectionPoint;
  62536. /**
  62537. * Gets the first edge operand input component
  62538. */
  62539. get edge0(): NodeMaterialConnectionPoint;
  62540. /**
  62541. * Gets the second edge operand input component
  62542. */
  62543. get edge1(): NodeMaterialConnectionPoint;
  62544. /**
  62545. * Gets the output component
  62546. */
  62547. get output(): NodeMaterialConnectionPoint;
  62548. protected _buildBlock(state: NodeMaterialBuildState): this;
  62549. }
  62550. }
  62551. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  62552. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62553. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62554. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62555. /**
  62556. * Block used to get the reciprocal (1 / x) of a value
  62557. */
  62558. export class ReciprocalBlock extends NodeMaterialBlock {
  62559. /**
  62560. * Creates a new ReciprocalBlock
  62561. * @param name defines the block name
  62562. */
  62563. constructor(name: string);
  62564. /**
  62565. * Gets the current class name
  62566. * @returns the class name
  62567. */
  62568. getClassName(): string;
  62569. /**
  62570. * Gets the input component
  62571. */
  62572. get input(): NodeMaterialConnectionPoint;
  62573. /**
  62574. * Gets the output component
  62575. */
  62576. get output(): NodeMaterialConnectionPoint;
  62577. protected _buildBlock(state: NodeMaterialBuildState): this;
  62578. }
  62579. }
  62580. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  62581. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62582. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62583. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62584. /**
  62585. * Block used to replace a color by another one
  62586. */
  62587. export class ReplaceColorBlock extends NodeMaterialBlock {
  62588. /**
  62589. * Creates a new ReplaceColorBlock
  62590. * @param name defines the block name
  62591. */
  62592. constructor(name: string);
  62593. /**
  62594. * Gets the current class name
  62595. * @returns the class name
  62596. */
  62597. getClassName(): string;
  62598. /**
  62599. * Gets the value input component
  62600. */
  62601. get value(): NodeMaterialConnectionPoint;
  62602. /**
  62603. * Gets the reference input component
  62604. */
  62605. get reference(): NodeMaterialConnectionPoint;
  62606. /**
  62607. * Gets the distance input component
  62608. */
  62609. get distance(): NodeMaterialConnectionPoint;
  62610. /**
  62611. * Gets the replacement input component
  62612. */
  62613. get replacement(): NodeMaterialConnectionPoint;
  62614. /**
  62615. * Gets the output component
  62616. */
  62617. get output(): NodeMaterialConnectionPoint;
  62618. protected _buildBlock(state: NodeMaterialBuildState): this;
  62619. }
  62620. }
  62621. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  62622. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62623. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62624. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62625. /**
  62626. * Block used to posterize a value
  62627. * @see https://en.wikipedia.org/wiki/Posterization
  62628. */
  62629. export class PosterizeBlock extends NodeMaterialBlock {
  62630. /**
  62631. * Creates a new PosterizeBlock
  62632. * @param name defines the block name
  62633. */
  62634. constructor(name: string);
  62635. /**
  62636. * Gets the current class name
  62637. * @returns the class name
  62638. */
  62639. getClassName(): string;
  62640. /**
  62641. * Gets the value input component
  62642. */
  62643. get value(): NodeMaterialConnectionPoint;
  62644. /**
  62645. * Gets the steps input component
  62646. */
  62647. get steps(): NodeMaterialConnectionPoint;
  62648. /**
  62649. * Gets the output component
  62650. */
  62651. get output(): NodeMaterialConnectionPoint;
  62652. protected _buildBlock(state: NodeMaterialBuildState): this;
  62653. }
  62654. }
  62655. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  62656. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62657. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62658. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62659. import { Scene } from "babylonjs/scene";
  62660. /**
  62661. * Operations supported by the Wave block
  62662. */
  62663. export enum WaveBlockKind {
  62664. /** SawTooth */
  62665. SawTooth = 0,
  62666. /** Square */
  62667. Square = 1,
  62668. /** Triangle */
  62669. Triangle = 2
  62670. }
  62671. /**
  62672. * Block used to apply wave operation to floats
  62673. */
  62674. export class WaveBlock extends NodeMaterialBlock {
  62675. /**
  62676. * Gets or sets the kibnd of wave to be applied by the block
  62677. */
  62678. kind: WaveBlockKind;
  62679. /**
  62680. * Creates a new WaveBlock
  62681. * @param name defines the block name
  62682. */
  62683. constructor(name: string);
  62684. /**
  62685. * Gets the current class name
  62686. * @returns the class name
  62687. */
  62688. getClassName(): string;
  62689. /**
  62690. * Gets the input component
  62691. */
  62692. get input(): NodeMaterialConnectionPoint;
  62693. /**
  62694. * Gets the output component
  62695. */
  62696. get output(): NodeMaterialConnectionPoint;
  62697. protected _buildBlock(state: NodeMaterialBuildState): this;
  62698. serialize(): any;
  62699. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62700. }
  62701. }
  62702. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  62703. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62704. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62705. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62706. import { Color3 } from "babylonjs/Maths/math.color";
  62707. import { Scene } from "babylonjs/scene";
  62708. /**
  62709. * Class used to store a color step for the GradientBlock
  62710. */
  62711. export class GradientBlockColorStep {
  62712. /**
  62713. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62714. */
  62715. step: number;
  62716. /**
  62717. * Gets or sets the color associated with this step
  62718. */
  62719. color: Color3;
  62720. /**
  62721. * Creates a new GradientBlockColorStep
  62722. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  62723. * @param color defines the color associated with this step
  62724. */
  62725. constructor(
  62726. /**
  62727. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62728. */
  62729. step: number,
  62730. /**
  62731. * Gets or sets the color associated with this step
  62732. */
  62733. color: Color3);
  62734. }
  62735. /**
  62736. * Block used to return a color from a gradient based on an input value between 0 and 1
  62737. */
  62738. export class GradientBlock extends NodeMaterialBlock {
  62739. /**
  62740. * Gets or sets the list of color steps
  62741. */
  62742. colorSteps: GradientBlockColorStep[];
  62743. /**
  62744. * Creates a new GradientBlock
  62745. * @param name defines the block name
  62746. */
  62747. constructor(name: string);
  62748. /**
  62749. * Gets the current class name
  62750. * @returns the class name
  62751. */
  62752. getClassName(): string;
  62753. /**
  62754. * Gets the gradient input component
  62755. */
  62756. get gradient(): NodeMaterialConnectionPoint;
  62757. /**
  62758. * Gets the output component
  62759. */
  62760. get output(): NodeMaterialConnectionPoint;
  62761. private _writeColorConstant;
  62762. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62763. serialize(): any;
  62764. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62765. protected _dumpPropertiesCode(): string;
  62766. }
  62767. }
  62768. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  62769. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62770. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62771. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62772. /**
  62773. * Block used to normalize lerp between 2 values
  62774. */
  62775. export class NLerpBlock extends NodeMaterialBlock {
  62776. /**
  62777. * Creates a new NLerpBlock
  62778. * @param name defines the block name
  62779. */
  62780. constructor(name: string);
  62781. /**
  62782. * Gets the current class name
  62783. * @returns the class name
  62784. */
  62785. getClassName(): string;
  62786. /**
  62787. * Gets the left operand input component
  62788. */
  62789. get left(): NodeMaterialConnectionPoint;
  62790. /**
  62791. * Gets the right operand input component
  62792. */
  62793. get right(): NodeMaterialConnectionPoint;
  62794. /**
  62795. * Gets the gradient operand input component
  62796. */
  62797. get gradient(): NodeMaterialConnectionPoint;
  62798. /**
  62799. * Gets the output component
  62800. */
  62801. get output(): NodeMaterialConnectionPoint;
  62802. protected _buildBlock(state: NodeMaterialBuildState): this;
  62803. }
  62804. }
  62805. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  62806. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62807. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62808. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62809. import { Scene } from "babylonjs/scene";
  62810. /**
  62811. * block used to Generate a Worley Noise 3D Noise Pattern
  62812. */
  62813. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  62814. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62815. manhattanDistance: boolean;
  62816. /**
  62817. * Creates a new WorleyNoise3DBlock
  62818. * @param name defines the block name
  62819. */
  62820. constructor(name: string);
  62821. /**
  62822. * Gets the current class name
  62823. * @returns the class name
  62824. */
  62825. getClassName(): string;
  62826. /**
  62827. * Gets the seed input component
  62828. */
  62829. get seed(): NodeMaterialConnectionPoint;
  62830. /**
  62831. * Gets the jitter input component
  62832. */
  62833. get jitter(): NodeMaterialConnectionPoint;
  62834. /**
  62835. * Gets the output component
  62836. */
  62837. get output(): NodeMaterialConnectionPoint;
  62838. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62839. /**
  62840. * Exposes the properties to the UI?
  62841. */
  62842. protected _dumpPropertiesCode(): string;
  62843. /**
  62844. * Exposes the properties to the Seralize?
  62845. */
  62846. serialize(): any;
  62847. /**
  62848. * Exposes the properties to the deseralize?
  62849. */
  62850. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62851. }
  62852. }
  62853. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  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 Generate a Simplex Perlin 3d Noise Pattern
  62859. */
  62860. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  62861. /**
  62862. * Creates a new SimplexPerlin3DBlock
  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 seed operand input component
  62873. */
  62874. get seed(): NodeMaterialConnectionPoint;
  62875. /**
  62876. * Gets the output component
  62877. */
  62878. get output(): NodeMaterialConnectionPoint;
  62879. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62880. }
  62881. }
  62882. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  62883. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62884. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62885. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62886. /**
  62887. * Block used to blend normals
  62888. */
  62889. export class NormalBlendBlock extends NodeMaterialBlock {
  62890. /**
  62891. * Creates a new NormalBlendBlock
  62892. * @param name defines the block name
  62893. */
  62894. constructor(name: string);
  62895. /**
  62896. * Gets the current class name
  62897. * @returns the class name
  62898. */
  62899. getClassName(): string;
  62900. /**
  62901. * Gets the first input component
  62902. */
  62903. get normalMap0(): NodeMaterialConnectionPoint;
  62904. /**
  62905. * Gets the second input component
  62906. */
  62907. get normalMap1(): NodeMaterialConnectionPoint;
  62908. /**
  62909. * Gets the output component
  62910. */
  62911. get output(): NodeMaterialConnectionPoint;
  62912. protected _buildBlock(state: NodeMaterialBuildState): this;
  62913. }
  62914. }
  62915. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  62916. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62917. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62918. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62919. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62920. /**
  62921. * Block used to rotate a 2d vector by a given angle
  62922. */
  62923. export class Rotate2dBlock extends NodeMaterialBlock {
  62924. /**
  62925. * Creates a new Rotate2dBlock
  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 input vector
  62936. */
  62937. get input(): NodeMaterialConnectionPoint;
  62938. /**
  62939. * Gets the input angle
  62940. */
  62941. get angle(): NodeMaterialConnectionPoint;
  62942. /**
  62943. * Gets the output component
  62944. */
  62945. get output(): NodeMaterialConnectionPoint;
  62946. autoConfigure(material: NodeMaterial): void;
  62947. protected _buildBlock(state: NodeMaterialBuildState): this;
  62948. }
  62949. }
  62950. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  62951. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62952. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62953. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62954. /**
  62955. * Block used to get the reflected vector from a direction and a normal
  62956. */
  62957. export class ReflectBlock extends NodeMaterialBlock {
  62958. /**
  62959. * Creates a new ReflectBlock
  62960. * @param name defines the block name
  62961. */
  62962. constructor(name: string);
  62963. /**
  62964. * Gets the current class name
  62965. * @returns the class name
  62966. */
  62967. getClassName(): string;
  62968. /**
  62969. * Gets the incident component
  62970. */
  62971. get incident(): NodeMaterialConnectionPoint;
  62972. /**
  62973. * Gets the normal component
  62974. */
  62975. get normal(): NodeMaterialConnectionPoint;
  62976. /**
  62977. * Gets the output component
  62978. */
  62979. get output(): NodeMaterialConnectionPoint;
  62980. protected _buildBlock(state: NodeMaterialBuildState): this;
  62981. }
  62982. }
  62983. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  62984. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62985. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62986. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62987. /**
  62988. * Block used to get the refracted vector from a direction and a normal
  62989. */
  62990. export class RefractBlock extends NodeMaterialBlock {
  62991. /**
  62992. * Creates a new RefractBlock
  62993. * @param name defines the block name
  62994. */
  62995. constructor(name: string);
  62996. /**
  62997. * Gets the current class name
  62998. * @returns the class name
  62999. */
  63000. getClassName(): string;
  63001. /**
  63002. * Gets the incident component
  63003. */
  63004. get incident(): NodeMaterialConnectionPoint;
  63005. /**
  63006. * Gets the normal component
  63007. */
  63008. get normal(): NodeMaterialConnectionPoint;
  63009. /**
  63010. * Gets the index of refraction component
  63011. */
  63012. get ior(): NodeMaterialConnectionPoint;
  63013. /**
  63014. * Gets the output component
  63015. */
  63016. get output(): NodeMaterialConnectionPoint;
  63017. protected _buildBlock(state: NodeMaterialBuildState): this;
  63018. }
  63019. }
  63020. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  63021. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63022. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63023. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63024. /**
  63025. * Block used to desaturate a color
  63026. */
  63027. export class DesaturateBlock extends NodeMaterialBlock {
  63028. /**
  63029. * Creates a new DesaturateBlock
  63030. * @param name defines the block name
  63031. */
  63032. constructor(name: string);
  63033. /**
  63034. * Gets the current class name
  63035. * @returns the class name
  63036. */
  63037. getClassName(): string;
  63038. /**
  63039. * Gets the color operand input component
  63040. */
  63041. get color(): NodeMaterialConnectionPoint;
  63042. /**
  63043. * Gets the level operand input component
  63044. */
  63045. get level(): NodeMaterialConnectionPoint;
  63046. /**
  63047. * Gets the output component
  63048. */
  63049. get output(): NodeMaterialConnectionPoint;
  63050. protected _buildBlock(state: NodeMaterialBuildState): this;
  63051. }
  63052. }
  63053. declare module "babylonjs/Materials/Node/Blocks/index" {
  63054. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  63055. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  63056. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  63057. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  63058. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  63059. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  63060. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  63061. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  63062. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  63063. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  63064. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  63065. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  63066. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  63067. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  63068. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  63069. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  63070. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  63071. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  63072. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  63073. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  63074. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  63075. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  63076. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  63077. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  63078. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  63079. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  63080. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  63081. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  63082. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  63083. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  63084. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  63085. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  63086. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  63087. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  63088. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  63089. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  63090. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  63091. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  63092. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  63093. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  63094. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  63095. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  63096. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  63097. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  63098. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  63099. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  63100. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  63101. }
  63102. declare module "babylonjs/Materials/Node/Optimizers/index" {
  63103. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  63104. }
  63105. declare module "babylonjs/Materials/Node/index" {
  63106. export * from "babylonjs/Materials/Node/Enums/index";
  63107. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63108. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  63109. export * from "babylonjs/Materials/Node/nodeMaterial";
  63110. export * from "babylonjs/Materials/Node/Blocks/index";
  63111. export * from "babylonjs/Materials/Node/Optimizers/index";
  63112. }
  63113. declare module "babylonjs/Materials/effectRenderer" {
  63114. import { Nullable } from "babylonjs/types";
  63115. import { Texture } from "babylonjs/Materials/Textures/texture";
  63116. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63117. import { Viewport } from "babylonjs/Maths/math.viewport";
  63118. import { Observable } from "babylonjs/Misc/observable";
  63119. import { Effect } from "babylonjs/Materials/effect";
  63120. import "babylonjs/Engines/Extensions/engine.renderTarget";
  63121. import "babylonjs/Shaders/postprocess.vertex";
  63122. /**
  63123. * Effect Render Options
  63124. */
  63125. export interface IEffectRendererOptions {
  63126. /**
  63127. * Defines the vertices positions.
  63128. */
  63129. positions?: number[];
  63130. /**
  63131. * Defines the indices.
  63132. */
  63133. indices?: number[];
  63134. }
  63135. /**
  63136. * Helper class to render one or more effects
  63137. */
  63138. export class EffectRenderer {
  63139. private engine;
  63140. private static _DefaultOptions;
  63141. private _vertexBuffers;
  63142. private _indexBuffer;
  63143. private _ringBufferIndex;
  63144. private _ringScreenBuffer;
  63145. private _fullscreenViewport;
  63146. private _getNextFrameBuffer;
  63147. /**
  63148. * Creates an effect renderer
  63149. * @param engine the engine to use for rendering
  63150. * @param options defines the options of the effect renderer
  63151. */
  63152. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  63153. /**
  63154. * Sets the current viewport in normalized coordinates 0-1
  63155. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  63156. */
  63157. setViewport(viewport?: Viewport): void;
  63158. /**
  63159. * Binds the embedded attributes buffer to the effect.
  63160. * @param effect Defines the effect to bind the attributes for
  63161. */
  63162. bindBuffers(effect: Effect): void;
  63163. /**
  63164. * Sets the current effect wrapper to use during draw.
  63165. * The effect needs to be ready before calling this api.
  63166. * This also sets the default full screen position attribute.
  63167. * @param effectWrapper Defines the effect to draw with
  63168. */
  63169. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  63170. /**
  63171. * Draws a full screen quad.
  63172. */
  63173. draw(): void;
  63174. /**
  63175. * renders one or more effects to a specified texture
  63176. * @param effectWrappers list of effects to renderer
  63177. * @param outputTexture texture to draw to, if null it will render to the screen
  63178. */
  63179. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  63180. /**
  63181. * Disposes of the effect renderer
  63182. */
  63183. dispose(): void;
  63184. }
  63185. /**
  63186. * Options to create an EffectWrapper
  63187. */
  63188. interface EffectWrapperCreationOptions {
  63189. /**
  63190. * Engine to use to create the effect
  63191. */
  63192. engine: ThinEngine;
  63193. /**
  63194. * Fragment shader for the effect
  63195. */
  63196. fragmentShader: string;
  63197. /**
  63198. * Vertex shader for the effect
  63199. */
  63200. vertexShader?: string;
  63201. /**
  63202. * Attributes to use in the shader
  63203. */
  63204. attributeNames?: Array<string>;
  63205. /**
  63206. * Uniforms to use in the shader
  63207. */
  63208. uniformNames?: Array<string>;
  63209. /**
  63210. * Texture sampler names to use in the shader
  63211. */
  63212. samplerNames?: Array<string>;
  63213. /**
  63214. * The friendly name of the effect displayed in Spector.
  63215. */
  63216. name?: string;
  63217. }
  63218. /**
  63219. * Wraps an effect to be used for rendering
  63220. */
  63221. export class EffectWrapper {
  63222. /**
  63223. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  63224. */
  63225. onApplyObservable: Observable<{}>;
  63226. /**
  63227. * The underlying effect
  63228. */
  63229. effect: Effect;
  63230. /**
  63231. * Creates an effect to be renderer
  63232. * @param creationOptions options to create the effect
  63233. */
  63234. constructor(creationOptions: EffectWrapperCreationOptions);
  63235. /**
  63236. * Disposes of the effect wrapper
  63237. */
  63238. dispose(): void;
  63239. }
  63240. }
  63241. declare module "babylonjs/Materials/index" {
  63242. export * from "babylonjs/Materials/Background/index";
  63243. export * from "babylonjs/Materials/colorCurves";
  63244. export * from "babylonjs/Materials/iEffectFallbacks";
  63245. export * from "babylonjs/Materials/effectFallbacks";
  63246. export * from "babylonjs/Materials/effect";
  63247. export * from "babylonjs/Materials/fresnelParameters";
  63248. export * from "babylonjs/Materials/imageProcessingConfiguration";
  63249. export * from "babylonjs/Materials/material";
  63250. export * from "babylonjs/Materials/materialDefines";
  63251. export * from "babylonjs/Materials/materialHelper";
  63252. export * from "babylonjs/Materials/multiMaterial";
  63253. export * from "babylonjs/Materials/PBR/index";
  63254. export * from "babylonjs/Materials/pushMaterial";
  63255. export * from "babylonjs/Materials/shaderMaterial";
  63256. export * from "babylonjs/Materials/standardMaterial";
  63257. export * from "babylonjs/Materials/Textures/index";
  63258. export * from "babylonjs/Materials/uniformBuffer";
  63259. export * from "babylonjs/Materials/materialFlags";
  63260. export * from "babylonjs/Materials/Node/index";
  63261. export * from "babylonjs/Materials/effectRenderer";
  63262. }
  63263. declare module "babylonjs/Maths/index" {
  63264. export * from "babylonjs/Maths/math.scalar";
  63265. export * from "babylonjs/Maths/math";
  63266. export * from "babylonjs/Maths/sphericalPolynomial";
  63267. }
  63268. declare module "babylonjs/Misc/workerPool" {
  63269. import { IDisposable } from "babylonjs/scene";
  63270. /**
  63271. * Helper class to push actions to a pool of workers.
  63272. */
  63273. export class WorkerPool implements IDisposable {
  63274. private _workerInfos;
  63275. private _pendingActions;
  63276. /**
  63277. * Constructor
  63278. * @param workers Array of workers to use for actions
  63279. */
  63280. constructor(workers: Array<Worker>);
  63281. /**
  63282. * Terminates all workers and clears any pending actions.
  63283. */
  63284. dispose(): void;
  63285. /**
  63286. * Pushes an action to the worker pool. If all the workers are active, the action will be
  63287. * pended until a worker has completed its action.
  63288. * @param action The action to perform. Call onComplete when the action is complete.
  63289. */
  63290. push(action: (worker: Worker, onComplete: () => void) => void): void;
  63291. private _execute;
  63292. }
  63293. }
  63294. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  63295. import { IDisposable } from "babylonjs/scene";
  63296. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  63297. /**
  63298. * Configuration for Draco compression
  63299. */
  63300. export interface IDracoCompressionConfiguration {
  63301. /**
  63302. * Configuration for the decoder.
  63303. */
  63304. decoder: {
  63305. /**
  63306. * The url to the WebAssembly module.
  63307. */
  63308. wasmUrl?: string;
  63309. /**
  63310. * The url to the WebAssembly binary.
  63311. */
  63312. wasmBinaryUrl?: string;
  63313. /**
  63314. * The url to the fallback JavaScript module.
  63315. */
  63316. fallbackUrl?: string;
  63317. };
  63318. }
  63319. /**
  63320. * Draco compression (https://google.github.io/draco/)
  63321. *
  63322. * This class wraps the Draco module.
  63323. *
  63324. * **Encoder**
  63325. *
  63326. * The encoder is not currently implemented.
  63327. *
  63328. * **Decoder**
  63329. *
  63330. * 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.
  63331. *
  63332. * To update the configuration, use the following code:
  63333. * ```javascript
  63334. * DracoCompression.Configuration = {
  63335. * decoder: {
  63336. * wasmUrl: "<url to the WebAssembly library>",
  63337. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  63338. * fallbackUrl: "<url to the fallback JavaScript library>",
  63339. * }
  63340. * };
  63341. * ```
  63342. *
  63343. * 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.
  63344. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  63345. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  63346. *
  63347. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  63348. * ```javascript
  63349. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  63350. * ```
  63351. *
  63352. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  63353. */
  63354. export class DracoCompression implements IDisposable {
  63355. private _workerPoolPromise?;
  63356. private _decoderModulePromise?;
  63357. /**
  63358. * The configuration. Defaults to the following urls:
  63359. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  63360. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  63361. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  63362. */
  63363. static Configuration: IDracoCompressionConfiguration;
  63364. /**
  63365. * Returns true if the decoder configuration is available.
  63366. */
  63367. static get DecoderAvailable(): boolean;
  63368. /**
  63369. * Default number of workers to create when creating the draco compression object.
  63370. */
  63371. static DefaultNumWorkers: number;
  63372. private static GetDefaultNumWorkers;
  63373. private static _Default;
  63374. /**
  63375. * Default instance for the draco compression object.
  63376. */
  63377. static get Default(): DracoCompression;
  63378. /**
  63379. * Constructor
  63380. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  63381. */
  63382. constructor(numWorkers?: number);
  63383. /**
  63384. * Stop all async operations and release resources.
  63385. */
  63386. dispose(): void;
  63387. /**
  63388. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  63389. * @returns a promise that resolves when ready
  63390. */
  63391. whenReadyAsync(): Promise<void>;
  63392. /**
  63393. * Decode Draco compressed mesh data to vertex data.
  63394. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  63395. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  63396. * @returns A promise that resolves with the decoded vertex data
  63397. */
  63398. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  63399. [kind: string]: number;
  63400. }): Promise<VertexData>;
  63401. }
  63402. }
  63403. declare module "babylonjs/Meshes/Compression/index" {
  63404. export * from "babylonjs/Meshes/Compression/dracoCompression";
  63405. }
  63406. declare module "babylonjs/Meshes/csg" {
  63407. import { Nullable } from "babylonjs/types";
  63408. import { Scene } from "babylonjs/scene";
  63409. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63410. import { Mesh } from "babylonjs/Meshes/mesh";
  63411. import { Material } from "babylonjs/Materials/material";
  63412. /**
  63413. * Class for building Constructive Solid Geometry
  63414. */
  63415. export class CSG {
  63416. private polygons;
  63417. /**
  63418. * The world matrix
  63419. */
  63420. matrix: Matrix;
  63421. /**
  63422. * Stores the position
  63423. */
  63424. position: Vector3;
  63425. /**
  63426. * Stores the rotation
  63427. */
  63428. rotation: Vector3;
  63429. /**
  63430. * Stores the rotation quaternion
  63431. */
  63432. rotationQuaternion: Nullable<Quaternion>;
  63433. /**
  63434. * Stores the scaling vector
  63435. */
  63436. scaling: Vector3;
  63437. /**
  63438. * Convert the Mesh to CSG
  63439. * @param mesh The Mesh to convert to CSG
  63440. * @returns A new CSG from the Mesh
  63441. */
  63442. static FromMesh(mesh: Mesh): CSG;
  63443. /**
  63444. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  63445. * @param polygons Polygons used to construct a CSG solid
  63446. */
  63447. private static FromPolygons;
  63448. /**
  63449. * Clones, or makes a deep copy, of the CSG
  63450. * @returns A new CSG
  63451. */
  63452. clone(): CSG;
  63453. /**
  63454. * Unions this CSG with another CSG
  63455. * @param csg The CSG to union against this CSG
  63456. * @returns The unioned CSG
  63457. */
  63458. union(csg: CSG): CSG;
  63459. /**
  63460. * Unions this CSG with another CSG in place
  63461. * @param csg The CSG to union against this CSG
  63462. */
  63463. unionInPlace(csg: CSG): void;
  63464. /**
  63465. * Subtracts this CSG with another CSG
  63466. * @param csg The CSG to subtract against this CSG
  63467. * @returns A new CSG
  63468. */
  63469. subtract(csg: CSG): CSG;
  63470. /**
  63471. * Subtracts this CSG with another CSG in place
  63472. * @param csg The CSG to subtact against this CSG
  63473. */
  63474. subtractInPlace(csg: CSG): void;
  63475. /**
  63476. * Intersect this CSG with another CSG
  63477. * @param csg The CSG to intersect against this CSG
  63478. * @returns A new CSG
  63479. */
  63480. intersect(csg: CSG): CSG;
  63481. /**
  63482. * Intersects this CSG with another CSG in place
  63483. * @param csg The CSG to intersect against this CSG
  63484. */
  63485. intersectInPlace(csg: CSG): void;
  63486. /**
  63487. * Return a new CSG solid with solid and empty space switched. This solid is
  63488. * not modified.
  63489. * @returns A new CSG solid with solid and empty space switched
  63490. */
  63491. inverse(): CSG;
  63492. /**
  63493. * Inverses the CSG in place
  63494. */
  63495. inverseInPlace(): void;
  63496. /**
  63497. * This is used to keep meshes transformations so they can be restored
  63498. * when we build back a Babylon Mesh
  63499. * NB : All CSG operations are performed in world coordinates
  63500. * @param csg The CSG to copy the transform attributes from
  63501. * @returns This CSG
  63502. */
  63503. copyTransformAttributes(csg: CSG): CSG;
  63504. /**
  63505. * Build Raw mesh from CSG
  63506. * Coordinates here are in world space
  63507. * @param name The name of the mesh geometry
  63508. * @param scene The Scene
  63509. * @param keepSubMeshes Specifies if the submeshes should be kept
  63510. * @returns A new Mesh
  63511. */
  63512. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63513. /**
  63514. * Build Mesh from CSG taking material and transforms into account
  63515. * @param name The name of the Mesh
  63516. * @param material The material of the Mesh
  63517. * @param scene The Scene
  63518. * @param keepSubMeshes Specifies if submeshes should be kept
  63519. * @returns The new Mesh
  63520. */
  63521. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63522. }
  63523. }
  63524. declare module "babylonjs/Meshes/trailMesh" {
  63525. import { Mesh } from "babylonjs/Meshes/mesh";
  63526. import { Scene } from "babylonjs/scene";
  63527. import { TransformNode } from "babylonjs/Meshes/transformNode";
  63528. /**
  63529. * Class used to create a trail following a mesh
  63530. */
  63531. export class TrailMesh extends Mesh {
  63532. private _generator;
  63533. private _autoStart;
  63534. private _running;
  63535. private _diameter;
  63536. private _length;
  63537. private _sectionPolygonPointsCount;
  63538. private _sectionVectors;
  63539. private _sectionNormalVectors;
  63540. private _beforeRenderObserver;
  63541. /**
  63542. * @constructor
  63543. * @param name The value used by scene.getMeshByName() to do a lookup.
  63544. * @param generator The mesh or transform node to generate a trail.
  63545. * @param scene The scene to add this mesh to.
  63546. * @param diameter Diameter of trailing mesh. Default is 1.
  63547. * @param length Length of trailing mesh. Default is 60.
  63548. * @param autoStart Automatically start trailing mesh. Default true.
  63549. */
  63550. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  63551. /**
  63552. * "TrailMesh"
  63553. * @returns "TrailMesh"
  63554. */
  63555. getClassName(): string;
  63556. private _createMesh;
  63557. /**
  63558. * Start trailing mesh.
  63559. */
  63560. start(): void;
  63561. /**
  63562. * Stop trailing mesh.
  63563. */
  63564. stop(): void;
  63565. /**
  63566. * Update trailing mesh geometry.
  63567. */
  63568. update(): void;
  63569. /**
  63570. * Returns a new TrailMesh object.
  63571. * @param name is a string, the name given to the new mesh
  63572. * @param newGenerator use new generator object for cloned trail mesh
  63573. * @returns a new mesh
  63574. */
  63575. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  63576. /**
  63577. * Serializes this trail mesh
  63578. * @param serializationObject object to write serialization to
  63579. */
  63580. serialize(serializationObject: any): void;
  63581. /**
  63582. * Parses a serialized trail mesh
  63583. * @param parsedMesh the serialized mesh
  63584. * @param scene the scene to create the trail mesh in
  63585. * @returns the created trail mesh
  63586. */
  63587. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  63588. }
  63589. }
  63590. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  63591. import { Nullable } from "babylonjs/types";
  63592. import { Scene } from "babylonjs/scene";
  63593. import { Vector4 } from "babylonjs/Maths/math.vector";
  63594. import { Color4 } from "babylonjs/Maths/math.color";
  63595. import { Mesh } from "babylonjs/Meshes/mesh";
  63596. /**
  63597. * Class containing static functions to help procedurally build meshes
  63598. */
  63599. export class TiledBoxBuilder {
  63600. /**
  63601. * Creates a box mesh
  63602. * 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)
  63603. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63604. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63605. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63606. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63607. * @param name defines the name of the mesh
  63608. * @param options defines the options used to create the mesh
  63609. * @param scene defines the hosting scene
  63610. * @returns the box mesh
  63611. */
  63612. static CreateTiledBox(name: string, options: {
  63613. pattern?: number;
  63614. width?: number;
  63615. height?: number;
  63616. depth?: number;
  63617. tileSize?: number;
  63618. tileWidth?: number;
  63619. tileHeight?: number;
  63620. alignHorizontal?: number;
  63621. alignVertical?: number;
  63622. faceUV?: Vector4[];
  63623. faceColors?: Color4[];
  63624. sideOrientation?: number;
  63625. updatable?: boolean;
  63626. }, scene?: Nullable<Scene>): Mesh;
  63627. }
  63628. }
  63629. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  63630. import { Vector4 } from "babylonjs/Maths/math.vector";
  63631. import { Mesh } from "babylonjs/Meshes/mesh";
  63632. /**
  63633. * Class containing static functions to help procedurally build meshes
  63634. */
  63635. export class TorusKnotBuilder {
  63636. /**
  63637. * Creates a torus knot mesh
  63638. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  63639. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  63640. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  63641. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  63642. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63643. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63644. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63645. * @param name defines the name of the mesh
  63646. * @param options defines the options used to create the mesh
  63647. * @param scene defines the hosting scene
  63648. * @returns the torus knot mesh
  63649. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  63650. */
  63651. static CreateTorusKnot(name: string, options: {
  63652. radius?: number;
  63653. tube?: number;
  63654. radialSegments?: number;
  63655. tubularSegments?: number;
  63656. p?: number;
  63657. q?: number;
  63658. updatable?: boolean;
  63659. sideOrientation?: number;
  63660. frontUVs?: Vector4;
  63661. backUVs?: Vector4;
  63662. }, scene: any): Mesh;
  63663. }
  63664. }
  63665. declare module "babylonjs/Meshes/polygonMesh" {
  63666. import { Scene } from "babylonjs/scene";
  63667. import { Vector2 } from "babylonjs/Maths/math.vector";
  63668. import { Mesh } from "babylonjs/Meshes/mesh";
  63669. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  63670. import { Path2 } from "babylonjs/Maths/math.path";
  63671. /**
  63672. * Polygon
  63673. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  63674. */
  63675. export class Polygon {
  63676. /**
  63677. * Creates a rectangle
  63678. * @param xmin bottom X coord
  63679. * @param ymin bottom Y coord
  63680. * @param xmax top X coord
  63681. * @param ymax top Y coord
  63682. * @returns points that make the resulting rectation
  63683. */
  63684. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  63685. /**
  63686. * Creates a circle
  63687. * @param radius radius of circle
  63688. * @param cx scale in x
  63689. * @param cy scale in y
  63690. * @param numberOfSides number of sides that make up the circle
  63691. * @returns points that make the resulting circle
  63692. */
  63693. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  63694. /**
  63695. * Creates a polygon from input string
  63696. * @param input Input polygon data
  63697. * @returns the parsed points
  63698. */
  63699. static Parse(input: string): Vector2[];
  63700. /**
  63701. * Starts building a polygon from x and y coordinates
  63702. * @param x x coordinate
  63703. * @param y y coordinate
  63704. * @returns the started path2
  63705. */
  63706. static StartingAt(x: number, y: number): Path2;
  63707. }
  63708. /**
  63709. * Builds a polygon
  63710. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  63711. */
  63712. export class PolygonMeshBuilder {
  63713. private _points;
  63714. private _outlinepoints;
  63715. private _holes;
  63716. private _name;
  63717. private _scene;
  63718. private _epoints;
  63719. private _eholes;
  63720. private _addToepoint;
  63721. /**
  63722. * Babylon reference to the earcut plugin.
  63723. */
  63724. bjsEarcut: any;
  63725. /**
  63726. * Creates a PolygonMeshBuilder
  63727. * @param name name of the builder
  63728. * @param contours Path of the polygon
  63729. * @param scene scene to add to when creating the mesh
  63730. * @param earcutInjection can be used to inject your own earcut reference
  63731. */
  63732. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  63733. /**
  63734. * Adds a whole within the polygon
  63735. * @param hole Array of points defining the hole
  63736. * @returns this
  63737. */
  63738. addHole(hole: Vector2[]): PolygonMeshBuilder;
  63739. /**
  63740. * Creates the polygon
  63741. * @param updatable If the mesh should be updatable
  63742. * @param depth The depth of the mesh created
  63743. * @returns the created mesh
  63744. */
  63745. build(updatable?: boolean, depth?: number): Mesh;
  63746. /**
  63747. * Creates the polygon
  63748. * @param depth The depth of the mesh created
  63749. * @returns the created VertexData
  63750. */
  63751. buildVertexData(depth?: number): VertexData;
  63752. /**
  63753. * Adds a side to the polygon
  63754. * @param positions points that make the polygon
  63755. * @param normals normals of the polygon
  63756. * @param uvs uvs of the polygon
  63757. * @param indices indices of the polygon
  63758. * @param bounds bounds of the polygon
  63759. * @param points points of the polygon
  63760. * @param depth depth of the polygon
  63761. * @param flip flip of the polygon
  63762. */
  63763. private addSide;
  63764. }
  63765. }
  63766. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  63767. import { Scene } from "babylonjs/scene";
  63768. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63769. import { Color4 } from "babylonjs/Maths/math.color";
  63770. import { Mesh } from "babylonjs/Meshes/mesh";
  63771. import { Nullable } from "babylonjs/types";
  63772. /**
  63773. * Class containing static functions to help procedurally build meshes
  63774. */
  63775. export class PolygonBuilder {
  63776. /**
  63777. * Creates a polygon mesh
  63778. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  63779. * * 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
  63780. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63781. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63782. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  63783. * * Remember you can only change the shape positions, not their number when updating a polygon
  63784. * @param name defines the name of the mesh
  63785. * @param options defines the options used to create the mesh
  63786. * @param scene defines the hosting scene
  63787. * @param earcutInjection can be used to inject your own earcut reference
  63788. * @returns the polygon mesh
  63789. */
  63790. static CreatePolygon(name: string, options: {
  63791. shape: Vector3[];
  63792. holes?: Vector3[][];
  63793. depth?: number;
  63794. faceUV?: Vector4[];
  63795. faceColors?: Color4[];
  63796. updatable?: boolean;
  63797. sideOrientation?: number;
  63798. frontUVs?: Vector4;
  63799. backUVs?: Vector4;
  63800. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63801. /**
  63802. * Creates an extruded polygon mesh, with depth in the Y direction.
  63803. * * 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)
  63804. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63805. * @param name defines the name of the mesh
  63806. * @param options defines the options used to create the mesh
  63807. * @param scene defines the hosting scene
  63808. * @param earcutInjection can be used to inject your own earcut reference
  63809. * @returns the polygon mesh
  63810. */
  63811. static ExtrudePolygon(name: string, options: {
  63812. shape: Vector3[];
  63813. holes?: Vector3[][];
  63814. depth?: number;
  63815. faceUV?: Vector4[];
  63816. faceColors?: Color4[];
  63817. updatable?: boolean;
  63818. sideOrientation?: number;
  63819. frontUVs?: Vector4;
  63820. backUVs?: Vector4;
  63821. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63822. }
  63823. }
  63824. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  63825. import { Scene } from "babylonjs/scene";
  63826. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63827. import { Mesh } from "babylonjs/Meshes/mesh";
  63828. import { Nullable } from "babylonjs/types";
  63829. /**
  63830. * Class containing static functions to help procedurally build meshes
  63831. */
  63832. export class LatheBuilder {
  63833. /**
  63834. * Creates lathe mesh.
  63835. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  63836. * * 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
  63837. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  63838. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  63839. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  63840. * * 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
  63841. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  63842. * * 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
  63843. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63844. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63845. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63846. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63847. * @param name defines the name of the mesh
  63848. * @param options defines the options used to create the mesh
  63849. * @param scene defines the hosting scene
  63850. * @returns the lathe mesh
  63851. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  63852. */
  63853. static CreateLathe(name: string, options: {
  63854. shape: Vector3[];
  63855. radius?: number;
  63856. tessellation?: number;
  63857. clip?: number;
  63858. arc?: number;
  63859. closed?: boolean;
  63860. updatable?: boolean;
  63861. sideOrientation?: number;
  63862. frontUVs?: Vector4;
  63863. backUVs?: Vector4;
  63864. cap?: number;
  63865. invertUV?: boolean;
  63866. }, scene?: Nullable<Scene>): Mesh;
  63867. }
  63868. }
  63869. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  63870. import { Nullable } from "babylonjs/types";
  63871. import { Scene } from "babylonjs/scene";
  63872. import { Vector4 } from "babylonjs/Maths/math.vector";
  63873. import { Mesh } from "babylonjs/Meshes/mesh";
  63874. /**
  63875. * Class containing static functions to help procedurally build meshes
  63876. */
  63877. export class TiledPlaneBuilder {
  63878. /**
  63879. * Creates a tiled plane mesh
  63880. * * The parameter `pattern` will, depending on value, do nothing or
  63881. * * * flip (reflect about central vertical) alternate tiles across and up
  63882. * * * flip every tile on alternate rows
  63883. * * * rotate (180 degs) alternate tiles across and up
  63884. * * * rotate every tile on alternate rows
  63885. * * * flip and rotate alternate tiles across and up
  63886. * * * flip and rotate every tile on alternate rows
  63887. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  63888. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  63889. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63890. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63891. * * 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)
  63892. * * 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)
  63893. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  63894. * @param name defines the name of the mesh
  63895. * @param options defines the options used to create the mesh
  63896. * @param scene defines the hosting scene
  63897. * @returns the box mesh
  63898. */
  63899. static CreateTiledPlane(name: string, options: {
  63900. pattern?: number;
  63901. tileSize?: number;
  63902. tileWidth?: number;
  63903. tileHeight?: number;
  63904. size?: number;
  63905. width?: number;
  63906. height?: number;
  63907. alignHorizontal?: number;
  63908. alignVertical?: number;
  63909. sideOrientation?: number;
  63910. frontUVs?: Vector4;
  63911. backUVs?: Vector4;
  63912. updatable?: boolean;
  63913. }, scene?: Nullable<Scene>): Mesh;
  63914. }
  63915. }
  63916. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  63917. import { Nullable } from "babylonjs/types";
  63918. import { Scene } from "babylonjs/scene";
  63919. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63920. import { Mesh } from "babylonjs/Meshes/mesh";
  63921. /**
  63922. * Class containing static functions to help procedurally build meshes
  63923. */
  63924. export class TubeBuilder {
  63925. /**
  63926. * Creates a tube mesh.
  63927. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  63928. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  63929. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  63930. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  63931. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  63932. * * 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)
  63933. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  63934. * * 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
  63935. * * 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
  63936. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63937. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63938. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63939. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63940. * @param name defines the name of the mesh
  63941. * @param options defines the options used to create the mesh
  63942. * @param scene defines the hosting scene
  63943. * @returns the tube mesh
  63944. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63945. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  63946. */
  63947. static CreateTube(name: string, options: {
  63948. path: Vector3[];
  63949. radius?: number;
  63950. tessellation?: number;
  63951. radiusFunction?: {
  63952. (i: number, distance: number): number;
  63953. };
  63954. cap?: number;
  63955. arc?: number;
  63956. updatable?: boolean;
  63957. sideOrientation?: number;
  63958. frontUVs?: Vector4;
  63959. backUVs?: Vector4;
  63960. instance?: Mesh;
  63961. invertUV?: boolean;
  63962. }, scene?: Nullable<Scene>): Mesh;
  63963. }
  63964. }
  63965. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  63966. import { Scene } from "babylonjs/scene";
  63967. import { Vector4 } from "babylonjs/Maths/math.vector";
  63968. import { Mesh } from "babylonjs/Meshes/mesh";
  63969. import { Nullable } from "babylonjs/types";
  63970. /**
  63971. * Class containing static functions to help procedurally build meshes
  63972. */
  63973. export class IcoSphereBuilder {
  63974. /**
  63975. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  63976. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  63977. * * 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`)
  63978. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  63979. * * 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
  63980. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63981. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63982. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63983. * @param name defines the name of the mesh
  63984. * @param options defines the options used to create the mesh
  63985. * @param scene defines the hosting scene
  63986. * @returns the icosahedron mesh
  63987. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  63988. */
  63989. static CreateIcoSphere(name: string, options: {
  63990. radius?: number;
  63991. radiusX?: number;
  63992. radiusY?: number;
  63993. radiusZ?: number;
  63994. flat?: boolean;
  63995. subdivisions?: number;
  63996. sideOrientation?: number;
  63997. frontUVs?: Vector4;
  63998. backUVs?: Vector4;
  63999. updatable?: boolean;
  64000. }, scene?: Nullable<Scene>): Mesh;
  64001. }
  64002. }
  64003. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  64004. import { Vector3 } from "babylonjs/Maths/math.vector";
  64005. import { Mesh } from "babylonjs/Meshes/mesh";
  64006. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64007. /**
  64008. * Class containing static functions to help procedurally build meshes
  64009. */
  64010. export class DecalBuilder {
  64011. /**
  64012. * Creates a decal mesh.
  64013. * 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
  64014. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64015. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64016. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64017. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64018. * @param name defines the name of the mesh
  64019. * @param sourceMesh defines the mesh where the decal must be applied
  64020. * @param options defines the options used to create the mesh
  64021. * @param scene defines the hosting scene
  64022. * @returns the decal mesh
  64023. * @see https://doc.babylonjs.com/how_to/decals
  64024. */
  64025. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64026. position?: Vector3;
  64027. normal?: Vector3;
  64028. size?: Vector3;
  64029. angle?: number;
  64030. }): Mesh;
  64031. }
  64032. }
  64033. declare module "babylonjs/Meshes/meshBuilder" {
  64034. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  64035. import { Nullable } from "babylonjs/types";
  64036. import { Scene } from "babylonjs/scene";
  64037. import { Mesh } from "babylonjs/Meshes/mesh";
  64038. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  64039. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  64040. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64041. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  64042. import { Plane } from "babylonjs/Maths/math.plane";
  64043. /**
  64044. * Class containing static functions to help procedurally build meshes
  64045. */
  64046. export class MeshBuilder {
  64047. /**
  64048. * Creates a box mesh
  64049. * * The parameter `size` sets the size (float) of each box side (default 1)
  64050. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  64051. * * 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)
  64052. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64053. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64054. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64055. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64056. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64057. * @param name defines the name of the mesh
  64058. * @param options defines the options used to create the mesh
  64059. * @param scene defines the hosting scene
  64060. * @returns the box mesh
  64061. */
  64062. static CreateBox(name: string, options: {
  64063. size?: number;
  64064. width?: number;
  64065. height?: number;
  64066. depth?: number;
  64067. faceUV?: Vector4[];
  64068. faceColors?: Color4[];
  64069. sideOrientation?: number;
  64070. frontUVs?: Vector4;
  64071. backUVs?: Vector4;
  64072. updatable?: boolean;
  64073. }, scene?: Nullable<Scene>): Mesh;
  64074. /**
  64075. * Creates a tiled box mesh
  64076. * * faceTiles sets the pattern, tile size and number of tiles for a face
  64077. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64078. * @param name defines the name of the mesh
  64079. * @param options defines the options used to create the mesh
  64080. * @param scene defines the hosting scene
  64081. * @returns the tiled box mesh
  64082. */
  64083. static CreateTiledBox(name: string, options: {
  64084. pattern?: number;
  64085. size?: number;
  64086. width?: number;
  64087. height?: number;
  64088. depth: number;
  64089. tileSize?: number;
  64090. tileWidth?: number;
  64091. tileHeight?: number;
  64092. faceUV?: Vector4[];
  64093. faceColors?: Color4[];
  64094. alignHorizontal?: number;
  64095. alignVertical?: number;
  64096. sideOrientation?: number;
  64097. updatable?: boolean;
  64098. }, scene?: Nullable<Scene>): Mesh;
  64099. /**
  64100. * Creates a sphere mesh
  64101. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  64102. * * 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`)
  64103. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  64104. * * 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
  64105. * * 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)
  64106. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64107. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64108. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64109. * @param name defines the name of the mesh
  64110. * @param options defines the options used to create the mesh
  64111. * @param scene defines the hosting scene
  64112. * @returns the sphere mesh
  64113. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  64114. */
  64115. static CreateSphere(name: string, options: {
  64116. segments?: number;
  64117. diameter?: number;
  64118. diameterX?: number;
  64119. diameterY?: number;
  64120. diameterZ?: number;
  64121. arc?: number;
  64122. slice?: number;
  64123. sideOrientation?: number;
  64124. frontUVs?: Vector4;
  64125. backUVs?: Vector4;
  64126. updatable?: boolean;
  64127. }, scene?: Nullable<Scene>): Mesh;
  64128. /**
  64129. * Creates a plane polygonal mesh. By default, this is a disc
  64130. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  64131. * * 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
  64132. * * 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
  64133. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64134. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64135. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64136. * @param name defines the name of the mesh
  64137. * @param options defines the options used to create the mesh
  64138. * @param scene defines the hosting scene
  64139. * @returns the plane polygonal mesh
  64140. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  64141. */
  64142. static CreateDisc(name: string, options: {
  64143. radius?: number;
  64144. tessellation?: number;
  64145. arc?: number;
  64146. updatable?: boolean;
  64147. sideOrientation?: number;
  64148. frontUVs?: Vector4;
  64149. backUVs?: Vector4;
  64150. }, scene?: Nullable<Scene>): Mesh;
  64151. /**
  64152. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64153. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64154. * * You can set some different icosphere dimensions, for instance to build an ellipsoid, by using the parameters `radiusX`, `radiusY` and `radiusZ` (all by default have the same value of `radius`)
  64155. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64156. * * The parameter `flat` (boolean, default true) gives each side its own normals. Set it to false to get a smooth continuous light reflection on the surface
  64157. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64158. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64159. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64160. * @param name defines the name of the mesh
  64161. * @param options defines the options used to create the mesh
  64162. * @param scene defines the hosting scene
  64163. * @returns the icosahedron mesh
  64164. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64165. */
  64166. static CreateIcoSphere(name: string, options: {
  64167. radius?: number;
  64168. radiusX?: number;
  64169. radiusY?: number;
  64170. radiusZ?: number;
  64171. flat?: boolean;
  64172. subdivisions?: number;
  64173. sideOrientation?: number;
  64174. frontUVs?: Vector4;
  64175. backUVs?: Vector4;
  64176. updatable?: boolean;
  64177. }, scene?: Nullable<Scene>): Mesh;
  64178. /**
  64179. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64180. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  64181. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  64182. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  64183. * * 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
  64184. * * 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
  64185. * * 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
  64186. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64187. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64188. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64189. * * 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
  64190. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  64191. * * 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
  64192. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  64193. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64194. * @param name defines the name of the mesh
  64195. * @param options defines the options used to create the mesh
  64196. * @param scene defines the hosting scene
  64197. * @returns the ribbon mesh
  64198. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  64199. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64200. */
  64201. static CreateRibbon(name: string, options: {
  64202. pathArray: Vector3[][];
  64203. closeArray?: boolean;
  64204. closePath?: boolean;
  64205. offset?: number;
  64206. updatable?: boolean;
  64207. sideOrientation?: number;
  64208. frontUVs?: Vector4;
  64209. backUVs?: Vector4;
  64210. instance?: Mesh;
  64211. invertUV?: boolean;
  64212. uvs?: Vector2[];
  64213. colors?: Color4[];
  64214. }, scene?: Nullable<Scene>): Mesh;
  64215. /**
  64216. * Creates a cylinder or a cone mesh
  64217. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  64218. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  64219. * * 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.
  64220. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  64221. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  64222. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  64223. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  64224. * * 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).
  64225. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  64226. * * 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).
  64227. * * 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
  64228. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  64229. * * 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
  64230. * * 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.
  64231. * * If `enclose` is false, a ring surface is one element.
  64232. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  64233. * * 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
  64234. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64235. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64236. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64237. * @param name defines the name of the mesh
  64238. * @param options defines the options used to create the mesh
  64239. * @param scene defines the hosting scene
  64240. * @returns the cylinder mesh
  64241. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  64242. */
  64243. static CreateCylinder(name: string, options: {
  64244. height?: number;
  64245. diameterTop?: number;
  64246. diameterBottom?: number;
  64247. diameter?: number;
  64248. tessellation?: number;
  64249. subdivisions?: number;
  64250. arc?: number;
  64251. faceColors?: Color4[];
  64252. faceUV?: Vector4[];
  64253. updatable?: boolean;
  64254. hasRings?: boolean;
  64255. enclose?: boolean;
  64256. cap?: number;
  64257. sideOrientation?: number;
  64258. frontUVs?: Vector4;
  64259. backUVs?: Vector4;
  64260. }, scene?: Nullable<Scene>): Mesh;
  64261. /**
  64262. * Creates a torus mesh
  64263. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  64264. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  64265. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  64266. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64267. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64268. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64269. * @param name defines the name of the mesh
  64270. * @param options defines the options used to create the mesh
  64271. * @param scene defines the hosting scene
  64272. * @returns the torus mesh
  64273. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  64274. */
  64275. static CreateTorus(name: string, options: {
  64276. diameter?: number;
  64277. thickness?: number;
  64278. tessellation?: number;
  64279. updatable?: boolean;
  64280. sideOrientation?: number;
  64281. frontUVs?: Vector4;
  64282. backUVs?: Vector4;
  64283. }, scene?: Nullable<Scene>): Mesh;
  64284. /**
  64285. * Creates a torus knot mesh
  64286. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64287. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64288. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64289. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64290. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64291. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64292. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64293. * @param name defines the name of the mesh
  64294. * @param options defines the options used to create the mesh
  64295. * @param scene defines the hosting scene
  64296. * @returns the torus knot mesh
  64297. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64298. */
  64299. static CreateTorusKnot(name: string, options: {
  64300. radius?: number;
  64301. tube?: number;
  64302. radialSegments?: number;
  64303. tubularSegments?: number;
  64304. p?: number;
  64305. q?: number;
  64306. updatable?: boolean;
  64307. sideOrientation?: number;
  64308. frontUVs?: Vector4;
  64309. backUVs?: Vector4;
  64310. }, scene?: Nullable<Scene>): Mesh;
  64311. /**
  64312. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  64313. * * 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
  64314. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  64315. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  64316. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  64317. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  64318. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  64319. * * 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
  64320. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  64321. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64322. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  64323. * @param name defines the name of the new line system
  64324. * @param options defines the options used to create the line system
  64325. * @param scene defines the hosting scene
  64326. * @returns a new line system mesh
  64327. */
  64328. static CreateLineSystem(name: string, options: {
  64329. lines: Vector3[][];
  64330. updatable?: boolean;
  64331. instance?: Nullable<LinesMesh>;
  64332. colors?: Nullable<Color4[][]>;
  64333. useVertexAlpha?: boolean;
  64334. }, scene: Nullable<Scene>): LinesMesh;
  64335. /**
  64336. * Creates a line mesh
  64337. * 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
  64338. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64339. * * The parameter `points` is an array successive Vector3
  64340. * * 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
  64341. * * The optional parameter `colors` is an array of successive Color4, one per line point
  64342. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  64343. * * When updating an instance, remember that only point positions can change, not the number of points
  64344. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64345. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  64346. * @param name defines the name of the new line system
  64347. * @param options defines the options used to create the line system
  64348. * @param scene defines the hosting scene
  64349. * @returns a new line mesh
  64350. */
  64351. static CreateLines(name: string, options: {
  64352. points: Vector3[];
  64353. updatable?: boolean;
  64354. instance?: Nullable<LinesMesh>;
  64355. colors?: Color4[];
  64356. useVertexAlpha?: boolean;
  64357. }, scene?: Nullable<Scene>): LinesMesh;
  64358. /**
  64359. * Creates a dashed line mesh
  64360. * * 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
  64361. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64362. * * The parameter `points` is an array successive Vector3
  64363. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  64364. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  64365. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  64366. * * 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
  64367. * * When updating an instance, remember that only point positions can change, not the number of points
  64368. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64369. * @param name defines the name of the mesh
  64370. * @param options defines the options used to create the mesh
  64371. * @param scene defines the hosting scene
  64372. * @returns the dashed line mesh
  64373. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  64374. */
  64375. static CreateDashedLines(name: string, options: {
  64376. points: Vector3[];
  64377. dashSize?: number;
  64378. gapSize?: number;
  64379. dashNb?: number;
  64380. updatable?: boolean;
  64381. instance?: LinesMesh;
  64382. }, scene?: Nullable<Scene>): LinesMesh;
  64383. /**
  64384. * 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.
  64385. * * 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.
  64386. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64387. * * 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.
  64388. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  64389. * * 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
  64390. * * 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
  64391. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  64392. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64393. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64394. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  64395. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64396. * @param name defines the name of the mesh
  64397. * @param options defines the options used to create the mesh
  64398. * @param scene defines the hosting scene
  64399. * @returns the extruded shape mesh
  64400. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64401. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64402. */
  64403. static ExtrudeShape(name: string, options: {
  64404. shape: Vector3[];
  64405. path: Vector3[];
  64406. scale?: number;
  64407. rotation?: number;
  64408. cap?: number;
  64409. updatable?: boolean;
  64410. sideOrientation?: number;
  64411. frontUVs?: Vector4;
  64412. backUVs?: Vector4;
  64413. instance?: Mesh;
  64414. invertUV?: boolean;
  64415. }, scene?: Nullable<Scene>): Mesh;
  64416. /**
  64417. * Creates an custom extruded shape mesh.
  64418. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  64419. * * 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.
  64420. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64421. * * 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
  64422. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  64423. * * 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
  64424. * * It must returns a float value that will be the scale value applied to the shape on each path point
  64425. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  64426. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  64427. * * 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
  64428. * * 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
  64429. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  64430. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64431. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64432. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64433. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64434. * @param name defines the name of the mesh
  64435. * @param options defines the options used to create the mesh
  64436. * @param scene defines the hosting scene
  64437. * @returns the custom extruded shape mesh
  64438. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  64439. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64440. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64441. */
  64442. static ExtrudeShapeCustom(name: string, options: {
  64443. shape: Vector3[];
  64444. path: Vector3[];
  64445. scaleFunction?: any;
  64446. rotationFunction?: any;
  64447. ribbonCloseArray?: boolean;
  64448. ribbonClosePath?: boolean;
  64449. cap?: number;
  64450. updatable?: boolean;
  64451. sideOrientation?: number;
  64452. frontUVs?: Vector4;
  64453. backUVs?: Vector4;
  64454. instance?: Mesh;
  64455. invertUV?: boolean;
  64456. }, scene?: Nullable<Scene>): Mesh;
  64457. /**
  64458. * Creates lathe mesh.
  64459. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64460. * * 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
  64461. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64462. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64463. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64464. * * 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
  64465. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64466. * * 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
  64467. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64468. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64469. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64470. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64471. * @param name defines the name of the mesh
  64472. * @param options defines the options used to create the mesh
  64473. * @param scene defines the hosting scene
  64474. * @returns the lathe mesh
  64475. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64476. */
  64477. static CreateLathe(name: string, options: {
  64478. shape: Vector3[];
  64479. radius?: number;
  64480. tessellation?: number;
  64481. clip?: number;
  64482. arc?: number;
  64483. closed?: boolean;
  64484. updatable?: boolean;
  64485. sideOrientation?: number;
  64486. frontUVs?: Vector4;
  64487. backUVs?: Vector4;
  64488. cap?: number;
  64489. invertUV?: boolean;
  64490. }, scene?: Nullable<Scene>): Mesh;
  64491. /**
  64492. * Creates a tiled plane mesh
  64493. * * You can set a limited pattern arrangement with the tiles
  64494. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64495. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64496. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64497. * @param name defines the name of the mesh
  64498. * @param options defines the options used to create the mesh
  64499. * @param scene defines the hosting scene
  64500. * @returns the plane mesh
  64501. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64502. */
  64503. static CreateTiledPlane(name: string, options: {
  64504. pattern?: number;
  64505. tileSize?: number;
  64506. tileWidth?: number;
  64507. tileHeight?: number;
  64508. size?: number;
  64509. width?: number;
  64510. height?: number;
  64511. alignHorizontal?: number;
  64512. alignVertical?: number;
  64513. sideOrientation?: number;
  64514. frontUVs?: Vector4;
  64515. backUVs?: Vector4;
  64516. updatable?: boolean;
  64517. }, scene?: Nullable<Scene>): Mesh;
  64518. /**
  64519. * Creates a plane mesh
  64520. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  64521. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  64522. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  64523. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64524. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64525. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64526. * @param name defines the name of the mesh
  64527. * @param options defines the options used to create the mesh
  64528. * @param scene defines the hosting scene
  64529. * @returns the plane mesh
  64530. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64531. */
  64532. static CreatePlane(name: string, options: {
  64533. size?: number;
  64534. width?: number;
  64535. height?: number;
  64536. sideOrientation?: number;
  64537. frontUVs?: Vector4;
  64538. backUVs?: Vector4;
  64539. updatable?: boolean;
  64540. sourcePlane?: Plane;
  64541. }, scene?: Nullable<Scene>): Mesh;
  64542. /**
  64543. * Creates a ground mesh
  64544. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  64545. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  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 ground mesh
  64551. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  64552. */
  64553. static CreateGround(name: string, options: {
  64554. width?: number;
  64555. height?: number;
  64556. subdivisions?: number;
  64557. subdivisionsX?: number;
  64558. subdivisionsY?: number;
  64559. updatable?: boolean;
  64560. }, scene?: Nullable<Scene>): Mesh;
  64561. /**
  64562. * Creates a tiled ground mesh
  64563. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  64564. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  64565. * * 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
  64566. * * 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
  64567. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64568. * @param name defines the name of the mesh
  64569. * @param options defines the options used to create the mesh
  64570. * @param scene defines the hosting scene
  64571. * @returns the tiled ground mesh
  64572. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  64573. */
  64574. static CreateTiledGround(name: string, options: {
  64575. xmin: number;
  64576. zmin: number;
  64577. xmax: number;
  64578. zmax: number;
  64579. subdivisions?: {
  64580. w: number;
  64581. h: number;
  64582. };
  64583. precision?: {
  64584. w: number;
  64585. h: number;
  64586. };
  64587. updatable?: boolean;
  64588. }, scene?: Nullable<Scene>): Mesh;
  64589. /**
  64590. * Creates a ground mesh from a height map
  64591. * * The parameter `url` sets the URL of the height map image resource.
  64592. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  64593. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  64594. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  64595. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  64596. * * 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.
  64597. * * 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).
  64598. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  64599. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64600. * @param name defines the name of the mesh
  64601. * @param url defines the url to the height map
  64602. * @param options defines the options used to create the mesh
  64603. * @param scene defines the hosting scene
  64604. * @returns the ground mesh
  64605. * @see https://doc.babylonjs.com/babylon101/height_map
  64606. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  64607. */
  64608. static CreateGroundFromHeightMap(name: string, url: string, options: {
  64609. width?: number;
  64610. height?: number;
  64611. subdivisions?: number;
  64612. minHeight?: number;
  64613. maxHeight?: number;
  64614. colorFilter?: Color3;
  64615. alphaFilter?: number;
  64616. updatable?: boolean;
  64617. onReady?: (mesh: GroundMesh) => void;
  64618. }, scene?: Nullable<Scene>): GroundMesh;
  64619. /**
  64620. * Creates a polygon mesh
  64621. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64622. * * 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
  64623. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64624. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  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)
  64626. * * Remember you can only change the shape positions, not their number when updating a polygon
  64627. * @param name defines the name of the mesh
  64628. * @param options defines the options used to create the mesh
  64629. * @param scene defines the hosting scene
  64630. * @param earcutInjection can be used to inject your own earcut reference
  64631. * @returns the polygon mesh
  64632. */
  64633. static CreatePolygon(name: string, options: {
  64634. shape: Vector3[];
  64635. holes?: Vector3[][];
  64636. depth?: number;
  64637. faceUV?: Vector4[];
  64638. faceColors?: Color4[];
  64639. updatable?: boolean;
  64640. sideOrientation?: number;
  64641. frontUVs?: Vector4;
  64642. backUVs?: Vector4;
  64643. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64644. /**
  64645. * Creates an extruded polygon mesh, with depth in the Y direction.
  64646. * * 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)
  64647. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64648. * @param name defines the name of the mesh
  64649. * @param options defines the options used to create the mesh
  64650. * @param scene defines the hosting scene
  64651. * @param earcutInjection can be used to inject your own earcut reference
  64652. * @returns the polygon mesh
  64653. */
  64654. static ExtrudePolygon(name: string, options: {
  64655. shape: Vector3[];
  64656. holes?: Vector3[][];
  64657. depth?: number;
  64658. faceUV?: Vector4[];
  64659. faceColors?: Color4[];
  64660. updatable?: boolean;
  64661. sideOrientation?: number;
  64662. frontUVs?: Vector4;
  64663. backUVs?: Vector4;
  64664. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64665. /**
  64666. * Creates a tube mesh.
  64667. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64668. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64669. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64670. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64671. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64672. * * 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)
  64673. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64674. * * 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
  64675. * * 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
  64676. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64677. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64678. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64679. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64680. * @param name defines the name of the mesh
  64681. * @param options defines the options used to create the mesh
  64682. * @param scene defines the hosting scene
  64683. * @returns the tube mesh
  64684. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64685. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64686. */
  64687. static CreateTube(name: string, options: {
  64688. path: Vector3[];
  64689. radius?: number;
  64690. tessellation?: number;
  64691. radiusFunction?: {
  64692. (i: number, distance: number): number;
  64693. };
  64694. cap?: number;
  64695. arc?: number;
  64696. updatable?: boolean;
  64697. sideOrientation?: number;
  64698. frontUVs?: Vector4;
  64699. backUVs?: Vector4;
  64700. instance?: Mesh;
  64701. invertUV?: boolean;
  64702. }, scene?: Nullable<Scene>): Mesh;
  64703. /**
  64704. * Creates a polyhedron mesh
  64705. * * 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
  64706. * * The parameter `size` (positive float, default 1) sets the polygon size
  64707. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  64708. * * 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`
  64709. * * 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
  64710. * * 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)`)
  64711. * * 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
  64712. * * 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
  64713. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64714. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64715. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64716. * @param name defines the name of the mesh
  64717. * @param options defines the options used to create the mesh
  64718. * @param scene defines the hosting scene
  64719. * @returns the polyhedron mesh
  64720. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  64721. */
  64722. static CreatePolyhedron(name: string, options: {
  64723. type?: number;
  64724. size?: number;
  64725. sizeX?: number;
  64726. sizeY?: number;
  64727. sizeZ?: number;
  64728. custom?: any;
  64729. faceUV?: Vector4[];
  64730. faceColors?: Color4[];
  64731. flat?: boolean;
  64732. updatable?: boolean;
  64733. sideOrientation?: number;
  64734. frontUVs?: Vector4;
  64735. backUVs?: Vector4;
  64736. }, scene?: Nullable<Scene>): Mesh;
  64737. /**
  64738. * Creates a decal mesh.
  64739. * 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
  64740. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64741. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64742. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64743. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64744. * @param name defines the name of the mesh
  64745. * @param sourceMesh defines the mesh where the decal must be applied
  64746. * @param options defines the options used to create the mesh
  64747. * @param scene defines the hosting scene
  64748. * @returns the decal mesh
  64749. * @see https://doc.babylonjs.com/how_to/decals
  64750. */
  64751. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64752. position?: Vector3;
  64753. normal?: Vector3;
  64754. size?: Vector3;
  64755. angle?: number;
  64756. }): Mesh;
  64757. }
  64758. }
  64759. declare module "babylonjs/Meshes/meshSimplification" {
  64760. import { Mesh } from "babylonjs/Meshes/mesh";
  64761. /**
  64762. * A simplifier interface for future simplification implementations
  64763. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64764. */
  64765. export interface ISimplifier {
  64766. /**
  64767. * Simplification of a given mesh according to the given settings.
  64768. * Since this requires computation, it is assumed that the function runs async.
  64769. * @param settings The settings of the simplification, including quality and distance
  64770. * @param successCallback A callback that will be called after the mesh was simplified.
  64771. * @param errorCallback in case of an error, this callback will be called. optional.
  64772. */
  64773. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  64774. }
  64775. /**
  64776. * Expected simplification settings.
  64777. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  64778. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64779. */
  64780. export interface ISimplificationSettings {
  64781. /**
  64782. * Gets or sets the expected quality
  64783. */
  64784. quality: number;
  64785. /**
  64786. * Gets or sets the distance when this optimized version should be used
  64787. */
  64788. distance: number;
  64789. /**
  64790. * Gets an already optimized mesh
  64791. */
  64792. optimizeMesh?: boolean;
  64793. }
  64794. /**
  64795. * Class used to specify simplification options
  64796. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64797. */
  64798. export class SimplificationSettings implements ISimplificationSettings {
  64799. /** expected quality */
  64800. quality: number;
  64801. /** distance when this optimized version should be used */
  64802. distance: number;
  64803. /** already optimized mesh */
  64804. optimizeMesh?: boolean | undefined;
  64805. /**
  64806. * Creates a SimplificationSettings
  64807. * @param quality expected quality
  64808. * @param distance distance when this optimized version should be used
  64809. * @param optimizeMesh already optimized mesh
  64810. */
  64811. constructor(
  64812. /** expected quality */
  64813. quality: number,
  64814. /** distance when this optimized version should be used */
  64815. distance: number,
  64816. /** already optimized mesh */
  64817. optimizeMesh?: boolean | undefined);
  64818. }
  64819. /**
  64820. * Interface used to define a simplification task
  64821. */
  64822. export interface ISimplificationTask {
  64823. /**
  64824. * Array of settings
  64825. */
  64826. settings: Array<ISimplificationSettings>;
  64827. /**
  64828. * Simplification type
  64829. */
  64830. simplificationType: SimplificationType;
  64831. /**
  64832. * Mesh to simplify
  64833. */
  64834. mesh: Mesh;
  64835. /**
  64836. * Callback called on success
  64837. */
  64838. successCallback?: () => void;
  64839. /**
  64840. * Defines if parallel processing can be used
  64841. */
  64842. parallelProcessing: boolean;
  64843. }
  64844. /**
  64845. * Queue used to order the simplification tasks
  64846. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64847. */
  64848. export class SimplificationQueue {
  64849. private _simplificationArray;
  64850. /**
  64851. * Gets a boolean indicating that the process is still running
  64852. */
  64853. running: boolean;
  64854. /**
  64855. * Creates a new queue
  64856. */
  64857. constructor();
  64858. /**
  64859. * Adds a new simplification task
  64860. * @param task defines a task to add
  64861. */
  64862. addTask(task: ISimplificationTask): void;
  64863. /**
  64864. * Execute next task
  64865. */
  64866. executeNext(): void;
  64867. /**
  64868. * Execute a simplification task
  64869. * @param task defines the task to run
  64870. */
  64871. runSimplification(task: ISimplificationTask): void;
  64872. private getSimplifier;
  64873. }
  64874. /**
  64875. * The implemented types of simplification
  64876. * At the moment only Quadratic Error Decimation is implemented
  64877. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64878. */
  64879. export enum SimplificationType {
  64880. /** Quadratic error decimation */
  64881. QUADRATIC = 0
  64882. }
  64883. }
  64884. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  64885. import { Scene } from "babylonjs/scene";
  64886. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  64887. import { ISceneComponent } from "babylonjs/sceneComponent";
  64888. module "babylonjs/scene" {
  64889. interface Scene {
  64890. /** @hidden (Backing field) */
  64891. _simplificationQueue: SimplificationQueue;
  64892. /**
  64893. * Gets or sets the simplification queue attached to the scene
  64894. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64895. */
  64896. simplificationQueue: SimplificationQueue;
  64897. }
  64898. }
  64899. module "babylonjs/Meshes/mesh" {
  64900. interface Mesh {
  64901. /**
  64902. * Simplify the mesh according to the given array of settings.
  64903. * Function will return immediately and will simplify async
  64904. * @param settings a collection of simplification settings
  64905. * @param parallelProcessing should all levels calculate parallel or one after the other
  64906. * @param simplificationType the type of simplification to run
  64907. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  64908. * @returns the current mesh
  64909. */
  64910. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  64911. }
  64912. }
  64913. /**
  64914. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  64915. * created in a scene
  64916. */
  64917. export class SimplicationQueueSceneComponent implements ISceneComponent {
  64918. /**
  64919. * The component name helpfull to identify the component in the list of scene components.
  64920. */
  64921. readonly name: string;
  64922. /**
  64923. * The scene the component belongs to.
  64924. */
  64925. scene: Scene;
  64926. /**
  64927. * Creates a new instance of the component for the given scene
  64928. * @param scene Defines the scene to register the component in
  64929. */
  64930. constructor(scene: Scene);
  64931. /**
  64932. * Registers the component in a given scene
  64933. */
  64934. register(): void;
  64935. /**
  64936. * Rebuilds the elements related to this component in case of
  64937. * context lost for instance.
  64938. */
  64939. rebuild(): void;
  64940. /**
  64941. * Disposes the component and the associated ressources
  64942. */
  64943. dispose(): void;
  64944. private _beforeCameraUpdate;
  64945. }
  64946. }
  64947. declare module "babylonjs/Meshes/Builders/index" {
  64948. export * from "babylonjs/Meshes/Builders/boxBuilder";
  64949. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  64950. export * from "babylonjs/Meshes/Builders/discBuilder";
  64951. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  64952. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  64953. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  64954. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  64955. export * from "babylonjs/Meshes/Builders/torusBuilder";
  64956. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  64957. export * from "babylonjs/Meshes/Builders/linesBuilder";
  64958. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  64959. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  64960. export * from "babylonjs/Meshes/Builders/latheBuilder";
  64961. export * from "babylonjs/Meshes/Builders/planeBuilder";
  64962. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  64963. export * from "babylonjs/Meshes/Builders/groundBuilder";
  64964. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  64965. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  64966. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  64967. export * from "babylonjs/Meshes/Builders/decalBuilder";
  64968. }
  64969. declare module "babylonjs/Meshes/index" {
  64970. export * from "babylonjs/Meshes/abstractMesh";
  64971. export * from "babylonjs/Meshes/buffer";
  64972. export * from "babylonjs/Meshes/Compression/index";
  64973. export * from "babylonjs/Meshes/csg";
  64974. export * from "babylonjs/Meshes/geometry";
  64975. export * from "babylonjs/Meshes/groundMesh";
  64976. export * from "babylonjs/Meshes/trailMesh";
  64977. export * from "babylonjs/Meshes/instancedMesh";
  64978. export * from "babylonjs/Meshes/linesMesh";
  64979. export * from "babylonjs/Meshes/mesh";
  64980. export * from "babylonjs/Meshes/mesh.vertexData";
  64981. export * from "babylonjs/Meshes/meshBuilder";
  64982. export * from "babylonjs/Meshes/meshSimplification";
  64983. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  64984. export * from "babylonjs/Meshes/polygonMesh";
  64985. export * from "babylonjs/Meshes/subMesh";
  64986. export * from "babylonjs/Meshes/meshLODLevel";
  64987. export * from "babylonjs/Meshes/transformNode";
  64988. export * from "babylonjs/Meshes/Builders/index";
  64989. export * from "babylonjs/Meshes/dataBuffer";
  64990. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  64991. }
  64992. declare module "babylonjs/Morph/index" {
  64993. export * from "babylonjs/Morph/morphTarget";
  64994. export * from "babylonjs/Morph/morphTargetManager";
  64995. }
  64996. declare module "babylonjs/Navigation/INavigationEngine" {
  64997. import { TransformNode } from "babylonjs/Meshes/transformNode";
  64998. import { Vector3 } from "babylonjs/Maths/math";
  64999. import { Mesh } from "babylonjs/Meshes/mesh";
  65000. import { Scene } from "babylonjs/scene";
  65001. /**
  65002. * Navigation plugin interface to add navigation constrained by a navigation mesh
  65003. */
  65004. export interface INavigationEnginePlugin {
  65005. /**
  65006. * plugin name
  65007. */
  65008. name: string;
  65009. /**
  65010. * Creates a navigation mesh
  65011. * @param meshes array of all the geometry used to compute the navigatio mesh
  65012. * @param parameters bunch of parameters used to filter geometry
  65013. */
  65014. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65015. /**
  65016. * Create a navigation mesh debug mesh
  65017. * @param scene is where the mesh will be added
  65018. * @returns debug display mesh
  65019. */
  65020. createDebugNavMesh(scene: Scene): Mesh;
  65021. /**
  65022. * Get a navigation mesh constrained position, closest to the parameter position
  65023. * @param position world position
  65024. * @returns the closest point to position constrained by the navigation mesh
  65025. */
  65026. getClosestPoint(position: Vector3): Vector3;
  65027. /**
  65028. * Get a navigation mesh constrained position, within a particular radius
  65029. * @param position world position
  65030. * @param maxRadius the maximum distance to the constrained world position
  65031. * @returns the closest point to position constrained by the navigation mesh
  65032. */
  65033. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65034. /**
  65035. * Compute the final position from a segment made of destination-position
  65036. * @param position world position
  65037. * @param destination world position
  65038. * @returns the resulting point along the navmesh
  65039. */
  65040. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65041. /**
  65042. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65043. * @param start world position
  65044. * @param end world position
  65045. * @returns array containing world position composing the path
  65046. */
  65047. computePath(start: Vector3, end: Vector3): Vector3[];
  65048. /**
  65049. * If this plugin is supported
  65050. * @returns true if plugin is supported
  65051. */
  65052. isSupported(): boolean;
  65053. /**
  65054. * Create a new Crowd so you can add agents
  65055. * @param maxAgents the maximum agent count in the crowd
  65056. * @param maxAgentRadius the maximum radius an agent can have
  65057. * @param scene to attach the crowd to
  65058. * @returns the crowd you can add agents to
  65059. */
  65060. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65061. /**
  65062. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65063. * The queries will try to find a solution within those bounds
  65064. * default is (1,1,1)
  65065. * @param extent x,y,z value that define the extent around the queries point of reference
  65066. */
  65067. setDefaultQueryExtent(extent: Vector3): void;
  65068. /**
  65069. * Get the Bounding box extent specified by setDefaultQueryExtent
  65070. * @returns the box extent values
  65071. */
  65072. getDefaultQueryExtent(): Vector3;
  65073. /**
  65074. * Release all resources
  65075. */
  65076. dispose(): void;
  65077. }
  65078. /**
  65079. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  65080. */
  65081. export interface ICrowd {
  65082. /**
  65083. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65084. * You can attach anything to that node. The node position is updated in the scene update tick.
  65085. * @param pos world position that will be constrained by the navigation mesh
  65086. * @param parameters agent parameters
  65087. * @param transform hooked to the agent that will be update by the scene
  65088. * @returns agent index
  65089. */
  65090. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65091. /**
  65092. * Returns the agent position in world space
  65093. * @param index agent index returned by addAgent
  65094. * @returns world space position
  65095. */
  65096. getAgentPosition(index: number): Vector3;
  65097. /**
  65098. * Gets the agent velocity in world space
  65099. * @param index agent index returned by addAgent
  65100. * @returns world space velocity
  65101. */
  65102. getAgentVelocity(index: number): Vector3;
  65103. /**
  65104. * remove a particular agent previously created
  65105. * @param index agent index returned by addAgent
  65106. */
  65107. removeAgent(index: number): void;
  65108. /**
  65109. * get the list of all agents attached to this crowd
  65110. * @returns list of agent indices
  65111. */
  65112. getAgents(): number[];
  65113. /**
  65114. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65115. * @param deltaTime in seconds
  65116. */
  65117. update(deltaTime: number): void;
  65118. /**
  65119. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65120. * @param index agent index returned by addAgent
  65121. * @param destination targeted world position
  65122. */
  65123. agentGoto(index: number, destination: Vector3): void;
  65124. /**
  65125. * Teleport the agent to a new position
  65126. * @param index agent index returned by addAgent
  65127. * @param destination targeted world position
  65128. */
  65129. agentTeleport(index: number, destination: Vector3): void;
  65130. /**
  65131. * Update agent parameters
  65132. * @param index agent index returned by addAgent
  65133. * @param parameters agent parameters
  65134. */
  65135. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65136. /**
  65137. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65138. * The queries will try to find a solution within those bounds
  65139. * default is (1,1,1)
  65140. * @param extent x,y,z value that define the extent around the queries point of reference
  65141. */
  65142. setDefaultQueryExtent(extent: Vector3): void;
  65143. /**
  65144. * Get the Bounding box extent specified by setDefaultQueryExtent
  65145. * @returns the box extent values
  65146. */
  65147. getDefaultQueryExtent(): Vector3;
  65148. /**
  65149. * Release all resources
  65150. */
  65151. dispose(): void;
  65152. }
  65153. /**
  65154. * Configures an agent
  65155. */
  65156. export interface IAgentParameters {
  65157. /**
  65158. * Agent radius. [Limit: >= 0]
  65159. */
  65160. radius: number;
  65161. /**
  65162. * Agent height. [Limit: > 0]
  65163. */
  65164. height: number;
  65165. /**
  65166. * Maximum allowed acceleration. [Limit: >= 0]
  65167. */
  65168. maxAcceleration: number;
  65169. /**
  65170. * Maximum allowed speed. [Limit: >= 0]
  65171. */
  65172. maxSpeed: number;
  65173. /**
  65174. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  65175. */
  65176. collisionQueryRange: number;
  65177. /**
  65178. * The path visibility optimization range. [Limit: > 0]
  65179. */
  65180. pathOptimizationRange: number;
  65181. /**
  65182. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  65183. */
  65184. separationWeight: number;
  65185. }
  65186. /**
  65187. * Configures the navigation mesh creation
  65188. */
  65189. export interface INavMeshParameters {
  65190. /**
  65191. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  65192. */
  65193. cs: number;
  65194. /**
  65195. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  65196. */
  65197. ch: number;
  65198. /**
  65199. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  65200. */
  65201. walkableSlopeAngle: number;
  65202. /**
  65203. * Minimum floor to 'ceiling' height that will still allow the floor area to
  65204. * be considered walkable. [Limit: >= 3] [Units: vx]
  65205. */
  65206. walkableHeight: number;
  65207. /**
  65208. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  65209. */
  65210. walkableClimb: number;
  65211. /**
  65212. * The distance to erode/shrink the walkable area of the heightfield away from
  65213. * obstructions. [Limit: >=0] [Units: vx]
  65214. */
  65215. walkableRadius: number;
  65216. /**
  65217. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  65218. */
  65219. maxEdgeLen: number;
  65220. /**
  65221. * The maximum distance a simplfied contour's border edges should deviate
  65222. * the original raw contour. [Limit: >=0] [Units: vx]
  65223. */
  65224. maxSimplificationError: number;
  65225. /**
  65226. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  65227. */
  65228. minRegionArea: number;
  65229. /**
  65230. * Any regions with a span count smaller than this value will, if possible,
  65231. * be merged with larger regions. [Limit: >=0] [Units: vx]
  65232. */
  65233. mergeRegionArea: number;
  65234. /**
  65235. * The maximum number of vertices allowed for polygons generated during the
  65236. * contour to polygon conversion process. [Limit: >= 3]
  65237. */
  65238. maxVertsPerPoly: number;
  65239. /**
  65240. * Sets the sampling distance to use when generating the detail mesh.
  65241. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  65242. */
  65243. detailSampleDist: number;
  65244. /**
  65245. * The maximum distance the detail mesh surface should deviate from heightfield
  65246. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  65247. */
  65248. detailSampleMaxError: number;
  65249. }
  65250. }
  65251. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  65252. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  65253. import { Mesh } from "babylonjs/Meshes/mesh";
  65254. import { Scene } from "babylonjs/scene";
  65255. import { Vector3 } from "babylonjs/Maths/math";
  65256. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65257. /**
  65258. * RecastJS navigation plugin
  65259. */
  65260. export class RecastJSPlugin implements INavigationEnginePlugin {
  65261. /**
  65262. * Reference to the Recast library
  65263. */
  65264. bjsRECAST: any;
  65265. /**
  65266. * plugin name
  65267. */
  65268. name: string;
  65269. /**
  65270. * the first navmesh created. We might extend this to support multiple navmeshes
  65271. */
  65272. navMesh: any;
  65273. /**
  65274. * Initializes the recastJS plugin
  65275. * @param recastInjection can be used to inject your own recast reference
  65276. */
  65277. constructor(recastInjection?: any);
  65278. /**
  65279. * Creates a navigation mesh
  65280. * @param meshes array of all the geometry used to compute the navigatio mesh
  65281. * @param parameters bunch of parameters used to filter geometry
  65282. */
  65283. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65284. /**
  65285. * Create a navigation mesh debug mesh
  65286. * @param scene is where the mesh will be added
  65287. * @returns debug display mesh
  65288. */
  65289. createDebugNavMesh(scene: Scene): Mesh;
  65290. /**
  65291. * Get a navigation mesh constrained position, closest to the parameter position
  65292. * @param position world position
  65293. * @returns the closest point to position constrained by the navigation mesh
  65294. */
  65295. getClosestPoint(position: Vector3): Vector3;
  65296. /**
  65297. * Get a navigation mesh constrained position, within a particular radius
  65298. * @param position world position
  65299. * @param maxRadius the maximum distance to the constrained world position
  65300. * @returns the closest point to position constrained by the navigation mesh
  65301. */
  65302. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65303. /**
  65304. * Compute the final position from a segment made of destination-position
  65305. * @param position world position
  65306. * @param destination world position
  65307. * @returns the resulting point along the navmesh
  65308. */
  65309. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65310. /**
  65311. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65312. * @param start world position
  65313. * @param end world position
  65314. * @returns array containing world position composing the path
  65315. */
  65316. computePath(start: Vector3, end: Vector3): Vector3[];
  65317. /**
  65318. * Create a new Crowd so you can add agents
  65319. * @param maxAgents the maximum agent count in the crowd
  65320. * @param maxAgentRadius the maximum radius an agent can have
  65321. * @param scene to attach the crowd to
  65322. * @returns the crowd you can add agents to
  65323. */
  65324. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65325. /**
  65326. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65327. * The queries will try to find a solution within those bounds
  65328. * default is (1,1,1)
  65329. * @param extent x,y,z value that define the extent around the queries point of reference
  65330. */
  65331. setDefaultQueryExtent(extent: Vector3): void;
  65332. /**
  65333. * Get the Bounding box extent specified by setDefaultQueryExtent
  65334. * @returns the box extent values
  65335. */
  65336. getDefaultQueryExtent(): Vector3;
  65337. /**
  65338. * Disposes
  65339. */
  65340. dispose(): void;
  65341. /**
  65342. * If this plugin is supported
  65343. * @returns true if plugin is supported
  65344. */
  65345. isSupported(): boolean;
  65346. }
  65347. /**
  65348. * Recast detour crowd implementation
  65349. */
  65350. export class RecastJSCrowd implements ICrowd {
  65351. /**
  65352. * Recast/detour plugin
  65353. */
  65354. bjsRECASTPlugin: RecastJSPlugin;
  65355. /**
  65356. * Link to the detour crowd
  65357. */
  65358. recastCrowd: any;
  65359. /**
  65360. * One transform per agent
  65361. */
  65362. transforms: TransformNode[];
  65363. /**
  65364. * All agents created
  65365. */
  65366. agents: number[];
  65367. /**
  65368. * Link to the scene is kept to unregister the crowd from the scene
  65369. */
  65370. private _scene;
  65371. /**
  65372. * Observer for crowd updates
  65373. */
  65374. private _onBeforeAnimationsObserver;
  65375. /**
  65376. * Constructor
  65377. * @param plugin recastJS plugin
  65378. * @param maxAgents the maximum agent count in the crowd
  65379. * @param maxAgentRadius the maximum radius an agent can have
  65380. * @param scene to attach the crowd to
  65381. * @returns the crowd you can add agents to
  65382. */
  65383. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  65384. /**
  65385. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65386. * You can attach anything to that node. The node position is updated in the scene update tick.
  65387. * @param pos world position that will be constrained by the navigation mesh
  65388. * @param parameters agent parameters
  65389. * @param transform hooked to the agent that will be update by the scene
  65390. * @returns agent index
  65391. */
  65392. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65393. /**
  65394. * Returns the agent position in world space
  65395. * @param index agent index returned by addAgent
  65396. * @returns world space position
  65397. */
  65398. getAgentPosition(index: number): Vector3;
  65399. /**
  65400. * Returns the agent velocity in world space
  65401. * @param index agent index returned by addAgent
  65402. * @returns world space velocity
  65403. */
  65404. getAgentVelocity(index: number): Vector3;
  65405. /**
  65406. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65407. * @param index agent index returned by addAgent
  65408. * @param destination targeted world position
  65409. */
  65410. agentGoto(index: number, destination: Vector3): void;
  65411. /**
  65412. * Teleport the agent to a new position
  65413. * @param index agent index returned by addAgent
  65414. * @param destination targeted world position
  65415. */
  65416. agentTeleport(index: number, destination: Vector3): void;
  65417. /**
  65418. * Update agent parameters
  65419. * @param index agent index returned by addAgent
  65420. * @param parameters agent parameters
  65421. */
  65422. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65423. /**
  65424. * remove a particular agent previously created
  65425. * @param index agent index returned by addAgent
  65426. */
  65427. removeAgent(index: number): void;
  65428. /**
  65429. * get the list of all agents attached to this crowd
  65430. * @returns list of agent indices
  65431. */
  65432. getAgents(): number[];
  65433. /**
  65434. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65435. * @param deltaTime in seconds
  65436. */
  65437. update(deltaTime: number): void;
  65438. /**
  65439. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65440. * The queries will try to find a solution within those bounds
  65441. * default is (1,1,1)
  65442. * @param extent x,y,z value that define the extent around the queries point of reference
  65443. */
  65444. setDefaultQueryExtent(extent: Vector3): void;
  65445. /**
  65446. * Get the Bounding box extent specified by setDefaultQueryExtent
  65447. * @returns the box extent values
  65448. */
  65449. getDefaultQueryExtent(): Vector3;
  65450. /**
  65451. * Release all resources
  65452. */
  65453. dispose(): void;
  65454. }
  65455. }
  65456. declare module "babylonjs/Navigation/Plugins/index" {
  65457. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  65458. }
  65459. declare module "babylonjs/Navigation/index" {
  65460. export * from "babylonjs/Navigation/INavigationEngine";
  65461. export * from "babylonjs/Navigation/Plugins/index";
  65462. }
  65463. declare module "babylonjs/Offline/database" {
  65464. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  65465. /**
  65466. * Class used to enable access to IndexedDB
  65467. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  65468. */
  65469. export class Database implements IOfflineProvider {
  65470. private _callbackManifestChecked;
  65471. private _currentSceneUrl;
  65472. private _db;
  65473. private _enableSceneOffline;
  65474. private _enableTexturesOffline;
  65475. private _manifestVersionFound;
  65476. private _mustUpdateRessources;
  65477. private _hasReachedQuota;
  65478. private _isSupported;
  65479. private _idbFactory;
  65480. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  65481. private static IsUASupportingBlobStorage;
  65482. /**
  65483. * Gets a boolean indicating if Database storate is enabled (off by default)
  65484. */
  65485. static IDBStorageEnabled: boolean;
  65486. /**
  65487. * Gets a boolean indicating if scene must be saved in the database
  65488. */
  65489. get enableSceneOffline(): boolean;
  65490. /**
  65491. * Gets a boolean indicating if textures must be saved in the database
  65492. */
  65493. get enableTexturesOffline(): boolean;
  65494. /**
  65495. * Creates a new Database
  65496. * @param urlToScene defines the url to load the scene
  65497. * @param callbackManifestChecked defines the callback to use when manifest is checked
  65498. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  65499. */
  65500. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  65501. private static _ParseURL;
  65502. private static _ReturnFullUrlLocation;
  65503. private _checkManifestFile;
  65504. /**
  65505. * Open the database and make it available
  65506. * @param successCallback defines the callback to call on success
  65507. * @param errorCallback defines the callback to call on error
  65508. */
  65509. open(successCallback: () => void, errorCallback: () => void): void;
  65510. /**
  65511. * Loads an image from the database
  65512. * @param url defines the url to load from
  65513. * @param image defines the target DOM image
  65514. */
  65515. loadImage(url: string, image: HTMLImageElement): void;
  65516. private _loadImageFromDBAsync;
  65517. private _saveImageIntoDBAsync;
  65518. private _checkVersionFromDB;
  65519. private _loadVersionFromDBAsync;
  65520. private _saveVersionIntoDBAsync;
  65521. /**
  65522. * Loads a file from database
  65523. * @param url defines the URL to load from
  65524. * @param sceneLoaded defines a callback to call on success
  65525. * @param progressCallBack defines a callback to call when progress changed
  65526. * @param errorCallback defines a callback to call on error
  65527. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  65528. */
  65529. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  65530. private _loadFileAsync;
  65531. private _saveFileAsync;
  65532. /**
  65533. * Validates if xhr data is correct
  65534. * @param xhr defines the request to validate
  65535. * @param dataType defines the expected data type
  65536. * @returns true if data is correct
  65537. */
  65538. private static _ValidateXHRData;
  65539. }
  65540. }
  65541. declare module "babylonjs/Offline/index" {
  65542. export * from "babylonjs/Offline/database";
  65543. export * from "babylonjs/Offline/IOfflineProvider";
  65544. }
  65545. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  65546. /** @hidden */
  65547. export var gpuUpdateParticlesPixelShader: {
  65548. name: string;
  65549. shader: string;
  65550. };
  65551. }
  65552. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  65553. /** @hidden */
  65554. export var gpuUpdateParticlesVertexShader: {
  65555. name: string;
  65556. shader: string;
  65557. };
  65558. }
  65559. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  65560. /** @hidden */
  65561. export var clipPlaneFragmentDeclaration2: {
  65562. name: string;
  65563. shader: string;
  65564. };
  65565. }
  65566. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  65567. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  65568. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  65569. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65570. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  65571. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  65572. /** @hidden */
  65573. export var gpuRenderParticlesPixelShader: {
  65574. name: string;
  65575. shader: string;
  65576. };
  65577. }
  65578. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  65579. /** @hidden */
  65580. export var clipPlaneVertexDeclaration2: {
  65581. name: string;
  65582. shader: string;
  65583. };
  65584. }
  65585. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  65586. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  65587. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  65588. /** @hidden */
  65589. export var gpuRenderParticlesVertexShader: {
  65590. name: string;
  65591. shader: string;
  65592. };
  65593. }
  65594. declare module "babylonjs/Particles/gpuParticleSystem" {
  65595. import { Nullable } from "babylonjs/types";
  65596. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  65597. import { Observable } from "babylonjs/Misc/observable";
  65598. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  65599. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65600. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  65601. import { Scene, IDisposable } from "babylonjs/scene";
  65602. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  65603. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  65604. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  65605. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  65606. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  65607. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  65608. /**
  65609. * This represents a GPU particle system in Babylon
  65610. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  65611. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  65612. */
  65613. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  65614. /**
  65615. * The layer mask we are rendering the particles through.
  65616. */
  65617. layerMask: number;
  65618. private _capacity;
  65619. private _activeCount;
  65620. private _currentActiveCount;
  65621. private _accumulatedCount;
  65622. private _renderEffect;
  65623. private _updateEffect;
  65624. private _buffer0;
  65625. private _buffer1;
  65626. private _spriteBuffer;
  65627. private _updateVAO;
  65628. private _renderVAO;
  65629. private _targetIndex;
  65630. private _sourceBuffer;
  65631. private _targetBuffer;
  65632. private _engine;
  65633. private _currentRenderId;
  65634. private _started;
  65635. private _stopped;
  65636. private _timeDelta;
  65637. private _randomTexture;
  65638. private _randomTexture2;
  65639. private _attributesStrideSize;
  65640. private _updateEffectOptions;
  65641. private _randomTextureSize;
  65642. private _actualFrame;
  65643. private readonly _rawTextureWidth;
  65644. /**
  65645. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  65646. */
  65647. static get IsSupported(): boolean;
  65648. /**
  65649. * An event triggered when the system is disposed.
  65650. */
  65651. onDisposeObservable: Observable<GPUParticleSystem>;
  65652. /**
  65653. * Gets the maximum number of particles active at the same time.
  65654. * @returns The max number of active particles.
  65655. */
  65656. getCapacity(): number;
  65657. /**
  65658. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  65659. * to override the particles.
  65660. */
  65661. forceDepthWrite: boolean;
  65662. /**
  65663. * Gets or set the number of active particles
  65664. */
  65665. get activeParticleCount(): number;
  65666. set activeParticleCount(value: number);
  65667. private _preWarmDone;
  65668. /**
  65669. * Is this system ready to be used/rendered
  65670. * @return true if the system is ready
  65671. */
  65672. isReady(): boolean;
  65673. /**
  65674. * Gets if the system has been started. (Note: this will still be true after stop is called)
  65675. * @returns True if it has been started, otherwise false.
  65676. */
  65677. isStarted(): boolean;
  65678. /**
  65679. * Starts the particle system and begins to emit
  65680. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  65681. */
  65682. start(delay?: number): void;
  65683. /**
  65684. * Stops the particle system.
  65685. */
  65686. stop(): void;
  65687. /**
  65688. * Remove all active particles
  65689. */
  65690. reset(): void;
  65691. /**
  65692. * Returns the string "GPUParticleSystem"
  65693. * @returns a string containing the class name
  65694. */
  65695. getClassName(): string;
  65696. private _colorGradientsTexture;
  65697. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  65698. /**
  65699. * Adds a new color gradient
  65700. * @param gradient defines the gradient to use (between 0 and 1)
  65701. * @param color1 defines the color to affect to the specified gradient
  65702. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  65703. * @returns the current particle system
  65704. */
  65705. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  65706. /**
  65707. * Remove a specific color gradient
  65708. * @param gradient defines the gradient to remove
  65709. * @returns the current particle system
  65710. */
  65711. removeColorGradient(gradient: number): GPUParticleSystem;
  65712. private _angularSpeedGradientsTexture;
  65713. private _sizeGradientsTexture;
  65714. private _velocityGradientsTexture;
  65715. private _limitVelocityGradientsTexture;
  65716. private _dragGradientsTexture;
  65717. private _addFactorGradient;
  65718. /**
  65719. * Adds a new size gradient
  65720. * @param gradient defines the gradient to use (between 0 and 1)
  65721. * @param factor defines the size factor to affect to the specified gradient
  65722. * @returns the current particle system
  65723. */
  65724. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  65725. /**
  65726. * Remove a specific size gradient
  65727. * @param gradient defines the gradient to remove
  65728. * @returns the current particle system
  65729. */
  65730. removeSizeGradient(gradient: number): GPUParticleSystem;
  65731. /**
  65732. * Adds a new angular speed gradient
  65733. * @param gradient defines the gradient to use (between 0 and 1)
  65734. * @param factor defines the angular speed to affect to the specified gradient
  65735. * @returns the current particle system
  65736. */
  65737. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  65738. /**
  65739. * Remove a specific angular speed gradient
  65740. * @param gradient defines the gradient to remove
  65741. * @returns the current particle system
  65742. */
  65743. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  65744. /**
  65745. * Adds a new velocity gradient
  65746. * @param gradient defines the gradient to use (between 0 and 1)
  65747. * @param factor defines the velocity to affect to the specified gradient
  65748. * @returns the current particle system
  65749. */
  65750. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65751. /**
  65752. * Remove a specific velocity gradient
  65753. * @param gradient defines the gradient to remove
  65754. * @returns the current particle system
  65755. */
  65756. removeVelocityGradient(gradient: number): GPUParticleSystem;
  65757. /**
  65758. * Adds a new limit velocity gradient
  65759. * @param gradient defines the gradient to use (between 0 and 1)
  65760. * @param factor defines the limit velocity value to affect to the specified gradient
  65761. * @returns the current particle system
  65762. */
  65763. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65764. /**
  65765. * Remove a specific limit velocity gradient
  65766. * @param gradient defines the gradient to remove
  65767. * @returns the current particle system
  65768. */
  65769. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  65770. /**
  65771. * Adds a new drag gradient
  65772. * @param gradient defines the gradient to use (between 0 and 1)
  65773. * @param factor defines the drag value to affect to the specified gradient
  65774. * @returns the current particle system
  65775. */
  65776. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  65777. /**
  65778. * Remove a specific drag gradient
  65779. * @param gradient defines the gradient to remove
  65780. * @returns the current particle system
  65781. */
  65782. removeDragGradient(gradient: number): GPUParticleSystem;
  65783. /**
  65784. * Not supported by GPUParticleSystem
  65785. * @param gradient defines the gradient to use (between 0 and 1)
  65786. * @param factor defines the emit rate value to affect to the specified gradient
  65787. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65788. * @returns the current particle system
  65789. */
  65790. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65791. /**
  65792. * Not supported by GPUParticleSystem
  65793. * @param gradient defines the gradient to remove
  65794. * @returns the current particle system
  65795. */
  65796. removeEmitRateGradient(gradient: number): IParticleSystem;
  65797. /**
  65798. * Not supported by GPUParticleSystem
  65799. * @param gradient defines the gradient to use (between 0 and 1)
  65800. * @param factor defines the start size value to affect to the specified gradient
  65801. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65802. * @returns the current particle system
  65803. */
  65804. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65805. /**
  65806. * Not supported by GPUParticleSystem
  65807. * @param gradient defines the gradient to remove
  65808. * @returns the current particle system
  65809. */
  65810. removeStartSizeGradient(gradient: number): IParticleSystem;
  65811. /**
  65812. * Not supported by GPUParticleSystem
  65813. * @param gradient defines the gradient to use (between 0 and 1)
  65814. * @param min defines the color remap minimal range
  65815. * @param max defines the color remap maximal range
  65816. * @returns the current particle system
  65817. */
  65818. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65819. /**
  65820. * Not supported by GPUParticleSystem
  65821. * @param gradient defines the gradient to remove
  65822. * @returns the current particle system
  65823. */
  65824. removeColorRemapGradient(): IParticleSystem;
  65825. /**
  65826. * Not supported by GPUParticleSystem
  65827. * @param gradient defines the gradient to use (between 0 and 1)
  65828. * @param min defines the alpha remap minimal range
  65829. * @param max defines the alpha remap maximal range
  65830. * @returns the current particle system
  65831. */
  65832. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65833. /**
  65834. * Not supported by GPUParticleSystem
  65835. * @param gradient defines the gradient to remove
  65836. * @returns the current particle system
  65837. */
  65838. removeAlphaRemapGradient(): IParticleSystem;
  65839. /**
  65840. * Not supported by GPUParticleSystem
  65841. * @param gradient defines the gradient to use (between 0 and 1)
  65842. * @param color defines the color to affect to the specified gradient
  65843. * @returns the current particle system
  65844. */
  65845. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  65846. /**
  65847. * Not supported by GPUParticleSystem
  65848. * @param gradient defines the gradient to remove
  65849. * @returns the current particle system
  65850. */
  65851. removeRampGradient(): IParticleSystem;
  65852. /**
  65853. * Not supported by GPUParticleSystem
  65854. * @returns the list of ramp gradients
  65855. */
  65856. getRampGradients(): Nullable<Array<Color3Gradient>>;
  65857. /**
  65858. * Not supported by GPUParticleSystem
  65859. * Gets or sets a boolean indicating that ramp gradients must be used
  65860. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  65861. */
  65862. get useRampGradients(): boolean;
  65863. set useRampGradients(value: boolean);
  65864. /**
  65865. * Not supported by GPUParticleSystem
  65866. * @param gradient defines the gradient to use (between 0 and 1)
  65867. * @param factor defines the life time factor to affect to the specified gradient
  65868. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65869. * @returns the current particle system
  65870. */
  65871. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65872. /**
  65873. * Not supported by GPUParticleSystem
  65874. * @param gradient defines the gradient to remove
  65875. * @returns the current particle system
  65876. */
  65877. removeLifeTimeGradient(gradient: number): IParticleSystem;
  65878. /**
  65879. * Instantiates a GPU particle system.
  65880. * 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.
  65881. * @param name The name of the particle system
  65882. * @param options The options used to create the system
  65883. * @param scene The scene the particle system belongs to
  65884. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  65885. */
  65886. constructor(name: string, options: Partial<{
  65887. capacity: number;
  65888. randomTextureSize: number;
  65889. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  65890. protected _reset(): void;
  65891. private _createUpdateVAO;
  65892. private _createRenderVAO;
  65893. private _initialize;
  65894. /** @hidden */
  65895. _recreateUpdateEffect(): void;
  65896. /** @hidden */
  65897. _recreateRenderEffect(): void;
  65898. /**
  65899. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  65900. * @param preWarm defines if we are in the pre-warmimg phase
  65901. */
  65902. animate(preWarm?: boolean): void;
  65903. private _createFactorGradientTexture;
  65904. private _createSizeGradientTexture;
  65905. private _createAngularSpeedGradientTexture;
  65906. private _createVelocityGradientTexture;
  65907. private _createLimitVelocityGradientTexture;
  65908. private _createDragGradientTexture;
  65909. private _createColorGradientTexture;
  65910. /**
  65911. * Renders the particle system in its current state
  65912. * @param preWarm defines if the system should only update the particles but not render them
  65913. * @returns the current number of particles
  65914. */
  65915. render(preWarm?: boolean): number;
  65916. /**
  65917. * Rebuilds the particle system
  65918. */
  65919. rebuild(): void;
  65920. private _releaseBuffers;
  65921. private _releaseVAOs;
  65922. /**
  65923. * Disposes the particle system and free the associated resources
  65924. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  65925. */
  65926. dispose(disposeTexture?: boolean): void;
  65927. /**
  65928. * Clones the particle system.
  65929. * @param name The name of the cloned object
  65930. * @param newEmitter The new emitter to use
  65931. * @returns the cloned particle system
  65932. */
  65933. clone(name: string, newEmitter: any): GPUParticleSystem;
  65934. /**
  65935. * Serializes the particle system to a JSON object.
  65936. * @returns the JSON object
  65937. */
  65938. serialize(): any;
  65939. /**
  65940. * Parses a JSON object to create a GPU particle system.
  65941. * @param parsedParticleSystem The JSON object to parse
  65942. * @param scene The scene to create the particle system in
  65943. * @param rootUrl The root url to use to load external dependencies like texture
  65944. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  65945. * @returns the parsed GPU particle system
  65946. */
  65947. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  65948. }
  65949. }
  65950. declare module "babylonjs/Particles/particleSystemSet" {
  65951. import { Nullable } from "babylonjs/types";
  65952. import { Color3 } from "babylonjs/Maths/math.color";
  65953. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65954. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65955. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65956. import { Scene, IDisposable } from "babylonjs/scene";
  65957. /**
  65958. * Represents a set of particle systems working together to create a specific effect
  65959. */
  65960. export class ParticleSystemSet implements IDisposable {
  65961. /**
  65962. * Gets or sets base Assets URL
  65963. */
  65964. static BaseAssetsUrl: string;
  65965. private _emitterCreationOptions;
  65966. private _emitterNode;
  65967. /**
  65968. * Gets the particle system list
  65969. */
  65970. systems: IParticleSystem[];
  65971. /**
  65972. * Gets the emitter node used with this set
  65973. */
  65974. get emitterNode(): Nullable<TransformNode>;
  65975. /**
  65976. * Creates a new emitter mesh as a sphere
  65977. * @param options defines the options used to create the sphere
  65978. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  65979. * @param scene defines the hosting scene
  65980. */
  65981. setEmitterAsSphere(options: {
  65982. diameter: number;
  65983. segments: number;
  65984. color: Color3;
  65985. }, renderingGroupId: number, scene: Scene): void;
  65986. /**
  65987. * Starts all particle systems of the set
  65988. * @param emitter defines an optional mesh to use as emitter for the particle systems
  65989. */
  65990. start(emitter?: AbstractMesh): void;
  65991. /**
  65992. * Release all associated resources
  65993. */
  65994. dispose(): void;
  65995. /**
  65996. * Serialize the set into a JSON compatible object
  65997. * @returns a JSON compatible representation of the set
  65998. */
  65999. serialize(): any;
  66000. /**
  66001. * Parse a new ParticleSystemSet from a serialized source
  66002. * @param data defines a JSON compatible representation of the set
  66003. * @param scene defines the hosting scene
  66004. * @param gpu defines if we want GPU particles or CPU particles
  66005. * @returns a new ParticleSystemSet
  66006. */
  66007. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  66008. }
  66009. }
  66010. declare module "babylonjs/Particles/particleHelper" {
  66011. import { Nullable } from "babylonjs/types";
  66012. import { Scene } from "babylonjs/scene";
  66013. import { Vector3 } from "babylonjs/Maths/math.vector";
  66014. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66015. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66016. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  66017. /**
  66018. * This class is made for on one-liner static method to help creating particle system set.
  66019. */
  66020. export class ParticleHelper {
  66021. /**
  66022. * Gets or sets base Assets URL
  66023. */
  66024. static BaseAssetsUrl: string;
  66025. /**
  66026. * Create a default particle system that you can tweak
  66027. * @param emitter defines the emitter to use
  66028. * @param capacity defines the system capacity (default is 500 particles)
  66029. * @param scene defines the hosting scene
  66030. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  66031. * @returns the new Particle system
  66032. */
  66033. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  66034. /**
  66035. * This is the main static method (one-liner) of this helper to create different particle systems
  66036. * @param type This string represents the type to the particle system to create
  66037. * @param scene The scene where the particle system should live
  66038. * @param gpu If the system will use gpu
  66039. * @returns the ParticleSystemSet created
  66040. */
  66041. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  66042. /**
  66043. * Static function used to export a particle system to a ParticleSystemSet variable.
  66044. * Please note that the emitter shape is not exported
  66045. * @param systems defines the particle systems to export
  66046. * @returns the created particle system set
  66047. */
  66048. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  66049. }
  66050. }
  66051. declare module "babylonjs/Particles/particleSystemComponent" {
  66052. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66053. import { Effect } from "babylonjs/Materials/effect";
  66054. import "babylonjs/Shaders/particles.vertex";
  66055. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  66056. module "babylonjs/Engines/engine" {
  66057. interface Engine {
  66058. /**
  66059. * Create an effect to use with particle systems.
  66060. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  66061. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  66062. * @param uniformsNames defines a list of attribute names
  66063. * @param samplers defines an array of string used to represent textures
  66064. * @param defines defines the string containing the defines to use to compile the shaders
  66065. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  66066. * @param onCompiled defines a function to call when the effect creation is successful
  66067. * @param onError defines a function to call when the effect creation has failed
  66068. * @returns the new Effect
  66069. */
  66070. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  66071. }
  66072. }
  66073. module "babylonjs/Meshes/mesh" {
  66074. interface Mesh {
  66075. /**
  66076. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  66077. * @returns an array of IParticleSystem
  66078. */
  66079. getEmittedParticleSystems(): IParticleSystem[];
  66080. /**
  66081. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  66082. * @returns an array of IParticleSystem
  66083. */
  66084. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  66085. }
  66086. }
  66087. /**
  66088. * @hidden
  66089. */
  66090. export var _IDoNeedToBeInTheBuild: number;
  66091. }
  66092. declare module "babylonjs/Particles/pointsCloudSystem" {
  66093. import { Color4 } from "babylonjs/Maths/math";
  66094. import { Mesh } from "babylonjs/Meshes/mesh";
  66095. import { Scene, IDisposable } from "babylonjs/scene";
  66096. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  66097. /** Defines the 4 color options */
  66098. export enum PointColor {
  66099. /** color value */
  66100. Color = 2,
  66101. /** uv value */
  66102. UV = 1,
  66103. /** random value */
  66104. Random = 0,
  66105. /** stated value */
  66106. Stated = 3
  66107. }
  66108. /**
  66109. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  66110. * 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.
  66111. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  66112. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  66113. *
  66114. * Full documentation here : TO BE ENTERED
  66115. */
  66116. export class PointsCloudSystem implements IDisposable {
  66117. /**
  66118. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  66119. * Example : var p = SPS.particles[i];
  66120. */
  66121. particles: CloudPoint[];
  66122. /**
  66123. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  66124. */
  66125. nbParticles: number;
  66126. /**
  66127. * This a counter for your own usage. It's not set by any SPS functions.
  66128. */
  66129. counter: number;
  66130. /**
  66131. * The PCS name. This name is also given to the underlying mesh.
  66132. */
  66133. name: string;
  66134. /**
  66135. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  66136. */
  66137. mesh: Mesh;
  66138. /**
  66139. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  66140. * Please read :
  66141. */
  66142. vars: any;
  66143. /**
  66144. * @hidden
  66145. */
  66146. _size: number;
  66147. private _scene;
  66148. private _promises;
  66149. private _positions;
  66150. private _indices;
  66151. private _normals;
  66152. private _colors;
  66153. private _uvs;
  66154. private _indices32;
  66155. private _positions32;
  66156. private _colors32;
  66157. private _uvs32;
  66158. private _updatable;
  66159. private _isVisibilityBoxLocked;
  66160. private _alwaysVisible;
  66161. private _groups;
  66162. private _groupCounter;
  66163. private _computeParticleColor;
  66164. private _computeParticleTexture;
  66165. private _computeParticleRotation;
  66166. private _computeBoundingBox;
  66167. private _isReady;
  66168. /**
  66169. * Creates a PCS (Points Cloud System) object
  66170. * @param name (String) is the PCS name, this will be the underlying mesh name
  66171. * @param pointSize (number) is the size for each point
  66172. * @param scene (Scene) is the scene in which the PCS is added
  66173. * @param options defines the options of the PCS e.g.
  66174. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  66175. */
  66176. constructor(name: string, pointSize: number, scene: Scene, options?: {
  66177. updatable?: boolean;
  66178. });
  66179. /**
  66180. * Builds the PCS underlying mesh. Returns a standard Mesh.
  66181. * If no points were added to the PCS, the returned mesh is just a single point.
  66182. * @returns a promise for the created mesh
  66183. */
  66184. buildMeshAsync(): Promise<Mesh>;
  66185. /**
  66186. * @hidden
  66187. */
  66188. private _buildMesh;
  66189. private _addParticle;
  66190. private _randomUnitVector;
  66191. private _getColorIndicesForCoord;
  66192. private _setPointsColorOrUV;
  66193. private _colorFromTexture;
  66194. private _calculateDensity;
  66195. /**
  66196. * Adds points to the PCS in random positions within a unit sphere
  66197. * @param nb (positive integer) the number of particles to be created from this model
  66198. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  66199. * @returns the number of groups in the system
  66200. */
  66201. addPoints(nb: number, pointFunction?: any): number;
  66202. /**
  66203. * Adds points to the PCS from the surface of the model shape
  66204. * @param mesh is any Mesh object that will be used as a surface model for the points
  66205. * @param nb (positive integer) the number of particles to be created from this model
  66206. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66207. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66208. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66209. * @returns the number of groups in the system
  66210. */
  66211. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66212. /**
  66213. * Adds points to the PCS inside the model shape
  66214. * @param mesh is any Mesh object that will be used as a surface model for the points
  66215. * @param nb (positive integer) the number of particles to be created from this model
  66216. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66217. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66218. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66219. * @returns the number of groups in the system
  66220. */
  66221. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66222. /**
  66223. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  66224. * This method calls `updateParticle()` for each particle of the SPS.
  66225. * For an animated SPS, it is usually called within the render loop.
  66226. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  66227. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  66228. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  66229. * @returns the PCS.
  66230. */
  66231. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  66232. /**
  66233. * Disposes the PCS.
  66234. */
  66235. dispose(): void;
  66236. /**
  66237. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  66238. * doc :
  66239. * @returns the PCS.
  66240. */
  66241. refreshVisibleSize(): PointsCloudSystem;
  66242. /**
  66243. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  66244. * @param size the size (float) of the visibility box
  66245. * note : this doesn't lock the PCS mesh bounding box.
  66246. * doc :
  66247. */
  66248. setVisibilityBox(size: number): void;
  66249. /**
  66250. * Gets whether the PCS is always visible or not
  66251. * doc :
  66252. */
  66253. get isAlwaysVisible(): boolean;
  66254. /**
  66255. * Sets the PCS as always visible or not
  66256. * doc :
  66257. */
  66258. set isAlwaysVisible(val: boolean);
  66259. /**
  66260. * Tells to `setParticles()` to compute the particle rotations or not
  66261. * Default value : false. The PCS is faster when it's set to false
  66262. * Note : particle rotations are only applied to parent particles
  66263. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  66264. */
  66265. set computeParticleRotation(val: boolean);
  66266. /**
  66267. * Tells to `setParticles()` to compute the particle colors or not.
  66268. * Default value : true. The PCS is faster when it's set to false.
  66269. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66270. */
  66271. set computeParticleColor(val: boolean);
  66272. set computeParticleTexture(val: boolean);
  66273. /**
  66274. * Gets if `setParticles()` computes the particle colors or not.
  66275. * Default value : false. The PCS is faster when it's set to false.
  66276. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66277. */
  66278. get computeParticleColor(): boolean;
  66279. /**
  66280. * Gets if `setParticles()` computes the particle textures or not.
  66281. * Default value : false. The PCS is faster when it's set to false.
  66282. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  66283. */
  66284. get computeParticleTexture(): boolean;
  66285. /**
  66286. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  66287. */
  66288. set computeBoundingBox(val: boolean);
  66289. /**
  66290. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  66291. */
  66292. get computeBoundingBox(): boolean;
  66293. /**
  66294. * This function does nothing. It may be overwritten to set all the particle first values.
  66295. * The PCS doesn't call this function, you may have to call it by your own.
  66296. * doc :
  66297. */
  66298. initParticles(): void;
  66299. /**
  66300. * This function does nothing. It may be overwritten to recycle a particle
  66301. * The PCS doesn't call this function, you can to call it
  66302. * doc :
  66303. * @param particle The particle to recycle
  66304. * @returns the recycled particle
  66305. */
  66306. recycleParticle(particle: CloudPoint): CloudPoint;
  66307. /**
  66308. * Updates a particle : this function should be overwritten by the user.
  66309. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  66310. * doc :
  66311. * @example : just set a particle position or velocity and recycle conditions
  66312. * @param particle The particle to update
  66313. * @returns the updated particle
  66314. */
  66315. updateParticle(particle: CloudPoint): CloudPoint;
  66316. /**
  66317. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  66318. * This does nothing and may be overwritten by the user.
  66319. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66320. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66321. * @param update the boolean update value actually passed to setParticles()
  66322. */
  66323. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66324. /**
  66325. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  66326. * This will be passed three parameters.
  66327. * This does nothing and may be overwritten by the user.
  66328. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66329. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66330. * @param update the boolean update value actually passed to setParticles()
  66331. */
  66332. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66333. }
  66334. }
  66335. declare module "babylonjs/Particles/cloudPoint" {
  66336. import { Nullable } from "babylonjs/types";
  66337. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  66338. import { Mesh } from "babylonjs/Meshes/mesh";
  66339. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  66340. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  66341. /**
  66342. * Represents one particle of a points cloud system.
  66343. */
  66344. export class CloudPoint {
  66345. /**
  66346. * particle global index
  66347. */
  66348. idx: number;
  66349. /**
  66350. * The color of the particle
  66351. */
  66352. color: Nullable<Color4>;
  66353. /**
  66354. * The world space position of the particle.
  66355. */
  66356. position: Vector3;
  66357. /**
  66358. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  66359. */
  66360. rotation: Vector3;
  66361. /**
  66362. * The world space rotation quaternion of the particle.
  66363. */
  66364. rotationQuaternion: Nullable<Quaternion>;
  66365. /**
  66366. * The uv of the particle.
  66367. */
  66368. uv: Nullable<Vector2>;
  66369. /**
  66370. * The current speed of the particle.
  66371. */
  66372. velocity: Vector3;
  66373. /**
  66374. * The pivot point in the particle local space.
  66375. */
  66376. pivot: Vector3;
  66377. /**
  66378. * Must the particle be translated from its pivot point in its local space ?
  66379. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  66380. * Default : false
  66381. */
  66382. translateFromPivot: boolean;
  66383. /**
  66384. * Index of this particle in the global "positions" array (Internal use)
  66385. * @hidden
  66386. */
  66387. _pos: number;
  66388. /**
  66389. * @hidden Index of this particle in the global "indices" array (Internal use)
  66390. */
  66391. _ind: number;
  66392. /**
  66393. * Group this particle belongs to
  66394. */
  66395. _group: PointsGroup;
  66396. /**
  66397. * Group id of this particle
  66398. */
  66399. groupId: number;
  66400. /**
  66401. * Index of the particle in its group id (Internal use)
  66402. */
  66403. idxInGroup: number;
  66404. /**
  66405. * @hidden Particle BoundingInfo object (Internal use)
  66406. */
  66407. _boundingInfo: BoundingInfo;
  66408. /**
  66409. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  66410. */
  66411. _pcs: PointsCloudSystem;
  66412. /**
  66413. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  66414. */
  66415. _stillInvisible: boolean;
  66416. /**
  66417. * @hidden Last computed particle rotation matrix
  66418. */
  66419. _rotationMatrix: number[];
  66420. /**
  66421. * Parent particle Id, if any.
  66422. * Default null.
  66423. */
  66424. parentId: Nullable<number>;
  66425. /**
  66426. * @hidden Internal global position in the PCS.
  66427. */
  66428. _globalPosition: Vector3;
  66429. /**
  66430. * Creates a Point Cloud object.
  66431. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  66432. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  66433. * @param group (PointsGroup) is the group the particle belongs to
  66434. * @param groupId (integer) is the group identifier in the PCS.
  66435. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  66436. * @param pcs defines the PCS it is associated to
  66437. */
  66438. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  66439. /**
  66440. * get point size
  66441. */
  66442. get size(): Vector3;
  66443. /**
  66444. * Set point size
  66445. */
  66446. set size(scale: Vector3);
  66447. /**
  66448. * Legacy support, changed quaternion to rotationQuaternion
  66449. */
  66450. get quaternion(): Nullable<Quaternion>;
  66451. /**
  66452. * Legacy support, changed quaternion to rotationQuaternion
  66453. */
  66454. set quaternion(q: Nullable<Quaternion>);
  66455. /**
  66456. * Returns a boolean. True if the particle intersects a mesh, else false
  66457. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  66458. * @param target is the object (point or mesh) what the intersection is computed against
  66459. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  66460. * @returns true if it intersects
  66461. */
  66462. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  66463. /**
  66464. * get the rotation matrix of the particle
  66465. * @hidden
  66466. */
  66467. getRotationMatrix(m: Matrix): void;
  66468. }
  66469. /**
  66470. * Represents a group of points in a points cloud system
  66471. * * PCS internal tool, don't use it manually.
  66472. */
  66473. export class PointsGroup {
  66474. /**
  66475. * The group id
  66476. * @hidden
  66477. */
  66478. groupID: number;
  66479. /**
  66480. * image data for group (internal use)
  66481. * @hidden
  66482. */
  66483. _groupImageData: Nullable<ArrayBufferView>;
  66484. /**
  66485. * Image Width (internal use)
  66486. * @hidden
  66487. */
  66488. _groupImgWidth: number;
  66489. /**
  66490. * Image Height (internal use)
  66491. * @hidden
  66492. */
  66493. _groupImgHeight: number;
  66494. /**
  66495. * Custom position function (internal use)
  66496. * @hidden
  66497. */
  66498. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  66499. /**
  66500. * density per facet for surface points
  66501. * @hidden
  66502. */
  66503. _groupDensity: number[];
  66504. /**
  66505. * Only when points are colored by texture carries pointer to texture list array
  66506. * @hidden
  66507. */
  66508. _textureNb: number;
  66509. /**
  66510. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  66511. * PCS internal tool, don't use it manually.
  66512. * @hidden
  66513. */
  66514. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  66515. }
  66516. }
  66517. declare module "babylonjs/Particles/index" {
  66518. export * from "babylonjs/Particles/baseParticleSystem";
  66519. export * from "babylonjs/Particles/EmitterTypes/index";
  66520. export * from "babylonjs/Particles/gpuParticleSystem";
  66521. export * from "babylonjs/Particles/IParticleSystem";
  66522. export * from "babylonjs/Particles/particle";
  66523. export * from "babylonjs/Particles/particleHelper";
  66524. export * from "babylonjs/Particles/particleSystem";
  66525. export * from "babylonjs/Particles/particleSystemComponent";
  66526. export * from "babylonjs/Particles/particleSystemSet";
  66527. export * from "babylonjs/Particles/solidParticle";
  66528. export * from "babylonjs/Particles/solidParticleSystem";
  66529. export * from "babylonjs/Particles/cloudPoint";
  66530. export * from "babylonjs/Particles/pointsCloudSystem";
  66531. export * from "babylonjs/Particles/subEmitter";
  66532. }
  66533. declare module "babylonjs/Physics/physicsEngineComponent" {
  66534. import { Nullable } from "babylonjs/types";
  66535. import { Observable, Observer } from "babylonjs/Misc/observable";
  66536. import { Vector3 } from "babylonjs/Maths/math.vector";
  66537. import { Mesh } from "babylonjs/Meshes/mesh";
  66538. import { ISceneComponent } from "babylonjs/sceneComponent";
  66539. import { Scene } from "babylonjs/scene";
  66540. import { Node } from "babylonjs/node";
  66541. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  66542. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  66543. module "babylonjs/scene" {
  66544. interface Scene {
  66545. /** @hidden (Backing field) */
  66546. _physicsEngine: Nullable<IPhysicsEngine>;
  66547. /** @hidden */
  66548. _physicsTimeAccumulator: number;
  66549. /**
  66550. * Gets the current physics engine
  66551. * @returns a IPhysicsEngine or null if none attached
  66552. */
  66553. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  66554. /**
  66555. * Enables physics to the current scene
  66556. * @param gravity defines the scene's gravity for the physics engine
  66557. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  66558. * @return a boolean indicating if the physics engine was initialized
  66559. */
  66560. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  66561. /**
  66562. * Disables and disposes the physics engine associated with the scene
  66563. */
  66564. disablePhysicsEngine(): void;
  66565. /**
  66566. * Gets a boolean indicating if there is an active physics engine
  66567. * @returns a boolean indicating if there is an active physics engine
  66568. */
  66569. isPhysicsEnabled(): boolean;
  66570. /**
  66571. * Deletes a physics compound impostor
  66572. * @param compound defines the compound to delete
  66573. */
  66574. deleteCompoundImpostor(compound: any): void;
  66575. /**
  66576. * An event triggered when physic simulation is about to be run
  66577. */
  66578. onBeforePhysicsObservable: Observable<Scene>;
  66579. /**
  66580. * An event triggered when physic simulation has been done
  66581. */
  66582. onAfterPhysicsObservable: Observable<Scene>;
  66583. }
  66584. }
  66585. module "babylonjs/Meshes/abstractMesh" {
  66586. interface AbstractMesh {
  66587. /** @hidden */
  66588. _physicsImpostor: Nullable<PhysicsImpostor>;
  66589. /**
  66590. * Gets or sets impostor used for physic simulation
  66591. * @see http://doc.babylonjs.com/features/physics_engine
  66592. */
  66593. physicsImpostor: Nullable<PhysicsImpostor>;
  66594. /**
  66595. * Gets the current physics impostor
  66596. * @see http://doc.babylonjs.com/features/physics_engine
  66597. * @returns a physics impostor or null
  66598. */
  66599. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  66600. /** Apply a physic impulse to the mesh
  66601. * @param force defines the force to apply
  66602. * @param contactPoint defines where to apply the force
  66603. * @returns the current mesh
  66604. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  66605. */
  66606. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  66607. /**
  66608. * Creates a physic joint between two meshes
  66609. * @param otherMesh defines the other mesh to use
  66610. * @param pivot1 defines the pivot to use on this mesh
  66611. * @param pivot2 defines the pivot to use on the other mesh
  66612. * @param options defines additional options (can be plugin dependent)
  66613. * @returns the current mesh
  66614. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  66615. */
  66616. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  66617. /** @hidden */
  66618. _disposePhysicsObserver: Nullable<Observer<Node>>;
  66619. }
  66620. }
  66621. /**
  66622. * Defines the physics engine scene component responsible to manage a physics engine
  66623. */
  66624. export class PhysicsEngineSceneComponent implements ISceneComponent {
  66625. /**
  66626. * The component name helpful to identify the component in the list of scene components.
  66627. */
  66628. readonly name: string;
  66629. /**
  66630. * The scene the component belongs to.
  66631. */
  66632. scene: Scene;
  66633. /**
  66634. * Creates a new instance of the component for the given scene
  66635. * @param scene Defines the scene to register the component in
  66636. */
  66637. constructor(scene: Scene);
  66638. /**
  66639. * Registers the component in a given scene
  66640. */
  66641. register(): void;
  66642. /**
  66643. * Rebuilds the elements related to this component in case of
  66644. * context lost for instance.
  66645. */
  66646. rebuild(): void;
  66647. /**
  66648. * Disposes the component and the associated ressources
  66649. */
  66650. dispose(): void;
  66651. }
  66652. }
  66653. declare module "babylonjs/Physics/physicsHelper" {
  66654. import { Nullable } from "babylonjs/types";
  66655. import { Vector3 } from "babylonjs/Maths/math.vector";
  66656. import { Mesh } from "babylonjs/Meshes/mesh";
  66657. import { Scene } from "babylonjs/scene";
  66658. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  66659. /**
  66660. * A helper for physics simulations
  66661. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66662. */
  66663. export class PhysicsHelper {
  66664. private _scene;
  66665. private _physicsEngine;
  66666. /**
  66667. * Initializes the Physics helper
  66668. * @param scene Babylon.js scene
  66669. */
  66670. constructor(scene: Scene);
  66671. /**
  66672. * Applies a radial explosion impulse
  66673. * @param origin the origin of the explosion
  66674. * @param radiusOrEventOptions the radius or the options of radial explosion
  66675. * @param strength the explosion strength
  66676. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66677. * @returns A physics radial explosion event, or null
  66678. */
  66679. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66680. /**
  66681. * Applies a radial explosion force
  66682. * @param origin the origin of the explosion
  66683. * @param radiusOrEventOptions the radius or the options of radial explosion
  66684. * @param strength the explosion strength
  66685. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66686. * @returns A physics radial explosion event, or null
  66687. */
  66688. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66689. /**
  66690. * Creates a gravitational field
  66691. * @param origin the origin of the explosion
  66692. * @param radiusOrEventOptions the radius or the options of radial explosion
  66693. * @param strength the explosion strength
  66694. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66695. * @returns A physics gravitational field event, or null
  66696. */
  66697. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  66698. /**
  66699. * Creates a physics updraft event
  66700. * @param origin the origin of the updraft
  66701. * @param radiusOrEventOptions the radius or the options of the updraft
  66702. * @param strength the strength of the updraft
  66703. * @param height the height of the updraft
  66704. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  66705. * @returns A physics updraft event, or null
  66706. */
  66707. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  66708. /**
  66709. * Creates a physics vortex event
  66710. * @param origin the of the vortex
  66711. * @param radiusOrEventOptions the radius or the options of the vortex
  66712. * @param strength the strength of the vortex
  66713. * @param height the height of the vortex
  66714. * @returns a Physics vortex event, or null
  66715. * A physics vortex event or null
  66716. */
  66717. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  66718. }
  66719. /**
  66720. * Represents a physics radial explosion event
  66721. */
  66722. class PhysicsRadialExplosionEvent {
  66723. private _scene;
  66724. private _options;
  66725. private _sphere;
  66726. private _dataFetched;
  66727. /**
  66728. * Initializes a radial explosioin event
  66729. * @param _scene BabylonJS scene
  66730. * @param _options The options for the vortex event
  66731. */
  66732. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  66733. /**
  66734. * Returns the data related to the radial explosion event (sphere).
  66735. * @returns The radial explosion event data
  66736. */
  66737. getData(): PhysicsRadialExplosionEventData;
  66738. /**
  66739. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  66740. * @param impostor A physics imposter
  66741. * @param origin the origin of the explosion
  66742. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  66743. */
  66744. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  66745. /**
  66746. * Triggers affecterd impostors callbacks
  66747. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  66748. */
  66749. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  66750. /**
  66751. * Disposes the sphere.
  66752. * @param force Specifies if the sphere should be disposed by force
  66753. */
  66754. dispose(force?: boolean): void;
  66755. /*** Helpers ***/
  66756. private _prepareSphere;
  66757. private _intersectsWithSphere;
  66758. }
  66759. /**
  66760. * Represents a gravitational field event
  66761. */
  66762. class PhysicsGravitationalFieldEvent {
  66763. private _physicsHelper;
  66764. private _scene;
  66765. private _origin;
  66766. private _options;
  66767. private _tickCallback;
  66768. private _sphere;
  66769. private _dataFetched;
  66770. /**
  66771. * Initializes the physics gravitational field event
  66772. * @param _physicsHelper A physics helper
  66773. * @param _scene BabylonJS scene
  66774. * @param _origin The origin position of the gravitational field event
  66775. * @param _options The options for the vortex event
  66776. */
  66777. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  66778. /**
  66779. * Returns the data related to the gravitational field event (sphere).
  66780. * @returns A gravitational field event
  66781. */
  66782. getData(): PhysicsGravitationalFieldEventData;
  66783. /**
  66784. * Enables the gravitational field.
  66785. */
  66786. enable(): void;
  66787. /**
  66788. * Disables the gravitational field.
  66789. */
  66790. disable(): void;
  66791. /**
  66792. * Disposes the sphere.
  66793. * @param force The force to dispose from the gravitational field event
  66794. */
  66795. dispose(force?: boolean): void;
  66796. private _tick;
  66797. }
  66798. /**
  66799. * Represents a physics updraft event
  66800. */
  66801. class PhysicsUpdraftEvent {
  66802. private _scene;
  66803. private _origin;
  66804. private _options;
  66805. private _physicsEngine;
  66806. private _originTop;
  66807. private _originDirection;
  66808. private _tickCallback;
  66809. private _cylinder;
  66810. private _cylinderPosition;
  66811. private _dataFetched;
  66812. /**
  66813. * Initializes the physics updraft event
  66814. * @param _scene BabylonJS scene
  66815. * @param _origin The origin position of the updraft
  66816. * @param _options The options for the updraft event
  66817. */
  66818. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  66819. /**
  66820. * Returns the data related to the updraft event (cylinder).
  66821. * @returns A physics updraft event
  66822. */
  66823. getData(): PhysicsUpdraftEventData;
  66824. /**
  66825. * Enables the updraft.
  66826. */
  66827. enable(): void;
  66828. /**
  66829. * Disables the updraft.
  66830. */
  66831. disable(): void;
  66832. /**
  66833. * Disposes the cylinder.
  66834. * @param force Specifies if the updraft should be disposed by force
  66835. */
  66836. dispose(force?: boolean): void;
  66837. private getImpostorHitData;
  66838. private _tick;
  66839. /*** Helpers ***/
  66840. private _prepareCylinder;
  66841. private _intersectsWithCylinder;
  66842. }
  66843. /**
  66844. * Represents a physics vortex event
  66845. */
  66846. class PhysicsVortexEvent {
  66847. private _scene;
  66848. private _origin;
  66849. private _options;
  66850. private _physicsEngine;
  66851. private _originTop;
  66852. private _tickCallback;
  66853. private _cylinder;
  66854. private _cylinderPosition;
  66855. private _dataFetched;
  66856. /**
  66857. * Initializes the physics vortex event
  66858. * @param _scene The BabylonJS scene
  66859. * @param _origin The origin position of the vortex
  66860. * @param _options The options for the vortex event
  66861. */
  66862. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  66863. /**
  66864. * Returns the data related to the vortex event (cylinder).
  66865. * @returns The physics vortex event data
  66866. */
  66867. getData(): PhysicsVortexEventData;
  66868. /**
  66869. * Enables the vortex.
  66870. */
  66871. enable(): void;
  66872. /**
  66873. * Disables the cortex.
  66874. */
  66875. disable(): void;
  66876. /**
  66877. * Disposes the sphere.
  66878. * @param force
  66879. */
  66880. dispose(force?: boolean): void;
  66881. private getImpostorHitData;
  66882. private _tick;
  66883. /*** Helpers ***/
  66884. private _prepareCylinder;
  66885. private _intersectsWithCylinder;
  66886. }
  66887. /**
  66888. * Options fot the radial explosion event
  66889. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66890. */
  66891. export class PhysicsRadialExplosionEventOptions {
  66892. /**
  66893. * The radius of the sphere for the radial explosion.
  66894. */
  66895. radius: number;
  66896. /**
  66897. * The strenth of the explosion.
  66898. */
  66899. strength: number;
  66900. /**
  66901. * The strenght of the force in correspondence to the distance of the affected object
  66902. */
  66903. falloff: PhysicsRadialImpulseFalloff;
  66904. /**
  66905. * Sphere options for the radial explosion.
  66906. */
  66907. sphere: {
  66908. segments: number;
  66909. diameter: number;
  66910. };
  66911. /**
  66912. * Sphere options for the radial explosion.
  66913. */
  66914. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  66915. }
  66916. /**
  66917. * Options fot the updraft event
  66918. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66919. */
  66920. export class PhysicsUpdraftEventOptions {
  66921. /**
  66922. * The radius of the cylinder for the vortex
  66923. */
  66924. radius: number;
  66925. /**
  66926. * The strenth of the updraft.
  66927. */
  66928. strength: number;
  66929. /**
  66930. * The height of the cylinder for the updraft.
  66931. */
  66932. height: number;
  66933. /**
  66934. * The mode for the the updraft.
  66935. */
  66936. updraftMode: PhysicsUpdraftMode;
  66937. }
  66938. /**
  66939. * Options fot the vortex event
  66940. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66941. */
  66942. export class PhysicsVortexEventOptions {
  66943. /**
  66944. * The radius of the cylinder for the vortex
  66945. */
  66946. radius: number;
  66947. /**
  66948. * The strenth of the vortex.
  66949. */
  66950. strength: number;
  66951. /**
  66952. * The height of the cylinder for the vortex.
  66953. */
  66954. height: number;
  66955. /**
  66956. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  66957. */
  66958. centripetalForceThreshold: number;
  66959. /**
  66960. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  66961. */
  66962. centripetalForceMultiplier: number;
  66963. /**
  66964. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  66965. */
  66966. centrifugalForceMultiplier: number;
  66967. /**
  66968. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  66969. */
  66970. updraftForceMultiplier: number;
  66971. }
  66972. /**
  66973. * The strenght of the force in correspondence to the distance of the affected object
  66974. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66975. */
  66976. export enum PhysicsRadialImpulseFalloff {
  66977. /** Defines that impulse is constant in strength across it's whole radius */
  66978. Constant = 0,
  66979. /** Defines that impulse gets weaker if it's further from the origin */
  66980. Linear = 1
  66981. }
  66982. /**
  66983. * The strength of the force in correspondence to the distance of the affected object
  66984. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66985. */
  66986. export enum PhysicsUpdraftMode {
  66987. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  66988. Center = 0,
  66989. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  66990. Perpendicular = 1
  66991. }
  66992. /**
  66993. * Interface for a physics hit data
  66994. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66995. */
  66996. export interface PhysicsHitData {
  66997. /**
  66998. * The force applied at the contact point
  66999. */
  67000. force: Vector3;
  67001. /**
  67002. * The contact point
  67003. */
  67004. contactPoint: Vector3;
  67005. /**
  67006. * The distance from the origin to the contact point
  67007. */
  67008. distanceFromOrigin: number;
  67009. }
  67010. /**
  67011. * Interface for radial explosion event data
  67012. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67013. */
  67014. export interface PhysicsRadialExplosionEventData {
  67015. /**
  67016. * A sphere used for the radial explosion event
  67017. */
  67018. sphere: Mesh;
  67019. }
  67020. /**
  67021. * Interface for gravitational field event data
  67022. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67023. */
  67024. export interface PhysicsGravitationalFieldEventData {
  67025. /**
  67026. * A sphere mesh used for the gravitational field event
  67027. */
  67028. sphere: Mesh;
  67029. }
  67030. /**
  67031. * Interface for updraft event data
  67032. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67033. */
  67034. export interface PhysicsUpdraftEventData {
  67035. /**
  67036. * A cylinder used for the updraft event
  67037. */
  67038. cylinder: Mesh;
  67039. }
  67040. /**
  67041. * Interface for vortex event data
  67042. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67043. */
  67044. export interface PhysicsVortexEventData {
  67045. /**
  67046. * A cylinder used for the vortex event
  67047. */
  67048. cylinder: Mesh;
  67049. }
  67050. /**
  67051. * Interface for an affected physics impostor
  67052. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67053. */
  67054. export interface PhysicsAffectedImpostorWithData {
  67055. /**
  67056. * The impostor affected by the effect
  67057. */
  67058. impostor: PhysicsImpostor;
  67059. /**
  67060. * The data about the hit/horce from the explosion
  67061. */
  67062. hitData: PhysicsHitData;
  67063. }
  67064. }
  67065. declare module "babylonjs/Physics/Plugins/index" {
  67066. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  67067. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  67068. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  67069. }
  67070. declare module "babylonjs/Physics/index" {
  67071. export * from "babylonjs/Physics/IPhysicsEngine";
  67072. export * from "babylonjs/Physics/physicsEngine";
  67073. export * from "babylonjs/Physics/physicsEngineComponent";
  67074. export * from "babylonjs/Physics/physicsHelper";
  67075. export * from "babylonjs/Physics/physicsImpostor";
  67076. export * from "babylonjs/Physics/physicsJoint";
  67077. export * from "babylonjs/Physics/Plugins/index";
  67078. }
  67079. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  67080. /** @hidden */
  67081. export var blackAndWhitePixelShader: {
  67082. name: string;
  67083. shader: string;
  67084. };
  67085. }
  67086. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  67087. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67088. import { Camera } from "babylonjs/Cameras/camera";
  67089. import { Engine } from "babylonjs/Engines/engine";
  67090. import "babylonjs/Shaders/blackAndWhite.fragment";
  67091. /**
  67092. * Post process used to render in black and white
  67093. */
  67094. export class BlackAndWhitePostProcess extends PostProcess {
  67095. /**
  67096. * Linear about to convert he result to black and white (default: 1)
  67097. */
  67098. degree: number;
  67099. /**
  67100. * Creates a black and white post process
  67101. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  67102. * @param name The name of the effect.
  67103. * @param options The required width/height ratio to downsize to before computing the render pass.
  67104. * @param camera The camera to apply the render pass to.
  67105. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67106. * @param engine The engine which the post process will be applied. (default: current engine)
  67107. * @param reusable If the post process can be reused on the same frame. (default: false)
  67108. */
  67109. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67110. }
  67111. }
  67112. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  67113. import { Nullable } from "babylonjs/types";
  67114. import { Camera } from "babylonjs/Cameras/camera";
  67115. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67116. import { Engine } from "babylonjs/Engines/engine";
  67117. /**
  67118. * This represents a set of one or more post processes in Babylon.
  67119. * A post process can be used to apply a shader to a texture after it is rendered.
  67120. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67121. */
  67122. export class PostProcessRenderEffect {
  67123. private _postProcesses;
  67124. private _getPostProcesses;
  67125. private _singleInstance;
  67126. private _cameras;
  67127. private _indicesForCamera;
  67128. /**
  67129. * Name of the effect
  67130. * @hidden
  67131. */
  67132. _name: string;
  67133. /**
  67134. * Instantiates a post process render effect.
  67135. * A post process can be used to apply a shader to a texture after it is rendered.
  67136. * @param engine The engine the effect is tied to
  67137. * @param name The name of the effect
  67138. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  67139. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  67140. */
  67141. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  67142. /**
  67143. * Checks if all the post processes in the effect are supported.
  67144. */
  67145. get isSupported(): boolean;
  67146. /**
  67147. * Updates the current state of the effect
  67148. * @hidden
  67149. */
  67150. _update(): void;
  67151. /**
  67152. * Attaches the effect on cameras
  67153. * @param cameras The camera to attach to.
  67154. * @hidden
  67155. */
  67156. _attachCameras(cameras: Camera): void;
  67157. /**
  67158. * Attaches the effect on cameras
  67159. * @param cameras The camera to attach to.
  67160. * @hidden
  67161. */
  67162. _attachCameras(cameras: Camera[]): void;
  67163. /**
  67164. * Detaches the effect on cameras
  67165. * @param cameras The camera to detatch from.
  67166. * @hidden
  67167. */
  67168. _detachCameras(cameras: Camera): void;
  67169. /**
  67170. * Detatches the effect on cameras
  67171. * @param cameras The camera to detatch from.
  67172. * @hidden
  67173. */
  67174. _detachCameras(cameras: Camera[]): void;
  67175. /**
  67176. * Enables the effect on given cameras
  67177. * @param cameras The camera to enable.
  67178. * @hidden
  67179. */
  67180. _enable(cameras: Camera): void;
  67181. /**
  67182. * Enables the effect on given cameras
  67183. * @param cameras The camera to enable.
  67184. * @hidden
  67185. */
  67186. _enable(cameras: Nullable<Camera[]>): void;
  67187. /**
  67188. * Disables the effect on the given cameras
  67189. * @param cameras The camera to disable.
  67190. * @hidden
  67191. */
  67192. _disable(cameras: Camera): void;
  67193. /**
  67194. * Disables the effect on the given cameras
  67195. * @param cameras The camera to disable.
  67196. * @hidden
  67197. */
  67198. _disable(cameras: Nullable<Camera[]>): void;
  67199. /**
  67200. * Gets a list of the post processes contained in the effect.
  67201. * @param camera The camera to get the post processes on.
  67202. * @returns The list of the post processes in the effect.
  67203. */
  67204. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  67205. }
  67206. }
  67207. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  67208. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67209. /** @hidden */
  67210. export var extractHighlightsPixelShader: {
  67211. name: string;
  67212. shader: string;
  67213. };
  67214. }
  67215. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  67216. import { Nullable } from "babylonjs/types";
  67217. import { Camera } from "babylonjs/Cameras/camera";
  67218. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67219. import { Engine } from "babylonjs/Engines/engine";
  67220. import "babylonjs/Shaders/extractHighlights.fragment";
  67221. /**
  67222. * 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.
  67223. */
  67224. export class ExtractHighlightsPostProcess extends PostProcess {
  67225. /**
  67226. * The luminance threshold, pixels below this value will be set to black.
  67227. */
  67228. threshold: number;
  67229. /** @hidden */
  67230. _exposure: number;
  67231. /**
  67232. * Post process which has the input texture to be used when performing highlight extraction
  67233. * @hidden
  67234. */
  67235. _inputPostProcess: Nullable<PostProcess>;
  67236. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67237. }
  67238. }
  67239. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  67240. /** @hidden */
  67241. export var bloomMergePixelShader: {
  67242. name: string;
  67243. shader: string;
  67244. };
  67245. }
  67246. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  67247. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67248. import { Nullable } from "babylonjs/types";
  67249. import { Engine } from "babylonjs/Engines/engine";
  67250. import { Camera } from "babylonjs/Cameras/camera";
  67251. import "babylonjs/Shaders/bloomMerge.fragment";
  67252. /**
  67253. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67254. */
  67255. export class BloomMergePostProcess extends PostProcess {
  67256. /** Weight of the bloom to be added to the original input. */
  67257. weight: number;
  67258. /**
  67259. * Creates a new instance of @see BloomMergePostProcess
  67260. * @param name The name of the effect.
  67261. * @param originalFromInput Post process which's input will be used for the merge.
  67262. * @param blurred Blurred highlights post process which's output will be used.
  67263. * @param weight Weight of the bloom to be added to the original input.
  67264. * @param options The required width/height ratio to downsize to before computing the render pass.
  67265. * @param camera The camera to apply the render pass to.
  67266. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67267. * @param engine The engine which the post process will be applied. (default: current engine)
  67268. * @param reusable If the post process can be reused on the same frame. (default: false)
  67269. * @param textureType Type of textures used when performing the post process. (default: 0)
  67270. * @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)
  67271. */
  67272. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  67273. /** Weight of the bloom to be added to the original input. */
  67274. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67275. }
  67276. }
  67277. declare module "babylonjs/PostProcesses/bloomEffect" {
  67278. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  67279. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67280. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  67281. import { Camera } from "babylonjs/Cameras/camera";
  67282. import { Scene } from "babylonjs/scene";
  67283. /**
  67284. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  67285. */
  67286. export class BloomEffect extends PostProcessRenderEffect {
  67287. private bloomScale;
  67288. /**
  67289. * @hidden Internal
  67290. */
  67291. _effects: Array<PostProcess>;
  67292. /**
  67293. * @hidden Internal
  67294. */
  67295. _downscale: ExtractHighlightsPostProcess;
  67296. private _blurX;
  67297. private _blurY;
  67298. private _merge;
  67299. /**
  67300. * The luminance threshold to find bright areas of the image to bloom.
  67301. */
  67302. get threshold(): number;
  67303. set threshold(value: number);
  67304. /**
  67305. * The strength of the bloom.
  67306. */
  67307. get weight(): number;
  67308. set weight(value: number);
  67309. /**
  67310. * Specifies the size of the bloom blur kernel, relative to the final output size
  67311. */
  67312. get kernel(): number;
  67313. set kernel(value: number);
  67314. /**
  67315. * Creates a new instance of @see BloomEffect
  67316. * @param scene The scene the effect belongs to.
  67317. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  67318. * @param bloomKernel The size of the kernel to be used when applying the blur.
  67319. * @param bloomWeight The the strength of bloom.
  67320. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67321. * @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)
  67322. */
  67323. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  67324. /**
  67325. * Disposes each of the internal effects for a given camera.
  67326. * @param camera The camera to dispose the effect on.
  67327. */
  67328. disposeEffects(camera: Camera): void;
  67329. /**
  67330. * @hidden Internal
  67331. */
  67332. _updateEffects(): void;
  67333. /**
  67334. * Internal
  67335. * @returns if all the contained post processes are ready.
  67336. * @hidden
  67337. */
  67338. _isReady(): boolean;
  67339. }
  67340. }
  67341. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  67342. /** @hidden */
  67343. export var chromaticAberrationPixelShader: {
  67344. name: string;
  67345. shader: string;
  67346. };
  67347. }
  67348. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  67349. import { Vector2 } from "babylonjs/Maths/math.vector";
  67350. import { Nullable } from "babylonjs/types";
  67351. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67352. import { Camera } from "babylonjs/Cameras/camera";
  67353. import { Engine } from "babylonjs/Engines/engine";
  67354. import "babylonjs/Shaders/chromaticAberration.fragment";
  67355. /**
  67356. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  67357. */
  67358. export class ChromaticAberrationPostProcess extends PostProcess {
  67359. /**
  67360. * The amount of seperation of rgb channels (default: 30)
  67361. */
  67362. aberrationAmount: number;
  67363. /**
  67364. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  67365. */
  67366. radialIntensity: number;
  67367. /**
  67368. * 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))
  67369. */
  67370. direction: Vector2;
  67371. /**
  67372. * 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))
  67373. */
  67374. centerPosition: Vector2;
  67375. /**
  67376. * Creates a new instance ChromaticAberrationPostProcess
  67377. * @param name The name of the effect.
  67378. * @param screenWidth The width of the screen to apply the effect on.
  67379. * @param screenHeight The height of the screen to apply the effect on.
  67380. * @param options The required width/height ratio to downsize to before computing the render pass.
  67381. * @param camera The camera to apply the render pass to.
  67382. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67383. * @param engine The engine which the post process will be applied. (default: current engine)
  67384. * @param reusable If the post process can be reused on the same frame. (default: false)
  67385. * @param textureType Type of textures used when performing the post process. (default: 0)
  67386. * @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)
  67387. */
  67388. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67389. }
  67390. }
  67391. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  67392. /** @hidden */
  67393. export var circleOfConfusionPixelShader: {
  67394. name: string;
  67395. shader: string;
  67396. };
  67397. }
  67398. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  67399. import { Nullable } from "babylonjs/types";
  67400. import { Engine } from "babylonjs/Engines/engine";
  67401. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67402. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67403. import { Camera } from "babylonjs/Cameras/camera";
  67404. import "babylonjs/Shaders/circleOfConfusion.fragment";
  67405. /**
  67406. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  67407. */
  67408. export class CircleOfConfusionPostProcess extends PostProcess {
  67409. /**
  67410. * 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.
  67411. */
  67412. lensSize: number;
  67413. /**
  67414. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67415. */
  67416. fStop: number;
  67417. /**
  67418. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67419. */
  67420. focusDistance: number;
  67421. /**
  67422. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  67423. */
  67424. focalLength: number;
  67425. private _depthTexture;
  67426. /**
  67427. * Creates a new instance CircleOfConfusionPostProcess
  67428. * @param name The name of the effect.
  67429. * @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.
  67430. * @param options The required width/height ratio to downsize to before computing the render pass.
  67431. * @param camera The camera to apply the render pass to.
  67432. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67433. * @param engine The engine which the post process will be applied. (default: current engine)
  67434. * @param reusable If the post process can be reused on the same frame. (default: false)
  67435. * @param textureType Type of textures used when performing the post process. (default: 0)
  67436. * @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)
  67437. */
  67438. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67439. /**
  67440. * 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.
  67441. */
  67442. set depthTexture(value: RenderTargetTexture);
  67443. }
  67444. }
  67445. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  67446. /** @hidden */
  67447. export var colorCorrectionPixelShader: {
  67448. name: string;
  67449. shader: string;
  67450. };
  67451. }
  67452. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  67453. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67454. import { Engine } from "babylonjs/Engines/engine";
  67455. import { Camera } from "babylonjs/Cameras/camera";
  67456. import "babylonjs/Shaders/colorCorrection.fragment";
  67457. /**
  67458. *
  67459. * This post-process allows the modification of rendered colors by using
  67460. * a 'look-up table' (LUT). This effect is also called Color Grading.
  67461. *
  67462. * The object needs to be provided an url to a texture containing the color
  67463. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  67464. * Use an image editing software to tweak the LUT to match your needs.
  67465. *
  67466. * For an example of a color LUT, see here:
  67467. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  67468. * For explanations on color grading, see here:
  67469. * @see http://udn.epicgames.com/Three/ColorGrading.html
  67470. *
  67471. */
  67472. export class ColorCorrectionPostProcess extends PostProcess {
  67473. private _colorTableTexture;
  67474. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67475. }
  67476. }
  67477. declare module "babylonjs/Shaders/convolution.fragment" {
  67478. /** @hidden */
  67479. export var convolutionPixelShader: {
  67480. name: string;
  67481. shader: string;
  67482. };
  67483. }
  67484. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  67485. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67486. import { Nullable } from "babylonjs/types";
  67487. import { Camera } from "babylonjs/Cameras/camera";
  67488. import { Engine } from "babylonjs/Engines/engine";
  67489. import "babylonjs/Shaders/convolution.fragment";
  67490. /**
  67491. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  67492. * input texture to perform effects such as edge detection or sharpening
  67493. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  67494. */
  67495. export class ConvolutionPostProcess extends PostProcess {
  67496. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67497. kernel: number[];
  67498. /**
  67499. * Creates a new instance ConvolutionPostProcess
  67500. * @param name The name of the effect.
  67501. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  67502. * @param options The required width/height ratio to downsize to before computing the render pass.
  67503. * @param camera The camera to apply the render pass to.
  67504. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67505. * @param engine The engine which the post process will be applied. (default: current engine)
  67506. * @param reusable If the post process can be reused on the same frame. (default: false)
  67507. * @param textureType Type of textures used when performing the post process. (default: 0)
  67508. */
  67509. constructor(name: string,
  67510. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67511. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67512. /**
  67513. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67514. */
  67515. static EdgeDetect0Kernel: number[];
  67516. /**
  67517. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67518. */
  67519. static EdgeDetect1Kernel: number[];
  67520. /**
  67521. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67522. */
  67523. static EdgeDetect2Kernel: number[];
  67524. /**
  67525. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67526. */
  67527. static SharpenKernel: number[];
  67528. /**
  67529. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67530. */
  67531. static EmbossKernel: number[];
  67532. /**
  67533. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67534. */
  67535. static GaussianKernel: number[];
  67536. }
  67537. }
  67538. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  67539. import { Nullable } from "babylonjs/types";
  67540. import { Vector2 } from "babylonjs/Maths/math.vector";
  67541. import { Camera } from "babylonjs/Cameras/camera";
  67542. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67543. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  67544. import { Engine } from "babylonjs/Engines/engine";
  67545. import { Scene } from "babylonjs/scene";
  67546. /**
  67547. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  67548. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  67549. * based on samples that have a large difference in distance than the center pixel.
  67550. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  67551. */
  67552. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  67553. direction: Vector2;
  67554. /**
  67555. * Creates a new instance CircleOfConfusionPostProcess
  67556. * @param name The name of the effect.
  67557. * @param scene The scene the effect belongs to.
  67558. * @param direction The direction the blur should be applied.
  67559. * @param kernel The size of the kernel used to blur.
  67560. * @param options The required width/height ratio to downsize to before computing the render pass.
  67561. * @param camera The camera to apply the render pass to.
  67562. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  67563. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  67564. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67565. * @param engine The engine which the post process will be applied. (default: current engine)
  67566. * @param reusable If the post process can be reused on the same frame. (default: false)
  67567. * @param textureType Type of textures used when performing the post process. (default: 0)
  67568. * @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)
  67569. */
  67570. 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);
  67571. }
  67572. }
  67573. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  67574. /** @hidden */
  67575. export var depthOfFieldMergePixelShader: {
  67576. name: string;
  67577. shader: string;
  67578. };
  67579. }
  67580. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  67581. import { Nullable } from "babylonjs/types";
  67582. import { Camera } from "babylonjs/Cameras/camera";
  67583. import { Effect } from "babylonjs/Materials/effect";
  67584. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67585. import { Engine } from "babylonjs/Engines/engine";
  67586. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  67587. /**
  67588. * Options to be set when merging outputs from the default pipeline.
  67589. */
  67590. export class DepthOfFieldMergePostProcessOptions {
  67591. /**
  67592. * The original image to merge on top of
  67593. */
  67594. originalFromInput: PostProcess;
  67595. /**
  67596. * Parameters to perform the merge of the depth of field effect
  67597. */
  67598. depthOfField?: {
  67599. circleOfConfusion: PostProcess;
  67600. blurSteps: Array<PostProcess>;
  67601. };
  67602. /**
  67603. * Parameters to perform the merge of bloom effect
  67604. */
  67605. bloom?: {
  67606. blurred: PostProcess;
  67607. weight: number;
  67608. };
  67609. }
  67610. /**
  67611. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67612. */
  67613. export class DepthOfFieldMergePostProcess extends PostProcess {
  67614. private blurSteps;
  67615. /**
  67616. * Creates a new instance of DepthOfFieldMergePostProcess
  67617. * @param name The name of the effect.
  67618. * @param originalFromInput Post process which's input will be used for the merge.
  67619. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  67620. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  67621. * @param options The required width/height ratio to downsize to before computing the render pass.
  67622. * @param camera The camera to apply the render pass to.
  67623. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67624. * @param engine The engine which the post process will be applied. (default: current engine)
  67625. * @param reusable If the post process can be reused on the same frame. (default: false)
  67626. * @param textureType Type of textures used when performing the post process. (default: 0)
  67627. * @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)
  67628. */
  67629. 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);
  67630. /**
  67631. * Updates the effect with the current post process compile time values and recompiles the shader.
  67632. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  67633. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  67634. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  67635. * @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
  67636. * @param onCompiled Called when the shader has been compiled.
  67637. * @param onError Called if there is an error when compiling a shader.
  67638. */
  67639. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  67640. }
  67641. }
  67642. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  67643. import { Nullable } from "babylonjs/types";
  67644. import { Camera } from "babylonjs/Cameras/camera";
  67645. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67646. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67647. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  67648. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  67649. import { Scene } from "babylonjs/scene";
  67650. /**
  67651. * Specifies the level of max blur that should be applied when using the depth of field effect
  67652. */
  67653. export enum DepthOfFieldEffectBlurLevel {
  67654. /**
  67655. * Subtle blur
  67656. */
  67657. Low = 0,
  67658. /**
  67659. * Medium blur
  67660. */
  67661. Medium = 1,
  67662. /**
  67663. * Large blur
  67664. */
  67665. High = 2
  67666. }
  67667. /**
  67668. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  67669. */
  67670. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  67671. private _circleOfConfusion;
  67672. /**
  67673. * @hidden Internal, blurs from high to low
  67674. */
  67675. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  67676. private _depthOfFieldBlurY;
  67677. private _dofMerge;
  67678. /**
  67679. * @hidden Internal post processes in depth of field effect
  67680. */
  67681. _effects: Array<PostProcess>;
  67682. /**
  67683. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  67684. */
  67685. set focalLength(value: number);
  67686. get focalLength(): number;
  67687. /**
  67688. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67689. */
  67690. set fStop(value: number);
  67691. get fStop(): number;
  67692. /**
  67693. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67694. */
  67695. set focusDistance(value: number);
  67696. get focusDistance(): number;
  67697. /**
  67698. * 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.
  67699. */
  67700. set lensSize(value: number);
  67701. get lensSize(): number;
  67702. /**
  67703. * Creates a new instance DepthOfFieldEffect
  67704. * @param scene The scene the effect belongs to.
  67705. * @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.
  67706. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67707. * @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)
  67708. */
  67709. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  67710. /**
  67711. * Get the current class name of the current effet
  67712. * @returns "DepthOfFieldEffect"
  67713. */
  67714. getClassName(): string;
  67715. /**
  67716. * 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.
  67717. */
  67718. set depthTexture(value: RenderTargetTexture);
  67719. /**
  67720. * Disposes each of the internal effects for a given camera.
  67721. * @param camera The camera to dispose the effect on.
  67722. */
  67723. disposeEffects(camera: Camera): void;
  67724. /**
  67725. * @hidden Internal
  67726. */
  67727. _updateEffects(): void;
  67728. /**
  67729. * Internal
  67730. * @returns if all the contained post processes are ready.
  67731. * @hidden
  67732. */
  67733. _isReady(): boolean;
  67734. }
  67735. }
  67736. declare module "babylonjs/Shaders/displayPass.fragment" {
  67737. /** @hidden */
  67738. export var displayPassPixelShader: {
  67739. name: string;
  67740. shader: string;
  67741. };
  67742. }
  67743. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  67744. import { Nullable } from "babylonjs/types";
  67745. import { Camera } from "babylonjs/Cameras/camera";
  67746. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67747. import { Engine } from "babylonjs/Engines/engine";
  67748. import "babylonjs/Shaders/displayPass.fragment";
  67749. /**
  67750. * DisplayPassPostProcess which produces an output the same as it's input
  67751. */
  67752. export class DisplayPassPostProcess extends PostProcess {
  67753. /**
  67754. * Creates the DisplayPassPostProcess
  67755. * @param name The name of the effect.
  67756. * @param options The required width/height ratio to downsize to before computing the render pass.
  67757. * @param camera The camera to apply the render pass to.
  67758. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67759. * @param engine The engine which the post process will be applied. (default: current engine)
  67760. * @param reusable If the post process can be reused on the same frame. (default: false)
  67761. */
  67762. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67763. }
  67764. }
  67765. declare module "babylonjs/Shaders/filter.fragment" {
  67766. /** @hidden */
  67767. export var filterPixelShader: {
  67768. name: string;
  67769. shader: string;
  67770. };
  67771. }
  67772. declare module "babylonjs/PostProcesses/filterPostProcess" {
  67773. import { Nullable } from "babylonjs/types";
  67774. import { Matrix } from "babylonjs/Maths/math.vector";
  67775. import { Camera } from "babylonjs/Cameras/camera";
  67776. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67777. import { Engine } from "babylonjs/Engines/engine";
  67778. import "babylonjs/Shaders/filter.fragment";
  67779. /**
  67780. * Applies a kernel filter to the image
  67781. */
  67782. export class FilterPostProcess extends PostProcess {
  67783. /** The matrix to be applied to the image */
  67784. kernelMatrix: Matrix;
  67785. /**
  67786. *
  67787. * @param name The name of the effect.
  67788. * @param kernelMatrix The matrix to be applied to the image
  67789. * @param options The required width/height ratio to downsize to before computing the render pass.
  67790. * @param camera The camera to apply the render pass to.
  67791. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67792. * @param engine The engine which the post process will be applied. (default: current engine)
  67793. * @param reusable If the post process can be reused on the same frame. (default: false)
  67794. */
  67795. constructor(name: string,
  67796. /** The matrix to be applied to the image */
  67797. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67798. }
  67799. }
  67800. declare module "babylonjs/Shaders/fxaa.fragment" {
  67801. /** @hidden */
  67802. export var fxaaPixelShader: {
  67803. name: string;
  67804. shader: string;
  67805. };
  67806. }
  67807. declare module "babylonjs/Shaders/fxaa.vertex" {
  67808. /** @hidden */
  67809. export var fxaaVertexShader: {
  67810. name: string;
  67811. shader: string;
  67812. };
  67813. }
  67814. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  67815. import { Nullable } from "babylonjs/types";
  67816. import { Camera } from "babylonjs/Cameras/camera";
  67817. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67818. import { Engine } from "babylonjs/Engines/engine";
  67819. import "babylonjs/Shaders/fxaa.fragment";
  67820. import "babylonjs/Shaders/fxaa.vertex";
  67821. /**
  67822. * Fxaa post process
  67823. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  67824. */
  67825. export class FxaaPostProcess extends PostProcess {
  67826. /** @hidden */
  67827. texelWidth: number;
  67828. /** @hidden */
  67829. texelHeight: number;
  67830. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67831. private _getDefines;
  67832. }
  67833. }
  67834. declare module "babylonjs/Shaders/grain.fragment" {
  67835. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67836. /** @hidden */
  67837. export var grainPixelShader: {
  67838. name: string;
  67839. shader: string;
  67840. };
  67841. }
  67842. declare module "babylonjs/PostProcesses/grainPostProcess" {
  67843. import { Nullable } from "babylonjs/types";
  67844. import { Camera } from "babylonjs/Cameras/camera";
  67845. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67846. import { Engine } from "babylonjs/Engines/engine";
  67847. import "babylonjs/Shaders/grain.fragment";
  67848. /**
  67849. * The GrainPostProcess adds noise to the image at mid luminance levels
  67850. */
  67851. export class GrainPostProcess extends PostProcess {
  67852. /**
  67853. * The intensity of the grain added (default: 30)
  67854. */
  67855. intensity: number;
  67856. /**
  67857. * If the grain should be randomized on every frame
  67858. */
  67859. animated: boolean;
  67860. /**
  67861. * Creates a new instance of @see GrainPostProcess
  67862. * @param name The name of the effect.
  67863. * @param options The required width/height ratio to downsize to before computing the render pass.
  67864. * @param camera The camera to apply the render pass to.
  67865. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67866. * @param engine The engine which the post process will be applied. (default: current engine)
  67867. * @param reusable If the post process can be reused on the same frame. (default: false)
  67868. * @param textureType Type of textures used when performing the post process. (default: 0)
  67869. * @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)
  67870. */
  67871. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67872. }
  67873. }
  67874. declare module "babylonjs/Shaders/highlights.fragment" {
  67875. /** @hidden */
  67876. export var highlightsPixelShader: {
  67877. name: string;
  67878. shader: string;
  67879. };
  67880. }
  67881. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  67882. import { Nullable } from "babylonjs/types";
  67883. import { Camera } from "babylonjs/Cameras/camera";
  67884. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67885. import { Engine } from "babylonjs/Engines/engine";
  67886. import "babylonjs/Shaders/highlights.fragment";
  67887. /**
  67888. * Extracts highlights from the image
  67889. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  67890. */
  67891. export class HighlightsPostProcess extends PostProcess {
  67892. /**
  67893. * Extracts highlights from the image
  67894. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  67895. * @param name The name of the effect.
  67896. * @param options The required width/height ratio to downsize to before computing the render pass.
  67897. * @param camera The camera to apply the render pass to.
  67898. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67899. * @param engine The engine which the post process will be applied. (default: current engine)
  67900. * @param reusable If the post process can be reused on the same frame. (default: false)
  67901. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  67902. */
  67903. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67904. }
  67905. }
  67906. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  67907. /** @hidden */
  67908. export var mrtFragmentDeclaration: {
  67909. name: string;
  67910. shader: string;
  67911. };
  67912. }
  67913. declare module "babylonjs/Shaders/geometry.fragment" {
  67914. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  67915. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  67916. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  67917. /** @hidden */
  67918. export var geometryPixelShader: {
  67919. name: string;
  67920. shader: string;
  67921. };
  67922. }
  67923. declare module "babylonjs/Shaders/geometry.vertex" {
  67924. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  67925. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  67926. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  67927. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  67928. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  67929. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  67930. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  67931. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  67932. /** @hidden */
  67933. export var geometryVertexShader: {
  67934. name: string;
  67935. shader: string;
  67936. };
  67937. }
  67938. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  67939. import { Matrix } from "babylonjs/Maths/math.vector";
  67940. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67941. import { Mesh } from "babylonjs/Meshes/mesh";
  67942. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  67943. import { Effect } from "babylonjs/Materials/effect";
  67944. import { Scene } from "babylonjs/scene";
  67945. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67946. import "babylonjs/Shaders/geometry.fragment";
  67947. import "babylonjs/Shaders/geometry.vertex";
  67948. /** @hidden */
  67949. interface ISavedTransformationMatrix {
  67950. world: Matrix;
  67951. viewProjection: Matrix;
  67952. }
  67953. /**
  67954. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  67955. */
  67956. export class GeometryBufferRenderer {
  67957. /**
  67958. * Constant used to retrieve the position texture index in the G-Buffer textures array
  67959. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  67960. */
  67961. static readonly POSITION_TEXTURE_TYPE: number;
  67962. /**
  67963. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  67964. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  67965. */
  67966. static readonly VELOCITY_TEXTURE_TYPE: number;
  67967. /**
  67968. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  67969. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  67970. */
  67971. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  67972. /**
  67973. * Dictionary used to store the previous transformation matrices of each rendered mesh
  67974. * in order to compute objects velocities when enableVelocity is set to "true"
  67975. * @hidden
  67976. */
  67977. _previousTransformationMatrices: {
  67978. [index: number]: ISavedTransformationMatrix;
  67979. };
  67980. /**
  67981. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  67982. * in order to compute objects velocities when enableVelocity is set to "true"
  67983. * @hidden
  67984. */
  67985. _previousBonesTransformationMatrices: {
  67986. [index: number]: Float32Array;
  67987. };
  67988. /**
  67989. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  67990. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  67991. */
  67992. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  67993. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  67994. renderTransparentMeshes: boolean;
  67995. private _scene;
  67996. private _multiRenderTarget;
  67997. private _ratio;
  67998. private _enablePosition;
  67999. private _enableVelocity;
  68000. private _enableReflectivity;
  68001. private _positionIndex;
  68002. private _velocityIndex;
  68003. private _reflectivityIndex;
  68004. protected _effect: Effect;
  68005. protected _cachedDefines: string;
  68006. /**
  68007. * Set the render list (meshes to be rendered) used in the G buffer.
  68008. */
  68009. set renderList(meshes: Mesh[]);
  68010. /**
  68011. * Gets wether or not G buffer are supported by the running hardware.
  68012. * This requires draw buffer supports
  68013. */
  68014. get isSupported(): boolean;
  68015. /**
  68016. * Returns the index of the given texture type in the G-Buffer textures array
  68017. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  68018. * @returns the index of the given texture type in the G-Buffer textures array
  68019. */
  68020. getTextureIndex(textureType: number): number;
  68021. /**
  68022. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  68023. */
  68024. get enablePosition(): boolean;
  68025. /**
  68026. * Sets whether or not objects positions are enabled for the G buffer.
  68027. */
  68028. set enablePosition(enable: boolean);
  68029. /**
  68030. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  68031. */
  68032. get enableVelocity(): boolean;
  68033. /**
  68034. * Sets wether or not objects velocities are enabled for the G buffer.
  68035. */
  68036. set enableVelocity(enable: boolean);
  68037. /**
  68038. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  68039. */
  68040. get enableReflectivity(): boolean;
  68041. /**
  68042. * Sets wether or not objects roughness are enabled for the G buffer.
  68043. */
  68044. set enableReflectivity(enable: boolean);
  68045. /**
  68046. * Gets the scene associated with the buffer.
  68047. */
  68048. get scene(): Scene;
  68049. /**
  68050. * Gets the ratio used by the buffer during its creation.
  68051. * How big is the buffer related to the main canvas.
  68052. */
  68053. get ratio(): number;
  68054. /** @hidden */
  68055. static _SceneComponentInitialization: (scene: Scene) => void;
  68056. /**
  68057. * Creates a new G Buffer for the scene
  68058. * @param scene The scene the buffer belongs to
  68059. * @param ratio How big is the buffer related to the main canvas.
  68060. */
  68061. constructor(scene: Scene, ratio?: number);
  68062. /**
  68063. * Checks wether everything is ready to render a submesh to the G buffer.
  68064. * @param subMesh the submesh to check readiness for
  68065. * @param useInstances is the mesh drawn using instance or not
  68066. * @returns true if ready otherwise false
  68067. */
  68068. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68069. /**
  68070. * Gets the current underlying G Buffer.
  68071. * @returns the buffer
  68072. */
  68073. getGBuffer(): MultiRenderTarget;
  68074. /**
  68075. * Gets the number of samples used to render the buffer (anti aliasing).
  68076. */
  68077. get samples(): number;
  68078. /**
  68079. * Sets the number of samples used to render the buffer (anti aliasing).
  68080. */
  68081. set samples(value: number);
  68082. /**
  68083. * Disposes the renderer and frees up associated resources.
  68084. */
  68085. dispose(): void;
  68086. protected _createRenderTargets(): void;
  68087. private _copyBonesTransformationMatrices;
  68088. }
  68089. }
  68090. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  68091. import { Nullable } from "babylonjs/types";
  68092. import { Scene } from "babylonjs/scene";
  68093. import { ISceneComponent } from "babylonjs/sceneComponent";
  68094. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  68095. module "babylonjs/scene" {
  68096. interface Scene {
  68097. /** @hidden (Backing field) */
  68098. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68099. /**
  68100. * Gets or Sets the current geometry buffer associated to the scene.
  68101. */
  68102. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68103. /**
  68104. * Enables a GeometryBufferRender and associates it with the scene
  68105. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  68106. * @returns the GeometryBufferRenderer
  68107. */
  68108. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  68109. /**
  68110. * Disables the GeometryBufferRender associated with the scene
  68111. */
  68112. disableGeometryBufferRenderer(): void;
  68113. }
  68114. }
  68115. /**
  68116. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  68117. * in several rendering techniques.
  68118. */
  68119. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  68120. /**
  68121. * The component name helpful to identify the component in the list of scene components.
  68122. */
  68123. readonly name: string;
  68124. /**
  68125. * The scene the component belongs to.
  68126. */
  68127. scene: Scene;
  68128. /**
  68129. * Creates a new instance of the component for the given scene
  68130. * @param scene Defines the scene to register the component in
  68131. */
  68132. constructor(scene: Scene);
  68133. /**
  68134. * Registers the component in a given scene
  68135. */
  68136. register(): void;
  68137. /**
  68138. * Rebuilds the elements related to this component in case of
  68139. * context lost for instance.
  68140. */
  68141. rebuild(): void;
  68142. /**
  68143. * Disposes the component and the associated ressources
  68144. */
  68145. dispose(): void;
  68146. private _gatherRenderTargets;
  68147. }
  68148. }
  68149. declare module "babylonjs/Shaders/motionBlur.fragment" {
  68150. /** @hidden */
  68151. export var motionBlurPixelShader: {
  68152. name: string;
  68153. shader: string;
  68154. };
  68155. }
  68156. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  68157. import { Nullable } from "babylonjs/types";
  68158. import { Camera } from "babylonjs/Cameras/camera";
  68159. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68160. import { Scene } from "babylonjs/scene";
  68161. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68162. import "babylonjs/Animations/animatable";
  68163. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  68164. import "babylonjs/Shaders/motionBlur.fragment";
  68165. import { Engine } from "babylonjs/Engines/engine";
  68166. /**
  68167. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  68168. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  68169. * As an example, all you have to do is to create the post-process:
  68170. * var mb = new BABYLON.MotionBlurPostProcess(
  68171. * 'mb', // The name of the effect.
  68172. * scene, // The scene containing the objects to blur according to their velocity.
  68173. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  68174. * camera // The camera to apply the render pass to.
  68175. * );
  68176. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  68177. */
  68178. export class MotionBlurPostProcess extends PostProcess {
  68179. /**
  68180. * Defines how much the image is blurred by the movement. Default value is equal to 1
  68181. */
  68182. motionStrength: number;
  68183. /**
  68184. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  68185. */
  68186. get motionBlurSamples(): number;
  68187. /**
  68188. * Sets the number of iterations to be used for motion blur quality
  68189. */
  68190. set motionBlurSamples(samples: number);
  68191. private _motionBlurSamples;
  68192. private _geometryBufferRenderer;
  68193. /**
  68194. * Creates a new instance MotionBlurPostProcess
  68195. * @param name The name of the effect.
  68196. * @param scene The scene containing the objects to blur according to their velocity.
  68197. * @param options The required width/height ratio to downsize to before computing the render pass.
  68198. * @param camera The camera to apply the render pass to.
  68199. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68200. * @param engine The engine which the post process will be applied. (default: current engine)
  68201. * @param reusable If the post process can be reused on the same frame. (default: false)
  68202. * @param textureType Type of textures used when performing the post process. (default: 0)
  68203. * @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)
  68204. */
  68205. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68206. /**
  68207. * Excludes the given skinned mesh from computing bones velocities.
  68208. * 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.
  68209. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  68210. */
  68211. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68212. /**
  68213. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  68214. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  68215. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  68216. */
  68217. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68218. /**
  68219. * Disposes the post process.
  68220. * @param camera The camera to dispose the post process on.
  68221. */
  68222. dispose(camera?: Camera): void;
  68223. }
  68224. }
  68225. declare module "babylonjs/Shaders/refraction.fragment" {
  68226. /** @hidden */
  68227. export var refractionPixelShader: {
  68228. name: string;
  68229. shader: string;
  68230. };
  68231. }
  68232. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  68233. import { Color3 } from "babylonjs/Maths/math.color";
  68234. import { Camera } from "babylonjs/Cameras/camera";
  68235. import { Texture } from "babylonjs/Materials/Textures/texture";
  68236. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68237. import { Engine } from "babylonjs/Engines/engine";
  68238. import "babylonjs/Shaders/refraction.fragment";
  68239. /**
  68240. * Post process which applies a refractin texture
  68241. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68242. */
  68243. export class RefractionPostProcess extends PostProcess {
  68244. /** the base color of the refraction (used to taint the rendering) */
  68245. color: Color3;
  68246. /** simulated refraction depth */
  68247. depth: number;
  68248. /** the coefficient of the base color (0 to remove base color tainting) */
  68249. colorLevel: number;
  68250. private _refTexture;
  68251. private _ownRefractionTexture;
  68252. /**
  68253. * Gets or sets the refraction texture
  68254. * Please note that you are responsible for disposing the texture if you set it manually
  68255. */
  68256. get refractionTexture(): Texture;
  68257. set refractionTexture(value: Texture);
  68258. /**
  68259. * Initializes the RefractionPostProcess
  68260. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68261. * @param name The name of the effect.
  68262. * @param refractionTextureUrl Url of the refraction texture to use
  68263. * @param color the base color of the refraction (used to taint the rendering)
  68264. * @param depth simulated refraction depth
  68265. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  68266. * @param camera The camera to apply the render pass to.
  68267. * @param options The required width/height ratio to downsize to before computing the render pass.
  68268. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68269. * @param engine The engine which the post process will be applied. (default: current engine)
  68270. * @param reusable If the post process can be reused on the same frame. (default: false)
  68271. */
  68272. constructor(name: string, refractionTextureUrl: string,
  68273. /** the base color of the refraction (used to taint the rendering) */
  68274. color: Color3,
  68275. /** simulated refraction depth */
  68276. depth: number,
  68277. /** the coefficient of the base color (0 to remove base color tainting) */
  68278. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68279. /**
  68280. * Disposes of the post process
  68281. * @param camera Camera to dispose post process on
  68282. */
  68283. dispose(camera: Camera): void;
  68284. }
  68285. }
  68286. declare module "babylonjs/Shaders/sharpen.fragment" {
  68287. /** @hidden */
  68288. export var sharpenPixelShader: {
  68289. name: string;
  68290. shader: string;
  68291. };
  68292. }
  68293. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  68294. import { Nullable } from "babylonjs/types";
  68295. import { Camera } from "babylonjs/Cameras/camera";
  68296. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68297. import "babylonjs/Shaders/sharpen.fragment";
  68298. import { Engine } from "babylonjs/Engines/engine";
  68299. /**
  68300. * The SharpenPostProcess applies a sharpen kernel to every pixel
  68301. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68302. */
  68303. export class SharpenPostProcess extends PostProcess {
  68304. /**
  68305. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  68306. */
  68307. colorAmount: number;
  68308. /**
  68309. * How much sharpness should be applied (default: 0.3)
  68310. */
  68311. edgeAmount: number;
  68312. /**
  68313. * Creates a new instance ConvolutionPostProcess
  68314. * @param name The name of the effect.
  68315. * @param options The required width/height ratio to downsize to before computing the render pass.
  68316. * @param camera The camera to apply the render pass to.
  68317. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68318. * @param engine The engine which the post process will be applied. (default: current engine)
  68319. * @param reusable If the post process can be reused on the same frame. (default: false)
  68320. * @param textureType Type of textures used when performing the post process. (default: 0)
  68321. * @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)
  68322. */
  68323. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68324. }
  68325. }
  68326. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  68327. import { Nullable } from "babylonjs/types";
  68328. import { Camera } from "babylonjs/Cameras/camera";
  68329. import { Engine } from "babylonjs/Engines/engine";
  68330. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  68331. import { IInspectable } from "babylonjs/Misc/iInspectable";
  68332. /**
  68333. * PostProcessRenderPipeline
  68334. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68335. */
  68336. export class PostProcessRenderPipeline {
  68337. private engine;
  68338. private _renderEffects;
  68339. private _renderEffectsForIsolatedPass;
  68340. /**
  68341. * List of inspectable custom properties (used by the Inspector)
  68342. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  68343. */
  68344. inspectableCustomProperties: IInspectable[];
  68345. /**
  68346. * @hidden
  68347. */
  68348. protected _cameras: Camera[];
  68349. /** @hidden */
  68350. _name: string;
  68351. /**
  68352. * Gets pipeline name
  68353. */
  68354. get name(): string;
  68355. /** Gets the list of attached cameras */
  68356. get cameras(): Camera[];
  68357. /**
  68358. * Initializes a PostProcessRenderPipeline
  68359. * @param engine engine to add the pipeline to
  68360. * @param name name of the pipeline
  68361. */
  68362. constructor(engine: Engine, name: string);
  68363. /**
  68364. * Gets the class name
  68365. * @returns "PostProcessRenderPipeline"
  68366. */
  68367. getClassName(): string;
  68368. /**
  68369. * If all the render effects in the pipeline are supported
  68370. */
  68371. get isSupported(): boolean;
  68372. /**
  68373. * Adds an effect to the pipeline
  68374. * @param renderEffect the effect to add
  68375. */
  68376. addEffect(renderEffect: PostProcessRenderEffect): void;
  68377. /** @hidden */
  68378. _rebuild(): void;
  68379. /** @hidden */
  68380. _enableEffect(renderEffectName: string, cameras: Camera): void;
  68381. /** @hidden */
  68382. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  68383. /** @hidden */
  68384. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68385. /** @hidden */
  68386. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68387. /** @hidden */
  68388. _attachCameras(cameras: Camera, unique: boolean): void;
  68389. /** @hidden */
  68390. _attachCameras(cameras: Camera[], unique: boolean): void;
  68391. /** @hidden */
  68392. _detachCameras(cameras: Camera): void;
  68393. /** @hidden */
  68394. _detachCameras(cameras: Nullable<Camera[]>): void;
  68395. /** @hidden */
  68396. _update(): void;
  68397. /** @hidden */
  68398. _reset(): void;
  68399. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  68400. /**
  68401. * Disposes of the pipeline
  68402. */
  68403. dispose(): void;
  68404. }
  68405. }
  68406. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  68407. import { Camera } from "babylonjs/Cameras/camera";
  68408. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68409. /**
  68410. * PostProcessRenderPipelineManager class
  68411. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68412. */
  68413. export class PostProcessRenderPipelineManager {
  68414. private _renderPipelines;
  68415. /**
  68416. * Initializes a PostProcessRenderPipelineManager
  68417. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68418. */
  68419. constructor();
  68420. /**
  68421. * Gets the list of supported render pipelines
  68422. */
  68423. get supportedPipelines(): PostProcessRenderPipeline[];
  68424. /**
  68425. * Adds a pipeline to the manager
  68426. * @param renderPipeline The pipeline to add
  68427. */
  68428. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  68429. /**
  68430. * Attaches a camera to the pipeline
  68431. * @param renderPipelineName The name of the pipeline to attach to
  68432. * @param cameras the camera to attach
  68433. * @param unique if the camera can be attached multiple times to the pipeline
  68434. */
  68435. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  68436. /**
  68437. * Detaches a camera from the pipeline
  68438. * @param renderPipelineName The name of the pipeline to detach from
  68439. * @param cameras the camera to detach
  68440. */
  68441. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  68442. /**
  68443. * Enables an effect by name on a pipeline
  68444. * @param renderPipelineName the name of the pipeline to enable the effect in
  68445. * @param renderEffectName the name of the effect to enable
  68446. * @param cameras the cameras that the effect should be enabled on
  68447. */
  68448. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68449. /**
  68450. * Disables an effect by name on a pipeline
  68451. * @param renderPipelineName the name of the pipeline to disable the effect in
  68452. * @param renderEffectName the name of the effect to disable
  68453. * @param cameras the cameras that the effect should be disabled on
  68454. */
  68455. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68456. /**
  68457. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  68458. */
  68459. update(): void;
  68460. /** @hidden */
  68461. _rebuild(): void;
  68462. /**
  68463. * Disposes of the manager and pipelines
  68464. */
  68465. dispose(): void;
  68466. }
  68467. }
  68468. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  68469. import { ISceneComponent } from "babylonjs/sceneComponent";
  68470. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  68471. import { Scene } from "babylonjs/scene";
  68472. module "babylonjs/scene" {
  68473. interface Scene {
  68474. /** @hidden (Backing field) */
  68475. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68476. /**
  68477. * Gets the postprocess render pipeline manager
  68478. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68479. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68480. */
  68481. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68482. }
  68483. }
  68484. /**
  68485. * Defines the Render Pipeline scene component responsible to rendering pipelines
  68486. */
  68487. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  68488. /**
  68489. * The component name helpfull to identify the component in the list of scene components.
  68490. */
  68491. readonly name: string;
  68492. /**
  68493. * The scene the component belongs to.
  68494. */
  68495. scene: Scene;
  68496. /**
  68497. * Creates a new instance of the component for the given scene
  68498. * @param scene Defines the scene to register the component in
  68499. */
  68500. constructor(scene: Scene);
  68501. /**
  68502. * Registers the component in a given scene
  68503. */
  68504. register(): void;
  68505. /**
  68506. * Rebuilds the elements related to this component in case of
  68507. * context lost for instance.
  68508. */
  68509. rebuild(): void;
  68510. /**
  68511. * Disposes the component and the associated ressources
  68512. */
  68513. dispose(): void;
  68514. private _gatherRenderTargets;
  68515. }
  68516. }
  68517. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  68518. import { Nullable } from "babylonjs/types";
  68519. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  68520. import { Camera } from "babylonjs/Cameras/camera";
  68521. import { IDisposable } from "babylonjs/scene";
  68522. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  68523. import { Scene } from "babylonjs/scene";
  68524. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  68525. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  68526. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  68527. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  68528. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  68529. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68530. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  68531. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68532. import { Animation } from "babylonjs/Animations/animation";
  68533. /**
  68534. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  68535. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68536. */
  68537. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  68538. private _scene;
  68539. private _camerasToBeAttached;
  68540. /**
  68541. * ID of the sharpen post process,
  68542. */
  68543. private readonly SharpenPostProcessId;
  68544. /**
  68545. * @ignore
  68546. * ID of the image processing post process;
  68547. */
  68548. readonly ImageProcessingPostProcessId: string;
  68549. /**
  68550. * @ignore
  68551. * ID of the Fast Approximate Anti-Aliasing post process;
  68552. */
  68553. readonly FxaaPostProcessId: string;
  68554. /**
  68555. * ID of the chromatic aberration post process,
  68556. */
  68557. private readonly ChromaticAberrationPostProcessId;
  68558. /**
  68559. * ID of the grain post process
  68560. */
  68561. private readonly GrainPostProcessId;
  68562. /**
  68563. * Sharpen post process which will apply a sharpen convolution to enhance edges
  68564. */
  68565. sharpen: SharpenPostProcess;
  68566. private _sharpenEffect;
  68567. private bloom;
  68568. /**
  68569. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  68570. */
  68571. depthOfField: DepthOfFieldEffect;
  68572. /**
  68573. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  68574. */
  68575. fxaa: FxaaPostProcess;
  68576. /**
  68577. * Image post processing pass used to perform operations such as tone mapping or color grading.
  68578. */
  68579. imageProcessing: ImageProcessingPostProcess;
  68580. /**
  68581. * Chromatic aberration post process which will shift rgb colors in the image
  68582. */
  68583. chromaticAberration: ChromaticAberrationPostProcess;
  68584. private _chromaticAberrationEffect;
  68585. /**
  68586. * Grain post process which add noise to the image
  68587. */
  68588. grain: GrainPostProcess;
  68589. private _grainEffect;
  68590. /**
  68591. * Glow post process which adds a glow to emissive areas of the image
  68592. */
  68593. private _glowLayer;
  68594. /**
  68595. * Animations which can be used to tweak settings over a period of time
  68596. */
  68597. animations: Animation[];
  68598. private _imageProcessingConfigurationObserver;
  68599. private _sharpenEnabled;
  68600. private _bloomEnabled;
  68601. private _depthOfFieldEnabled;
  68602. private _depthOfFieldBlurLevel;
  68603. private _fxaaEnabled;
  68604. private _imageProcessingEnabled;
  68605. private _defaultPipelineTextureType;
  68606. private _bloomScale;
  68607. private _chromaticAberrationEnabled;
  68608. private _grainEnabled;
  68609. private _buildAllowed;
  68610. /**
  68611. * Gets active scene
  68612. */
  68613. get scene(): Scene;
  68614. /**
  68615. * Enable or disable the sharpen process from the pipeline
  68616. */
  68617. set sharpenEnabled(enabled: boolean);
  68618. get sharpenEnabled(): boolean;
  68619. private _resizeObserver;
  68620. private _hardwareScaleLevel;
  68621. private _bloomKernel;
  68622. /**
  68623. * Specifies the size of the bloom blur kernel, relative to the final output size
  68624. */
  68625. get bloomKernel(): number;
  68626. set bloomKernel(value: number);
  68627. /**
  68628. * Specifies the weight of the bloom in the final rendering
  68629. */
  68630. private _bloomWeight;
  68631. /**
  68632. * Specifies the luma threshold for the area that will be blurred by the bloom
  68633. */
  68634. private _bloomThreshold;
  68635. private _hdr;
  68636. /**
  68637. * The strength of the bloom.
  68638. */
  68639. set bloomWeight(value: number);
  68640. get bloomWeight(): number;
  68641. /**
  68642. * The strength of the bloom.
  68643. */
  68644. set bloomThreshold(value: number);
  68645. get bloomThreshold(): number;
  68646. /**
  68647. * The scale of the bloom, lower value will provide better performance.
  68648. */
  68649. set bloomScale(value: number);
  68650. get bloomScale(): number;
  68651. /**
  68652. * Enable or disable the bloom from the pipeline
  68653. */
  68654. set bloomEnabled(enabled: boolean);
  68655. get bloomEnabled(): boolean;
  68656. private _rebuildBloom;
  68657. /**
  68658. * If the depth of field is enabled.
  68659. */
  68660. get depthOfFieldEnabled(): boolean;
  68661. set depthOfFieldEnabled(enabled: boolean);
  68662. /**
  68663. * Blur level of the depth of field effect. (Higher blur will effect performance)
  68664. */
  68665. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  68666. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  68667. /**
  68668. * If the anti aliasing is enabled.
  68669. */
  68670. set fxaaEnabled(enabled: boolean);
  68671. get fxaaEnabled(): boolean;
  68672. private _samples;
  68673. /**
  68674. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  68675. */
  68676. set samples(sampleCount: number);
  68677. get samples(): number;
  68678. /**
  68679. * If image processing is enabled.
  68680. */
  68681. set imageProcessingEnabled(enabled: boolean);
  68682. get imageProcessingEnabled(): boolean;
  68683. /**
  68684. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  68685. */
  68686. set glowLayerEnabled(enabled: boolean);
  68687. get glowLayerEnabled(): boolean;
  68688. /**
  68689. * Gets the glow layer (or null if not defined)
  68690. */
  68691. get glowLayer(): Nullable<GlowLayer>;
  68692. /**
  68693. * Enable or disable the chromaticAberration process from the pipeline
  68694. */
  68695. set chromaticAberrationEnabled(enabled: boolean);
  68696. get chromaticAberrationEnabled(): boolean;
  68697. /**
  68698. * Enable or disable the grain process from the pipeline
  68699. */
  68700. set grainEnabled(enabled: boolean);
  68701. get grainEnabled(): boolean;
  68702. /**
  68703. * @constructor
  68704. * @param name - The rendering pipeline name (default: "")
  68705. * @param hdr - If high dynamic range textures should be used (default: true)
  68706. * @param scene - The scene linked to this pipeline (default: the last created scene)
  68707. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  68708. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  68709. */
  68710. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  68711. /**
  68712. * Get the class name
  68713. * @returns "DefaultRenderingPipeline"
  68714. */
  68715. getClassName(): string;
  68716. /**
  68717. * Force the compilation of the entire pipeline.
  68718. */
  68719. prepare(): void;
  68720. private _hasCleared;
  68721. private _prevPostProcess;
  68722. private _prevPrevPostProcess;
  68723. private _setAutoClearAndTextureSharing;
  68724. private _depthOfFieldSceneObserver;
  68725. private _buildPipeline;
  68726. private _disposePostProcesses;
  68727. /**
  68728. * Adds a camera to the pipeline
  68729. * @param camera the camera to be added
  68730. */
  68731. addCamera(camera: Camera): void;
  68732. /**
  68733. * Removes a camera from the pipeline
  68734. * @param camera the camera to remove
  68735. */
  68736. removeCamera(camera: Camera): void;
  68737. /**
  68738. * Dispose of the pipeline and stop all post processes
  68739. */
  68740. dispose(): void;
  68741. /**
  68742. * Serialize the rendering pipeline (Used when exporting)
  68743. * @returns the serialized object
  68744. */
  68745. serialize(): any;
  68746. /**
  68747. * Parse the serialized pipeline
  68748. * @param source Source pipeline.
  68749. * @param scene The scene to load the pipeline to.
  68750. * @param rootUrl The URL of the serialized pipeline.
  68751. * @returns An instantiated pipeline from the serialized object.
  68752. */
  68753. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  68754. }
  68755. }
  68756. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  68757. /** @hidden */
  68758. export var lensHighlightsPixelShader: {
  68759. name: string;
  68760. shader: string;
  68761. };
  68762. }
  68763. declare module "babylonjs/Shaders/depthOfField.fragment" {
  68764. /** @hidden */
  68765. export var depthOfFieldPixelShader: {
  68766. name: string;
  68767. shader: string;
  68768. };
  68769. }
  68770. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  68771. import { Camera } from "babylonjs/Cameras/camera";
  68772. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68773. import { Scene } from "babylonjs/scene";
  68774. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68775. import "babylonjs/Shaders/chromaticAberration.fragment";
  68776. import "babylonjs/Shaders/lensHighlights.fragment";
  68777. import "babylonjs/Shaders/depthOfField.fragment";
  68778. /**
  68779. * BABYLON.JS Chromatic Aberration GLSL Shader
  68780. * Author: Olivier Guyot
  68781. * Separates very slightly R, G and B colors on the edges of the screen
  68782. * Inspired by Francois Tarlier & Martins Upitis
  68783. */
  68784. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  68785. /**
  68786. * @ignore
  68787. * The chromatic aberration PostProcess id in the pipeline
  68788. */
  68789. LensChromaticAberrationEffect: string;
  68790. /**
  68791. * @ignore
  68792. * The highlights enhancing PostProcess id in the pipeline
  68793. */
  68794. HighlightsEnhancingEffect: string;
  68795. /**
  68796. * @ignore
  68797. * The depth-of-field PostProcess id in the pipeline
  68798. */
  68799. LensDepthOfFieldEffect: string;
  68800. private _scene;
  68801. private _depthTexture;
  68802. private _grainTexture;
  68803. private _chromaticAberrationPostProcess;
  68804. private _highlightsPostProcess;
  68805. private _depthOfFieldPostProcess;
  68806. private _edgeBlur;
  68807. private _grainAmount;
  68808. private _chromaticAberration;
  68809. private _distortion;
  68810. private _highlightsGain;
  68811. private _highlightsThreshold;
  68812. private _dofDistance;
  68813. private _dofAperture;
  68814. private _dofDarken;
  68815. private _dofPentagon;
  68816. private _blurNoise;
  68817. /**
  68818. * @constructor
  68819. *
  68820. * Effect parameters are as follow:
  68821. * {
  68822. * chromatic_aberration: number; // from 0 to x (1 for realism)
  68823. * edge_blur: number; // from 0 to x (1 for realism)
  68824. * distortion: number; // from 0 to x (1 for realism)
  68825. * grain_amount: number; // from 0 to 1
  68826. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  68827. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  68828. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  68829. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  68830. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  68831. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  68832. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  68833. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  68834. * }
  68835. * Note: if an effect parameter is unset, effect is disabled
  68836. *
  68837. * @param name The rendering pipeline name
  68838. * @param parameters - An object containing all parameters (see above)
  68839. * @param scene The scene linked to this pipeline
  68840. * @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)
  68841. * @param cameras The array of cameras that the rendering pipeline will be attached to
  68842. */
  68843. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  68844. /**
  68845. * Get the class name
  68846. * @returns "LensRenderingPipeline"
  68847. */
  68848. getClassName(): string;
  68849. /**
  68850. * Gets associated scene
  68851. */
  68852. get scene(): Scene;
  68853. /**
  68854. * Gets or sets the edge blur
  68855. */
  68856. get edgeBlur(): number;
  68857. set edgeBlur(value: number);
  68858. /**
  68859. * Gets or sets the grain amount
  68860. */
  68861. get grainAmount(): number;
  68862. set grainAmount(value: number);
  68863. /**
  68864. * Gets or sets the chromatic aberration amount
  68865. */
  68866. get chromaticAberration(): number;
  68867. set chromaticAberration(value: number);
  68868. /**
  68869. * Gets or sets the depth of field aperture
  68870. */
  68871. get dofAperture(): number;
  68872. set dofAperture(value: number);
  68873. /**
  68874. * Gets or sets the edge distortion
  68875. */
  68876. get edgeDistortion(): number;
  68877. set edgeDistortion(value: number);
  68878. /**
  68879. * Gets or sets the depth of field distortion
  68880. */
  68881. get dofDistortion(): number;
  68882. set dofDistortion(value: number);
  68883. /**
  68884. * Gets or sets the darken out of focus amount
  68885. */
  68886. get darkenOutOfFocus(): number;
  68887. set darkenOutOfFocus(value: number);
  68888. /**
  68889. * Gets or sets a boolean indicating if blur noise is enabled
  68890. */
  68891. get blurNoise(): boolean;
  68892. set blurNoise(value: boolean);
  68893. /**
  68894. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  68895. */
  68896. get pentagonBokeh(): boolean;
  68897. set pentagonBokeh(value: boolean);
  68898. /**
  68899. * Gets or sets the highlight grain amount
  68900. */
  68901. get highlightsGain(): number;
  68902. set highlightsGain(value: number);
  68903. /**
  68904. * Gets or sets the highlight threshold
  68905. */
  68906. get highlightsThreshold(): number;
  68907. set highlightsThreshold(value: number);
  68908. /**
  68909. * Sets the amount of blur at the edges
  68910. * @param amount blur amount
  68911. */
  68912. setEdgeBlur(amount: number): void;
  68913. /**
  68914. * Sets edge blur to 0
  68915. */
  68916. disableEdgeBlur(): void;
  68917. /**
  68918. * Sets the amout of grain
  68919. * @param amount Amount of grain
  68920. */
  68921. setGrainAmount(amount: number): void;
  68922. /**
  68923. * Set grain amount to 0
  68924. */
  68925. disableGrain(): void;
  68926. /**
  68927. * Sets the chromatic aberration amount
  68928. * @param amount amount of chromatic aberration
  68929. */
  68930. setChromaticAberration(amount: number): void;
  68931. /**
  68932. * Sets chromatic aberration amount to 0
  68933. */
  68934. disableChromaticAberration(): void;
  68935. /**
  68936. * Sets the EdgeDistortion amount
  68937. * @param amount amount of EdgeDistortion
  68938. */
  68939. setEdgeDistortion(amount: number): void;
  68940. /**
  68941. * Sets edge distortion to 0
  68942. */
  68943. disableEdgeDistortion(): void;
  68944. /**
  68945. * Sets the FocusDistance amount
  68946. * @param amount amount of FocusDistance
  68947. */
  68948. setFocusDistance(amount: number): void;
  68949. /**
  68950. * Disables depth of field
  68951. */
  68952. disableDepthOfField(): void;
  68953. /**
  68954. * Sets the Aperture amount
  68955. * @param amount amount of Aperture
  68956. */
  68957. setAperture(amount: number): void;
  68958. /**
  68959. * Sets the DarkenOutOfFocus amount
  68960. * @param amount amount of DarkenOutOfFocus
  68961. */
  68962. setDarkenOutOfFocus(amount: number): void;
  68963. private _pentagonBokehIsEnabled;
  68964. /**
  68965. * Creates a pentagon bokeh effect
  68966. */
  68967. enablePentagonBokeh(): void;
  68968. /**
  68969. * Disables the pentagon bokeh effect
  68970. */
  68971. disablePentagonBokeh(): void;
  68972. /**
  68973. * Enables noise blur
  68974. */
  68975. enableNoiseBlur(): void;
  68976. /**
  68977. * Disables noise blur
  68978. */
  68979. disableNoiseBlur(): void;
  68980. /**
  68981. * Sets the HighlightsGain amount
  68982. * @param amount amount of HighlightsGain
  68983. */
  68984. setHighlightsGain(amount: number): void;
  68985. /**
  68986. * Sets the HighlightsThreshold amount
  68987. * @param amount amount of HighlightsThreshold
  68988. */
  68989. setHighlightsThreshold(amount: number): void;
  68990. /**
  68991. * Disables highlights
  68992. */
  68993. disableHighlights(): void;
  68994. /**
  68995. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  68996. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  68997. */
  68998. dispose(disableDepthRender?: boolean): void;
  68999. private _createChromaticAberrationPostProcess;
  69000. private _createHighlightsPostProcess;
  69001. private _createDepthOfFieldPostProcess;
  69002. private _createGrainTexture;
  69003. }
  69004. }
  69005. declare module "babylonjs/Shaders/ssao2.fragment" {
  69006. /** @hidden */
  69007. export var ssao2PixelShader: {
  69008. name: string;
  69009. shader: string;
  69010. };
  69011. }
  69012. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  69013. /** @hidden */
  69014. export var ssaoCombinePixelShader: {
  69015. name: string;
  69016. shader: string;
  69017. };
  69018. }
  69019. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  69020. import { Camera } from "babylonjs/Cameras/camera";
  69021. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69022. import { Scene } from "babylonjs/scene";
  69023. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69024. import "babylonjs/Shaders/ssao2.fragment";
  69025. import "babylonjs/Shaders/ssaoCombine.fragment";
  69026. /**
  69027. * Render pipeline to produce ssao effect
  69028. */
  69029. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  69030. /**
  69031. * @ignore
  69032. * The PassPostProcess id in the pipeline that contains the original scene color
  69033. */
  69034. SSAOOriginalSceneColorEffect: string;
  69035. /**
  69036. * @ignore
  69037. * The SSAO PostProcess id in the pipeline
  69038. */
  69039. SSAORenderEffect: string;
  69040. /**
  69041. * @ignore
  69042. * The horizontal blur PostProcess id in the pipeline
  69043. */
  69044. SSAOBlurHRenderEffect: string;
  69045. /**
  69046. * @ignore
  69047. * The vertical blur PostProcess id in the pipeline
  69048. */
  69049. SSAOBlurVRenderEffect: string;
  69050. /**
  69051. * @ignore
  69052. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69053. */
  69054. SSAOCombineRenderEffect: string;
  69055. /**
  69056. * The output strength of the SSAO post-process. Default value is 1.0.
  69057. */
  69058. totalStrength: number;
  69059. /**
  69060. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  69061. */
  69062. maxZ: number;
  69063. /**
  69064. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  69065. */
  69066. minZAspect: number;
  69067. private _samples;
  69068. /**
  69069. * Number of samples used for the SSAO calculations. Default value is 8
  69070. */
  69071. set samples(n: number);
  69072. get samples(): number;
  69073. private _textureSamples;
  69074. /**
  69075. * Number of samples to use for antialiasing
  69076. */
  69077. set textureSamples(n: number);
  69078. get textureSamples(): number;
  69079. /**
  69080. * Ratio object used for SSAO ratio and blur ratio
  69081. */
  69082. private _ratio;
  69083. /**
  69084. * Dynamically generated sphere sampler.
  69085. */
  69086. private _sampleSphere;
  69087. /**
  69088. * Blur filter offsets
  69089. */
  69090. private _samplerOffsets;
  69091. private _expensiveBlur;
  69092. /**
  69093. * If bilateral blur should be used
  69094. */
  69095. set expensiveBlur(b: boolean);
  69096. get expensiveBlur(): boolean;
  69097. /**
  69098. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  69099. */
  69100. radius: number;
  69101. /**
  69102. * The base color of the SSAO post-process
  69103. * The final result is "base + ssao" between [0, 1]
  69104. */
  69105. base: number;
  69106. /**
  69107. * Support test.
  69108. */
  69109. static get IsSupported(): boolean;
  69110. private _scene;
  69111. private _depthTexture;
  69112. private _normalTexture;
  69113. private _randomTexture;
  69114. private _originalColorPostProcess;
  69115. private _ssaoPostProcess;
  69116. private _blurHPostProcess;
  69117. private _blurVPostProcess;
  69118. private _ssaoCombinePostProcess;
  69119. /**
  69120. * Gets active scene
  69121. */
  69122. get scene(): Scene;
  69123. /**
  69124. * @constructor
  69125. * @param name The rendering pipeline name
  69126. * @param scene The scene linked to this pipeline
  69127. * @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 }
  69128. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69129. */
  69130. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69131. /**
  69132. * Get the class name
  69133. * @returns "SSAO2RenderingPipeline"
  69134. */
  69135. getClassName(): string;
  69136. /**
  69137. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69138. */
  69139. dispose(disableGeometryBufferRenderer?: boolean): void;
  69140. private _createBlurPostProcess;
  69141. /** @hidden */
  69142. _rebuild(): void;
  69143. private _bits;
  69144. private _radicalInverse_VdC;
  69145. private _hammersley;
  69146. private _hemisphereSample_uniform;
  69147. private _generateHemisphere;
  69148. private _createSSAOPostProcess;
  69149. private _createSSAOCombinePostProcess;
  69150. private _createRandomTexture;
  69151. /**
  69152. * Serialize the rendering pipeline (Used when exporting)
  69153. * @returns the serialized object
  69154. */
  69155. serialize(): any;
  69156. /**
  69157. * Parse the serialized pipeline
  69158. * @param source Source pipeline.
  69159. * @param scene The scene to load the pipeline to.
  69160. * @param rootUrl The URL of the serialized pipeline.
  69161. * @returns An instantiated pipeline from the serialized object.
  69162. */
  69163. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  69164. }
  69165. }
  69166. declare module "babylonjs/Shaders/ssao.fragment" {
  69167. /** @hidden */
  69168. export var ssaoPixelShader: {
  69169. name: string;
  69170. shader: string;
  69171. };
  69172. }
  69173. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  69174. import { Camera } from "babylonjs/Cameras/camera";
  69175. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69176. import { Scene } from "babylonjs/scene";
  69177. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69178. import "babylonjs/Shaders/ssao.fragment";
  69179. import "babylonjs/Shaders/ssaoCombine.fragment";
  69180. /**
  69181. * Render pipeline to produce ssao effect
  69182. */
  69183. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  69184. /**
  69185. * @ignore
  69186. * The PassPostProcess id in the pipeline that contains the original scene color
  69187. */
  69188. SSAOOriginalSceneColorEffect: string;
  69189. /**
  69190. * @ignore
  69191. * The SSAO PostProcess id in the pipeline
  69192. */
  69193. SSAORenderEffect: string;
  69194. /**
  69195. * @ignore
  69196. * The horizontal blur PostProcess id in the pipeline
  69197. */
  69198. SSAOBlurHRenderEffect: string;
  69199. /**
  69200. * @ignore
  69201. * The vertical blur PostProcess id in the pipeline
  69202. */
  69203. SSAOBlurVRenderEffect: string;
  69204. /**
  69205. * @ignore
  69206. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69207. */
  69208. SSAOCombineRenderEffect: string;
  69209. /**
  69210. * The output strength of the SSAO post-process. Default value is 1.0.
  69211. */
  69212. totalStrength: number;
  69213. /**
  69214. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  69215. */
  69216. radius: number;
  69217. /**
  69218. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  69219. * Must not be equal to fallOff and superior to fallOff.
  69220. * Default value is 0.0075
  69221. */
  69222. area: number;
  69223. /**
  69224. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  69225. * Must not be equal to area and inferior to area.
  69226. * Default value is 0.000001
  69227. */
  69228. fallOff: number;
  69229. /**
  69230. * The base color of the SSAO post-process
  69231. * The final result is "base + ssao" between [0, 1]
  69232. */
  69233. base: number;
  69234. private _scene;
  69235. private _depthTexture;
  69236. private _randomTexture;
  69237. private _originalColorPostProcess;
  69238. private _ssaoPostProcess;
  69239. private _blurHPostProcess;
  69240. private _blurVPostProcess;
  69241. private _ssaoCombinePostProcess;
  69242. private _firstUpdate;
  69243. /**
  69244. * Gets active scene
  69245. */
  69246. get scene(): Scene;
  69247. /**
  69248. * @constructor
  69249. * @param name - The rendering pipeline name
  69250. * @param scene - The scene linked to this pipeline
  69251. * @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 }
  69252. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  69253. */
  69254. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69255. /**
  69256. * Get the class name
  69257. * @returns "SSAORenderingPipeline"
  69258. */
  69259. getClassName(): string;
  69260. /**
  69261. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69262. */
  69263. dispose(disableDepthRender?: boolean): void;
  69264. private _createBlurPostProcess;
  69265. /** @hidden */
  69266. _rebuild(): void;
  69267. private _createSSAOPostProcess;
  69268. private _createSSAOCombinePostProcess;
  69269. private _createRandomTexture;
  69270. }
  69271. }
  69272. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  69273. /** @hidden */
  69274. export var screenSpaceReflectionPixelShader: {
  69275. name: string;
  69276. shader: string;
  69277. };
  69278. }
  69279. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  69280. import { Nullable } from "babylonjs/types";
  69281. import { Camera } from "babylonjs/Cameras/camera";
  69282. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69283. import { Scene } from "babylonjs/scene";
  69284. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  69285. import { Engine } from "babylonjs/Engines/engine";
  69286. /**
  69287. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  69288. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  69289. */
  69290. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  69291. /**
  69292. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  69293. */
  69294. threshold: number;
  69295. /**
  69296. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  69297. */
  69298. strength: number;
  69299. /**
  69300. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  69301. */
  69302. reflectionSpecularFalloffExponent: number;
  69303. /**
  69304. * 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]
  69305. */
  69306. step: number;
  69307. /**
  69308. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  69309. */
  69310. roughnessFactor: number;
  69311. private _geometryBufferRenderer;
  69312. private _enableSmoothReflections;
  69313. private _reflectionSamples;
  69314. private _smoothSteps;
  69315. /**
  69316. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  69317. * @param name The name of the effect.
  69318. * @param scene The scene containing the objects to calculate reflections.
  69319. * @param options The required width/height ratio to downsize to before computing the render pass.
  69320. * @param camera The camera to apply the render pass to.
  69321. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69322. * @param engine The engine which the post process will be applied. (default: current engine)
  69323. * @param reusable If the post process can be reused on the same frame. (default: false)
  69324. * @param textureType Type of textures used when performing the post process. (default: 0)
  69325. * @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)
  69326. */
  69327. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69328. /**
  69329. * Gets wether or not smoothing reflections is enabled.
  69330. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69331. */
  69332. get enableSmoothReflections(): boolean;
  69333. /**
  69334. * Sets wether or not smoothing reflections is enabled.
  69335. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69336. */
  69337. set enableSmoothReflections(enabled: boolean);
  69338. /**
  69339. * Gets the number of samples taken while computing reflections. More samples count is high,
  69340. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69341. */
  69342. get reflectionSamples(): number;
  69343. /**
  69344. * Sets the number of samples taken while computing reflections. More samples count is high,
  69345. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69346. */
  69347. set reflectionSamples(samples: number);
  69348. /**
  69349. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  69350. * more the post-process will require GPU power and can generate a drop in FPS.
  69351. * Default value (5.0) work pretty well in all cases but can be adjusted.
  69352. */
  69353. get smoothSteps(): number;
  69354. set smoothSteps(steps: number);
  69355. private _updateEffectDefines;
  69356. }
  69357. }
  69358. declare module "babylonjs/Shaders/standard.fragment" {
  69359. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  69360. /** @hidden */
  69361. export var standardPixelShader: {
  69362. name: string;
  69363. shader: string;
  69364. };
  69365. }
  69366. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  69367. import { Nullable } from "babylonjs/types";
  69368. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  69369. import { Camera } from "babylonjs/Cameras/camera";
  69370. import { Texture } from "babylonjs/Materials/Textures/texture";
  69371. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69372. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69373. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  69374. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  69375. import { IDisposable } from "babylonjs/scene";
  69376. import { SpotLight } from "babylonjs/Lights/spotLight";
  69377. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  69378. import { Scene } from "babylonjs/scene";
  69379. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  69380. import { Animation } from "babylonjs/Animations/animation";
  69381. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69382. import "babylonjs/Shaders/standard.fragment";
  69383. /**
  69384. * Standard rendering pipeline
  69385. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69386. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  69387. */
  69388. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69389. /**
  69390. * Public members
  69391. */
  69392. /**
  69393. * Post-process which contains the original scene color before the pipeline applies all the effects
  69394. */
  69395. originalPostProcess: Nullable<PostProcess>;
  69396. /**
  69397. * Post-process used to down scale an image x4
  69398. */
  69399. downSampleX4PostProcess: Nullable<PostProcess>;
  69400. /**
  69401. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  69402. */
  69403. brightPassPostProcess: Nullable<PostProcess>;
  69404. /**
  69405. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  69406. */
  69407. blurHPostProcesses: PostProcess[];
  69408. /**
  69409. * Post-process array storing all the vertical blur post-processes used by the pipeline
  69410. */
  69411. blurVPostProcesses: PostProcess[];
  69412. /**
  69413. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  69414. */
  69415. textureAdderPostProcess: Nullable<PostProcess>;
  69416. /**
  69417. * Post-process used to create volumetric lighting effect
  69418. */
  69419. volumetricLightPostProcess: Nullable<PostProcess>;
  69420. /**
  69421. * Post-process used to smooth the previous volumetric light post-process on the X axis
  69422. */
  69423. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  69424. /**
  69425. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  69426. */
  69427. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  69428. /**
  69429. * Post-process used to merge the volumetric light effect and the real scene color
  69430. */
  69431. volumetricLightMergePostProces: Nullable<PostProcess>;
  69432. /**
  69433. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  69434. */
  69435. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  69436. /**
  69437. * Base post-process used to calculate the average luminance of the final image for HDR
  69438. */
  69439. luminancePostProcess: Nullable<PostProcess>;
  69440. /**
  69441. * Post-processes used to create down sample post-processes in order to get
  69442. * the average luminance of the final image for HDR
  69443. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  69444. */
  69445. luminanceDownSamplePostProcesses: PostProcess[];
  69446. /**
  69447. * Post-process used to create a HDR effect (light adaptation)
  69448. */
  69449. hdrPostProcess: Nullable<PostProcess>;
  69450. /**
  69451. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  69452. */
  69453. textureAdderFinalPostProcess: Nullable<PostProcess>;
  69454. /**
  69455. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  69456. */
  69457. lensFlareFinalPostProcess: Nullable<PostProcess>;
  69458. /**
  69459. * Post-process used to merge the final HDR post-process and the real scene color
  69460. */
  69461. hdrFinalPostProcess: Nullable<PostProcess>;
  69462. /**
  69463. * Post-process used to create a lens flare effect
  69464. */
  69465. lensFlarePostProcess: Nullable<PostProcess>;
  69466. /**
  69467. * Post-process that merges the result of the lens flare post-process and the real scene color
  69468. */
  69469. lensFlareComposePostProcess: Nullable<PostProcess>;
  69470. /**
  69471. * Post-process used to create a motion blur effect
  69472. */
  69473. motionBlurPostProcess: Nullable<PostProcess>;
  69474. /**
  69475. * Post-process used to create a depth of field effect
  69476. */
  69477. depthOfFieldPostProcess: Nullable<PostProcess>;
  69478. /**
  69479. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69480. */
  69481. fxaaPostProcess: Nullable<FxaaPostProcess>;
  69482. /**
  69483. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  69484. */
  69485. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  69486. /**
  69487. * Represents the brightness threshold in order to configure the illuminated surfaces
  69488. */
  69489. brightThreshold: number;
  69490. /**
  69491. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  69492. */
  69493. blurWidth: number;
  69494. /**
  69495. * Sets if the blur for highlighted surfaces must be only horizontal
  69496. */
  69497. horizontalBlur: boolean;
  69498. /**
  69499. * Gets the overall exposure used by the pipeline
  69500. */
  69501. get exposure(): number;
  69502. /**
  69503. * Sets the overall exposure used by the pipeline
  69504. */
  69505. set exposure(value: number);
  69506. /**
  69507. * Texture used typically to simulate "dirty" on camera lens
  69508. */
  69509. lensTexture: Nullable<Texture>;
  69510. /**
  69511. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  69512. */
  69513. volumetricLightCoefficient: number;
  69514. /**
  69515. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  69516. */
  69517. volumetricLightPower: number;
  69518. /**
  69519. * Used the set the blur intensity to smooth the volumetric lights
  69520. */
  69521. volumetricLightBlurScale: number;
  69522. /**
  69523. * Light (spot or directional) used to generate the volumetric lights rays
  69524. * The source light must have a shadow generate so the pipeline can get its
  69525. * depth map
  69526. */
  69527. sourceLight: Nullable<SpotLight | DirectionalLight>;
  69528. /**
  69529. * For eye adaptation, represents the minimum luminance the eye can see
  69530. */
  69531. hdrMinimumLuminance: number;
  69532. /**
  69533. * For eye adaptation, represents the decrease luminance speed
  69534. */
  69535. hdrDecreaseRate: number;
  69536. /**
  69537. * For eye adaptation, represents the increase luminance speed
  69538. */
  69539. hdrIncreaseRate: number;
  69540. /**
  69541. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69542. */
  69543. get hdrAutoExposure(): boolean;
  69544. /**
  69545. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69546. */
  69547. set hdrAutoExposure(value: boolean);
  69548. /**
  69549. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  69550. */
  69551. lensColorTexture: Nullable<Texture>;
  69552. /**
  69553. * The overall strengh for the lens flare effect
  69554. */
  69555. lensFlareStrength: number;
  69556. /**
  69557. * Dispersion coefficient for lens flare ghosts
  69558. */
  69559. lensFlareGhostDispersal: number;
  69560. /**
  69561. * Main lens flare halo width
  69562. */
  69563. lensFlareHaloWidth: number;
  69564. /**
  69565. * Based on the lens distortion effect, defines how much the lens flare result
  69566. * is distorted
  69567. */
  69568. lensFlareDistortionStrength: number;
  69569. /**
  69570. * Configures the blur intensity used for for lens flare (halo)
  69571. */
  69572. lensFlareBlurWidth: number;
  69573. /**
  69574. * Lens star texture must be used to simulate rays on the flares and is available
  69575. * in the documentation
  69576. */
  69577. lensStarTexture: Nullable<Texture>;
  69578. /**
  69579. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  69580. * flare effect by taking account of the dirt texture
  69581. */
  69582. lensFlareDirtTexture: Nullable<Texture>;
  69583. /**
  69584. * Represents the focal length for the depth of field effect
  69585. */
  69586. depthOfFieldDistance: number;
  69587. /**
  69588. * Represents the blur intensity for the blurred part of the depth of field effect
  69589. */
  69590. depthOfFieldBlurWidth: number;
  69591. /**
  69592. * Gets how much the image is blurred by the movement while using the motion blur post-process
  69593. */
  69594. get motionStrength(): number;
  69595. /**
  69596. * Sets how much the image is blurred by the movement while using the motion blur post-process
  69597. */
  69598. set motionStrength(strength: number);
  69599. /**
  69600. * Gets wether or not the motion blur post-process is object based or screen based.
  69601. */
  69602. get objectBasedMotionBlur(): boolean;
  69603. /**
  69604. * Sets wether or not the motion blur post-process should be object based or screen based
  69605. */
  69606. set objectBasedMotionBlur(value: boolean);
  69607. /**
  69608. * List of animations for the pipeline (IAnimatable implementation)
  69609. */
  69610. animations: Animation[];
  69611. /**
  69612. * Private members
  69613. */
  69614. private _scene;
  69615. private _currentDepthOfFieldSource;
  69616. private _basePostProcess;
  69617. private _fixedExposure;
  69618. private _currentExposure;
  69619. private _hdrAutoExposure;
  69620. private _hdrCurrentLuminance;
  69621. private _motionStrength;
  69622. private _isObjectBasedMotionBlur;
  69623. private _floatTextureType;
  69624. private _camerasToBeAttached;
  69625. private _ratio;
  69626. private _bloomEnabled;
  69627. private _depthOfFieldEnabled;
  69628. private _vlsEnabled;
  69629. private _lensFlareEnabled;
  69630. private _hdrEnabled;
  69631. private _motionBlurEnabled;
  69632. private _fxaaEnabled;
  69633. private _screenSpaceReflectionsEnabled;
  69634. private _motionBlurSamples;
  69635. private _volumetricLightStepsCount;
  69636. private _samples;
  69637. /**
  69638. * @ignore
  69639. * Specifies if the bloom pipeline is enabled
  69640. */
  69641. get BloomEnabled(): boolean;
  69642. set BloomEnabled(enabled: boolean);
  69643. /**
  69644. * @ignore
  69645. * Specifies if the depth of field pipeline is enabed
  69646. */
  69647. get DepthOfFieldEnabled(): boolean;
  69648. set DepthOfFieldEnabled(enabled: boolean);
  69649. /**
  69650. * @ignore
  69651. * Specifies if the lens flare pipeline is enabed
  69652. */
  69653. get LensFlareEnabled(): boolean;
  69654. set LensFlareEnabled(enabled: boolean);
  69655. /**
  69656. * @ignore
  69657. * Specifies if the HDR pipeline is enabled
  69658. */
  69659. get HDREnabled(): boolean;
  69660. set HDREnabled(enabled: boolean);
  69661. /**
  69662. * @ignore
  69663. * Specifies if the volumetric lights scattering effect is enabled
  69664. */
  69665. get VLSEnabled(): boolean;
  69666. set VLSEnabled(enabled: boolean);
  69667. /**
  69668. * @ignore
  69669. * Specifies if the motion blur effect is enabled
  69670. */
  69671. get MotionBlurEnabled(): boolean;
  69672. set MotionBlurEnabled(enabled: boolean);
  69673. /**
  69674. * Specifies if anti-aliasing is enabled
  69675. */
  69676. get fxaaEnabled(): boolean;
  69677. set fxaaEnabled(enabled: boolean);
  69678. /**
  69679. * Specifies if screen space reflections are enabled.
  69680. */
  69681. get screenSpaceReflectionsEnabled(): boolean;
  69682. set screenSpaceReflectionsEnabled(enabled: boolean);
  69683. /**
  69684. * Specifies the number of steps used to calculate the volumetric lights
  69685. * Typically in interval [50, 200]
  69686. */
  69687. get volumetricLightStepsCount(): number;
  69688. set volumetricLightStepsCount(count: number);
  69689. /**
  69690. * Specifies the number of samples used for the motion blur effect
  69691. * Typically in interval [16, 64]
  69692. */
  69693. get motionBlurSamples(): number;
  69694. set motionBlurSamples(samples: number);
  69695. /**
  69696. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69697. */
  69698. get samples(): number;
  69699. set samples(sampleCount: number);
  69700. /**
  69701. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69702. * @constructor
  69703. * @param name The rendering pipeline name
  69704. * @param scene The scene linked to this pipeline
  69705. * @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)
  69706. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  69707. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69708. */
  69709. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  69710. private _buildPipeline;
  69711. private _createDownSampleX4PostProcess;
  69712. private _createBrightPassPostProcess;
  69713. private _createBlurPostProcesses;
  69714. private _createTextureAdderPostProcess;
  69715. private _createVolumetricLightPostProcess;
  69716. private _createLuminancePostProcesses;
  69717. private _createHdrPostProcess;
  69718. private _createLensFlarePostProcess;
  69719. private _createDepthOfFieldPostProcess;
  69720. private _createMotionBlurPostProcess;
  69721. private _getDepthTexture;
  69722. private _disposePostProcesses;
  69723. /**
  69724. * Dispose of the pipeline and stop all post processes
  69725. */
  69726. dispose(): void;
  69727. /**
  69728. * Serialize the rendering pipeline (Used when exporting)
  69729. * @returns the serialized object
  69730. */
  69731. serialize(): any;
  69732. /**
  69733. * Parse the serialized pipeline
  69734. * @param source Source pipeline.
  69735. * @param scene The scene to load the pipeline to.
  69736. * @param rootUrl The URL of the serialized pipeline.
  69737. * @returns An instantiated pipeline from the serialized object.
  69738. */
  69739. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  69740. /**
  69741. * Luminance steps
  69742. */
  69743. static LuminanceSteps: number;
  69744. }
  69745. }
  69746. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  69747. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  69748. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  69749. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  69750. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  69751. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  69752. }
  69753. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  69754. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  69755. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  69756. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69757. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  69758. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69759. }
  69760. declare module "babylonjs/Shaders/tonemap.fragment" {
  69761. /** @hidden */
  69762. export var tonemapPixelShader: {
  69763. name: string;
  69764. shader: string;
  69765. };
  69766. }
  69767. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  69768. import { Camera } from "babylonjs/Cameras/camera";
  69769. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69770. import "babylonjs/Shaders/tonemap.fragment";
  69771. import { Engine } from "babylonjs/Engines/engine";
  69772. /** Defines operator used for tonemapping */
  69773. export enum TonemappingOperator {
  69774. /** Hable */
  69775. Hable = 0,
  69776. /** Reinhard */
  69777. Reinhard = 1,
  69778. /** HejiDawson */
  69779. HejiDawson = 2,
  69780. /** Photographic */
  69781. Photographic = 3
  69782. }
  69783. /**
  69784. * Defines a post process to apply tone mapping
  69785. */
  69786. export class TonemapPostProcess extends PostProcess {
  69787. private _operator;
  69788. /** Defines the required exposure adjustement */
  69789. exposureAdjustment: number;
  69790. /**
  69791. * Creates a new TonemapPostProcess
  69792. * @param name defines the name of the postprocess
  69793. * @param _operator defines the operator to use
  69794. * @param exposureAdjustment defines the required exposure adjustement
  69795. * @param camera defines the camera to use (can be null)
  69796. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  69797. * @param engine defines the hosting engine (can be ignore if camera is set)
  69798. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  69799. */
  69800. constructor(name: string, _operator: TonemappingOperator,
  69801. /** Defines the required exposure adjustement */
  69802. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  69803. }
  69804. }
  69805. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  69806. /** @hidden */
  69807. export var volumetricLightScatteringPixelShader: {
  69808. name: string;
  69809. shader: string;
  69810. };
  69811. }
  69812. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  69813. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  69814. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  69815. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  69816. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  69817. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  69818. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  69819. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  69820. /** @hidden */
  69821. export var volumetricLightScatteringPassVertexShader: {
  69822. name: string;
  69823. shader: string;
  69824. };
  69825. }
  69826. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  69827. /** @hidden */
  69828. export var volumetricLightScatteringPassPixelShader: {
  69829. name: string;
  69830. shader: string;
  69831. };
  69832. }
  69833. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  69834. import { Vector3 } from "babylonjs/Maths/math.vector";
  69835. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69836. import { Mesh } from "babylonjs/Meshes/mesh";
  69837. import { Camera } from "babylonjs/Cameras/camera";
  69838. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  69839. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69840. import { Scene } from "babylonjs/scene";
  69841. import "babylonjs/Meshes/Builders/planeBuilder";
  69842. import "babylonjs/Shaders/depth.vertex";
  69843. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  69844. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  69845. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  69846. import { Engine } from "babylonjs/Engines/engine";
  69847. /**
  69848. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  69849. */
  69850. export class VolumetricLightScatteringPostProcess extends PostProcess {
  69851. private _volumetricLightScatteringPass;
  69852. private _volumetricLightScatteringRTT;
  69853. private _viewPort;
  69854. private _screenCoordinates;
  69855. private _cachedDefines;
  69856. /**
  69857. * If not undefined, the mesh position is computed from the attached node position
  69858. */
  69859. attachedNode: {
  69860. position: Vector3;
  69861. };
  69862. /**
  69863. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  69864. */
  69865. customMeshPosition: Vector3;
  69866. /**
  69867. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  69868. */
  69869. useCustomMeshPosition: boolean;
  69870. /**
  69871. * If the post-process should inverse the light scattering direction
  69872. */
  69873. invert: boolean;
  69874. /**
  69875. * The internal mesh used by the post-process
  69876. */
  69877. mesh: Mesh;
  69878. /**
  69879. * @hidden
  69880. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  69881. */
  69882. get useDiffuseColor(): boolean;
  69883. set useDiffuseColor(useDiffuseColor: boolean);
  69884. /**
  69885. * Array containing the excluded meshes not rendered in the internal pass
  69886. */
  69887. excludedMeshes: AbstractMesh[];
  69888. /**
  69889. * Controls the overall intensity of the post-process
  69890. */
  69891. exposure: number;
  69892. /**
  69893. * Dissipates each sample's contribution in range [0, 1]
  69894. */
  69895. decay: number;
  69896. /**
  69897. * Controls the overall intensity of each sample
  69898. */
  69899. weight: number;
  69900. /**
  69901. * Controls the density of each sample
  69902. */
  69903. density: number;
  69904. /**
  69905. * @constructor
  69906. * @param name The post-process name
  69907. * @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)
  69908. * @param camera The camera that the post-process will be attached to
  69909. * @param mesh The mesh used to create the light scattering
  69910. * @param samples The post-process quality, default 100
  69911. * @param samplingModeThe post-process filtering mode
  69912. * @param engine The babylon engine
  69913. * @param reusable If the post-process is reusable
  69914. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  69915. */
  69916. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  69917. /**
  69918. * Returns the string "VolumetricLightScatteringPostProcess"
  69919. * @returns "VolumetricLightScatteringPostProcess"
  69920. */
  69921. getClassName(): string;
  69922. private _isReady;
  69923. /**
  69924. * Sets the new light position for light scattering effect
  69925. * @param position The new custom light position
  69926. */
  69927. setCustomMeshPosition(position: Vector3): void;
  69928. /**
  69929. * Returns the light position for light scattering effect
  69930. * @return Vector3 The custom light position
  69931. */
  69932. getCustomMeshPosition(): Vector3;
  69933. /**
  69934. * Disposes the internal assets and detaches the post-process from the camera
  69935. */
  69936. dispose(camera: Camera): void;
  69937. /**
  69938. * Returns the render target texture used by the post-process
  69939. * @return the render target texture used by the post-process
  69940. */
  69941. getPass(): RenderTargetTexture;
  69942. private _meshExcluded;
  69943. private _createPass;
  69944. private _updateMeshScreenCoordinates;
  69945. /**
  69946. * Creates a default mesh for the Volumeric Light Scattering post-process
  69947. * @param name The mesh name
  69948. * @param scene The scene where to create the mesh
  69949. * @return the default mesh
  69950. */
  69951. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  69952. }
  69953. }
  69954. declare module "babylonjs/PostProcesses/index" {
  69955. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  69956. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  69957. export * from "babylonjs/PostProcesses/bloomEffect";
  69958. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  69959. export * from "babylonjs/PostProcesses/blurPostProcess";
  69960. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  69961. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  69962. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  69963. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  69964. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  69965. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  69966. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  69967. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  69968. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  69969. export * from "babylonjs/PostProcesses/filterPostProcess";
  69970. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  69971. export * from "babylonjs/PostProcesses/grainPostProcess";
  69972. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  69973. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  69974. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  69975. export * from "babylonjs/PostProcesses/passPostProcess";
  69976. export * from "babylonjs/PostProcesses/postProcess";
  69977. export * from "babylonjs/PostProcesses/postProcessManager";
  69978. export * from "babylonjs/PostProcesses/refractionPostProcess";
  69979. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  69980. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  69981. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  69982. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  69983. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  69984. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  69985. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  69986. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  69987. }
  69988. declare module "babylonjs/Probes/index" {
  69989. export * from "babylonjs/Probes/reflectionProbe";
  69990. }
  69991. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  69992. import { Scene } from "babylonjs/scene";
  69993. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69994. import { SmartArray } from "babylonjs/Misc/smartArray";
  69995. import { ISceneComponent } from "babylonjs/sceneComponent";
  69996. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  69997. import "babylonjs/Meshes/Builders/boxBuilder";
  69998. import "babylonjs/Shaders/color.fragment";
  69999. import "babylonjs/Shaders/color.vertex";
  70000. import { Color3 } from "babylonjs/Maths/math.color";
  70001. module "babylonjs/scene" {
  70002. interface Scene {
  70003. /** @hidden (Backing field) */
  70004. _boundingBoxRenderer: BoundingBoxRenderer;
  70005. /** @hidden (Backing field) */
  70006. _forceShowBoundingBoxes: boolean;
  70007. /**
  70008. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  70009. */
  70010. forceShowBoundingBoxes: boolean;
  70011. /**
  70012. * Gets the bounding box renderer associated with the scene
  70013. * @returns a BoundingBoxRenderer
  70014. */
  70015. getBoundingBoxRenderer(): BoundingBoxRenderer;
  70016. }
  70017. }
  70018. module "babylonjs/Meshes/abstractMesh" {
  70019. interface AbstractMesh {
  70020. /** @hidden (Backing field) */
  70021. _showBoundingBox: boolean;
  70022. /**
  70023. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  70024. */
  70025. showBoundingBox: boolean;
  70026. }
  70027. }
  70028. /**
  70029. * Component responsible of rendering the bounding box of the meshes in a scene.
  70030. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  70031. */
  70032. export class BoundingBoxRenderer implements ISceneComponent {
  70033. /**
  70034. * The component name helpfull to identify the component in the list of scene components.
  70035. */
  70036. readonly name: string;
  70037. /**
  70038. * The scene the component belongs to.
  70039. */
  70040. scene: Scene;
  70041. /**
  70042. * Color of the bounding box lines placed in front of an object
  70043. */
  70044. frontColor: Color3;
  70045. /**
  70046. * Color of the bounding box lines placed behind an object
  70047. */
  70048. backColor: Color3;
  70049. /**
  70050. * Defines if the renderer should show the back lines or not
  70051. */
  70052. showBackLines: boolean;
  70053. /**
  70054. * @hidden
  70055. */
  70056. renderList: SmartArray<BoundingBox>;
  70057. private _colorShader;
  70058. private _vertexBuffers;
  70059. private _indexBuffer;
  70060. private _fillIndexBuffer;
  70061. private _fillIndexData;
  70062. /**
  70063. * Instantiates a new bounding box renderer in a scene.
  70064. * @param scene the scene the renderer renders in
  70065. */
  70066. constructor(scene: Scene);
  70067. /**
  70068. * Registers the component in a given scene
  70069. */
  70070. register(): void;
  70071. private _evaluateSubMesh;
  70072. private _activeMesh;
  70073. private _prepareRessources;
  70074. private _createIndexBuffer;
  70075. /**
  70076. * Rebuilds the elements related to this component in case of
  70077. * context lost for instance.
  70078. */
  70079. rebuild(): void;
  70080. /**
  70081. * @hidden
  70082. */
  70083. reset(): void;
  70084. /**
  70085. * Render the bounding boxes of a specific rendering group
  70086. * @param renderingGroupId defines the rendering group to render
  70087. */
  70088. render(renderingGroupId: number): void;
  70089. /**
  70090. * In case of occlusion queries, we can render the occlusion bounding box through this method
  70091. * @param mesh Define the mesh to render the occlusion bounding box for
  70092. */
  70093. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  70094. /**
  70095. * Dispose and release the resources attached to this renderer.
  70096. */
  70097. dispose(): void;
  70098. }
  70099. }
  70100. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  70101. import { Nullable } from "babylonjs/types";
  70102. import { Scene } from "babylonjs/scene";
  70103. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  70104. import { Camera } from "babylonjs/Cameras/camera";
  70105. import { ISceneComponent } from "babylonjs/sceneComponent";
  70106. module "babylonjs/scene" {
  70107. interface Scene {
  70108. /** @hidden (Backing field) */
  70109. _depthRenderer: {
  70110. [id: string]: DepthRenderer;
  70111. };
  70112. /**
  70113. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  70114. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  70115. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  70116. * @returns the created depth renderer
  70117. */
  70118. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  70119. /**
  70120. * Disables a depth renderer for a given camera
  70121. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  70122. */
  70123. disableDepthRenderer(camera?: Nullable<Camera>): void;
  70124. }
  70125. }
  70126. /**
  70127. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  70128. * in several rendering techniques.
  70129. */
  70130. export class DepthRendererSceneComponent implements ISceneComponent {
  70131. /**
  70132. * The component name helpfull to identify the component in the list of scene components.
  70133. */
  70134. readonly name: string;
  70135. /**
  70136. * The scene the component belongs to.
  70137. */
  70138. scene: Scene;
  70139. /**
  70140. * Creates a new instance of the component for the given scene
  70141. * @param scene Defines the scene to register the component in
  70142. */
  70143. constructor(scene: Scene);
  70144. /**
  70145. * Registers the component in a given scene
  70146. */
  70147. register(): void;
  70148. /**
  70149. * Rebuilds the elements related to this component in case of
  70150. * context lost for instance.
  70151. */
  70152. rebuild(): void;
  70153. /**
  70154. * Disposes the component and the associated ressources
  70155. */
  70156. dispose(): void;
  70157. private _gatherRenderTargets;
  70158. private _gatherActiveCameraRenderTargets;
  70159. }
  70160. }
  70161. declare module "babylonjs/Shaders/outline.fragment" {
  70162. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  70163. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  70164. /** @hidden */
  70165. export var outlinePixelShader: {
  70166. name: string;
  70167. shader: string;
  70168. };
  70169. }
  70170. declare module "babylonjs/Shaders/outline.vertex" {
  70171. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  70172. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  70173. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  70174. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  70175. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  70176. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  70177. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  70178. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  70179. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  70180. /** @hidden */
  70181. export var outlineVertexShader: {
  70182. name: string;
  70183. shader: string;
  70184. };
  70185. }
  70186. declare module "babylonjs/Rendering/outlineRenderer" {
  70187. import { SubMesh } from "babylonjs/Meshes/subMesh";
  70188. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  70189. import { Scene } from "babylonjs/scene";
  70190. import { ISceneComponent } from "babylonjs/sceneComponent";
  70191. import "babylonjs/Shaders/outline.fragment";
  70192. import "babylonjs/Shaders/outline.vertex";
  70193. module "babylonjs/scene" {
  70194. interface Scene {
  70195. /** @hidden */
  70196. _outlineRenderer: OutlineRenderer;
  70197. /**
  70198. * Gets the outline renderer associated with the scene
  70199. * @returns a OutlineRenderer
  70200. */
  70201. getOutlineRenderer(): OutlineRenderer;
  70202. }
  70203. }
  70204. module "babylonjs/Meshes/abstractMesh" {
  70205. interface AbstractMesh {
  70206. /** @hidden (Backing field) */
  70207. _renderOutline: boolean;
  70208. /**
  70209. * Gets or sets a boolean indicating if the outline must be rendered as well
  70210. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  70211. */
  70212. renderOutline: boolean;
  70213. /** @hidden (Backing field) */
  70214. _renderOverlay: boolean;
  70215. /**
  70216. * Gets or sets a boolean indicating if the overlay must be rendered as well
  70217. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  70218. */
  70219. renderOverlay: boolean;
  70220. }
  70221. }
  70222. /**
  70223. * This class is responsible to draw bothe outline/overlay of meshes.
  70224. * It should not be used directly but through the available method on mesh.
  70225. */
  70226. export class OutlineRenderer implements ISceneComponent {
  70227. /**
  70228. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  70229. */
  70230. private static _StencilReference;
  70231. /**
  70232. * The name of the component. Each component must have a unique name.
  70233. */
  70234. name: string;
  70235. /**
  70236. * The scene the component belongs to.
  70237. */
  70238. scene: Scene;
  70239. /**
  70240. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  70241. */
  70242. zOffset: number;
  70243. private _engine;
  70244. private _effect;
  70245. private _cachedDefines;
  70246. private _savedDepthWrite;
  70247. /**
  70248. * Instantiates a new outline renderer. (There could be only one per scene).
  70249. * @param scene Defines the scene it belongs to
  70250. */
  70251. constructor(scene: Scene);
  70252. /**
  70253. * Register the component to one instance of a scene.
  70254. */
  70255. register(): void;
  70256. /**
  70257. * Rebuilds the elements related to this component in case of
  70258. * context lost for instance.
  70259. */
  70260. rebuild(): void;
  70261. /**
  70262. * Disposes the component and the associated ressources.
  70263. */
  70264. dispose(): void;
  70265. /**
  70266. * Renders the outline in the canvas.
  70267. * @param subMesh Defines the sumesh to render
  70268. * @param batch Defines the batch of meshes in case of instances
  70269. * @param useOverlay Defines if the rendering is for the overlay or the outline
  70270. */
  70271. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  70272. /**
  70273. * Returns whether or not the outline renderer is ready for a given submesh.
  70274. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  70275. * @param subMesh Defines the submesh to check readyness for
  70276. * @param useInstances Defines wheter wee are trying to render instances or not
  70277. * @returns true if ready otherwise false
  70278. */
  70279. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70280. private _beforeRenderingMesh;
  70281. private _afterRenderingMesh;
  70282. }
  70283. }
  70284. declare module "babylonjs/Rendering/index" {
  70285. export * from "babylonjs/Rendering/boundingBoxRenderer";
  70286. export * from "babylonjs/Rendering/depthRenderer";
  70287. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  70288. export * from "babylonjs/Rendering/edgesRenderer";
  70289. export * from "babylonjs/Rendering/geometryBufferRenderer";
  70290. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  70291. export * from "babylonjs/Rendering/outlineRenderer";
  70292. export * from "babylonjs/Rendering/renderingGroup";
  70293. export * from "babylonjs/Rendering/renderingManager";
  70294. export * from "babylonjs/Rendering/utilityLayerRenderer";
  70295. }
  70296. declare module "babylonjs/Sprites/ISprites" {
  70297. /**
  70298. * Defines the basic options interface of a Sprite Frame Source Size.
  70299. */
  70300. export interface ISpriteJSONSpriteSourceSize {
  70301. /**
  70302. * number of the original width of the Frame
  70303. */
  70304. w: number;
  70305. /**
  70306. * number of the original height of the Frame
  70307. */
  70308. h: number;
  70309. }
  70310. /**
  70311. * Defines the basic options interface of a Sprite Frame Data.
  70312. */
  70313. export interface ISpriteJSONSpriteFrameData {
  70314. /**
  70315. * number of the x offset of the Frame
  70316. */
  70317. x: number;
  70318. /**
  70319. * number of the y offset of the Frame
  70320. */
  70321. y: number;
  70322. /**
  70323. * number of the width of the Frame
  70324. */
  70325. w: number;
  70326. /**
  70327. * number of the height of the Frame
  70328. */
  70329. h: number;
  70330. }
  70331. /**
  70332. * Defines the basic options interface of a JSON Sprite.
  70333. */
  70334. export interface ISpriteJSONSprite {
  70335. /**
  70336. * string name of the Frame
  70337. */
  70338. filename: string;
  70339. /**
  70340. * ISpriteJSONSpriteFrame basic object of the frame data
  70341. */
  70342. frame: ISpriteJSONSpriteFrameData;
  70343. /**
  70344. * boolean to flag is the frame was rotated.
  70345. */
  70346. rotated: boolean;
  70347. /**
  70348. * boolean to flag is the frame was trimmed.
  70349. */
  70350. trimmed: boolean;
  70351. /**
  70352. * ISpriteJSONSpriteFrame basic object of the source data
  70353. */
  70354. spriteSourceSize: ISpriteJSONSpriteFrameData;
  70355. /**
  70356. * ISpriteJSONSpriteFrame basic object of the source data
  70357. */
  70358. sourceSize: ISpriteJSONSpriteSourceSize;
  70359. }
  70360. /**
  70361. * Defines the basic options interface of a JSON atlas.
  70362. */
  70363. export interface ISpriteJSONAtlas {
  70364. /**
  70365. * Array of objects that contain the frame data.
  70366. */
  70367. frames: Array<ISpriteJSONSprite>;
  70368. /**
  70369. * object basic object containing the sprite meta data.
  70370. */
  70371. meta?: object;
  70372. }
  70373. }
  70374. declare module "babylonjs/Shaders/spriteMap.fragment" {
  70375. /** @hidden */
  70376. export var spriteMapPixelShader: {
  70377. name: string;
  70378. shader: string;
  70379. };
  70380. }
  70381. declare module "babylonjs/Shaders/spriteMap.vertex" {
  70382. /** @hidden */
  70383. export var spriteMapVertexShader: {
  70384. name: string;
  70385. shader: string;
  70386. };
  70387. }
  70388. declare module "babylonjs/Sprites/spriteMap" {
  70389. import { IDisposable, Scene } from "babylonjs/scene";
  70390. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  70391. import { Texture } from "babylonjs/Materials/Textures/texture";
  70392. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  70393. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  70394. import "babylonjs/Meshes/Builders/planeBuilder";
  70395. import "babylonjs/Shaders/spriteMap.fragment";
  70396. import "babylonjs/Shaders/spriteMap.vertex";
  70397. /**
  70398. * Defines the basic options interface of a SpriteMap
  70399. */
  70400. export interface ISpriteMapOptions {
  70401. /**
  70402. * Vector2 of the number of cells in the grid.
  70403. */
  70404. stageSize?: Vector2;
  70405. /**
  70406. * Vector2 of the size of the output plane in World Units.
  70407. */
  70408. outputSize?: Vector2;
  70409. /**
  70410. * Vector3 of the position of the output plane in World Units.
  70411. */
  70412. outputPosition?: Vector3;
  70413. /**
  70414. * Vector3 of the rotation of the output plane.
  70415. */
  70416. outputRotation?: Vector3;
  70417. /**
  70418. * number of layers that the system will reserve in resources.
  70419. */
  70420. layerCount?: number;
  70421. /**
  70422. * number of max animation frames a single cell will reserve in resources.
  70423. */
  70424. maxAnimationFrames?: number;
  70425. /**
  70426. * number cell index of the base tile when the system compiles.
  70427. */
  70428. baseTile?: number;
  70429. /**
  70430. * boolean flip the sprite after its been repositioned by the framing data.
  70431. */
  70432. flipU?: boolean;
  70433. /**
  70434. * Vector3 scalar of the global RGB values of the SpriteMap.
  70435. */
  70436. colorMultiply?: Vector3;
  70437. }
  70438. /**
  70439. * Defines the IDisposable interface in order to be cleanable from resources.
  70440. */
  70441. export interface ISpriteMap extends IDisposable {
  70442. /**
  70443. * String name of the SpriteMap.
  70444. */
  70445. name: string;
  70446. /**
  70447. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  70448. */
  70449. atlasJSON: ISpriteJSONAtlas;
  70450. /**
  70451. * Texture of the SpriteMap.
  70452. */
  70453. spriteSheet: Texture;
  70454. /**
  70455. * The parameters to initialize the SpriteMap with.
  70456. */
  70457. options: ISpriteMapOptions;
  70458. }
  70459. /**
  70460. * Class used to manage a grid restricted sprite deployment on an Output plane.
  70461. */
  70462. export class SpriteMap implements ISpriteMap {
  70463. /** The Name of the spriteMap */
  70464. name: string;
  70465. /** The JSON file with the frame and meta data */
  70466. atlasJSON: ISpriteJSONAtlas;
  70467. /** The systems Sprite Sheet Texture */
  70468. spriteSheet: Texture;
  70469. /** Arguments passed with the Constructor */
  70470. options: ISpriteMapOptions;
  70471. /** Public Sprite Storage array, parsed from atlasJSON */
  70472. sprites: Array<ISpriteJSONSprite>;
  70473. /** Returns the Number of Sprites in the System */
  70474. get spriteCount(): number;
  70475. /** Returns the Position of Output Plane*/
  70476. get position(): Vector3;
  70477. /** Returns the Position of Output Plane*/
  70478. set position(v: Vector3);
  70479. /** Returns the Rotation of Output Plane*/
  70480. get rotation(): Vector3;
  70481. /** Returns the Rotation of Output Plane*/
  70482. set rotation(v: Vector3);
  70483. /** Sets the AnimationMap*/
  70484. get animationMap(): RawTexture;
  70485. /** Sets the AnimationMap*/
  70486. set animationMap(v: RawTexture);
  70487. /** Scene that the SpriteMap was created in */
  70488. private _scene;
  70489. /** Texture Buffer of Float32 that holds tile frame data*/
  70490. private _frameMap;
  70491. /** Texture Buffers of Float32 that holds tileMap data*/
  70492. private _tileMaps;
  70493. /** Texture Buffer of Float32 that holds Animation Data*/
  70494. private _animationMap;
  70495. /** Custom ShaderMaterial Central to the System*/
  70496. private _material;
  70497. /** Custom ShaderMaterial Central to the System*/
  70498. private _output;
  70499. /** Systems Time Ticker*/
  70500. private _time;
  70501. /**
  70502. * Creates a new SpriteMap
  70503. * @param name defines the SpriteMaps Name
  70504. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  70505. * @param spriteSheet is the Texture that the Sprites are on.
  70506. * @param options a basic deployment configuration
  70507. * @param scene The Scene that the map is deployed on
  70508. */
  70509. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  70510. /**
  70511. * Returns tileID location
  70512. * @returns Vector2 the cell position ID
  70513. */
  70514. getTileID(): Vector2;
  70515. /**
  70516. * Gets the UV location of the mouse over the SpriteMap.
  70517. * @returns Vector2 the UV position of the mouse interaction
  70518. */
  70519. getMousePosition(): Vector2;
  70520. /**
  70521. * Creates the "frame" texture Buffer
  70522. * -------------------------------------
  70523. * Structure of frames
  70524. * "filename": "Falling-Water-2.png",
  70525. * "frame": {"x":69,"y":103,"w":24,"h":32},
  70526. * "rotated": true,
  70527. * "trimmed": true,
  70528. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  70529. * "sourceSize": {"w":32,"h":32}
  70530. * @returns RawTexture of the frameMap
  70531. */
  70532. private _createFrameBuffer;
  70533. /**
  70534. * Creates the tileMap texture Buffer
  70535. * @param buffer normally and array of numbers, or a false to generate from scratch
  70536. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  70537. * @returns RawTexture of the tileMap
  70538. */
  70539. private _createTileBuffer;
  70540. /**
  70541. * Modifies the data of the tileMaps
  70542. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  70543. * @param pos is the iVector2 Coordinates of the Tile
  70544. * @param tile The SpriteIndex of the new Tile
  70545. */
  70546. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  70547. /**
  70548. * Creates the animationMap texture Buffer
  70549. * @param buffer normally and array of numbers, or a false to generate from scratch
  70550. * @returns RawTexture of the animationMap
  70551. */
  70552. private _createTileAnimationBuffer;
  70553. /**
  70554. * Modifies the data of the animationMap
  70555. * @param cellID is the Index of the Sprite
  70556. * @param _frame is the target Animation frame
  70557. * @param toCell is the Target Index of the next frame of the animation
  70558. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  70559. * @param speed is a global scalar of the time variable on the map.
  70560. */
  70561. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  70562. /**
  70563. * Exports the .tilemaps file
  70564. */
  70565. saveTileMaps(): void;
  70566. /**
  70567. * Imports the .tilemaps file
  70568. * @param url of the .tilemaps file
  70569. */
  70570. loadTileMaps(url: string): void;
  70571. /**
  70572. * Release associated resources
  70573. */
  70574. dispose(): void;
  70575. }
  70576. }
  70577. declare module "babylonjs/Sprites/spritePackedManager" {
  70578. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  70579. import { Scene } from "babylonjs/scene";
  70580. /**
  70581. * Class used to manage multiple sprites of different sizes on the same spritesheet
  70582. * @see http://doc.babylonjs.com/babylon101/sprites
  70583. */
  70584. export class SpritePackedManager extends SpriteManager {
  70585. /** defines the packed manager's name */
  70586. name: string;
  70587. /**
  70588. * Creates a new sprite manager from a packed sprite sheet
  70589. * @param name defines the manager's name
  70590. * @param imgUrl defines the sprite sheet url
  70591. * @param capacity defines the maximum allowed number of sprites
  70592. * @param scene defines the hosting scene
  70593. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  70594. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  70595. * @param samplingMode defines the smapling mode to use with spritesheet
  70596. * @param fromPacked set to true; do not alter
  70597. */
  70598. constructor(
  70599. /** defines the packed manager's name */
  70600. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  70601. }
  70602. }
  70603. declare module "babylonjs/Sprites/index" {
  70604. export * from "babylonjs/Sprites/sprite";
  70605. export * from "babylonjs/Sprites/ISprites";
  70606. export * from "babylonjs/Sprites/spriteManager";
  70607. export * from "babylonjs/Sprites/spriteMap";
  70608. export * from "babylonjs/Sprites/spritePackedManager";
  70609. export * from "babylonjs/Sprites/spriteSceneComponent";
  70610. }
  70611. declare module "babylonjs/States/index" {
  70612. export * from "babylonjs/States/alphaCullingState";
  70613. export * from "babylonjs/States/depthCullingState";
  70614. export * from "babylonjs/States/stencilState";
  70615. }
  70616. declare module "babylonjs/Misc/assetsManager" {
  70617. import { Scene } from "babylonjs/scene";
  70618. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70619. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70620. import { Skeleton } from "babylonjs/Bones/skeleton";
  70621. import { Observable } from "babylonjs/Misc/observable";
  70622. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  70623. import { Texture } from "babylonjs/Materials/Textures/texture";
  70624. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  70625. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  70626. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  70627. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  70628. /**
  70629. * Defines the list of states available for a task inside a AssetsManager
  70630. */
  70631. export enum AssetTaskState {
  70632. /**
  70633. * Initialization
  70634. */
  70635. INIT = 0,
  70636. /**
  70637. * Running
  70638. */
  70639. RUNNING = 1,
  70640. /**
  70641. * Done
  70642. */
  70643. DONE = 2,
  70644. /**
  70645. * Error
  70646. */
  70647. ERROR = 3
  70648. }
  70649. /**
  70650. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  70651. */
  70652. export abstract class AbstractAssetTask {
  70653. /**
  70654. * Task name
  70655. */ name: string;
  70656. /**
  70657. * Callback called when the task is successful
  70658. */
  70659. onSuccess: (task: any) => void;
  70660. /**
  70661. * Callback called when the task is not successful
  70662. */
  70663. onError: (task: any, message?: string, exception?: any) => void;
  70664. /**
  70665. * Creates a new AssetsManager
  70666. * @param name defines the name of the task
  70667. */
  70668. constructor(
  70669. /**
  70670. * Task name
  70671. */ name: string);
  70672. private _isCompleted;
  70673. private _taskState;
  70674. private _errorObject;
  70675. /**
  70676. * Get if the task is completed
  70677. */
  70678. get isCompleted(): boolean;
  70679. /**
  70680. * Gets the current state of the task
  70681. */
  70682. get taskState(): AssetTaskState;
  70683. /**
  70684. * Gets the current error object (if task is in error)
  70685. */
  70686. get errorObject(): {
  70687. message?: string;
  70688. exception?: any;
  70689. };
  70690. /**
  70691. * Internal only
  70692. * @hidden
  70693. */
  70694. _setErrorObject(message?: string, exception?: any): void;
  70695. /**
  70696. * Execute the current task
  70697. * @param scene defines the scene where you want your assets to be loaded
  70698. * @param onSuccess is a callback called when the task is successfully executed
  70699. * @param onError is a callback called if an error occurs
  70700. */
  70701. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70702. /**
  70703. * Execute the current task
  70704. * @param scene defines the scene where you want your assets to be loaded
  70705. * @param onSuccess is a callback called when the task is successfully executed
  70706. * @param onError is a callback called if an error occurs
  70707. */
  70708. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70709. /**
  70710. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  70711. * This can be used with failed tasks that have the reason for failure fixed.
  70712. */
  70713. reset(): void;
  70714. private onErrorCallback;
  70715. private onDoneCallback;
  70716. }
  70717. /**
  70718. * Define the interface used by progress events raised during assets loading
  70719. */
  70720. export interface IAssetsProgressEvent {
  70721. /**
  70722. * Defines the number of remaining tasks to process
  70723. */
  70724. remainingCount: number;
  70725. /**
  70726. * Defines the total number of tasks
  70727. */
  70728. totalCount: number;
  70729. /**
  70730. * Defines the task that was just processed
  70731. */
  70732. task: AbstractAssetTask;
  70733. }
  70734. /**
  70735. * Class used to share progress information about assets loading
  70736. */
  70737. export class AssetsProgressEvent implements IAssetsProgressEvent {
  70738. /**
  70739. * Defines the number of remaining tasks to process
  70740. */
  70741. remainingCount: number;
  70742. /**
  70743. * Defines the total number of tasks
  70744. */
  70745. totalCount: number;
  70746. /**
  70747. * Defines the task that was just processed
  70748. */
  70749. task: AbstractAssetTask;
  70750. /**
  70751. * Creates a AssetsProgressEvent
  70752. * @param remainingCount defines the number of remaining tasks to process
  70753. * @param totalCount defines the total number of tasks
  70754. * @param task defines the task that was just processed
  70755. */
  70756. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  70757. }
  70758. /**
  70759. * Define a task used by AssetsManager to load meshes
  70760. */
  70761. export class MeshAssetTask extends AbstractAssetTask {
  70762. /**
  70763. * Defines the name of the task
  70764. */
  70765. name: string;
  70766. /**
  70767. * Defines the list of mesh's names you want to load
  70768. */
  70769. meshesNames: any;
  70770. /**
  70771. * Defines the root url to use as a base to load your meshes and associated resources
  70772. */
  70773. rootUrl: string;
  70774. /**
  70775. * Defines the filename of the scene to load from
  70776. */
  70777. sceneFilename: string;
  70778. /**
  70779. * Gets the list of loaded meshes
  70780. */
  70781. loadedMeshes: Array<AbstractMesh>;
  70782. /**
  70783. * Gets the list of loaded particle systems
  70784. */
  70785. loadedParticleSystems: Array<IParticleSystem>;
  70786. /**
  70787. * Gets the list of loaded skeletons
  70788. */
  70789. loadedSkeletons: Array<Skeleton>;
  70790. /**
  70791. * Gets the list of loaded animation groups
  70792. */
  70793. loadedAnimationGroups: Array<AnimationGroup>;
  70794. /**
  70795. * Callback called when the task is successful
  70796. */
  70797. onSuccess: (task: MeshAssetTask) => void;
  70798. /**
  70799. * Callback called when the task is successful
  70800. */
  70801. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  70802. /**
  70803. * Creates a new MeshAssetTask
  70804. * @param name defines the name of the task
  70805. * @param meshesNames defines the list of mesh's names you want to load
  70806. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  70807. * @param sceneFilename defines the filename of the scene to load from
  70808. */
  70809. constructor(
  70810. /**
  70811. * Defines the name of the task
  70812. */
  70813. name: string,
  70814. /**
  70815. * Defines the list of mesh's names you want to load
  70816. */
  70817. meshesNames: any,
  70818. /**
  70819. * Defines the root url to use as a base to load your meshes and associated resources
  70820. */
  70821. rootUrl: string,
  70822. /**
  70823. * Defines the filename of the scene to load from
  70824. */
  70825. sceneFilename: string);
  70826. /**
  70827. * Execute the current task
  70828. * @param scene defines the scene where you want your assets to be loaded
  70829. * @param onSuccess is a callback called when the task is successfully executed
  70830. * @param onError is a callback called if an error occurs
  70831. */
  70832. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70833. }
  70834. /**
  70835. * Define a task used by AssetsManager to load text content
  70836. */
  70837. export class TextFileAssetTask extends AbstractAssetTask {
  70838. /**
  70839. * Defines the name of the task
  70840. */
  70841. name: string;
  70842. /**
  70843. * Defines the location of the file to load
  70844. */
  70845. url: string;
  70846. /**
  70847. * Gets the loaded text string
  70848. */
  70849. text: string;
  70850. /**
  70851. * Callback called when the task is successful
  70852. */
  70853. onSuccess: (task: TextFileAssetTask) => void;
  70854. /**
  70855. * Callback called when the task is successful
  70856. */
  70857. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  70858. /**
  70859. * Creates a new TextFileAssetTask object
  70860. * @param name defines the name of the task
  70861. * @param url defines the location of the file to load
  70862. */
  70863. constructor(
  70864. /**
  70865. * Defines the name of the task
  70866. */
  70867. name: string,
  70868. /**
  70869. * Defines the location of the file to load
  70870. */
  70871. url: string);
  70872. /**
  70873. * Execute the current task
  70874. * @param scene defines the scene where you want your assets to be loaded
  70875. * @param onSuccess is a callback called when the task is successfully executed
  70876. * @param onError is a callback called if an error occurs
  70877. */
  70878. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70879. }
  70880. /**
  70881. * Define a task used by AssetsManager to load binary data
  70882. */
  70883. export class BinaryFileAssetTask extends AbstractAssetTask {
  70884. /**
  70885. * Defines the name of the task
  70886. */
  70887. name: string;
  70888. /**
  70889. * Defines the location of the file to load
  70890. */
  70891. url: string;
  70892. /**
  70893. * Gets the lodaded data (as an array buffer)
  70894. */
  70895. data: ArrayBuffer;
  70896. /**
  70897. * Callback called when the task is successful
  70898. */
  70899. onSuccess: (task: BinaryFileAssetTask) => void;
  70900. /**
  70901. * Callback called when the task is successful
  70902. */
  70903. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  70904. /**
  70905. * Creates a new BinaryFileAssetTask object
  70906. * @param name defines the name of the new task
  70907. * @param url defines the location of the file to load
  70908. */
  70909. constructor(
  70910. /**
  70911. * Defines the name of the task
  70912. */
  70913. name: string,
  70914. /**
  70915. * Defines the location of the file to load
  70916. */
  70917. url: string);
  70918. /**
  70919. * Execute the current task
  70920. * @param scene defines the scene where you want your assets to be loaded
  70921. * @param onSuccess is a callback called when the task is successfully executed
  70922. * @param onError is a callback called if an error occurs
  70923. */
  70924. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70925. }
  70926. /**
  70927. * Define a task used by AssetsManager to load images
  70928. */
  70929. export class ImageAssetTask extends AbstractAssetTask {
  70930. /**
  70931. * Defines the name of the task
  70932. */
  70933. name: string;
  70934. /**
  70935. * Defines the location of the image to load
  70936. */
  70937. url: string;
  70938. /**
  70939. * Gets the loaded images
  70940. */
  70941. image: HTMLImageElement;
  70942. /**
  70943. * Callback called when the task is successful
  70944. */
  70945. onSuccess: (task: ImageAssetTask) => void;
  70946. /**
  70947. * Callback called when the task is successful
  70948. */
  70949. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  70950. /**
  70951. * Creates a new ImageAssetTask
  70952. * @param name defines the name of the task
  70953. * @param url defines the location of the image to load
  70954. */
  70955. constructor(
  70956. /**
  70957. * Defines the name of the task
  70958. */
  70959. name: string,
  70960. /**
  70961. * Defines the location of the image to load
  70962. */
  70963. url: string);
  70964. /**
  70965. * Execute the current task
  70966. * @param scene defines the scene where you want your assets to be loaded
  70967. * @param onSuccess is a callback called when the task is successfully executed
  70968. * @param onError is a callback called if an error occurs
  70969. */
  70970. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70971. }
  70972. /**
  70973. * Defines the interface used by texture loading tasks
  70974. */
  70975. export interface ITextureAssetTask<TEX extends BaseTexture> {
  70976. /**
  70977. * Gets the loaded texture
  70978. */
  70979. texture: TEX;
  70980. }
  70981. /**
  70982. * Define a task used by AssetsManager to load 2D textures
  70983. */
  70984. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  70985. /**
  70986. * Defines the name of the task
  70987. */
  70988. name: string;
  70989. /**
  70990. * Defines the location of the file to load
  70991. */
  70992. url: string;
  70993. /**
  70994. * Defines if mipmap should not be generated (default is false)
  70995. */
  70996. noMipmap?: boolean | undefined;
  70997. /**
  70998. * Defines if texture must be inverted on Y axis (default is false)
  70999. */
  71000. invertY?: boolean | undefined;
  71001. /**
  71002. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71003. */
  71004. samplingMode: number;
  71005. /**
  71006. * Gets the loaded texture
  71007. */
  71008. texture: Texture;
  71009. /**
  71010. * Callback called when the task is successful
  71011. */
  71012. onSuccess: (task: TextureAssetTask) => void;
  71013. /**
  71014. * Callback called when the task is successful
  71015. */
  71016. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  71017. /**
  71018. * Creates a new TextureAssetTask object
  71019. * @param name defines the name of the task
  71020. * @param url defines the location of the file to load
  71021. * @param noMipmap defines if mipmap should not be generated (default is false)
  71022. * @param invertY defines if texture must be inverted on Y axis (default is false)
  71023. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71024. */
  71025. constructor(
  71026. /**
  71027. * Defines the name of the task
  71028. */
  71029. name: string,
  71030. /**
  71031. * Defines the location of the file to load
  71032. */
  71033. url: string,
  71034. /**
  71035. * Defines if mipmap should not be generated (default is false)
  71036. */
  71037. noMipmap?: boolean | undefined,
  71038. /**
  71039. * Defines if texture must be inverted on Y axis (default is false)
  71040. */
  71041. invertY?: boolean | undefined,
  71042. /**
  71043. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71044. */
  71045. samplingMode?: number);
  71046. /**
  71047. * Execute the current task
  71048. * @param scene defines the scene where you want your assets to be loaded
  71049. * @param onSuccess is a callback called when the task is successfully executed
  71050. * @param onError is a callback called if an error occurs
  71051. */
  71052. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71053. }
  71054. /**
  71055. * Define a task used by AssetsManager to load cube textures
  71056. */
  71057. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  71058. /**
  71059. * Defines the name of the task
  71060. */
  71061. name: string;
  71062. /**
  71063. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71064. */
  71065. url: string;
  71066. /**
  71067. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71068. */
  71069. extensions?: string[] | undefined;
  71070. /**
  71071. * Defines if mipmaps should not be generated (default is false)
  71072. */
  71073. noMipmap?: boolean | undefined;
  71074. /**
  71075. * Defines the explicit list of files (undefined by default)
  71076. */
  71077. files?: string[] | undefined;
  71078. /**
  71079. * Gets the loaded texture
  71080. */
  71081. texture: CubeTexture;
  71082. /**
  71083. * Callback called when the task is successful
  71084. */
  71085. onSuccess: (task: CubeTextureAssetTask) => void;
  71086. /**
  71087. * Callback called when the task is successful
  71088. */
  71089. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  71090. /**
  71091. * Creates a new CubeTextureAssetTask
  71092. * @param name defines the name of the task
  71093. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71094. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71095. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71096. * @param files defines the explicit list of files (undefined by default)
  71097. */
  71098. constructor(
  71099. /**
  71100. * Defines the name of the task
  71101. */
  71102. name: string,
  71103. /**
  71104. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71105. */
  71106. url: string,
  71107. /**
  71108. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71109. */
  71110. extensions?: string[] | undefined,
  71111. /**
  71112. * Defines if mipmaps should not be generated (default is false)
  71113. */
  71114. noMipmap?: boolean | undefined,
  71115. /**
  71116. * Defines the explicit list of files (undefined by default)
  71117. */
  71118. files?: string[] | undefined);
  71119. /**
  71120. * Execute the current task
  71121. * @param scene defines the scene where you want your assets to be loaded
  71122. * @param onSuccess is a callback called when the task is successfully executed
  71123. * @param onError is a callback called if an error occurs
  71124. */
  71125. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71126. }
  71127. /**
  71128. * Define a task used by AssetsManager to load HDR cube textures
  71129. */
  71130. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  71131. /**
  71132. * Defines the name of the task
  71133. */
  71134. name: string;
  71135. /**
  71136. * Defines the location of the file to load
  71137. */
  71138. url: string;
  71139. /**
  71140. * Defines the desired size (the more it increases the longer the generation will be)
  71141. */
  71142. size: number;
  71143. /**
  71144. * Defines if mipmaps should not be generated (default is false)
  71145. */
  71146. noMipmap: boolean;
  71147. /**
  71148. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71149. */
  71150. generateHarmonics: boolean;
  71151. /**
  71152. * 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)
  71153. */
  71154. gammaSpace: boolean;
  71155. /**
  71156. * Internal Use Only
  71157. */
  71158. reserved: boolean;
  71159. /**
  71160. * Gets the loaded texture
  71161. */
  71162. texture: HDRCubeTexture;
  71163. /**
  71164. * Callback called when the task is successful
  71165. */
  71166. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  71167. /**
  71168. * Callback called when the task is successful
  71169. */
  71170. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  71171. /**
  71172. * Creates a new HDRCubeTextureAssetTask object
  71173. * @param name defines the name of the task
  71174. * @param url defines the location of the file to load
  71175. * @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.
  71176. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71177. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71178. * @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)
  71179. * @param reserved Internal use only
  71180. */
  71181. constructor(
  71182. /**
  71183. * Defines the name of the task
  71184. */
  71185. name: string,
  71186. /**
  71187. * Defines the location of the file to load
  71188. */
  71189. url: string,
  71190. /**
  71191. * Defines the desired size (the more it increases the longer the generation will be)
  71192. */
  71193. size: number,
  71194. /**
  71195. * Defines if mipmaps should not be generated (default is false)
  71196. */
  71197. noMipmap?: boolean,
  71198. /**
  71199. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71200. */
  71201. generateHarmonics?: boolean,
  71202. /**
  71203. * 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)
  71204. */
  71205. gammaSpace?: boolean,
  71206. /**
  71207. * Internal Use Only
  71208. */
  71209. reserved?: boolean);
  71210. /**
  71211. * Execute the current task
  71212. * @param scene defines the scene where you want your assets to be loaded
  71213. * @param onSuccess is a callback called when the task is successfully executed
  71214. * @param onError is a callback called if an error occurs
  71215. */
  71216. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71217. }
  71218. /**
  71219. * Define a task used by AssetsManager to load Equirectangular cube textures
  71220. */
  71221. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  71222. /**
  71223. * Defines the name of the task
  71224. */
  71225. name: string;
  71226. /**
  71227. * Defines the location of the file to load
  71228. */
  71229. url: string;
  71230. /**
  71231. * Defines the desired size (the more it increases the longer the generation will be)
  71232. */
  71233. size: number;
  71234. /**
  71235. * Defines if mipmaps should not be generated (default is false)
  71236. */
  71237. noMipmap: boolean;
  71238. /**
  71239. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71240. * but the standard material would require them in Gamma space) (default is true)
  71241. */
  71242. gammaSpace: boolean;
  71243. /**
  71244. * Gets the loaded texture
  71245. */
  71246. texture: EquiRectangularCubeTexture;
  71247. /**
  71248. * Callback called when the task is successful
  71249. */
  71250. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  71251. /**
  71252. * Callback called when the task is successful
  71253. */
  71254. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  71255. /**
  71256. * Creates a new EquiRectangularCubeTextureAssetTask object
  71257. * @param name defines the name of the task
  71258. * @param url defines the location of the file to load
  71259. * @param size defines the desired size (the more it increases the longer the generation will be)
  71260. * If the size is omitted this implies you are using a preprocessed cubemap.
  71261. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71262. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  71263. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  71264. * (default is true)
  71265. */
  71266. constructor(
  71267. /**
  71268. * Defines the name of the task
  71269. */
  71270. name: string,
  71271. /**
  71272. * Defines the location of the file to load
  71273. */
  71274. url: string,
  71275. /**
  71276. * Defines the desired size (the more it increases the longer the generation will be)
  71277. */
  71278. size: number,
  71279. /**
  71280. * Defines if mipmaps should not be generated (default is false)
  71281. */
  71282. noMipmap?: boolean,
  71283. /**
  71284. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71285. * but the standard material would require them in Gamma space) (default is true)
  71286. */
  71287. gammaSpace?: boolean);
  71288. /**
  71289. * Execute the current task
  71290. * @param scene defines the scene where you want your assets to be loaded
  71291. * @param onSuccess is a callback called when the task is successfully executed
  71292. * @param onError is a callback called if an error occurs
  71293. */
  71294. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71295. }
  71296. /**
  71297. * This class can be used to easily import assets into a scene
  71298. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  71299. */
  71300. export class AssetsManager {
  71301. private _scene;
  71302. private _isLoading;
  71303. protected _tasks: AbstractAssetTask[];
  71304. protected _waitingTasksCount: number;
  71305. protected _totalTasksCount: number;
  71306. /**
  71307. * Callback called when all tasks are processed
  71308. */
  71309. onFinish: (tasks: AbstractAssetTask[]) => void;
  71310. /**
  71311. * Callback called when a task is successful
  71312. */
  71313. onTaskSuccess: (task: AbstractAssetTask) => void;
  71314. /**
  71315. * Callback called when a task had an error
  71316. */
  71317. onTaskError: (task: AbstractAssetTask) => void;
  71318. /**
  71319. * Callback called when a task is done (whatever the result is)
  71320. */
  71321. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  71322. /**
  71323. * Observable called when all tasks are processed
  71324. */
  71325. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  71326. /**
  71327. * Observable called when a task had an error
  71328. */
  71329. onTaskErrorObservable: Observable<AbstractAssetTask>;
  71330. /**
  71331. * Observable called when all tasks were executed
  71332. */
  71333. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  71334. /**
  71335. * Observable called when a task is done (whatever the result is)
  71336. */
  71337. onProgressObservable: Observable<IAssetsProgressEvent>;
  71338. /**
  71339. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  71340. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  71341. */
  71342. useDefaultLoadingScreen: boolean;
  71343. /**
  71344. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  71345. * when all assets have been downloaded.
  71346. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  71347. */
  71348. autoHideLoadingUI: boolean;
  71349. /**
  71350. * Creates a new AssetsManager
  71351. * @param scene defines the scene to work on
  71352. */
  71353. constructor(scene: Scene);
  71354. /**
  71355. * Add a MeshAssetTask to the list of active tasks
  71356. * @param taskName defines the name of the new task
  71357. * @param meshesNames defines the name of meshes to load
  71358. * @param rootUrl defines the root url to use to locate files
  71359. * @param sceneFilename defines the filename of the scene file
  71360. * @returns a new MeshAssetTask object
  71361. */
  71362. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  71363. /**
  71364. * Add a TextFileAssetTask to the list of active tasks
  71365. * @param taskName defines the name of the new task
  71366. * @param url defines the url of the file to load
  71367. * @returns a new TextFileAssetTask object
  71368. */
  71369. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  71370. /**
  71371. * Add a BinaryFileAssetTask to the list of active tasks
  71372. * @param taskName defines the name of the new task
  71373. * @param url defines the url of the file to load
  71374. * @returns a new BinaryFileAssetTask object
  71375. */
  71376. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  71377. /**
  71378. * Add a ImageAssetTask to the list of active tasks
  71379. * @param taskName defines the name of the new task
  71380. * @param url defines the url of the file to load
  71381. * @returns a new ImageAssetTask object
  71382. */
  71383. addImageTask(taskName: string, url: string): ImageAssetTask;
  71384. /**
  71385. * Add a TextureAssetTask to the list of active tasks
  71386. * @param taskName defines the name of the new task
  71387. * @param url defines the url of the file to load
  71388. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71389. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  71390. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  71391. * @returns a new TextureAssetTask object
  71392. */
  71393. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  71394. /**
  71395. * Add a CubeTextureAssetTask to the list of active tasks
  71396. * @param taskName defines the name of the new task
  71397. * @param url defines the url of the file to load
  71398. * @param extensions defines the extension to use to load the cube map (can be null)
  71399. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71400. * @param files defines the list of files to load (can be null)
  71401. * @returns a new CubeTextureAssetTask object
  71402. */
  71403. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  71404. /**
  71405. *
  71406. * Add a HDRCubeTextureAssetTask to the list of active tasks
  71407. * @param taskName defines the name of the new task
  71408. * @param url defines the url of the file to load
  71409. * @param size defines the size you want for the cubemap (can be null)
  71410. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71411. * @param generateHarmonics defines if you want to automatically generate (true by default)
  71412. * @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)
  71413. * @param reserved Internal use only
  71414. * @returns a new HDRCubeTextureAssetTask object
  71415. */
  71416. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  71417. /**
  71418. *
  71419. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  71420. * @param taskName defines the name of the new task
  71421. * @param url defines the url of the file to load
  71422. * @param size defines the size you want for the cubemap (can be null)
  71423. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71424. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  71425. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  71426. * @returns a new EquiRectangularCubeTextureAssetTask object
  71427. */
  71428. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  71429. /**
  71430. * Remove a task from the assets manager.
  71431. * @param task the task to remove
  71432. */
  71433. removeTask(task: AbstractAssetTask): void;
  71434. private _decreaseWaitingTasksCount;
  71435. private _runTask;
  71436. /**
  71437. * Reset the AssetsManager and remove all tasks
  71438. * @return the current instance of the AssetsManager
  71439. */
  71440. reset(): AssetsManager;
  71441. /**
  71442. * Start the loading process
  71443. * @return the current instance of the AssetsManager
  71444. */
  71445. load(): AssetsManager;
  71446. /**
  71447. * Start the loading process as an async operation
  71448. * @return a promise returning the list of failed tasks
  71449. */
  71450. loadAsync(): Promise<void>;
  71451. }
  71452. }
  71453. declare module "babylonjs/Misc/deferred" {
  71454. /**
  71455. * Wrapper class for promise with external resolve and reject.
  71456. */
  71457. export class Deferred<T> {
  71458. /**
  71459. * The promise associated with this deferred object.
  71460. */
  71461. readonly promise: Promise<T>;
  71462. private _resolve;
  71463. private _reject;
  71464. /**
  71465. * The resolve method of the promise associated with this deferred object.
  71466. */
  71467. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  71468. /**
  71469. * The reject method of the promise associated with this deferred object.
  71470. */
  71471. get reject(): (reason?: any) => void;
  71472. /**
  71473. * Constructor for this deferred object.
  71474. */
  71475. constructor();
  71476. }
  71477. }
  71478. declare module "babylonjs/Misc/meshExploder" {
  71479. import { Mesh } from "babylonjs/Meshes/mesh";
  71480. /**
  71481. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  71482. */
  71483. export class MeshExploder {
  71484. private _centerMesh;
  71485. private _meshes;
  71486. private _meshesOrigins;
  71487. private _toCenterVectors;
  71488. private _scaledDirection;
  71489. private _newPosition;
  71490. private _centerPosition;
  71491. /**
  71492. * Explodes meshes from a center mesh.
  71493. * @param meshes The meshes to explode.
  71494. * @param centerMesh The mesh to be center of explosion.
  71495. */
  71496. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  71497. private _setCenterMesh;
  71498. /**
  71499. * Get class name
  71500. * @returns "MeshExploder"
  71501. */
  71502. getClassName(): string;
  71503. /**
  71504. * "Exploded meshes"
  71505. * @returns Array of meshes with the centerMesh at index 0.
  71506. */
  71507. getMeshes(): Array<Mesh>;
  71508. /**
  71509. * Explodes meshes giving a specific direction
  71510. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  71511. */
  71512. explode(direction?: number): void;
  71513. }
  71514. }
  71515. declare module "babylonjs/Misc/filesInput" {
  71516. import { Engine } from "babylonjs/Engines/engine";
  71517. import { Scene } from "babylonjs/scene";
  71518. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  71519. /**
  71520. * Class used to help managing file picking and drag'n'drop
  71521. */
  71522. export class FilesInput {
  71523. /**
  71524. * List of files ready to be loaded
  71525. */
  71526. static get FilesToLoad(): {
  71527. [key: string]: File;
  71528. };
  71529. /**
  71530. * Callback called when a file is processed
  71531. */
  71532. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  71533. private _engine;
  71534. private _currentScene;
  71535. private _sceneLoadedCallback;
  71536. private _progressCallback;
  71537. private _additionalRenderLoopLogicCallback;
  71538. private _textureLoadingCallback;
  71539. private _startingProcessingFilesCallback;
  71540. private _onReloadCallback;
  71541. private _errorCallback;
  71542. private _elementToMonitor;
  71543. private _sceneFileToLoad;
  71544. private _filesToLoad;
  71545. /**
  71546. * Creates a new FilesInput
  71547. * @param engine defines the rendering engine
  71548. * @param scene defines the hosting scene
  71549. * @param sceneLoadedCallback callback called when scene is loaded
  71550. * @param progressCallback callback called to track progress
  71551. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  71552. * @param textureLoadingCallback callback called when a texture is loading
  71553. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  71554. * @param onReloadCallback callback called when a reload is requested
  71555. * @param errorCallback callback call if an error occurs
  71556. */
  71557. 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);
  71558. private _dragEnterHandler;
  71559. private _dragOverHandler;
  71560. private _dropHandler;
  71561. /**
  71562. * Calls this function to listen to drag'n'drop events on a specific DOM element
  71563. * @param elementToMonitor defines the DOM element to track
  71564. */
  71565. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  71566. /**
  71567. * Release all associated resources
  71568. */
  71569. dispose(): void;
  71570. private renderFunction;
  71571. private drag;
  71572. private drop;
  71573. private _traverseFolder;
  71574. private _processFiles;
  71575. /**
  71576. * Load files from a drop event
  71577. * @param event defines the drop event to use as source
  71578. */
  71579. loadFiles(event: any): void;
  71580. private _processReload;
  71581. /**
  71582. * Reload the current scene from the loaded files
  71583. */
  71584. reload(): void;
  71585. }
  71586. }
  71587. declare module "babylonjs/Misc/HighDynamicRange/index" {
  71588. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  71589. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  71590. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  71591. }
  71592. declare module "babylonjs/Misc/sceneOptimizer" {
  71593. import { Scene, IDisposable } from "babylonjs/scene";
  71594. import { Observable } from "babylonjs/Misc/observable";
  71595. /**
  71596. * Defines the root class used to create scene optimization to use with SceneOptimizer
  71597. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71598. */
  71599. export class SceneOptimization {
  71600. /**
  71601. * Defines the priority of this optimization (0 by default which means first in the list)
  71602. */
  71603. priority: number;
  71604. /**
  71605. * Gets a string describing the action executed by the current optimization
  71606. * @returns description string
  71607. */
  71608. getDescription(): string;
  71609. /**
  71610. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71611. * @param scene defines the current scene where to apply this optimization
  71612. * @param optimizer defines the current optimizer
  71613. * @returns true if everything that can be done was applied
  71614. */
  71615. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71616. /**
  71617. * Creates the SceneOptimization object
  71618. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71619. * @param desc defines the description associated with the optimization
  71620. */
  71621. constructor(
  71622. /**
  71623. * Defines the priority of this optimization (0 by default which means first in the list)
  71624. */
  71625. priority?: number);
  71626. }
  71627. /**
  71628. * Defines an optimization used to reduce the size of render target textures
  71629. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71630. */
  71631. export class TextureOptimization extends SceneOptimization {
  71632. /**
  71633. * Defines the priority of this optimization (0 by default which means first in the list)
  71634. */
  71635. priority: number;
  71636. /**
  71637. * Defines the maximum 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
  71638. */
  71639. maximumSize: number;
  71640. /**
  71641. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71642. */
  71643. step: number;
  71644. /**
  71645. * Gets a string describing the action executed by the current optimization
  71646. * @returns description string
  71647. */
  71648. getDescription(): string;
  71649. /**
  71650. * Creates the TextureOptimization object
  71651. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71652. * @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
  71653. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71654. */
  71655. constructor(
  71656. /**
  71657. * Defines the priority of this optimization (0 by default which means first in the list)
  71658. */
  71659. priority?: number,
  71660. /**
  71661. * 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
  71662. */
  71663. maximumSize?: number,
  71664. /**
  71665. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71666. */
  71667. step?: number);
  71668. /**
  71669. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71670. * @param scene defines the current scene where to apply this optimization
  71671. * @param optimizer defines the current optimizer
  71672. * @returns true if everything that can be done was applied
  71673. */
  71674. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71675. }
  71676. /**
  71677. * Defines an optimization used to increase or decrease the rendering resolution
  71678. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71679. */
  71680. export class HardwareScalingOptimization extends SceneOptimization {
  71681. /**
  71682. * Defines the priority of this optimization (0 by default which means first in the list)
  71683. */
  71684. priority: number;
  71685. /**
  71686. * Defines the maximum scale to use (2 by default)
  71687. */
  71688. maximumScale: number;
  71689. /**
  71690. * Defines the step to use between two passes (0.5 by default)
  71691. */
  71692. step: number;
  71693. private _currentScale;
  71694. private _directionOffset;
  71695. /**
  71696. * Gets a string describing the action executed by the current optimization
  71697. * @return description string
  71698. */
  71699. getDescription(): string;
  71700. /**
  71701. * Creates the HardwareScalingOptimization object
  71702. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71703. * @param maximumScale defines the maximum scale to use (2 by default)
  71704. * @param step defines the step to use between two passes (0.5 by default)
  71705. */
  71706. constructor(
  71707. /**
  71708. * Defines the priority of this optimization (0 by default which means first in the list)
  71709. */
  71710. priority?: number,
  71711. /**
  71712. * Defines the maximum scale to use (2 by default)
  71713. */
  71714. maximumScale?: number,
  71715. /**
  71716. * Defines the step to use between two passes (0.5 by default)
  71717. */
  71718. step?: number);
  71719. /**
  71720. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71721. * @param scene defines the current scene where to apply this optimization
  71722. * @param optimizer defines the current optimizer
  71723. * @returns true if everything that can be done was applied
  71724. */
  71725. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71726. }
  71727. /**
  71728. * Defines an optimization used to remove shadows
  71729. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71730. */
  71731. export class ShadowsOptimization extends SceneOptimization {
  71732. /**
  71733. * Gets a string describing the action executed by the current optimization
  71734. * @return description string
  71735. */
  71736. getDescription(): string;
  71737. /**
  71738. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71739. * @param scene defines the current scene where to apply this optimization
  71740. * @param optimizer defines the current optimizer
  71741. * @returns true if everything that can be done was applied
  71742. */
  71743. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71744. }
  71745. /**
  71746. * Defines an optimization used to turn post-processes off
  71747. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71748. */
  71749. export class PostProcessesOptimization extends SceneOptimization {
  71750. /**
  71751. * Gets a string describing the action executed by the current optimization
  71752. * @return description string
  71753. */
  71754. getDescription(): string;
  71755. /**
  71756. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71757. * @param scene defines the current scene where to apply this optimization
  71758. * @param optimizer defines the current optimizer
  71759. * @returns true if everything that can be done was applied
  71760. */
  71761. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71762. }
  71763. /**
  71764. * Defines an optimization used to turn lens flares off
  71765. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71766. */
  71767. export class LensFlaresOptimization extends SceneOptimization {
  71768. /**
  71769. * Gets a string describing the action executed by the current optimization
  71770. * @return description string
  71771. */
  71772. getDescription(): string;
  71773. /**
  71774. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71775. * @param scene defines the current scene where to apply this optimization
  71776. * @param optimizer defines the current optimizer
  71777. * @returns true if everything that can be done was applied
  71778. */
  71779. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71780. }
  71781. /**
  71782. * Defines an optimization based on user defined callback.
  71783. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71784. */
  71785. export class CustomOptimization extends SceneOptimization {
  71786. /**
  71787. * Callback called to apply the custom optimization.
  71788. */
  71789. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  71790. /**
  71791. * Callback called to get custom description
  71792. */
  71793. onGetDescription: () => string;
  71794. /**
  71795. * Gets a string describing the action executed by the current optimization
  71796. * @returns description string
  71797. */
  71798. getDescription(): string;
  71799. /**
  71800. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71801. * @param scene defines the current scene where to apply this optimization
  71802. * @param optimizer defines the current optimizer
  71803. * @returns true if everything that can be done was applied
  71804. */
  71805. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71806. }
  71807. /**
  71808. * Defines an optimization used to turn particles off
  71809. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71810. */
  71811. export class ParticlesOptimization extends SceneOptimization {
  71812. /**
  71813. * Gets a string describing the action executed by the current optimization
  71814. * @return description string
  71815. */
  71816. getDescription(): string;
  71817. /**
  71818. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71819. * @param scene defines the current scene where to apply this optimization
  71820. * @param optimizer defines the current optimizer
  71821. * @returns true if everything that can be done was applied
  71822. */
  71823. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71824. }
  71825. /**
  71826. * Defines an optimization used to turn render targets off
  71827. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71828. */
  71829. export class RenderTargetsOptimization extends SceneOptimization {
  71830. /**
  71831. * Gets a string describing the action executed by the current optimization
  71832. * @return description string
  71833. */
  71834. getDescription(): string;
  71835. /**
  71836. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71837. * @param scene defines the current scene where to apply this optimization
  71838. * @param optimizer defines the current optimizer
  71839. * @returns true if everything that can be done was applied
  71840. */
  71841. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71842. }
  71843. /**
  71844. * Defines an optimization used to merge meshes with compatible materials
  71845. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71846. */
  71847. export class MergeMeshesOptimization extends SceneOptimization {
  71848. private static _UpdateSelectionTree;
  71849. /**
  71850. * Gets or sets a boolean which defines if optimization octree has to be updated
  71851. */
  71852. static get UpdateSelectionTree(): boolean;
  71853. /**
  71854. * Gets or sets a boolean which defines if optimization octree has to be updated
  71855. */
  71856. static set UpdateSelectionTree(value: boolean);
  71857. /**
  71858. * Gets a string describing the action executed by the current optimization
  71859. * @return description string
  71860. */
  71861. getDescription(): string;
  71862. private _canBeMerged;
  71863. /**
  71864. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71865. * @param scene defines the current scene where to apply this optimization
  71866. * @param optimizer defines the current optimizer
  71867. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  71868. * @returns true if everything that can be done was applied
  71869. */
  71870. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  71871. }
  71872. /**
  71873. * Defines a list of options used by SceneOptimizer
  71874. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71875. */
  71876. export class SceneOptimizerOptions {
  71877. /**
  71878. * Defines the target frame rate to reach (60 by default)
  71879. */
  71880. targetFrameRate: number;
  71881. /**
  71882. * Defines the interval between two checkes (2000ms by default)
  71883. */
  71884. trackerDuration: number;
  71885. /**
  71886. * Gets the list of optimizations to apply
  71887. */
  71888. optimizations: SceneOptimization[];
  71889. /**
  71890. * Creates a new list of options used by SceneOptimizer
  71891. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  71892. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  71893. */
  71894. constructor(
  71895. /**
  71896. * Defines the target frame rate to reach (60 by default)
  71897. */
  71898. targetFrameRate?: number,
  71899. /**
  71900. * Defines the interval between two checkes (2000ms by default)
  71901. */
  71902. trackerDuration?: number);
  71903. /**
  71904. * Add a new optimization
  71905. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  71906. * @returns the current SceneOptimizerOptions
  71907. */
  71908. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  71909. /**
  71910. * Add a new custom optimization
  71911. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  71912. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  71913. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71914. * @returns the current SceneOptimizerOptions
  71915. */
  71916. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  71917. /**
  71918. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  71919. * @param targetFrameRate defines the target frame rate (60 by default)
  71920. * @returns a SceneOptimizerOptions object
  71921. */
  71922. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71923. /**
  71924. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  71925. * @param targetFrameRate defines the target frame rate (60 by default)
  71926. * @returns a SceneOptimizerOptions object
  71927. */
  71928. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71929. /**
  71930. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  71931. * @param targetFrameRate defines the target frame rate (60 by default)
  71932. * @returns a SceneOptimizerOptions object
  71933. */
  71934. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71935. }
  71936. /**
  71937. * Class used to run optimizations in order to reach a target frame rate
  71938. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71939. */
  71940. export class SceneOptimizer implements IDisposable {
  71941. private _isRunning;
  71942. private _options;
  71943. private _scene;
  71944. private _currentPriorityLevel;
  71945. private _targetFrameRate;
  71946. private _trackerDuration;
  71947. private _currentFrameRate;
  71948. private _sceneDisposeObserver;
  71949. private _improvementMode;
  71950. /**
  71951. * Defines an observable called when the optimizer reaches the target frame rate
  71952. */
  71953. onSuccessObservable: Observable<SceneOptimizer>;
  71954. /**
  71955. * Defines an observable called when the optimizer enables an optimization
  71956. */
  71957. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  71958. /**
  71959. * Defines an observable called when the optimizer is not able to reach the target frame rate
  71960. */
  71961. onFailureObservable: Observable<SceneOptimizer>;
  71962. /**
  71963. * Gets a boolean indicating if the optimizer is in improvement mode
  71964. */
  71965. get isInImprovementMode(): boolean;
  71966. /**
  71967. * Gets the current priority level (0 at start)
  71968. */
  71969. get currentPriorityLevel(): number;
  71970. /**
  71971. * Gets the current frame rate checked by the SceneOptimizer
  71972. */
  71973. get currentFrameRate(): number;
  71974. /**
  71975. * Gets or sets the current target frame rate (60 by default)
  71976. */
  71977. get targetFrameRate(): number;
  71978. /**
  71979. * Gets or sets the current target frame rate (60 by default)
  71980. */
  71981. set targetFrameRate(value: number);
  71982. /**
  71983. * Gets or sets the current interval between two checks (every 2000ms by default)
  71984. */
  71985. get trackerDuration(): number;
  71986. /**
  71987. * Gets or sets the current interval between two checks (every 2000ms by default)
  71988. */
  71989. set trackerDuration(value: number);
  71990. /**
  71991. * Gets the list of active optimizations
  71992. */
  71993. get optimizations(): SceneOptimization[];
  71994. /**
  71995. * Creates a new SceneOptimizer
  71996. * @param scene defines the scene to work on
  71997. * @param options defines the options to use with the SceneOptimizer
  71998. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  71999. * @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)
  72000. */
  72001. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  72002. /**
  72003. * Stops the current optimizer
  72004. */
  72005. stop(): void;
  72006. /**
  72007. * Reset the optimizer to initial step (current priority level = 0)
  72008. */
  72009. reset(): void;
  72010. /**
  72011. * Start the optimizer. By default it will try to reach a specific framerate
  72012. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  72013. */
  72014. start(): void;
  72015. private _checkCurrentState;
  72016. /**
  72017. * Release all resources
  72018. */
  72019. dispose(): void;
  72020. /**
  72021. * Helper function to create a SceneOptimizer with one single line of code
  72022. * @param scene defines the scene to work on
  72023. * @param options defines the options to use with the SceneOptimizer
  72024. * @param onSuccess defines a callback to call on success
  72025. * @param onFailure defines a callback to call on failure
  72026. * @returns the new SceneOptimizer object
  72027. */
  72028. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  72029. }
  72030. }
  72031. declare module "babylonjs/Misc/sceneSerializer" {
  72032. import { Scene } from "babylonjs/scene";
  72033. /**
  72034. * Class used to serialize a scene into a string
  72035. */
  72036. export class SceneSerializer {
  72037. /**
  72038. * Clear cache used by a previous serialization
  72039. */
  72040. static ClearCache(): void;
  72041. /**
  72042. * Serialize a scene into a JSON compatible object
  72043. * @param scene defines the scene to serialize
  72044. * @returns a JSON compatible object
  72045. */
  72046. static Serialize(scene: Scene): any;
  72047. /**
  72048. * Serialize a mesh into a JSON compatible object
  72049. * @param toSerialize defines the mesh to serialize
  72050. * @param withParents defines if parents must be serialized as well
  72051. * @param withChildren defines if children must be serialized as well
  72052. * @returns a JSON compatible object
  72053. */
  72054. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  72055. }
  72056. }
  72057. declare module "babylonjs/Misc/textureTools" {
  72058. import { Texture } from "babylonjs/Materials/Textures/texture";
  72059. /**
  72060. * Class used to host texture specific utilities
  72061. */
  72062. export class TextureTools {
  72063. /**
  72064. * Uses the GPU to create a copy texture rescaled at a given size
  72065. * @param texture Texture to copy from
  72066. * @param width defines the desired width
  72067. * @param height defines the desired height
  72068. * @param useBilinearMode defines if bilinear mode has to be used
  72069. * @return the generated texture
  72070. */
  72071. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  72072. }
  72073. }
  72074. declare module "babylonjs/Misc/videoRecorder" {
  72075. import { Nullable } from "babylonjs/types";
  72076. import { Engine } from "babylonjs/Engines/engine";
  72077. /**
  72078. * This represents the different options available for the video capture.
  72079. */
  72080. export interface VideoRecorderOptions {
  72081. /** Defines the mime type of the video. */
  72082. mimeType: string;
  72083. /** Defines the FPS the video should be recorded at. */
  72084. fps: number;
  72085. /** Defines the chunk size for the recording data. */
  72086. recordChunckSize: number;
  72087. /** The audio tracks to attach to the recording. */
  72088. audioTracks?: MediaStreamTrack[];
  72089. }
  72090. /**
  72091. * This can help with recording videos from BabylonJS.
  72092. * This is based on the available WebRTC functionalities of the browser.
  72093. *
  72094. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  72095. */
  72096. export class VideoRecorder {
  72097. private static readonly _defaultOptions;
  72098. /**
  72099. * Returns whether or not the VideoRecorder is available in your browser.
  72100. * @param engine Defines the Babylon Engine.
  72101. * @returns true if supported otherwise false.
  72102. */
  72103. static IsSupported(engine: Engine): boolean;
  72104. private readonly _options;
  72105. private _canvas;
  72106. private _mediaRecorder;
  72107. private _recordedChunks;
  72108. private _fileName;
  72109. private _resolve;
  72110. private _reject;
  72111. /**
  72112. * True when a recording is already in progress.
  72113. */
  72114. get isRecording(): boolean;
  72115. /**
  72116. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  72117. * @param engine Defines the BabylonJS Engine you wish to record.
  72118. * @param options Defines options that can be used to customize the capture.
  72119. */
  72120. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  72121. /**
  72122. * Stops the current recording before the default capture timeout passed in the startRecording function.
  72123. */
  72124. stopRecording(): void;
  72125. /**
  72126. * Starts recording the canvas for a max duration specified in parameters.
  72127. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  72128. * If null no automatic download will start and you can rely on the promise to get the data back.
  72129. * @param maxDuration Defines the maximum recording time in seconds.
  72130. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  72131. * @return A promise callback at the end of the recording with the video data in Blob.
  72132. */
  72133. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  72134. /**
  72135. * Releases internal resources used during the recording.
  72136. */
  72137. dispose(): void;
  72138. private _handleDataAvailable;
  72139. private _handleError;
  72140. private _handleStop;
  72141. }
  72142. }
  72143. declare module "babylonjs/Misc/screenshotTools" {
  72144. import { Camera } from "babylonjs/Cameras/camera";
  72145. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  72146. import { Engine } from "babylonjs/Engines/engine";
  72147. /**
  72148. * Class containing a set of static utilities functions for screenshots
  72149. */
  72150. export class ScreenshotTools {
  72151. /**
  72152. * Captures a screenshot of the current rendering
  72153. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72154. * @param engine defines the rendering engine
  72155. * @param camera defines the source camera
  72156. * @param size This parameter can be set to a single number or to an object with the
  72157. * following (optional) properties: precision, width, height. If a single number is passed,
  72158. * it will be used for both width and height. If an object is passed, the screenshot size
  72159. * will be derived from the parameters. The precision property is a multiplier allowing
  72160. * rendering at a higher or lower resolution
  72161. * @param successCallback defines the callback receives a single parameter which contains the
  72162. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72163. * src parameter of an <img> to display it
  72164. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72165. * Check your browser for supported MIME types
  72166. */
  72167. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  72168. /**
  72169. * Captures a screenshot of the current rendering
  72170. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72171. * @param engine defines the rendering engine
  72172. * @param camera defines the source camera
  72173. * @param size This parameter can be set to a single number or to an object with the
  72174. * following (optional) properties: precision, width, height. If a single number is passed,
  72175. * it will be used for both width and height. If an object is passed, the screenshot size
  72176. * will be derived from the parameters. The precision property is a multiplier allowing
  72177. * rendering at a higher or lower resolution
  72178. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72179. * Check your browser for supported MIME types
  72180. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72181. * to the src parameter of an <img> to display it
  72182. */
  72183. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  72184. /**
  72185. * Generates an image screenshot from the specified camera.
  72186. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72187. * @param engine The engine to use for rendering
  72188. * @param camera The camera to use for rendering
  72189. * @param size This parameter can be set to a single number or to an object with the
  72190. * following (optional) properties: precision, width, height. If a single number is passed,
  72191. * it will be used for both width and height. If an object is passed, the screenshot size
  72192. * will be derived from the parameters. The precision property is a multiplier allowing
  72193. * rendering at a higher or lower resolution
  72194. * @param successCallback The callback receives a single parameter which contains the
  72195. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72196. * src parameter of an <img> to display it
  72197. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72198. * Check your browser for supported MIME types
  72199. * @param samples Texture samples (default: 1)
  72200. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72201. * @param fileName A name for for the downloaded file.
  72202. */
  72203. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  72204. /**
  72205. * Generates an image screenshot from the specified camera.
  72206. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72207. * @param engine The engine to use for rendering
  72208. * @param camera The camera to use for rendering
  72209. * @param size This parameter can be set to a single number or to an object with the
  72210. * following (optional) properties: precision, width, height. If a single number is passed,
  72211. * it will be used for both width and height. If an object is passed, the screenshot size
  72212. * will be derived from the parameters. The precision property is a multiplier allowing
  72213. * rendering at a higher or lower resolution
  72214. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72215. * Check your browser for supported MIME types
  72216. * @param samples Texture samples (default: 1)
  72217. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72218. * @param fileName A name for for the downloaded file.
  72219. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72220. * to the src parameter of an <img> to display it
  72221. */
  72222. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  72223. /**
  72224. * Gets height and width for screenshot size
  72225. * @private
  72226. */
  72227. private static _getScreenshotSize;
  72228. }
  72229. }
  72230. declare module "babylonjs/Misc/dataReader" {
  72231. /**
  72232. * Interface for a data buffer
  72233. */
  72234. export interface IDataBuffer {
  72235. /**
  72236. * Reads bytes from the data buffer.
  72237. * @param byteOffset The byte offset to read
  72238. * @param byteLength The byte length to read
  72239. * @returns A promise that resolves when the bytes are read
  72240. */
  72241. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  72242. /**
  72243. * The byte length of the buffer.
  72244. */
  72245. readonly byteLength: number;
  72246. }
  72247. /**
  72248. * Utility class for reading from a data buffer
  72249. */
  72250. export class DataReader {
  72251. /**
  72252. * The data buffer associated with this data reader.
  72253. */
  72254. readonly buffer: IDataBuffer;
  72255. /**
  72256. * The current byte offset from the beginning of the data buffer.
  72257. */
  72258. byteOffset: number;
  72259. private _dataView;
  72260. private _dataByteOffset;
  72261. /**
  72262. * Constructor
  72263. * @param buffer The buffer to read
  72264. */
  72265. constructor(buffer: IDataBuffer);
  72266. /**
  72267. * Loads the given byte length.
  72268. * @param byteLength The byte length to load
  72269. * @returns A promise that resolves when the load is complete
  72270. */
  72271. loadAsync(byteLength: number): Promise<void>;
  72272. /**
  72273. * Read a unsigned 32-bit integer from the currently loaded data range.
  72274. * @returns The 32-bit integer read
  72275. */
  72276. readUint32(): number;
  72277. /**
  72278. * Read a byte array from the currently loaded data range.
  72279. * @param byteLength The byte length to read
  72280. * @returns The byte array read
  72281. */
  72282. readUint8Array(byteLength: number): Uint8Array;
  72283. /**
  72284. * Read a string from the currently loaded data range.
  72285. * @param byteLength The byte length to read
  72286. * @returns The string read
  72287. */
  72288. readString(byteLength: number): string;
  72289. /**
  72290. * Skips the given byte length the currently loaded data range.
  72291. * @param byteLength The byte length to skip
  72292. */
  72293. skipBytes(byteLength: number): void;
  72294. }
  72295. }
  72296. declare module "babylonjs/Misc/index" {
  72297. export * from "babylonjs/Misc/andOrNotEvaluator";
  72298. export * from "babylonjs/Misc/assetsManager";
  72299. export * from "babylonjs/Misc/basis";
  72300. export * from "babylonjs/Misc/dds";
  72301. export * from "babylonjs/Misc/decorators";
  72302. export * from "babylonjs/Misc/deferred";
  72303. export * from "babylonjs/Misc/environmentTextureTools";
  72304. export * from "babylonjs/Misc/meshExploder";
  72305. export * from "babylonjs/Misc/filesInput";
  72306. export * from "babylonjs/Misc/HighDynamicRange/index";
  72307. export * from "babylonjs/Misc/khronosTextureContainer";
  72308. export * from "babylonjs/Misc/observable";
  72309. export * from "babylonjs/Misc/performanceMonitor";
  72310. export * from "babylonjs/Misc/promise";
  72311. export * from "babylonjs/Misc/sceneOptimizer";
  72312. export * from "babylonjs/Misc/sceneSerializer";
  72313. export * from "babylonjs/Misc/smartArray";
  72314. export * from "babylonjs/Misc/stringDictionary";
  72315. export * from "babylonjs/Misc/tags";
  72316. export * from "babylonjs/Misc/textureTools";
  72317. export * from "babylonjs/Misc/tga";
  72318. export * from "babylonjs/Misc/tools";
  72319. export * from "babylonjs/Misc/videoRecorder";
  72320. export * from "babylonjs/Misc/virtualJoystick";
  72321. export * from "babylonjs/Misc/workerPool";
  72322. export * from "babylonjs/Misc/logger";
  72323. export * from "babylonjs/Misc/typeStore";
  72324. export * from "babylonjs/Misc/filesInputStore";
  72325. export * from "babylonjs/Misc/deepCopier";
  72326. export * from "babylonjs/Misc/pivotTools";
  72327. export * from "babylonjs/Misc/precisionDate";
  72328. export * from "babylonjs/Misc/screenshotTools";
  72329. export * from "babylonjs/Misc/typeStore";
  72330. export * from "babylonjs/Misc/webRequest";
  72331. export * from "babylonjs/Misc/iInspectable";
  72332. export * from "babylonjs/Misc/brdfTextureTools";
  72333. export * from "babylonjs/Misc/rgbdTextureTools";
  72334. export * from "babylonjs/Misc/gradients";
  72335. export * from "babylonjs/Misc/perfCounter";
  72336. export * from "babylonjs/Misc/fileRequest";
  72337. export * from "babylonjs/Misc/customAnimationFrameRequester";
  72338. export * from "babylonjs/Misc/retryStrategy";
  72339. export * from "babylonjs/Misc/interfaces/screenshotSize";
  72340. export * from "babylonjs/Misc/canvasGenerator";
  72341. export * from "babylonjs/Misc/fileTools";
  72342. export * from "babylonjs/Misc/stringTools";
  72343. export * from "babylonjs/Misc/dataReader";
  72344. export * from "babylonjs/Misc/minMaxReducer";
  72345. export * from "babylonjs/Misc/depthReducer";
  72346. }
  72347. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  72348. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72349. import { Observable } from "babylonjs/Misc/observable";
  72350. import { Matrix } from "babylonjs/Maths/math.vector";
  72351. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72352. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72353. /**
  72354. * Options used for hit testing
  72355. */
  72356. export interface IWebXRHitTestOptions {
  72357. /**
  72358. * Only test when user interacted with the scene. Default - hit test every frame
  72359. */
  72360. testOnPointerDownOnly?: boolean;
  72361. /**
  72362. * The node to use to transform the local results to world coordinates
  72363. */
  72364. worldParentNode?: TransformNode;
  72365. }
  72366. /**
  72367. * Interface defining the babylon result of raycasting/hit-test
  72368. */
  72369. export interface IWebXRHitResult {
  72370. /**
  72371. * The native hit test result
  72372. */
  72373. xrHitResult: XRHitResult;
  72374. /**
  72375. * Transformation matrix that can be applied to a node that will put it in the hit point location
  72376. */
  72377. transformationMatrix: Matrix;
  72378. }
  72379. /**
  72380. * The currently-working hit-test module.
  72381. * Hit test (or raycasting) is used to interact with the real world.
  72382. * For further information read here - https://github.com/immersive-web/hit-test
  72383. */
  72384. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  72385. /**
  72386. * options to use when constructing this feature
  72387. */
  72388. readonly options: IWebXRHitTestOptions;
  72389. /**
  72390. * The module's name
  72391. */
  72392. static readonly Name: string;
  72393. /**
  72394. * The (Babylon) version of this module.
  72395. * This is an integer representing the implementation version.
  72396. * This number does not correspond to the webxr specs version
  72397. */
  72398. static readonly Version: number;
  72399. /**
  72400. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  72401. * @param event the (select) event to use to select with
  72402. * @param referenceSpace the reference space to use for this hit test
  72403. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72404. */
  72405. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  72406. /**
  72407. * execute a hit test with an XR Ray
  72408. *
  72409. * @param xrSession a native xrSession that will execute this hit test
  72410. * @param xrRay the ray (position and direction) to use for raycasting
  72411. * @param referenceSpace native XR reference space to use for the hit-test
  72412. * @param filter filter function that will filter the results
  72413. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72414. */
  72415. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  72416. /**
  72417. * Triggered when new babylon (transformed) hit test results are available
  72418. */
  72419. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  72420. private _onSelectEnabled;
  72421. /**
  72422. * Creates a new instance of the (legacy version) hit test feature
  72423. * @param _xrSessionManager an instance of WebXRSessionManager
  72424. * @param options options to use when constructing this feature
  72425. */
  72426. constructor(_xrSessionManager: WebXRSessionManager,
  72427. /**
  72428. * options to use when constructing this feature
  72429. */
  72430. options?: IWebXRHitTestOptions);
  72431. /**
  72432. * Populated with the last native XR Hit Results
  72433. */
  72434. lastNativeXRHitResults: XRHitResult[];
  72435. /**
  72436. * attach this feature
  72437. * Will usually be called by the features manager
  72438. *
  72439. * @returns true if successful.
  72440. */
  72441. attach(): boolean;
  72442. /**
  72443. * detach this feature.
  72444. * Will usually be called by the features manager
  72445. *
  72446. * @returns true if successful.
  72447. */
  72448. detach(): boolean;
  72449. private _onHitTestResults;
  72450. private _origin;
  72451. private _direction;
  72452. private _mat;
  72453. protected _onXRFrame(frame: XRFrame): void;
  72454. private _onSelect;
  72455. /**
  72456. * Dispose this feature and all of the resources attached
  72457. */
  72458. dispose(): void;
  72459. }
  72460. }
  72461. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  72462. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72463. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72464. import { Observable } from "babylonjs/Misc/observable";
  72465. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  72466. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72467. /**
  72468. * Options used in the plane detector module
  72469. */
  72470. export interface IWebXRPlaneDetectorOptions {
  72471. /**
  72472. * The node to use to transform the local results to world coordinates
  72473. */
  72474. worldParentNode?: TransformNode;
  72475. }
  72476. /**
  72477. * A babylon interface for a webxr plane.
  72478. * A Plane is actually a polygon, built from N points in space
  72479. *
  72480. * Supported in chrome 79, not supported in canary 81 ATM
  72481. */
  72482. export interface IWebXRPlane {
  72483. /**
  72484. * a babylon-assigned ID for this polygon
  72485. */
  72486. id: number;
  72487. /**
  72488. * the native xr-plane object
  72489. */
  72490. xrPlane: XRPlane;
  72491. /**
  72492. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  72493. */
  72494. polygonDefinition: Array<Vector3>;
  72495. /**
  72496. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  72497. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  72498. */
  72499. transformationMatrix: Matrix;
  72500. }
  72501. /**
  72502. * The plane detector is used to detect planes in the real world when in AR
  72503. * For more information see https://github.com/immersive-web/real-world-geometry/
  72504. */
  72505. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  72506. private _options;
  72507. /**
  72508. * The module's name
  72509. */
  72510. static readonly Name: string;
  72511. /**
  72512. * The (Babylon) version of this module.
  72513. * This is an integer representing the implementation version.
  72514. * This number does not correspond to the webxr specs version
  72515. */
  72516. static readonly Version: number;
  72517. /**
  72518. * Observers registered here will be executed when a new plane was added to the session
  72519. */
  72520. onPlaneAddedObservable: Observable<IWebXRPlane>;
  72521. /**
  72522. * Observers registered here will be executed when a plane is no longer detected in the session
  72523. */
  72524. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  72525. /**
  72526. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  72527. * This can execute N times every frame
  72528. */
  72529. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  72530. private _enabled;
  72531. private _detectedPlanes;
  72532. private _lastFrameDetected;
  72533. /**
  72534. * construct a new Plane Detector
  72535. * @param _xrSessionManager an instance of xr Session manager
  72536. * @param _options configuration to use when constructing this feature
  72537. */
  72538. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  72539. private _init;
  72540. protected _onXRFrame(frame: XRFrame): void;
  72541. /**
  72542. * Dispose this feature and all of the resources attached
  72543. */
  72544. dispose(): void;
  72545. private _updatePlaneWithXRPlane;
  72546. /**
  72547. * avoiding using Array.find for global support.
  72548. * @param xrPlane the plane to find in the array
  72549. */
  72550. private findIndexInPlaneArray;
  72551. }
  72552. }
  72553. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  72554. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72555. import { Observable } from "babylonjs/Misc/observable";
  72556. import { Matrix } from "babylonjs/Maths/math.vector";
  72557. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72558. import { WebXRPlaneDetector } from "babylonjs/XR/features/WebXRPlaneDetector";
  72559. import { WebXRHitTestLegacy } from "babylonjs/XR/features/WebXRHitTestLegacy";
  72560. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72561. /**
  72562. * Configuration options of the anchor system
  72563. */
  72564. export interface IWebXRAnchorSystemOptions {
  72565. /**
  72566. * a node that will be used to convert local to world coordinates
  72567. */
  72568. worldParentNode?: TransformNode;
  72569. /**
  72570. * should the anchor system use plane detection.
  72571. * If set to true, the plane-detection feature should be set using setPlaneDetector
  72572. */
  72573. usePlaneDetection?: boolean;
  72574. /**
  72575. * Should a new anchor be added every time a select event is triggered
  72576. */
  72577. addAnchorOnSelect?: boolean;
  72578. }
  72579. /**
  72580. * A babylon container for an XR Anchor
  72581. */
  72582. export interface IWebXRAnchor {
  72583. /**
  72584. * A babylon-assigned ID for this anchor
  72585. */
  72586. id: number;
  72587. /**
  72588. * The native anchor object
  72589. */
  72590. xrAnchor: XRAnchor;
  72591. /**
  72592. * Transformation matrix to apply to an object attached to this anchor
  72593. */
  72594. transformationMatrix: Matrix;
  72595. }
  72596. /**
  72597. * An implementation of the anchor system of WebXR.
  72598. * Note that the current documented implementation is not available in any browser. Future implementations
  72599. * will use the frame to create an anchor and not the session or a detected plane
  72600. * For further information see https://github.com/immersive-web/anchors/
  72601. */
  72602. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  72603. private _options;
  72604. /**
  72605. * The module's name
  72606. */
  72607. static readonly Name: string;
  72608. /**
  72609. * The (Babylon) version of this module.
  72610. * This is an integer representing the implementation version.
  72611. * This number does not correspond to the webxr specs version
  72612. */
  72613. static readonly Version: number;
  72614. /**
  72615. * Observers registered here will be executed when a new anchor was added to the session
  72616. */
  72617. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  72618. /**
  72619. * Observers registered here will be executed when an existing anchor updates
  72620. * This can execute N times every frame
  72621. */
  72622. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  72623. /**
  72624. * Observers registered here will be executed when an anchor was removed from the session
  72625. */
  72626. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  72627. private _planeDetector;
  72628. private _hitTestModule;
  72629. private _enabled;
  72630. private _trackedAnchors;
  72631. private _lastFrameDetected;
  72632. /**
  72633. * constructs a new anchor system
  72634. * @param _xrSessionManager an instance of WebXRSessionManager
  72635. * @param _options configuration object for this feature
  72636. */
  72637. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  72638. /**
  72639. * set the plane detector to use in order to create anchors from frames
  72640. * @param planeDetector the plane-detector module to use
  72641. * @param enable enable plane-anchors. default is true
  72642. */
  72643. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  72644. /**
  72645. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  72646. * @param hitTestModule the hit-test module to use.
  72647. */
  72648. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  72649. /**
  72650. * attach this feature
  72651. * Will usually be called by the features manager
  72652. *
  72653. * @returns true if successful.
  72654. */
  72655. attach(): boolean;
  72656. /**
  72657. * detach this feature.
  72658. * Will usually be called by the features manager
  72659. *
  72660. * @returns true if successful.
  72661. */
  72662. detach(): boolean;
  72663. /**
  72664. * Dispose this feature and all of the resources attached
  72665. */
  72666. dispose(): void;
  72667. protected _onXRFrame(frame: XRFrame): void;
  72668. private _onSelect;
  72669. /**
  72670. * Add anchor at a specific XR point.
  72671. *
  72672. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  72673. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  72674. * @returns a promise the fulfills when the anchor was created
  72675. */
  72676. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  72677. private _updateAnchorWithXRFrame;
  72678. /**
  72679. * avoiding using Array.find for global support.
  72680. * @param xrAnchor the plane to find in the array
  72681. */
  72682. private _findIndexInAnchorArray;
  72683. }
  72684. }
  72685. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  72686. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72687. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72688. import { Observable } from "babylonjs/Misc/observable";
  72689. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72690. /**
  72691. * Options interface for the background remover plugin
  72692. */
  72693. export interface IWebXRBackgroundRemoverOptions {
  72694. /**
  72695. * don't disable the environment helper
  72696. */
  72697. ignoreEnvironmentHelper?: boolean;
  72698. /**
  72699. * flags to configure the removal of the environment helper.
  72700. * If not set, the entire background will be removed. If set, flags should be set as well.
  72701. */
  72702. environmentHelperRemovalFlags?: {
  72703. /**
  72704. * Should the skybox be removed (default false)
  72705. */
  72706. skyBox?: boolean;
  72707. /**
  72708. * Should the ground be removed (default false)
  72709. */
  72710. ground?: boolean;
  72711. };
  72712. /**
  72713. * Further background meshes to disable when entering AR
  72714. */
  72715. backgroundMeshes?: AbstractMesh[];
  72716. }
  72717. /**
  72718. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  72719. */
  72720. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  72721. /**
  72722. * read-only options to be used in this module
  72723. */
  72724. readonly options: IWebXRBackgroundRemoverOptions;
  72725. /**
  72726. * The module's name
  72727. */
  72728. static readonly Name: string;
  72729. /**
  72730. * The (Babylon) version of this module.
  72731. * This is an integer representing the implementation version.
  72732. * This number does not correspond to the webxr specs version
  72733. */
  72734. static readonly Version: number;
  72735. /**
  72736. * registered observers will be triggered when the background state changes
  72737. */
  72738. onBackgroundStateChangedObservable: Observable<boolean>;
  72739. /**
  72740. * constructs a new background remover module
  72741. * @param _xrSessionManager the session manager for this module
  72742. * @param options read-only options to be used in this module
  72743. */
  72744. constructor(_xrSessionManager: WebXRSessionManager,
  72745. /**
  72746. * read-only options to be used in this module
  72747. */
  72748. options?: IWebXRBackgroundRemoverOptions);
  72749. /**
  72750. * attach this feature
  72751. * Will usually be called by the features manager
  72752. *
  72753. * @returns true if successful.
  72754. */
  72755. attach(): boolean;
  72756. /**
  72757. * detach this feature.
  72758. * Will usually be called by the features manager
  72759. *
  72760. * @returns true if successful.
  72761. */
  72762. detach(): boolean;
  72763. private _setBackgroundState;
  72764. /**
  72765. * Dispose this feature and all of the resources attached
  72766. */
  72767. dispose(): void;
  72768. protected _onXRFrame(_xrFrame: XRFrame): void;
  72769. }
  72770. }
  72771. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  72772. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72773. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  72774. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  72775. import { WebXRInput } from "babylonjs/XR/webXRInput";
  72776. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72777. import { Nullable } from "babylonjs/types";
  72778. /**
  72779. * Options for the controller physics feature
  72780. */
  72781. export class IWebXRControllerPhysicsOptions {
  72782. /**
  72783. * the xr input to use with this pointer selection
  72784. */
  72785. xrInput: WebXRInput;
  72786. /**
  72787. * The physics properties of the future impostors
  72788. */
  72789. physicsProperties?: {
  72790. /**
  72791. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  72792. * Note that this requires a physics engine that supports mesh impostors!
  72793. */
  72794. useControllerMesh?: boolean;
  72795. /**
  72796. * The type of impostor to create. Default is sphere
  72797. */
  72798. impostorType?: number;
  72799. /**
  72800. * the size of the impostor. Defaults to 10cm
  72801. */
  72802. impostorSize?: number | {
  72803. width: number;
  72804. height: number;
  72805. depth: number;
  72806. };
  72807. /**
  72808. * Friction definitions
  72809. */
  72810. friction?: number;
  72811. /**
  72812. * Restitution
  72813. */
  72814. restitution?: number;
  72815. };
  72816. /**
  72817. * Should the headset get its own impostor
  72818. */
  72819. enableHeadsetImpostor?: boolean;
  72820. /**
  72821. * Optional parameters for the headset impostor
  72822. */
  72823. headsetImpostorParams?: {
  72824. /**
  72825. * The type of impostor to create. Default is sphere
  72826. */
  72827. impostorType: number;
  72828. /**
  72829. * the size of the impostor. Defaults to 10cm
  72830. */
  72831. impostorSize?: number | {
  72832. width: number;
  72833. height: number;
  72834. depth: number;
  72835. };
  72836. /**
  72837. * Friction definitions
  72838. */
  72839. friction?: number;
  72840. /**
  72841. * Restitution
  72842. */
  72843. restitution?: number;
  72844. };
  72845. }
  72846. /**
  72847. * Add physics impostor to your webxr controllers,
  72848. * including naive calculation of their linear and angular velocity
  72849. */
  72850. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  72851. private readonly _options;
  72852. /**
  72853. * The module's name
  72854. */
  72855. static readonly Name: string;
  72856. /**
  72857. * The (Babylon) version of this module.
  72858. * This is an integer representing the implementation version.
  72859. * This number does not correspond to the webxr specs version
  72860. */
  72861. static readonly Version: number;
  72862. private _lastTimestamp;
  72863. private _delta;
  72864. private _controllers;
  72865. private _headsetImpostor?;
  72866. private _headsetMesh?;
  72867. private _tmpVector;
  72868. private _tmpQuaternion;
  72869. /**
  72870. * Construct a new Controller Physics Feature
  72871. * @param _xrSessionManager the corresponding xr session manager
  72872. * @param _options options to create this feature with
  72873. */
  72874. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  72875. /**
  72876. * Update the physics properties provided in the constructor
  72877. * @param newProperties the new properties object
  72878. */
  72879. setPhysicsProperties(newProperties: {
  72880. impostorType?: number;
  72881. impostorSize?: number | {
  72882. width: number;
  72883. height: number;
  72884. depth: number;
  72885. };
  72886. friction?: number;
  72887. restitution?: number;
  72888. }): void;
  72889. /**
  72890. * Get the physics impostor of a specific controller.
  72891. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  72892. * @param controller the controller or the controller id of which to get the impostor
  72893. * @returns the impostor or null
  72894. */
  72895. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  72896. /**
  72897. * Get the headset impostor, if enabled
  72898. * @returns the impostor
  72899. */
  72900. getHeadsetImpostor(): PhysicsImpostor | undefined;
  72901. /**
  72902. * attach this feature
  72903. * Will usually be called by the features manager
  72904. *
  72905. * @returns true if successful.
  72906. */
  72907. attach(): boolean;
  72908. /**
  72909. * detach this feature.
  72910. * Will usually be called by the features manager
  72911. *
  72912. * @returns true if successful.
  72913. */
  72914. detach(): boolean;
  72915. /**
  72916. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  72917. * @param xrController the controller to add
  72918. */
  72919. addController(xrController: WebXRInputSource): void;
  72920. private _debugMode;
  72921. /**
  72922. * @hidden
  72923. * enable debugging - will show console outputs and the impostor mesh
  72924. */
  72925. _enablePhysicsDebug(): void;
  72926. private _attachController;
  72927. private _detachController;
  72928. protected _onXRFrame(_xrFrame: any): void;
  72929. }
  72930. }
  72931. declare module "babylonjs/XR/features/index" {
  72932. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  72933. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  72934. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  72935. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  72936. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  72937. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  72938. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  72939. }
  72940. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  72941. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  72942. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72943. import { Scene } from "babylonjs/scene";
  72944. /**
  72945. * The motion controller class for all microsoft mixed reality controllers
  72946. */
  72947. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  72948. /**
  72949. * The base url used to load the left and right controller models
  72950. */
  72951. static MODEL_BASE_URL: string;
  72952. /**
  72953. * The name of the left controller model file
  72954. */
  72955. static MODEL_LEFT_FILENAME: string;
  72956. /**
  72957. * The name of the right controller model file
  72958. */
  72959. static MODEL_RIGHT_FILENAME: string;
  72960. profileId: string;
  72961. protected readonly _mapping: {
  72962. defaultButton: {
  72963. "valueNodeName": string;
  72964. "unpressedNodeName": string;
  72965. "pressedNodeName": string;
  72966. };
  72967. defaultAxis: {
  72968. "valueNodeName": string;
  72969. "minNodeName": string;
  72970. "maxNodeName": string;
  72971. };
  72972. buttons: {
  72973. "xr-standard-trigger": {
  72974. "rootNodeName": string;
  72975. "componentProperty": string;
  72976. "states": string[];
  72977. };
  72978. "xr-standard-squeeze": {
  72979. "rootNodeName": string;
  72980. "componentProperty": string;
  72981. "states": string[];
  72982. };
  72983. "xr-standard-touchpad": {
  72984. "rootNodeName": string;
  72985. "labelAnchorNodeName": string;
  72986. "touchPointNodeName": string;
  72987. };
  72988. "xr-standard-thumbstick": {
  72989. "rootNodeName": string;
  72990. "componentProperty": string;
  72991. "states": string[];
  72992. };
  72993. };
  72994. axes: {
  72995. "xr-standard-touchpad": {
  72996. "x-axis": {
  72997. "rootNodeName": string;
  72998. };
  72999. "y-axis": {
  73000. "rootNodeName": string;
  73001. };
  73002. };
  73003. "xr-standard-thumbstick": {
  73004. "x-axis": {
  73005. "rootNodeName": string;
  73006. };
  73007. "y-axis": {
  73008. "rootNodeName": string;
  73009. };
  73010. };
  73011. };
  73012. };
  73013. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  73014. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73015. protected _getFilenameAndPath(): {
  73016. filename: string;
  73017. path: string;
  73018. };
  73019. protected _updateModel(): void;
  73020. protected _getModelLoadingConstraints(): boolean;
  73021. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73022. }
  73023. }
  73024. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  73025. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73026. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73027. import { Scene } from "babylonjs/scene";
  73028. /**
  73029. * The motion controller class for oculus touch (quest, rift).
  73030. * This class supports legacy mapping as well the standard xr mapping
  73031. */
  73032. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  73033. private _forceLegacyControllers;
  73034. /**
  73035. * The base url used to load the left and right controller models
  73036. */
  73037. static MODEL_BASE_URL: string;
  73038. /**
  73039. * The name of the left controller model file
  73040. */
  73041. static MODEL_LEFT_FILENAME: string;
  73042. /**
  73043. * The name of the right controller model file
  73044. */
  73045. static MODEL_RIGHT_FILENAME: string;
  73046. /**
  73047. * Base Url for the Quest controller model.
  73048. */
  73049. static QUEST_MODEL_BASE_URL: string;
  73050. profileId: string;
  73051. private _modelRootNode;
  73052. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  73053. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73054. protected _getFilenameAndPath(): {
  73055. filename: string;
  73056. path: string;
  73057. };
  73058. /**
  73059. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  73060. * between the touch and touch 2.
  73061. */
  73062. private _isQuest;
  73063. protected _updateModel(): void;
  73064. protected _getModelLoadingConstraints(): boolean;
  73065. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73066. }
  73067. }
  73068. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  73069. import { IMinimalMotionControllerObject, MotionControllerHandness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73070. import { Scene } from "babylonjs/scene";
  73071. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73072. /**
  73073. * The motion controller class for the standard HTC-Vive controllers
  73074. */
  73075. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  73076. /**
  73077. * The base url used to load the left and right controller models
  73078. */
  73079. static MODEL_BASE_URL: string;
  73080. /**
  73081. * File name for the controller model.
  73082. */
  73083. static MODEL_FILENAME: string;
  73084. profileId: string;
  73085. private _modelRootNode;
  73086. /**
  73087. * Create a new Vive motion controller object
  73088. * @param scene the scene to use to create this controller
  73089. * @param gamepadObject the corresponding gamepad object
  73090. * @param handness the handness of the controller
  73091. */
  73092. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  73093. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73094. protected _getFilenameAndPath(): {
  73095. filename: string;
  73096. path: string;
  73097. };
  73098. protected _updateModel(): void;
  73099. protected _getModelLoadingConstraints(): boolean;
  73100. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73101. }
  73102. }
  73103. declare module "babylonjs/XR/motionController/index" {
  73104. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73105. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  73106. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  73107. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  73108. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  73109. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  73110. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  73111. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  73112. }
  73113. declare module "babylonjs/XR/index" {
  73114. export * from "babylonjs/XR/webXRCamera";
  73115. export * from "babylonjs/XR/webXREnterExitUI";
  73116. export * from "babylonjs/XR/webXRExperienceHelper";
  73117. export * from "babylonjs/XR/webXRInput";
  73118. export * from "babylonjs/XR/webXRInputSource";
  73119. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  73120. export * from "babylonjs/XR/webXRTypes";
  73121. export * from "babylonjs/XR/webXRSessionManager";
  73122. export * from "babylonjs/XR/webXRDefaultExperience";
  73123. export * from "babylonjs/XR/webXRFeaturesManager";
  73124. export * from "babylonjs/XR/features/index";
  73125. export * from "babylonjs/XR/motionController/index";
  73126. }
  73127. declare module "babylonjs/index" {
  73128. export * from "babylonjs/abstractScene";
  73129. export * from "babylonjs/Actions/index";
  73130. export * from "babylonjs/Animations/index";
  73131. export * from "babylonjs/assetContainer";
  73132. export * from "babylonjs/Audio/index";
  73133. export * from "babylonjs/Behaviors/index";
  73134. export * from "babylonjs/Bones/index";
  73135. export * from "babylonjs/Cameras/index";
  73136. export * from "babylonjs/Collisions/index";
  73137. export * from "babylonjs/Culling/index";
  73138. export * from "babylonjs/Debug/index";
  73139. export * from "babylonjs/Engines/index";
  73140. export * from "babylonjs/Events/index";
  73141. export * from "babylonjs/Gamepads/index";
  73142. export * from "babylonjs/Gizmos/index";
  73143. export * from "babylonjs/Helpers/index";
  73144. export * from "babylonjs/Instrumentation/index";
  73145. export * from "babylonjs/Layers/index";
  73146. export * from "babylonjs/LensFlares/index";
  73147. export * from "babylonjs/Lights/index";
  73148. export * from "babylonjs/Loading/index";
  73149. export * from "babylonjs/Materials/index";
  73150. export * from "babylonjs/Maths/index";
  73151. export * from "babylonjs/Meshes/index";
  73152. export * from "babylonjs/Morph/index";
  73153. export * from "babylonjs/Navigation/index";
  73154. export * from "babylonjs/node";
  73155. export * from "babylonjs/Offline/index";
  73156. export * from "babylonjs/Particles/index";
  73157. export * from "babylonjs/Physics/index";
  73158. export * from "babylonjs/PostProcesses/index";
  73159. export * from "babylonjs/Probes/index";
  73160. export * from "babylonjs/Rendering/index";
  73161. export * from "babylonjs/scene";
  73162. export * from "babylonjs/sceneComponent";
  73163. export * from "babylonjs/Sprites/index";
  73164. export * from "babylonjs/States/index";
  73165. export * from "babylonjs/Misc/index";
  73166. export * from "babylonjs/XR/index";
  73167. export * from "babylonjs/types";
  73168. }
  73169. declare module "babylonjs/Animations/pathCursor" {
  73170. import { Vector3 } from "babylonjs/Maths/math.vector";
  73171. import { Path2 } from "babylonjs/Maths/math.path";
  73172. /**
  73173. * A cursor which tracks a point on a path
  73174. */
  73175. export class PathCursor {
  73176. private path;
  73177. /**
  73178. * Stores path cursor callbacks for when an onchange event is triggered
  73179. */
  73180. private _onchange;
  73181. /**
  73182. * The value of the path cursor
  73183. */
  73184. value: number;
  73185. /**
  73186. * The animation array of the path cursor
  73187. */
  73188. animations: Animation[];
  73189. /**
  73190. * Initializes the path cursor
  73191. * @param path The path to track
  73192. */
  73193. constructor(path: Path2);
  73194. /**
  73195. * Gets the cursor point on the path
  73196. * @returns A point on the path cursor at the cursor location
  73197. */
  73198. getPoint(): Vector3;
  73199. /**
  73200. * Moves the cursor ahead by the step amount
  73201. * @param step The amount to move the cursor forward
  73202. * @returns This path cursor
  73203. */
  73204. moveAhead(step?: number): PathCursor;
  73205. /**
  73206. * Moves the cursor behind by the step amount
  73207. * @param step The amount to move the cursor back
  73208. * @returns This path cursor
  73209. */
  73210. moveBack(step?: number): PathCursor;
  73211. /**
  73212. * Moves the cursor by the step amount
  73213. * If the step amount is greater than one, an exception is thrown
  73214. * @param step The amount to move the cursor
  73215. * @returns This path cursor
  73216. */
  73217. move(step: number): PathCursor;
  73218. /**
  73219. * Ensures that the value is limited between zero and one
  73220. * @returns This path cursor
  73221. */
  73222. private ensureLimits;
  73223. /**
  73224. * Runs onchange callbacks on change (used by the animation engine)
  73225. * @returns This path cursor
  73226. */
  73227. private raiseOnChange;
  73228. /**
  73229. * Executes a function on change
  73230. * @param f A path cursor onchange callback
  73231. * @returns This path cursor
  73232. */
  73233. onchange(f: (cursor: PathCursor) => void): PathCursor;
  73234. }
  73235. }
  73236. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  73237. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  73238. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  73239. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  73240. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  73241. }
  73242. declare module "babylonjs/Engines/Processors/Expressions/index" {
  73243. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  73244. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  73245. }
  73246. declare module "babylonjs/Engines/Processors/index" {
  73247. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  73248. export * from "babylonjs/Engines/Processors/Expressions/index";
  73249. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  73250. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  73251. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  73252. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  73253. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  73254. export * from "babylonjs/Engines/Processors/shaderProcessor";
  73255. }
  73256. declare module "babylonjs/Legacy/legacy" {
  73257. import * as Babylon from "babylonjs/index";
  73258. export * from "babylonjs/index";
  73259. }
  73260. declare module "babylonjs/Shaders/blur.fragment" {
  73261. /** @hidden */
  73262. export var blurPixelShader: {
  73263. name: string;
  73264. shader: string;
  73265. };
  73266. }
  73267. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  73268. /** @hidden */
  73269. export var pointCloudVertexDeclaration: {
  73270. name: string;
  73271. shader: string;
  73272. };
  73273. }
  73274. declare module "babylonjs" {
  73275. export * from "babylonjs/Legacy/legacy";
  73276. }
  73277. declare module BABYLON {
  73278. /** Alias type for value that can be null */
  73279. export type Nullable<T> = T | null;
  73280. /**
  73281. * Alias type for number that are floats
  73282. * @ignorenaming
  73283. */
  73284. export type float = number;
  73285. /**
  73286. * Alias type for number that are doubles.
  73287. * @ignorenaming
  73288. */
  73289. export type double = number;
  73290. /**
  73291. * Alias type for number that are integer
  73292. * @ignorenaming
  73293. */
  73294. export type int = number;
  73295. /** Alias type for number array or Float32Array */
  73296. export type FloatArray = number[] | Float32Array;
  73297. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  73298. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  73299. /**
  73300. * Alias for types that can be used by a Buffer or VertexBuffer.
  73301. */
  73302. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  73303. /**
  73304. * Alias type for primitive types
  73305. * @ignorenaming
  73306. */
  73307. type Primitive = undefined | null | boolean | string | number | Function;
  73308. /**
  73309. * Type modifier to make all the properties of an object Readonly
  73310. */
  73311. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  73312. /**
  73313. * Type modifier to make all the properties of an object Readonly recursively
  73314. */
  73315. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  73316. /**
  73317. * Type modifier to make object properties readonly.
  73318. */
  73319. export type DeepImmutableObject<T> = {
  73320. readonly [K in keyof T]: DeepImmutable<T[K]>;
  73321. };
  73322. /** @hidden */
  73323. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  73324. }
  73325. }
  73326. declare module BABYLON {
  73327. /**
  73328. * A class serves as a medium between the observable and its observers
  73329. */
  73330. export class EventState {
  73331. /**
  73332. * Create a new EventState
  73333. * @param mask defines the mask associated with this state
  73334. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  73335. * @param target defines the original target of the state
  73336. * @param currentTarget defines the current target of the state
  73337. */
  73338. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  73339. /**
  73340. * Initialize the current event state
  73341. * @param mask defines the mask associated with this state
  73342. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  73343. * @param target defines the original target of the state
  73344. * @param currentTarget defines the current target of the state
  73345. * @returns the current event state
  73346. */
  73347. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73348. /**
  73349. * An Observer can set this property to true to prevent subsequent observers of being notified
  73350. */
  73351. skipNextObservers: boolean;
  73352. /**
  73353. * Get the mask value that were used to trigger the event corresponding to this EventState object
  73354. */
  73355. mask: number;
  73356. /**
  73357. * The object that originally notified the event
  73358. */
  73359. target?: any;
  73360. /**
  73361. * The current object in the bubbling phase
  73362. */
  73363. currentTarget?: any;
  73364. /**
  73365. * This will be populated with the return value of the last function that was executed.
  73366. * If it is the first function in the callback chain it will be the event data.
  73367. */
  73368. lastReturnValue?: any;
  73369. }
  73370. /**
  73371. * Represent an Observer registered to a given Observable object.
  73372. */
  73373. export class Observer<T> {
  73374. /**
  73375. * Defines the callback to call when the observer is notified
  73376. */
  73377. callback: (eventData: T, eventState: EventState) => void;
  73378. /**
  73379. * Defines the mask of the observer (used to filter notifications)
  73380. */
  73381. mask: number;
  73382. /**
  73383. * Defines the current scope used to restore the JS context
  73384. */
  73385. scope: any;
  73386. /** @hidden */
  73387. _willBeUnregistered: boolean;
  73388. /**
  73389. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  73390. */
  73391. unregisterOnNextCall: boolean;
  73392. /**
  73393. * Creates a new observer
  73394. * @param callback defines the callback to call when the observer is notified
  73395. * @param mask defines the mask of the observer (used to filter notifications)
  73396. * @param scope defines the current scope used to restore the JS context
  73397. */
  73398. constructor(
  73399. /**
  73400. * Defines the callback to call when the observer is notified
  73401. */
  73402. callback: (eventData: T, eventState: EventState) => void,
  73403. /**
  73404. * Defines the mask of the observer (used to filter notifications)
  73405. */
  73406. mask: number,
  73407. /**
  73408. * Defines the current scope used to restore the JS context
  73409. */
  73410. scope?: any);
  73411. }
  73412. /**
  73413. * Represent a list of observers registered to multiple Observables object.
  73414. */
  73415. export class MultiObserver<T> {
  73416. private _observers;
  73417. private _observables;
  73418. /**
  73419. * Release associated resources
  73420. */
  73421. dispose(): void;
  73422. /**
  73423. * Raise a callback when one of the observable will notify
  73424. * @param observables defines a list of observables to watch
  73425. * @param callback defines the callback to call on notification
  73426. * @param mask defines the mask used to filter notifications
  73427. * @param scope defines the current scope used to restore the JS context
  73428. * @returns the new MultiObserver
  73429. */
  73430. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  73431. }
  73432. /**
  73433. * The Observable class is a simple implementation of the Observable pattern.
  73434. *
  73435. * 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.
  73436. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  73437. * 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).
  73438. * 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.
  73439. */
  73440. export class Observable<T> {
  73441. private _observers;
  73442. private _eventState;
  73443. private _onObserverAdded;
  73444. /**
  73445. * Gets the list of observers
  73446. */
  73447. get observers(): Array<Observer<T>>;
  73448. /**
  73449. * Creates a new observable
  73450. * @param onObserverAdded defines a callback to call when a new observer is added
  73451. */
  73452. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  73453. /**
  73454. * Create a new Observer with the specified callback
  73455. * @param callback the callback that will be executed for that Observer
  73456. * @param mask the mask used to filter observers
  73457. * @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.
  73458. * @param scope optional scope for the callback to be called from
  73459. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  73460. * @returns the new observer created for the callback
  73461. */
  73462. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  73463. /**
  73464. * Create a new Observer with the specified callback and unregisters after the next notification
  73465. * @param callback the callback that will be executed for that Observer
  73466. * @returns the new observer created for the callback
  73467. */
  73468. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  73469. /**
  73470. * Remove an Observer from the Observable object
  73471. * @param observer the instance of the Observer to remove
  73472. * @returns false if it doesn't belong to this Observable
  73473. */
  73474. remove(observer: Nullable<Observer<T>>): boolean;
  73475. /**
  73476. * Remove a callback from the Observable object
  73477. * @param callback the callback to remove
  73478. * @param scope optional scope. If used only the callbacks with this scope will be removed
  73479. * @returns false if it doesn't belong to this Observable
  73480. */
  73481. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  73482. private _deferUnregister;
  73483. private _remove;
  73484. /**
  73485. * Moves the observable to the top of the observer list making it get called first when notified
  73486. * @param observer the observer to move
  73487. */
  73488. makeObserverTopPriority(observer: Observer<T>): void;
  73489. /**
  73490. * Moves the observable to the bottom of the observer list making it get called last when notified
  73491. * @param observer the observer to move
  73492. */
  73493. makeObserverBottomPriority(observer: Observer<T>): void;
  73494. /**
  73495. * Notify all Observers by calling their respective callback with the given data
  73496. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  73497. * @param eventData defines the data to send to all observers
  73498. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  73499. * @param target defines the original target of the state
  73500. * @param currentTarget defines the current target of the state
  73501. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  73502. */
  73503. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  73504. /**
  73505. * Calling this will execute each callback, expecting it to be a promise or return a value.
  73506. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  73507. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  73508. * and it is crucial that all callbacks will be executed.
  73509. * The order of the callbacks is kept, callbacks are not executed parallel.
  73510. *
  73511. * @param eventData The data to be sent to each callback
  73512. * @param mask is used to filter observers defaults to -1
  73513. * @param target defines the callback target (see EventState)
  73514. * @param currentTarget defines he current object in the bubbling phase
  73515. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  73516. */
  73517. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  73518. /**
  73519. * Notify a specific observer
  73520. * @param observer defines the observer to notify
  73521. * @param eventData defines the data to be sent to each callback
  73522. * @param mask is used to filter observers defaults to -1
  73523. */
  73524. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  73525. /**
  73526. * Gets a boolean indicating if the observable has at least one observer
  73527. * @returns true is the Observable has at least one Observer registered
  73528. */
  73529. hasObservers(): boolean;
  73530. /**
  73531. * Clear the list of observers
  73532. */
  73533. clear(): void;
  73534. /**
  73535. * Clone the current observable
  73536. * @returns a new observable
  73537. */
  73538. clone(): Observable<T>;
  73539. /**
  73540. * Does this observable handles observer registered with a given mask
  73541. * @param mask defines the mask to be tested
  73542. * @return whether or not one observer registered with the given mask is handeled
  73543. **/
  73544. hasSpecificMask(mask?: number): boolean;
  73545. }
  73546. }
  73547. declare module BABYLON {
  73548. /**
  73549. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  73550. * Babylon.js
  73551. */
  73552. export class DomManagement {
  73553. /**
  73554. * Checks if the window object exists
  73555. * @returns true if the window object exists
  73556. */
  73557. static IsWindowObjectExist(): boolean;
  73558. /**
  73559. * Checks if the navigator object exists
  73560. * @returns true if the navigator object exists
  73561. */
  73562. static IsNavigatorAvailable(): boolean;
  73563. /**
  73564. * Extracts text content from a DOM element hierarchy
  73565. * @param element defines the root element
  73566. * @returns a string
  73567. */
  73568. static GetDOMTextContent(element: HTMLElement): string;
  73569. }
  73570. }
  73571. declare module BABYLON {
  73572. /**
  73573. * Logger used througouht the application to allow configuration of
  73574. * the log level required for the messages.
  73575. */
  73576. export class Logger {
  73577. /**
  73578. * No log
  73579. */
  73580. static readonly NoneLogLevel: number;
  73581. /**
  73582. * Only message logs
  73583. */
  73584. static readonly MessageLogLevel: number;
  73585. /**
  73586. * Only warning logs
  73587. */
  73588. static readonly WarningLogLevel: number;
  73589. /**
  73590. * Only error logs
  73591. */
  73592. static readonly ErrorLogLevel: number;
  73593. /**
  73594. * All logs
  73595. */
  73596. static readonly AllLogLevel: number;
  73597. private static _LogCache;
  73598. /**
  73599. * Gets a value indicating the number of loading errors
  73600. * @ignorenaming
  73601. */
  73602. static errorsCount: number;
  73603. /**
  73604. * Callback called when a new log is added
  73605. */
  73606. static OnNewCacheEntry: (entry: string) => void;
  73607. private static _AddLogEntry;
  73608. private static _FormatMessage;
  73609. private static _LogDisabled;
  73610. private static _LogEnabled;
  73611. private static _WarnDisabled;
  73612. private static _WarnEnabled;
  73613. private static _ErrorDisabled;
  73614. private static _ErrorEnabled;
  73615. /**
  73616. * Log a message to the console
  73617. */
  73618. static Log: (message: string) => void;
  73619. /**
  73620. * Write a warning message to the console
  73621. */
  73622. static Warn: (message: string) => void;
  73623. /**
  73624. * Write an error message to the console
  73625. */
  73626. static Error: (message: string) => void;
  73627. /**
  73628. * Gets current log cache (list of logs)
  73629. */
  73630. static get LogCache(): string;
  73631. /**
  73632. * Clears the log cache
  73633. */
  73634. static ClearLogCache(): void;
  73635. /**
  73636. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  73637. */
  73638. static set LogLevels(level: number);
  73639. }
  73640. }
  73641. declare module BABYLON {
  73642. /** @hidden */
  73643. export class _TypeStore {
  73644. /** @hidden */
  73645. static RegisteredTypes: {
  73646. [key: string]: Object;
  73647. };
  73648. /** @hidden */
  73649. static GetClass(fqdn: string): any;
  73650. }
  73651. }
  73652. declare module BABYLON {
  73653. /**
  73654. * Helper to manipulate strings
  73655. */
  73656. export class StringTools {
  73657. /**
  73658. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  73659. * @param str Source string
  73660. * @param suffix Suffix to search for in the source string
  73661. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  73662. */
  73663. static EndsWith(str: string, suffix: string): boolean;
  73664. /**
  73665. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  73666. * @param str Source string
  73667. * @param suffix Suffix to search for in the source string
  73668. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  73669. */
  73670. static StartsWith(str: string, suffix: string): boolean;
  73671. /**
  73672. * Decodes a buffer into a string
  73673. * @param buffer The buffer to decode
  73674. * @returns The decoded string
  73675. */
  73676. static Decode(buffer: Uint8Array | Uint16Array): string;
  73677. /**
  73678. * Encode a buffer to a base64 string
  73679. * @param buffer defines the buffer to encode
  73680. * @returns the encoded string
  73681. */
  73682. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  73683. }
  73684. }
  73685. declare module BABYLON {
  73686. /**
  73687. * Class containing a set of static utilities functions for deep copy.
  73688. */
  73689. export class DeepCopier {
  73690. /**
  73691. * Tries to copy an object by duplicating every property
  73692. * @param source defines the source object
  73693. * @param destination defines the target object
  73694. * @param doNotCopyList defines a list of properties to avoid
  73695. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  73696. */
  73697. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  73698. }
  73699. }
  73700. declare module BABYLON {
  73701. /**
  73702. * Class containing a set of static utilities functions for precision date
  73703. */
  73704. export class PrecisionDate {
  73705. /**
  73706. * Gets either window.performance.now() if supported or Date.now() else
  73707. */
  73708. static get Now(): number;
  73709. }
  73710. }
  73711. declare module BABYLON {
  73712. /** @hidden */
  73713. export class _DevTools {
  73714. static WarnImport(name: string): string;
  73715. }
  73716. }
  73717. declare module BABYLON {
  73718. /**
  73719. * Interface used to define the mechanism to get data from the network
  73720. */
  73721. export interface IWebRequest {
  73722. /**
  73723. * Returns client's response url
  73724. */
  73725. responseURL: string;
  73726. /**
  73727. * Returns client's status
  73728. */
  73729. status: number;
  73730. /**
  73731. * Returns client's status as a text
  73732. */
  73733. statusText: string;
  73734. }
  73735. }
  73736. declare module BABYLON {
  73737. /**
  73738. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  73739. */
  73740. export class WebRequest implements IWebRequest {
  73741. private _xhr;
  73742. /**
  73743. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  73744. * i.e. when loading files, where the server/service expects an Authorization header
  73745. */
  73746. static CustomRequestHeaders: {
  73747. [key: string]: string;
  73748. };
  73749. /**
  73750. * Add callback functions in this array to update all the requests before they get sent to the network
  73751. */
  73752. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  73753. private _injectCustomRequestHeaders;
  73754. /**
  73755. * Gets or sets a function to be called when loading progress changes
  73756. */
  73757. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  73758. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  73759. /**
  73760. * Returns client's state
  73761. */
  73762. get readyState(): number;
  73763. /**
  73764. * Returns client's status
  73765. */
  73766. get status(): number;
  73767. /**
  73768. * Returns client's status as a text
  73769. */
  73770. get statusText(): string;
  73771. /**
  73772. * Returns client's response
  73773. */
  73774. get response(): any;
  73775. /**
  73776. * Returns client's response url
  73777. */
  73778. get responseURL(): string;
  73779. /**
  73780. * Returns client's response as text
  73781. */
  73782. get responseText(): string;
  73783. /**
  73784. * Gets or sets the expected response type
  73785. */
  73786. get responseType(): XMLHttpRequestResponseType;
  73787. set responseType(value: XMLHttpRequestResponseType);
  73788. /** @hidden */
  73789. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  73790. /** @hidden */
  73791. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  73792. /**
  73793. * Cancels any network activity
  73794. */
  73795. abort(): void;
  73796. /**
  73797. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  73798. * @param body defines an optional request body
  73799. */
  73800. send(body?: Document | BodyInit | null): void;
  73801. /**
  73802. * Sets the request method, request URL
  73803. * @param method defines the method to use (GET, POST, etc..)
  73804. * @param url defines the url to connect with
  73805. */
  73806. open(method: string, url: string): void;
  73807. /**
  73808. * Sets the value of a request header.
  73809. * @param name The name of the header whose value is to be set
  73810. * @param value The value to set as the body of the header
  73811. */
  73812. setRequestHeader(name: string, value: string): void;
  73813. /**
  73814. * Get the string containing the text of a particular header's value.
  73815. * @param name The name of the header
  73816. * @returns The string containing the text of the given header name
  73817. */
  73818. getResponseHeader(name: string): Nullable<string>;
  73819. }
  73820. }
  73821. declare module BABYLON {
  73822. /**
  73823. * File request interface
  73824. */
  73825. export interface IFileRequest {
  73826. /**
  73827. * Raised when the request is complete (success or error).
  73828. */
  73829. onCompleteObservable: Observable<IFileRequest>;
  73830. /**
  73831. * Aborts the request for a file.
  73832. */
  73833. abort: () => void;
  73834. }
  73835. }
  73836. declare module BABYLON {
  73837. /**
  73838. * Define options used to create a render target texture
  73839. */
  73840. export class RenderTargetCreationOptions {
  73841. /**
  73842. * Specifies is mipmaps must be generated
  73843. */
  73844. generateMipMaps?: boolean;
  73845. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  73846. generateDepthBuffer?: boolean;
  73847. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  73848. generateStencilBuffer?: boolean;
  73849. /** Defines texture type (int by default) */
  73850. type?: number;
  73851. /** Defines sampling mode (trilinear by default) */
  73852. samplingMode?: number;
  73853. /** Defines format (RGBA by default) */
  73854. format?: number;
  73855. }
  73856. }
  73857. declare module BABYLON {
  73858. /** Defines the cross module used constants to avoid circular dependncies */
  73859. export class Constants {
  73860. /** Defines that alpha blending is disabled */
  73861. static readonly ALPHA_DISABLE: number;
  73862. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  73863. static readonly ALPHA_ADD: number;
  73864. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  73865. static readonly ALPHA_COMBINE: number;
  73866. /** Defines that alpha blending is DEST - SRC * DEST */
  73867. static readonly ALPHA_SUBTRACT: number;
  73868. /** Defines that alpha blending is SRC * DEST */
  73869. static readonly ALPHA_MULTIPLY: number;
  73870. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  73871. static readonly ALPHA_MAXIMIZED: number;
  73872. /** Defines that alpha blending is SRC + DEST */
  73873. static readonly ALPHA_ONEONE: number;
  73874. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  73875. static readonly ALPHA_PREMULTIPLIED: number;
  73876. /**
  73877. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  73878. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  73879. */
  73880. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  73881. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  73882. static readonly ALPHA_INTERPOLATE: number;
  73883. /**
  73884. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  73885. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  73886. */
  73887. static readonly ALPHA_SCREENMODE: number;
  73888. /**
  73889. * Defines that alpha blending is SRC + DST
  73890. * Alpha will be set to SRC ALPHA + DST ALPHA
  73891. */
  73892. static readonly ALPHA_ONEONE_ONEONE: number;
  73893. /**
  73894. * Defines that alpha blending is SRC * DST ALPHA + DST
  73895. * Alpha will be set to 0
  73896. */
  73897. static readonly ALPHA_ALPHATOCOLOR: number;
  73898. /**
  73899. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  73900. */
  73901. static readonly ALPHA_REVERSEONEMINUS: number;
  73902. /**
  73903. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  73904. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  73905. */
  73906. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  73907. /**
  73908. * Defines that alpha blending is SRC + DST
  73909. * Alpha will be set to SRC ALPHA
  73910. */
  73911. static readonly ALPHA_ONEONE_ONEZERO: number;
  73912. /**
  73913. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  73914. * Alpha will be set to DST ALPHA
  73915. */
  73916. static readonly ALPHA_EXCLUSION: number;
  73917. /** Defines that alpha blending equation a SUM */
  73918. static readonly ALPHA_EQUATION_ADD: number;
  73919. /** Defines that alpha blending equation a SUBSTRACTION */
  73920. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  73921. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  73922. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  73923. /** Defines that alpha blending equation a MAX operation */
  73924. static readonly ALPHA_EQUATION_MAX: number;
  73925. /** Defines that alpha blending equation a MIN operation */
  73926. static readonly ALPHA_EQUATION_MIN: number;
  73927. /**
  73928. * Defines that alpha blending equation a DARKEN operation:
  73929. * It takes the min of the src and sums the alpha channels.
  73930. */
  73931. static readonly ALPHA_EQUATION_DARKEN: number;
  73932. /** Defines that the ressource is not delayed*/
  73933. static readonly DELAYLOADSTATE_NONE: number;
  73934. /** Defines that the ressource was successfully delay loaded */
  73935. static readonly DELAYLOADSTATE_LOADED: number;
  73936. /** Defines that the ressource is currently delay loading */
  73937. static readonly DELAYLOADSTATE_LOADING: number;
  73938. /** Defines that the ressource is delayed and has not started loading */
  73939. static readonly DELAYLOADSTATE_NOTLOADED: number;
  73940. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  73941. static readonly NEVER: number;
  73942. /** 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 */
  73943. static readonly ALWAYS: number;
  73944. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  73945. static readonly LESS: number;
  73946. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  73947. static readonly EQUAL: number;
  73948. /** 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 */
  73949. static readonly LEQUAL: number;
  73950. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  73951. static readonly GREATER: number;
  73952. /** 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 */
  73953. static readonly GEQUAL: number;
  73954. /** 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 */
  73955. static readonly NOTEQUAL: number;
  73956. /** Passed to stencilOperation to specify that stencil value must be kept */
  73957. static readonly KEEP: number;
  73958. /** Passed to stencilOperation to specify that stencil value must be replaced */
  73959. static readonly REPLACE: number;
  73960. /** Passed to stencilOperation to specify that stencil value must be incremented */
  73961. static readonly INCR: number;
  73962. /** Passed to stencilOperation to specify that stencil value must be decremented */
  73963. static readonly DECR: number;
  73964. /** Passed to stencilOperation to specify that stencil value must be inverted */
  73965. static readonly INVERT: number;
  73966. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  73967. static readonly INCR_WRAP: number;
  73968. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  73969. static readonly DECR_WRAP: number;
  73970. /** Texture is not repeating outside of 0..1 UVs */
  73971. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  73972. /** Texture is repeating outside of 0..1 UVs */
  73973. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  73974. /** Texture is repeating and mirrored */
  73975. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  73976. /** ALPHA */
  73977. static readonly TEXTUREFORMAT_ALPHA: number;
  73978. /** LUMINANCE */
  73979. static readonly TEXTUREFORMAT_LUMINANCE: number;
  73980. /** LUMINANCE_ALPHA */
  73981. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  73982. /** RGB */
  73983. static readonly TEXTUREFORMAT_RGB: number;
  73984. /** RGBA */
  73985. static readonly TEXTUREFORMAT_RGBA: number;
  73986. /** RED */
  73987. static readonly TEXTUREFORMAT_RED: number;
  73988. /** RED (2nd reference) */
  73989. static readonly TEXTUREFORMAT_R: number;
  73990. /** RG */
  73991. static readonly TEXTUREFORMAT_RG: number;
  73992. /** RED_INTEGER */
  73993. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  73994. /** RED_INTEGER (2nd reference) */
  73995. static readonly TEXTUREFORMAT_R_INTEGER: number;
  73996. /** RG_INTEGER */
  73997. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  73998. /** RGB_INTEGER */
  73999. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  74000. /** RGBA_INTEGER */
  74001. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  74002. /** UNSIGNED_BYTE */
  74003. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  74004. /** UNSIGNED_BYTE (2nd reference) */
  74005. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  74006. /** FLOAT */
  74007. static readonly TEXTURETYPE_FLOAT: number;
  74008. /** HALF_FLOAT */
  74009. static readonly TEXTURETYPE_HALF_FLOAT: number;
  74010. /** BYTE */
  74011. static readonly TEXTURETYPE_BYTE: number;
  74012. /** SHORT */
  74013. static readonly TEXTURETYPE_SHORT: number;
  74014. /** UNSIGNED_SHORT */
  74015. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  74016. /** INT */
  74017. static readonly TEXTURETYPE_INT: number;
  74018. /** UNSIGNED_INT */
  74019. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  74020. /** UNSIGNED_SHORT_4_4_4_4 */
  74021. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  74022. /** UNSIGNED_SHORT_5_5_5_1 */
  74023. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  74024. /** UNSIGNED_SHORT_5_6_5 */
  74025. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  74026. /** UNSIGNED_INT_2_10_10_10_REV */
  74027. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  74028. /** UNSIGNED_INT_24_8 */
  74029. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  74030. /** UNSIGNED_INT_10F_11F_11F_REV */
  74031. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  74032. /** UNSIGNED_INT_5_9_9_9_REV */
  74033. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  74034. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  74035. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  74036. /** nearest is mag = nearest and min = nearest and no mip */
  74037. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  74038. /** mag = nearest and min = nearest and mip = none */
  74039. static readonly TEXTURE_NEAREST_NEAREST: number;
  74040. /** Bilinear is mag = linear and min = linear and no mip */
  74041. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  74042. /** mag = linear and min = linear and mip = none */
  74043. static readonly TEXTURE_LINEAR_LINEAR: number;
  74044. /** Trilinear is mag = linear and min = linear and mip = linear */
  74045. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  74046. /** Trilinear is mag = linear and min = linear and mip = linear */
  74047. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  74048. /** mag = nearest and min = nearest and mip = nearest */
  74049. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  74050. /** mag = nearest and min = linear and mip = nearest */
  74051. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  74052. /** mag = nearest and min = linear and mip = linear */
  74053. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  74054. /** mag = nearest and min = linear and mip = none */
  74055. static readonly TEXTURE_NEAREST_LINEAR: number;
  74056. /** nearest is mag = nearest and min = nearest and mip = linear */
  74057. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  74058. /** mag = linear and min = nearest and mip = nearest */
  74059. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  74060. /** mag = linear and min = nearest and mip = linear */
  74061. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  74062. /** Bilinear is mag = linear and min = linear and mip = nearest */
  74063. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  74064. /** mag = linear and min = nearest and mip = none */
  74065. static readonly TEXTURE_LINEAR_NEAREST: number;
  74066. /** Explicit coordinates mode */
  74067. static readonly TEXTURE_EXPLICIT_MODE: number;
  74068. /** Spherical coordinates mode */
  74069. static readonly TEXTURE_SPHERICAL_MODE: number;
  74070. /** Planar coordinates mode */
  74071. static readonly TEXTURE_PLANAR_MODE: number;
  74072. /** Cubic coordinates mode */
  74073. static readonly TEXTURE_CUBIC_MODE: number;
  74074. /** Projection coordinates mode */
  74075. static readonly TEXTURE_PROJECTION_MODE: number;
  74076. /** Skybox coordinates mode */
  74077. static readonly TEXTURE_SKYBOX_MODE: number;
  74078. /** Inverse Cubic coordinates mode */
  74079. static readonly TEXTURE_INVCUBIC_MODE: number;
  74080. /** Equirectangular coordinates mode */
  74081. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  74082. /** Equirectangular Fixed coordinates mode */
  74083. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  74084. /** Equirectangular Fixed Mirrored coordinates mode */
  74085. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  74086. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  74087. static readonly SCALEMODE_FLOOR: number;
  74088. /** Defines that texture rescaling will look for the nearest power of 2 size */
  74089. static readonly SCALEMODE_NEAREST: number;
  74090. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  74091. static readonly SCALEMODE_CEILING: number;
  74092. /**
  74093. * The dirty texture flag value
  74094. */
  74095. static readonly MATERIAL_TextureDirtyFlag: number;
  74096. /**
  74097. * The dirty light flag value
  74098. */
  74099. static readonly MATERIAL_LightDirtyFlag: number;
  74100. /**
  74101. * The dirty fresnel flag value
  74102. */
  74103. static readonly MATERIAL_FresnelDirtyFlag: number;
  74104. /**
  74105. * The dirty attribute flag value
  74106. */
  74107. static readonly MATERIAL_AttributesDirtyFlag: number;
  74108. /**
  74109. * The dirty misc flag value
  74110. */
  74111. static readonly MATERIAL_MiscDirtyFlag: number;
  74112. /**
  74113. * The all dirty flag value
  74114. */
  74115. static readonly MATERIAL_AllDirtyFlag: number;
  74116. /**
  74117. * Returns the triangle fill mode
  74118. */
  74119. static readonly MATERIAL_TriangleFillMode: number;
  74120. /**
  74121. * Returns the wireframe mode
  74122. */
  74123. static readonly MATERIAL_WireFrameFillMode: number;
  74124. /**
  74125. * Returns the point fill mode
  74126. */
  74127. static readonly MATERIAL_PointFillMode: number;
  74128. /**
  74129. * Returns the point list draw mode
  74130. */
  74131. static readonly MATERIAL_PointListDrawMode: number;
  74132. /**
  74133. * Returns the line list draw mode
  74134. */
  74135. static readonly MATERIAL_LineListDrawMode: number;
  74136. /**
  74137. * Returns the line loop draw mode
  74138. */
  74139. static readonly MATERIAL_LineLoopDrawMode: number;
  74140. /**
  74141. * Returns the line strip draw mode
  74142. */
  74143. static readonly MATERIAL_LineStripDrawMode: number;
  74144. /**
  74145. * Returns the triangle strip draw mode
  74146. */
  74147. static readonly MATERIAL_TriangleStripDrawMode: number;
  74148. /**
  74149. * Returns the triangle fan draw mode
  74150. */
  74151. static readonly MATERIAL_TriangleFanDrawMode: number;
  74152. /**
  74153. * Stores the clock-wise side orientation
  74154. */
  74155. static readonly MATERIAL_ClockWiseSideOrientation: number;
  74156. /**
  74157. * Stores the counter clock-wise side orientation
  74158. */
  74159. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  74160. /**
  74161. * Nothing
  74162. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74163. */
  74164. static readonly ACTION_NothingTrigger: number;
  74165. /**
  74166. * On pick
  74167. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74168. */
  74169. static readonly ACTION_OnPickTrigger: number;
  74170. /**
  74171. * On left pick
  74172. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74173. */
  74174. static readonly ACTION_OnLeftPickTrigger: number;
  74175. /**
  74176. * On right pick
  74177. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74178. */
  74179. static readonly ACTION_OnRightPickTrigger: number;
  74180. /**
  74181. * On center pick
  74182. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74183. */
  74184. static readonly ACTION_OnCenterPickTrigger: number;
  74185. /**
  74186. * On pick down
  74187. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74188. */
  74189. static readonly ACTION_OnPickDownTrigger: number;
  74190. /**
  74191. * On double pick
  74192. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74193. */
  74194. static readonly ACTION_OnDoublePickTrigger: number;
  74195. /**
  74196. * On pick up
  74197. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74198. */
  74199. static readonly ACTION_OnPickUpTrigger: number;
  74200. /**
  74201. * On pick out.
  74202. * This trigger will only be raised if you also declared a OnPickDown
  74203. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74204. */
  74205. static readonly ACTION_OnPickOutTrigger: number;
  74206. /**
  74207. * On long press
  74208. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74209. */
  74210. static readonly ACTION_OnLongPressTrigger: number;
  74211. /**
  74212. * On pointer over
  74213. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74214. */
  74215. static readonly ACTION_OnPointerOverTrigger: number;
  74216. /**
  74217. * On pointer out
  74218. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74219. */
  74220. static readonly ACTION_OnPointerOutTrigger: number;
  74221. /**
  74222. * On every frame
  74223. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74224. */
  74225. static readonly ACTION_OnEveryFrameTrigger: number;
  74226. /**
  74227. * On intersection enter
  74228. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74229. */
  74230. static readonly ACTION_OnIntersectionEnterTrigger: number;
  74231. /**
  74232. * On intersection exit
  74233. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74234. */
  74235. static readonly ACTION_OnIntersectionExitTrigger: number;
  74236. /**
  74237. * On key down
  74238. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74239. */
  74240. static readonly ACTION_OnKeyDownTrigger: number;
  74241. /**
  74242. * On key up
  74243. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74244. */
  74245. static readonly ACTION_OnKeyUpTrigger: number;
  74246. /**
  74247. * Billboard mode will only apply to Y axis
  74248. */
  74249. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  74250. /**
  74251. * Billboard mode will apply to all axes
  74252. */
  74253. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  74254. /**
  74255. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  74256. */
  74257. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  74258. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  74259. * Test order :
  74260. * Is the bounding sphere outside the frustum ?
  74261. * If not, are the bounding box vertices outside the frustum ?
  74262. * It not, then the cullable object is in the frustum.
  74263. */
  74264. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  74265. /** Culling strategy : Bounding Sphere Only.
  74266. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  74267. * It's also less accurate than the standard because some not visible objects can still be selected.
  74268. * Test : is the bounding sphere outside the frustum ?
  74269. * If not, then the cullable object is in the frustum.
  74270. */
  74271. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  74272. /** Culling strategy : Optimistic Inclusion.
  74273. * This in an inclusion test first, then the standard exclusion test.
  74274. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  74275. * 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.
  74276. * Anyway, it's as accurate as the standard strategy.
  74277. * Test :
  74278. * Is the cullable object bounding sphere center in the frustum ?
  74279. * If not, apply the default culling strategy.
  74280. */
  74281. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  74282. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  74283. * This in an inclusion test first, then the bounding sphere only exclusion test.
  74284. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  74285. * 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.
  74286. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  74287. * Test :
  74288. * Is the cullable object bounding sphere center in the frustum ?
  74289. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  74290. */
  74291. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  74292. /**
  74293. * No logging while loading
  74294. */
  74295. static readonly SCENELOADER_NO_LOGGING: number;
  74296. /**
  74297. * Minimal logging while loading
  74298. */
  74299. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  74300. /**
  74301. * Summary logging while loading
  74302. */
  74303. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  74304. /**
  74305. * Detailled logging while loading
  74306. */
  74307. static readonly SCENELOADER_DETAILED_LOGGING: number;
  74308. }
  74309. }
  74310. declare module BABYLON {
  74311. /**
  74312. * This represents the required contract to create a new type of texture loader.
  74313. */
  74314. export interface IInternalTextureLoader {
  74315. /**
  74316. * Defines wether the loader supports cascade loading the different faces.
  74317. */
  74318. supportCascades: boolean;
  74319. /**
  74320. * This returns if the loader support the current file information.
  74321. * @param extension defines the file extension of the file being loaded
  74322. * @param textureFormatInUse defines the current compressed format in use iun the engine
  74323. * @param fallback defines the fallback internal texture if any
  74324. * @param isBase64 defines whether the texture is encoded as a base64
  74325. * @param isBuffer defines whether the texture data are stored as a buffer
  74326. * @returns true if the loader can load the specified file
  74327. */
  74328. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  74329. /**
  74330. * Transform the url before loading if required.
  74331. * @param rootUrl the url of the texture
  74332. * @param textureFormatInUse defines the current compressed format in use iun the engine
  74333. * @returns the transformed texture
  74334. */
  74335. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  74336. /**
  74337. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  74338. * @param rootUrl the url of the texture
  74339. * @param textureFormatInUse defines the current compressed format in use iun the engine
  74340. * @returns the fallback texture
  74341. */
  74342. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  74343. /**
  74344. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  74345. * @param data contains the texture data
  74346. * @param texture defines the BabylonJS internal texture
  74347. * @param createPolynomials will be true if polynomials have been requested
  74348. * @param onLoad defines the callback to trigger once the texture is ready
  74349. * @param onError defines the callback to trigger in case of error
  74350. */
  74351. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  74352. /**
  74353. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  74354. * @param data contains the texture data
  74355. * @param texture defines the BabylonJS internal texture
  74356. * @param callback defines the method to call once ready to upload
  74357. */
  74358. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  74359. }
  74360. }
  74361. declare module BABYLON {
  74362. /**
  74363. * Class used to store and describe the pipeline context associated with an effect
  74364. */
  74365. export interface IPipelineContext {
  74366. /**
  74367. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  74368. */
  74369. isAsync: boolean;
  74370. /**
  74371. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  74372. */
  74373. isReady: boolean;
  74374. /** @hidden */
  74375. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  74376. }
  74377. }
  74378. declare module BABYLON {
  74379. /**
  74380. * Class used to store gfx data (like WebGLBuffer)
  74381. */
  74382. export class DataBuffer {
  74383. /**
  74384. * Gets or sets the number of objects referencing this buffer
  74385. */
  74386. references: number;
  74387. /** Gets or sets the size of the underlying buffer */
  74388. capacity: number;
  74389. /**
  74390. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  74391. */
  74392. is32Bits: boolean;
  74393. /**
  74394. * Gets the underlying buffer
  74395. */
  74396. get underlyingResource(): any;
  74397. }
  74398. }
  74399. declare module BABYLON {
  74400. /** @hidden */
  74401. export interface IShaderProcessor {
  74402. attributeProcessor?: (attribute: string) => string;
  74403. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  74404. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  74405. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  74406. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  74407. lineProcessor?: (line: string, isFragment: boolean) => string;
  74408. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  74409. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  74410. }
  74411. }
  74412. declare module BABYLON {
  74413. /** @hidden */
  74414. export interface ProcessingOptions {
  74415. defines: string[];
  74416. indexParameters: any;
  74417. isFragment: boolean;
  74418. shouldUseHighPrecisionShader: boolean;
  74419. supportsUniformBuffers: boolean;
  74420. shadersRepository: string;
  74421. includesShadersStore: {
  74422. [key: string]: string;
  74423. };
  74424. processor?: IShaderProcessor;
  74425. version: string;
  74426. platformName: string;
  74427. lookForClosingBracketForUniformBuffer?: boolean;
  74428. }
  74429. }
  74430. declare module BABYLON {
  74431. /** @hidden */
  74432. export class ShaderCodeNode {
  74433. line: string;
  74434. children: ShaderCodeNode[];
  74435. additionalDefineKey?: string;
  74436. additionalDefineValue?: string;
  74437. isValid(preprocessors: {
  74438. [key: string]: string;
  74439. }): boolean;
  74440. process(preprocessors: {
  74441. [key: string]: string;
  74442. }, options: ProcessingOptions): string;
  74443. }
  74444. }
  74445. declare module BABYLON {
  74446. /** @hidden */
  74447. export class ShaderCodeCursor {
  74448. private _lines;
  74449. lineIndex: number;
  74450. get currentLine(): string;
  74451. get canRead(): boolean;
  74452. set lines(value: string[]);
  74453. }
  74454. }
  74455. declare module BABYLON {
  74456. /** @hidden */
  74457. export class ShaderCodeConditionNode extends ShaderCodeNode {
  74458. process(preprocessors: {
  74459. [key: string]: string;
  74460. }, options: ProcessingOptions): string;
  74461. }
  74462. }
  74463. declare module BABYLON {
  74464. /** @hidden */
  74465. export class ShaderDefineExpression {
  74466. isTrue(preprocessors: {
  74467. [key: string]: string;
  74468. }): boolean;
  74469. }
  74470. }
  74471. declare module BABYLON {
  74472. /** @hidden */
  74473. export class ShaderCodeTestNode extends ShaderCodeNode {
  74474. testExpression: ShaderDefineExpression;
  74475. isValid(preprocessors: {
  74476. [key: string]: string;
  74477. }): boolean;
  74478. }
  74479. }
  74480. declare module BABYLON {
  74481. /** @hidden */
  74482. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  74483. define: string;
  74484. not: boolean;
  74485. constructor(define: string, not?: boolean);
  74486. isTrue(preprocessors: {
  74487. [key: string]: string;
  74488. }): boolean;
  74489. }
  74490. }
  74491. declare module BABYLON {
  74492. /** @hidden */
  74493. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  74494. leftOperand: ShaderDefineExpression;
  74495. rightOperand: ShaderDefineExpression;
  74496. isTrue(preprocessors: {
  74497. [key: string]: string;
  74498. }): boolean;
  74499. }
  74500. }
  74501. declare module BABYLON {
  74502. /** @hidden */
  74503. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  74504. leftOperand: ShaderDefineExpression;
  74505. rightOperand: ShaderDefineExpression;
  74506. isTrue(preprocessors: {
  74507. [key: string]: string;
  74508. }): boolean;
  74509. }
  74510. }
  74511. declare module BABYLON {
  74512. /** @hidden */
  74513. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  74514. define: string;
  74515. operand: string;
  74516. testValue: string;
  74517. constructor(define: string, operand: string, testValue: string);
  74518. isTrue(preprocessors: {
  74519. [key: string]: string;
  74520. }): boolean;
  74521. }
  74522. }
  74523. declare module BABYLON {
  74524. /**
  74525. * Class used to enable access to offline support
  74526. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  74527. */
  74528. export interface IOfflineProvider {
  74529. /**
  74530. * Gets a boolean indicating if scene must be saved in the database
  74531. */
  74532. enableSceneOffline: boolean;
  74533. /**
  74534. * Gets a boolean indicating if textures must be saved in the database
  74535. */
  74536. enableTexturesOffline: boolean;
  74537. /**
  74538. * Open the offline support and make it available
  74539. * @param successCallback defines the callback to call on success
  74540. * @param errorCallback defines the callback to call on error
  74541. */
  74542. open(successCallback: () => void, errorCallback: () => void): void;
  74543. /**
  74544. * Loads an image from the offline support
  74545. * @param url defines the url to load from
  74546. * @param image defines the target DOM image
  74547. */
  74548. loadImage(url: string, image: HTMLImageElement): void;
  74549. /**
  74550. * Loads a file from offline support
  74551. * @param url defines the URL to load from
  74552. * @param sceneLoaded defines a callback to call on success
  74553. * @param progressCallBack defines a callback to call when progress changed
  74554. * @param errorCallback defines a callback to call on error
  74555. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  74556. */
  74557. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  74558. }
  74559. }
  74560. declare module BABYLON {
  74561. /**
  74562. * Class used to help managing file picking and drag'n'drop
  74563. * File Storage
  74564. */
  74565. export class FilesInputStore {
  74566. /**
  74567. * List of files ready to be loaded
  74568. */
  74569. static FilesToLoad: {
  74570. [key: string]: File;
  74571. };
  74572. }
  74573. }
  74574. declare module BABYLON {
  74575. /**
  74576. * Class used to define a retry strategy when error happens while loading assets
  74577. */
  74578. export class RetryStrategy {
  74579. /**
  74580. * Function used to defines an exponential back off strategy
  74581. * @param maxRetries defines the maximum number of retries (3 by default)
  74582. * @param baseInterval defines the interval between retries
  74583. * @returns the strategy function to use
  74584. */
  74585. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  74586. }
  74587. }
  74588. declare module BABYLON {
  74589. /**
  74590. * @ignore
  74591. * Application error to support additional information when loading a file
  74592. */
  74593. export abstract class BaseError extends Error {
  74594. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  74595. }
  74596. }
  74597. declare module BABYLON {
  74598. /** @ignore */
  74599. export class LoadFileError extends BaseError {
  74600. request?: WebRequest;
  74601. file?: File;
  74602. /**
  74603. * Creates a new LoadFileError
  74604. * @param message defines the message of the error
  74605. * @param request defines the optional web request
  74606. * @param file defines the optional file
  74607. */
  74608. constructor(message: string, object?: WebRequest | File);
  74609. }
  74610. /** @ignore */
  74611. export class RequestFileError extends BaseError {
  74612. request: WebRequest;
  74613. /**
  74614. * Creates a new LoadFileError
  74615. * @param message defines the message of the error
  74616. * @param request defines the optional web request
  74617. */
  74618. constructor(message: string, request: WebRequest);
  74619. }
  74620. /** @ignore */
  74621. export class ReadFileError extends BaseError {
  74622. file: File;
  74623. /**
  74624. * Creates a new ReadFileError
  74625. * @param message defines the message of the error
  74626. * @param file defines the optional file
  74627. */
  74628. constructor(message: string, file: File);
  74629. }
  74630. /**
  74631. * @hidden
  74632. */
  74633. export class FileTools {
  74634. /**
  74635. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  74636. */
  74637. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  74638. /**
  74639. * Gets or sets the base URL to use to load assets
  74640. */
  74641. static BaseUrl: string;
  74642. /**
  74643. * Default behaviour for cors in the application.
  74644. * It can be a string if the expected behavior is identical in the entire app.
  74645. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  74646. */
  74647. static CorsBehavior: string | ((url: string | string[]) => string);
  74648. /**
  74649. * Gets or sets a function used to pre-process url before using them to load assets
  74650. */
  74651. static PreprocessUrl: (url: string) => string;
  74652. /**
  74653. * Removes unwanted characters from an url
  74654. * @param url defines the url to clean
  74655. * @returns the cleaned url
  74656. */
  74657. private static _CleanUrl;
  74658. /**
  74659. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  74660. * @param url define the url we are trying
  74661. * @param element define the dom element where to configure the cors policy
  74662. */
  74663. static SetCorsBehavior(url: string | string[], element: {
  74664. crossOrigin: string | null;
  74665. }): void;
  74666. /**
  74667. * Loads an image as an HTMLImageElement.
  74668. * @param input url string, ArrayBuffer, or Blob to load
  74669. * @param onLoad callback called when the image successfully loads
  74670. * @param onError callback called when the image fails to load
  74671. * @param offlineProvider offline provider for caching
  74672. * @param mimeType optional mime type
  74673. * @returns the HTMLImageElement of the loaded image
  74674. */
  74675. 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>;
  74676. /**
  74677. * Reads a file from a File object
  74678. * @param file defines the file to load
  74679. * @param onSuccess defines the callback to call when data is loaded
  74680. * @param onProgress defines the callback to call during loading process
  74681. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  74682. * @param onError defines the callback to call when an error occurs
  74683. * @returns a file request object
  74684. */
  74685. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  74686. /**
  74687. * Loads a file from a url
  74688. * @param url url to load
  74689. * @param onSuccess callback called when the file successfully loads
  74690. * @param onProgress callback called while file is loading (if the server supports this mode)
  74691. * @param offlineProvider defines the offline provider for caching
  74692. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74693. * @param onError callback called when the file fails to load
  74694. * @returns a file request object
  74695. */
  74696. 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;
  74697. /**
  74698. * Loads a file
  74699. * @param url url to load
  74700. * @param onSuccess callback called when the file successfully loads
  74701. * @param onProgress callback called while file is loading (if the server supports this mode)
  74702. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74703. * @param onError callback called when the file fails to load
  74704. * @param onOpened callback called when the web request is opened
  74705. * @returns a file request object
  74706. */
  74707. 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;
  74708. /**
  74709. * Checks if the loaded document was accessed via `file:`-Protocol.
  74710. * @returns boolean
  74711. */
  74712. static IsFileURL(): boolean;
  74713. }
  74714. }
  74715. declare module BABYLON {
  74716. /** @hidden */
  74717. export class ShaderProcessor {
  74718. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  74719. private static _ProcessPrecision;
  74720. private static _ExtractOperation;
  74721. private static _BuildSubExpression;
  74722. private static _BuildExpression;
  74723. private static _MoveCursorWithinIf;
  74724. private static _MoveCursor;
  74725. private static _EvaluatePreProcessors;
  74726. private static _PreparePreProcessors;
  74727. private static _ProcessShaderConversion;
  74728. private static _ProcessIncludes;
  74729. /**
  74730. * Loads a file from a url
  74731. * @param url url to load
  74732. * @param onSuccess callback called when the file successfully loads
  74733. * @param onProgress callback called while file is loading (if the server supports this mode)
  74734. * @param offlineProvider defines the offline provider for caching
  74735. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74736. * @param onError callback called when the file fails to load
  74737. * @returns a file request object
  74738. * @hidden
  74739. */
  74740. 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;
  74741. }
  74742. }
  74743. declare module BABYLON {
  74744. /**
  74745. * @hidden
  74746. */
  74747. export interface IColor4Like {
  74748. r: float;
  74749. g: float;
  74750. b: float;
  74751. a: float;
  74752. }
  74753. /**
  74754. * @hidden
  74755. */
  74756. export interface IColor3Like {
  74757. r: float;
  74758. g: float;
  74759. b: float;
  74760. }
  74761. /**
  74762. * @hidden
  74763. */
  74764. export interface IVector4Like {
  74765. x: float;
  74766. y: float;
  74767. z: float;
  74768. w: float;
  74769. }
  74770. /**
  74771. * @hidden
  74772. */
  74773. export interface IVector3Like {
  74774. x: float;
  74775. y: float;
  74776. z: float;
  74777. }
  74778. /**
  74779. * @hidden
  74780. */
  74781. export interface IVector2Like {
  74782. x: float;
  74783. y: float;
  74784. }
  74785. /**
  74786. * @hidden
  74787. */
  74788. export interface IMatrixLike {
  74789. toArray(): DeepImmutable<Float32Array>;
  74790. updateFlag: int;
  74791. }
  74792. /**
  74793. * @hidden
  74794. */
  74795. export interface IViewportLike {
  74796. x: float;
  74797. y: float;
  74798. width: float;
  74799. height: float;
  74800. }
  74801. /**
  74802. * @hidden
  74803. */
  74804. export interface IPlaneLike {
  74805. normal: IVector3Like;
  74806. d: float;
  74807. normalize(): void;
  74808. }
  74809. }
  74810. declare module BABYLON {
  74811. /**
  74812. * Interface used to define common properties for effect fallbacks
  74813. */
  74814. export interface IEffectFallbacks {
  74815. /**
  74816. * Removes the defines that should be removed when falling back.
  74817. * @param currentDefines defines the current define statements for the shader.
  74818. * @param effect defines the current effect we try to compile
  74819. * @returns The resulting defines with defines of the current rank removed.
  74820. */
  74821. reduce(currentDefines: string, effect: Effect): string;
  74822. /**
  74823. * Removes the fallback from the bound mesh.
  74824. */
  74825. unBindMesh(): void;
  74826. /**
  74827. * Checks to see if more fallbacks are still availible.
  74828. */
  74829. hasMoreFallbacks: boolean;
  74830. }
  74831. }
  74832. declare module BABYLON {
  74833. /**
  74834. * Class used to evalaute queries containing `and` and `or` operators
  74835. */
  74836. export class AndOrNotEvaluator {
  74837. /**
  74838. * Evaluate a query
  74839. * @param query defines the query to evaluate
  74840. * @param evaluateCallback defines the callback used to filter result
  74841. * @returns true if the query matches
  74842. */
  74843. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  74844. private static _HandleParenthesisContent;
  74845. private static _SimplifyNegation;
  74846. }
  74847. }
  74848. declare module BABYLON {
  74849. /**
  74850. * Class used to store custom tags
  74851. */
  74852. export class Tags {
  74853. /**
  74854. * Adds support for tags on the given object
  74855. * @param obj defines the object to use
  74856. */
  74857. static EnableFor(obj: any): void;
  74858. /**
  74859. * Removes tags support
  74860. * @param obj defines the object to use
  74861. */
  74862. static DisableFor(obj: any): void;
  74863. /**
  74864. * Gets a boolean indicating if the given object has tags
  74865. * @param obj defines the object to use
  74866. * @returns a boolean
  74867. */
  74868. static HasTags(obj: any): boolean;
  74869. /**
  74870. * Gets the tags available on a given object
  74871. * @param obj defines the object to use
  74872. * @param asString defines if the tags must be returned as a string instead of an array of strings
  74873. * @returns the tags
  74874. */
  74875. static GetTags(obj: any, asString?: boolean): any;
  74876. /**
  74877. * Adds tags to an object
  74878. * @param obj defines the object to use
  74879. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  74880. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  74881. */
  74882. static AddTagsTo(obj: any, tagsString: string): void;
  74883. /**
  74884. * @hidden
  74885. */
  74886. static _AddTagTo(obj: any, tag: string): void;
  74887. /**
  74888. * Removes specific tags from a specific object
  74889. * @param obj defines the object to use
  74890. * @param tagsString defines the tags to remove
  74891. */
  74892. static RemoveTagsFrom(obj: any, tagsString: string): void;
  74893. /**
  74894. * @hidden
  74895. */
  74896. static _RemoveTagFrom(obj: any, tag: string): void;
  74897. /**
  74898. * Defines if tags hosted on an object match a given query
  74899. * @param obj defines the object to use
  74900. * @param tagsQuery defines the tag query
  74901. * @returns a boolean
  74902. */
  74903. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  74904. }
  74905. }
  74906. declare module BABYLON {
  74907. /**
  74908. * Scalar computation library
  74909. */
  74910. export class Scalar {
  74911. /**
  74912. * Two pi constants convenient for computation.
  74913. */
  74914. static TwoPi: number;
  74915. /**
  74916. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74917. * @param a number
  74918. * @param b number
  74919. * @param epsilon (default = 1.401298E-45)
  74920. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74921. */
  74922. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  74923. /**
  74924. * Returns a string : the upper case translation of the number i to hexadecimal.
  74925. * @param i number
  74926. * @returns the upper case translation of the number i to hexadecimal.
  74927. */
  74928. static ToHex(i: number): string;
  74929. /**
  74930. * Returns -1 if value is negative and +1 is value is positive.
  74931. * @param value the value
  74932. * @returns the value itself if it's equal to zero.
  74933. */
  74934. static Sign(value: number): number;
  74935. /**
  74936. * Returns the value itself if it's between min and max.
  74937. * Returns min if the value is lower than min.
  74938. * Returns max if the value is greater than max.
  74939. * @param value the value to clmap
  74940. * @param min the min value to clamp to (default: 0)
  74941. * @param max the max value to clamp to (default: 1)
  74942. * @returns the clamped value
  74943. */
  74944. static Clamp(value: number, min?: number, max?: number): number;
  74945. /**
  74946. * the log2 of value.
  74947. * @param value the value to compute log2 of
  74948. * @returns the log2 of value.
  74949. */
  74950. static Log2(value: number): number;
  74951. /**
  74952. * Loops the value, so that it is never larger than length and never smaller than 0.
  74953. *
  74954. * This is similar to the modulo operator but it works with floating point numbers.
  74955. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  74956. * With t = 5 and length = 2.5, the result would be 0.0.
  74957. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  74958. * @param value the value
  74959. * @param length the length
  74960. * @returns the looped value
  74961. */
  74962. static Repeat(value: number, length: number): number;
  74963. /**
  74964. * Normalize the value between 0.0 and 1.0 using min and max values
  74965. * @param value value to normalize
  74966. * @param min max to normalize between
  74967. * @param max min to normalize between
  74968. * @returns the normalized value
  74969. */
  74970. static Normalize(value: number, min: number, max: number): number;
  74971. /**
  74972. * Denormalize the value from 0.0 and 1.0 using min and max values
  74973. * @param normalized value to denormalize
  74974. * @param min max to denormalize between
  74975. * @param max min to denormalize between
  74976. * @returns the denormalized value
  74977. */
  74978. static Denormalize(normalized: number, min: number, max: number): number;
  74979. /**
  74980. * Calculates the shortest difference between two given angles given in degrees.
  74981. * @param current current angle in degrees
  74982. * @param target target angle in degrees
  74983. * @returns the delta
  74984. */
  74985. static DeltaAngle(current: number, target: number): number;
  74986. /**
  74987. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  74988. * @param tx value
  74989. * @param length length
  74990. * @returns The returned value will move back and forth between 0 and length
  74991. */
  74992. static PingPong(tx: number, length: number): number;
  74993. /**
  74994. * Interpolates between min and max with smoothing at the limits.
  74995. *
  74996. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  74997. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  74998. * @param from from
  74999. * @param to to
  75000. * @param tx value
  75001. * @returns the smooth stepped value
  75002. */
  75003. static SmoothStep(from: number, to: number, tx: number): number;
  75004. /**
  75005. * Moves a value current towards target.
  75006. *
  75007. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  75008. * Negative values of maxDelta pushes the value away from target.
  75009. * @param current current value
  75010. * @param target target value
  75011. * @param maxDelta max distance to move
  75012. * @returns resulting value
  75013. */
  75014. static MoveTowards(current: number, target: number, maxDelta: number): number;
  75015. /**
  75016. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  75017. *
  75018. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  75019. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  75020. * @param current current value
  75021. * @param target target value
  75022. * @param maxDelta max distance to move
  75023. * @returns resulting angle
  75024. */
  75025. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  75026. /**
  75027. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  75028. * @param start start value
  75029. * @param end target value
  75030. * @param amount amount to lerp between
  75031. * @returns the lerped value
  75032. */
  75033. static Lerp(start: number, end: number, amount: number): number;
  75034. /**
  75035. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  75036. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  75037. * @param start start value
  75038. * @param end target value
  75039. * @param amount amount to lerp between
  75040. * @returns the lerped value
  75041. */
  75042. static LerpAngle(start: number, end: number, amount: number): number;
  75043. /**
  75044. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  75045. * @param a start value
  75046. * @param b target value
  75047. * @param value value between a and b
  75048. * @returns the inverseLerp value
  75049. */
  75050. static InverseLerp(a: number, b: number, value: number): number;
  75051. /**
  75052. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  75053. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  75054. * @param value1 spline value
  75055. * @param tangent1 spline value
  75056. * @param value2 spline value
  75057. * @param tangent2 spline value
  75058. * @param amount input value
  75059. * @returns hermite result
  75060. */
  75061. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  75062. /**
  75063. * Returns a random float number between and min and max values
  75064. * @param min min value of random
  75065. * @param max max value of random
  75066. * @returns random value
  75067. */
  75068. static RandomRange(min: number, max: number): number;
  75069. /**
  75070. * This function returns percentage of a number in a given range.
  75071. *
  75072. * RangeToPercent(40,20,60) will return 0.5 (50%)
  75073. * RangeToPercent(34,0,100) will return 0.34 (34%)
  75074. * @param number to convert to percentage
  75075. * @param min min range
  75076. * @param max max range
  75077. * @returns the percentage
  75078. */
  75079. static RangeToPercent(number: number, min: number, max: number): number;
  75080. /**
  75081. * This function returns number that corresponds to the percentage in a given range.
  75082. *
  75083. * PercentToRange(0.34,0,100) will return 34.
  75084. * @param percent to convert to number
  75085. * @param min min range
  75086. * @param max max range
  75087. * @returns the number
  75088. */
  75089. static PercentToRange(percent: number, min: number, max: number): number;
  75090. /**
  75091. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  75092. * @param angle The angle to normalize in radian.
  75093. * @return The converted angle.
  75094. */
  75095. static NormalizeRadians(angle: number): number;
  75096. }
  75097. }
  75098. declare module BABYLON {
  75099. /**
  75100. * Constant used to convert a value to gamma space
  75101. * @ignorenaming
  75102. */
  75103. export const ToGammaSpace: number;
  75104. /**
  75105. * Constant used to convert a value to linear space
  75106. * @ignorenaming
  75107. */
  75108. export const ToLinearSpace = 2.2;
  75109. /**
  75110. * Constant used to define the minimal number value in Babylon.js
  75111. * @ignorenaming
  75112. */
  75113. let Epsilon: number;
  75114. }
  75115. declare module BABYLON {
  75116. /**
  75117. * Class used to represent a viewport on screen
  75118. */
  75119. export class Viewport {
  75120. /** viewport left coordinate */
  75121. x: number;
  75122. /** viewport top coordinate */
  75123. y: number;
  75124. /**viewport width */
  75125. width: number;
  75126. /** viewport height */
  75127. height: number;
  75128. /**
  75129. * Creates a Viewport object located at (x, y) and sized (width, height)
  75130. * @param x defines viewport left coordinate
  75131. * @param y defines viewport top coordinate
  75132. * @param width defines the viewport width
  75133. * @param height defines the viewport height
  75134. */
  75135. constructor(
  75136. /** viewport left coordinate */
  75137. x: number,
  75138. /** viewport top coordinate */
  75139. y: number,
  75140. /**viewport width */
  75141. width: number,
  75142. /** viewport height */
  75143. height: number);
  75144. /**
  75145. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  75146. * @param renderWidth defines the rendering width
  75147. * @param renderHeight defines the rendering height
  75148. * @returns a new Viewport
  75149. */
  75150. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  75151. /**
  75152. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  75153. * @param renderWidth defines the rendering width
  75154. * @param renderHeight defines the rendering height
  75155. * @param ref defines the target viewport
  75156. * @returns the current viewport
  75157. */
  75158. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  75159. /**
  75160. * Returns a new Viewport copied from the current one
  75161. * @returns a new Viewport
  75162. */
  75163. clone(): Viewport;
  75164. }
  75165. }
  75166. declare module BABYLON {
  75167. /**
  75168. * Class containing a set of static utilities functions for arrays.
  75169. */
  75170. export class ArrayTools {
  75171. /**
  75172. * Returns an array of the given size filled with element built from the given constructor and the paramters
  75173. * @param size the number of element to construct and put in the array
  75174. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  75175. * @returns a new array filled with new objects
  75176. */
  75177. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  75178. }
  75179. }
  75180. declare module BABYLON {
  75181. /**
  75182. * Class representing a vector containing 2 coordinates
  75183. */
  75184. export class Vector2 {
  75185. /** defines the first coordinate */
  75186. x: number;
  75187. /** defines the second coordinate */
  75188. y: number;
  75189. /**
  75190. * Creates a new Vector2 from the given x and y coordinates
  75191. * @param x defines the first coordinate
  75192. * @param y defines the second coordinate
  75193. */
  75194. constructor(
  75195. /** defines the first coordinate */
  75196. x?: number,
  75197. /** defines the second coordinate */
  75198. y?: number);
  75199. /**
  75200. * Gets a string with the Vector2 coordinates
  75201. * @returns a string with the Vector2 coordinates
  75202. */
  75203. toString(): string;
  75204. /**
  75205. * Gets class name
  75206. * @returns the string "Vector2"
  75207. */
  75208. getClassName(): string;
  75209. /**
  75210. * Gets current vector hash code
  75211. * @returns the Vector2 hash code as a number
  75212. */
  75213. getHashCode(): number;
  75214. /**
  75215. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  75216. * @param array defines the source array
  75217. * @param index defines the offset in source array
  75218. * @returns the current Vector2
  75219. */
  75220. toArray(array: FloatArray, index?: number): Vector2;
  75221. /**
  75222. * Copy the current vector to an array
  75223. * @returns a new array with 2 elements: the Vector2 coordinates.
  75224. */
  75225. asArray(): number[];
  75226. /**
  75227. * Sets the Vector2 coordinates with the given Vector2 coordinates
  75228. * @param source defines the source Vector2
  75229. * @returns the current updated Vector2
  75230. */
  75231. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  75232. /**
  75233. * Sets the Vector2 coordinates with the given floats
  75234. * @param x defines the first coordinate
  75235. * @param y defines the second coordinate
  75236. * @returns the current updated Vector2
  75237. */
  75238. copyFromFloats(x: number, y: number): Vector2;
  75239. /**
  75240. * Sets the Vector2 coordinates with the given floats
  75241. * @param x defines the first coordinate
  75242. * @param y defines the second coordinate
  75243. * @returns the current updated Vector2
  75244. */
  75245. set(x: number, y: number): Vector2;
  75246. /**
  75247. * Add another vector with the current one
  75248. * @param otherVector defines the other vector
  75249. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  75250. */
  75251. add(otherVector: DeepImmutable<Vector2>): Vector2;
  75252. /**
  75253. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  75254. * @param otherVector defines the other vector
  75255. * @param result defines the target vector
  75256. * @returns the unmodified current Vector2
  75257. */
  75258. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75259. /**
  75260. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  75261. * @param otherVector defines the other vector
  75262. * @returns the current updated Vector2
  75263. */
  75264. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75265. /**
  75266. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  75267. * @param otherVector defines the other vector
  75268. * @returns a new Vector2
  75269. */
  75270. addVector3(otherVector: Vector3): Vector2;
  75271. /**
  75272. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  75273. * @param otherVector defines the other vector
  75274. * @returns a new Vector2
  75275. */
  75276. subtract(otherVector: Vector2): Vector2;
  75277. /**
  75278. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  75279. * @param otherVector defines the other vector
  75280. * @param result defines the target vector
  75281. * @returns the unmodified current Vector2
  75282. */
  75283. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75284. /**
  75285. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  75286. * @param otherVector defines the other vector
  75287. * @returns the current updated Vector2
  75288. */
  75289. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75290. /**
  75291. * Multiplies in place the current Vector2 coordinates by the given ones
  75292. * @param otherVector defines the other vector
  75293. * @returns the current updated Vector2
  75294. */
  75295. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75296. /**
  75297. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  75298. * @param otherVector defines the other vector
  75299. * @returns a new Vector2
  75300. */
  75301. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  75302. /**
  75303. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  75304. * @param otherVector defines the other vector
  75305. * @param result defines the target vector
  75306. * @returns the unmodified current Vector2
  75307. */
  75308. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75309. /**
  75310. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  75311. * @param x defines the first coordinate
  75312. * @param y defines the second coordinate
  75313. * @returns a new Vector2
  75314. */
  75315. multiplyByFloats(x: number, y: number): Vector2;
  75316. /**
  75317. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  75318. * @param otherVector defines the other vector
  75319. * @returns a new Vector2
  75320. */
  75321. divide(otherVector: Vector2): Vector2;
  75322. /**
  75323. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  75324. * @param otherVector defines the other vector
  75325. * @param result defines the target vector
  75326. * @returns the unmodified current Vector2
  75327. */
  75328. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75329. /**
  75330. * Divides the current Vector2 coordinates by the given ones
  75331. * @param otherVector defines the other vector
  75332. * @returns the current updated Vector2
  75333. */
  75334. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75335. /**
  75336. * Gets a new Vector2 with current Vector2 negated coordinates
  75337. * @returns a new Vector2
  75338. */
  75339. negate(): Vector2;
  75340. /**
  75341. * Negate this vector in place
  75342. * @returns this
  75343. */
  75344. negateInPlace(): Vector2;
  75345. /**
  75346. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  75347. * @param result defines the Vector3 object where to store the result
  75348. * @returns the current Vector2
  75349. */
  75350. negateToRef(result: Vector2): Vector2;
  75351. /**
  75352. * Multiply the Vector2 coordinates by scale
  75353. * @param scale defines the scaling factor
  75354. * @returns the current updated Vector2
  75355. */
  75356. scaleInPlace(scale: number): Vector2;
  75357. /**
  75358. * Returns a new Vector2 scaled by "scale" from the current Vector2
  75359. * @param scale defines the scaling factor
  75360. * @returns a new Vector2
  75361. */
  75362. scale(scale: number): Vector2;
  75363. /**
  75364. * Scale the current Vector2 values by a factor to a given Vector2
  75365. * @param scale defines the scale factor
  75366. * @param result defines the Vector2 object where to store the result
  75367. * @returns the unmodified current Vector2
  75368. */
  75369. scaleToRef(scale: number, result: Vector2): Vector2;
  75370. /**
  75371. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  75372. * @param scale defines the scale factor
  75373. * @param result defines the Vector2 object where to store the result
  75374. * @returns the unmodified current Vector2
  75375. */
  75376. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  75377. /**
  75378. * Gets a boolean if two vectors are equals
  75379. * @param otherVector defines the other vector
  75380. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  75381. */
  75382. equals(otherVector: DeepImmutable<Vector2>): boolean;
  75383. /**
  75384. * Gets a boolean if two vectors are equals (using an epsilon value)
  75385. * @param otherVector defines the other vector
  75386. * @param epsilon defines the minimal distance to consider equality
  75387. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  75388. */
  75389. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  75390. /**
  75391. * Gets a new Vector2 from current Vector2 floored values
  75392. * @returns a new Vector2
  75393. */
  75394. floor(): Vector2;
  75395. /**
  75396. * Gets a new Vector2 from current Vector2 floored values
  75397. * @returns a new Vector2
  75398. */
  75399. fract(): Vector2;
  75400. /**
  75401. * Gets the length of the vector
  75402. * @returns the vector length (float)
  75403. */
  75404. length(): number;
  75405. /**
  75406. * Gets the vector squared length
  75407. * @returns the vector squared length (float)
  75408. */
  75409. lengthSquared(): number;
  75410. /**
  75411. * Normalize the vector
  75412. * @returns the current updated Vector2
  75413. */
  75414. normalize(): Vector2;
  75415. /**
  75416. * Gets a new Vector2 copied from the Vector2
  75417. * @returns a new Vector2
  75418. */
  75419. clone(): Vector2;
  75420. /**
  75421. * Gets a new Vector2(0, 0)
  75422. * @returns a new Vector2
  75423. */
  75424. static Zero(): Vector2;
  75425. /**
  75426. * Gets a new Vector2(1, 1)
  75427. * @returns a new Vector2
  75428. */
  75429. static One(): Vector2;
  75430. /**
  75431. * Gets a new Vector2 set from the given index element of the given array
  75432. * @param array defines the data source
  75433. * @param offset defines the offset in the data source
  75434. * @returns a new Vector2
  75435. */
  75436. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  75437. /**
  75438. * Sets "result" from the given index element of the given array
  75439. * @param array defines the data source
  75440. * @param offset defines the offset in the data source
  75441. * @param result defines the target vector
  75442. */
  75443. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  75444. /**
  75445. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  75446. * @param value1 defines 1st point of control
  75447. * @param value2 defines 2nd point of control
  75448. * @param value3 defines 3rd point of control
  75449. * @param value4 defines 4th point of control
  75450. * @param amount defines the interpolation factor
  75451. * @returns a new Vector2
  75452. */
  75453. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  75454. /**
  75455. * 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".
  75456. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  75457. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  75458. * @param value defines the value to clamp
  75459. * @param min defines the lower limit
  75460. * @param max defines the upper limit
  75461. * @returns a new Vector2
  75462. */
  75463. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  75464. /**
  75465. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  75466. * @param value1 defines the 1st control point
  75467. * @param tangent1 defines the outgoing tangent
  75468. * @param value2 defines the 2nd control point
  75469. * @param tangent2 defines the incoming tangent
  75470. * @param amount defines the interpolation factor
  75471. * @returns a new Vector2
  75472. */
  75473. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  75474. /**
  75475. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  75476. * @param start defines the start vector
  75477. * @param end defines the end vector
  75478. * @param amount defines the interpolation factor
  75479. * @returns a new Vector2
  75480. */
  75481. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  75482. /**
  75483. * Gets the dot product of the vector "left" and the vector "right"
  75484. * @param left defines first vector
  75485. * @param right defines second vector
  75486. * @returns the dot product (float)
  75487. */
  75488. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  75489. /**
  75490. * Returns a new Vector2 equal to the normalized given vector
  75491. * @param vector defines the vector to normalize
  75492. * @returns a new Vector2
  75493. */
  75494. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  75495. /**
  75496. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  75497. * @param left defines 1st vector
  75498. * @param right defines 2nd vector
  75499. * @returns a new Vector2
  75500. */
  75501. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  75502. /**
  75503. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  75504. * @param left defines 1st vector
  75505. * @param right defines 2nd vector
  75506. * @returns a new Vector2
  75507. */
  75508. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  75509. /**
  75510. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  75511. * @param vector defines the vector to transform
  75512. * @param transformation defines the matrix to apply
  75513. * @returns a new Vector2
  75514. */
  75515. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  75516. /**
  75517. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  75518. * @param vector defines the vector to transform
  75519. * @param transformation defines the matrix to apply
  75520. * @param result defines the target vector
  75521. */
  75522. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  75523. /**
  75524. * Determines if a given vector is included in a triangle
  75525. * @param p defines the vector to test
  75526. * @param p0 defines 1st triangle point
  75527. * @param p1 defines 2nd triangle point
  75528. * @param p2 defines 3rd triangle point
  75529. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  75530. */
  75531. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  75532. /**
  75533. * Gets the distance between the vectors "value1" and "value2"
  75534. * @param value1 defines first vector
  75535. * @param value2 defines second vector
  75536. * @returns the distance between vectors
  75537. */
  75538. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  75539. /**
  75540. * Returns the squared distance between the vectors "value1" and "value2"
  75541. * @param value1 defines first vector
  75542. * @param value2 defines second vector
  75543. * @returns the squared distance between vectors
  75544. */
  75545. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  75546. /**
  75547. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  75548. * @param value1 defines first vector
  75549. * @param value2 defines second vector
  75550. * @returns a new Vector2
  75551. */
  75552. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  75553. /**
  75554. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  75555. * @param p defines the middle point
  75556. * @param segA defines one point of the segment
  75557. * @param segB defines the other point of the segment
  75558. * @returns the shortest distance
  75559. */
  75560. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  75561. }
  75562. /**
  75563. * Class used to store (x,y,z) vector representation
  75564. * A Vector3 is the main object used in 3D geometry
  75565. * It can represent etiher the coordinates of a point the space, either a direction
  75566. * Reminder: js uses a left handed forward facing system
  75567. */
  75568. export class Vector3 {
  75569. /**
  75570. * Defines the first coordinates (on X axis)
  75571. */
  75572. x: number;
  75573. /**
  75574. * Defines the second coordinates (on Y axis)
  75575. */
  75576. y: number;
  75577. /**
  75578. * Defines the third coordinates (on Z axis)
  75579. */
  75580. z: number;
  75581. private static _UpReadOnly;
  75582. private static _ZeroReadOnly;
  75583. /**
  75584. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  75585. * @param x defines the first coordinates (on X axis)
  75586. * @param y defines the second coordinates (on Y axis)
  75587. * @param z defines the third coordinates (on Z axis)
  75588. */
  75589. constructor(
  75590. /**
  75591. * Defines the first coordinates (on X axis)
  75592. */
  75593. x?: number,
  75594. /**
  75595. * Defines the second coordinates (on Y axis)
  75596. */
  75597. y?: number,
  75598. /**
  75599. * Defines the third coordinates (on Z axis)
  75600. */
  75601. z?: number);
  75602. /**
  75603. * Creates a string representation of the Vector3
  75604. * @returns a string with the Vector3 coordinates.
  75605. */
  75606. toString(): string;
  75607. /**
  75608. * Gets the class name
  75609. * @returns the string "Vector3"
  75610. */
  75611. getClassName(): string;
  75612. /**
  75613. * Creates the Vector3 hash code
  75614. * @returns a number which tends to be unique between Vector3 instances
  75615. */
  75616. getHashCode(): number;
  75617. /**
  75618. * Creates an array containing three elements : the coordinates of the Vector3
  75619. * @returns a new array of numbers
  75620. */
  75621. asArray(): number[];
  75622. /**
  75623. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  75624. * @param array defines the destination array
  75625. * @param index defines the offset in the destination array
  75626. * @returns the current Vector3
  75627. */
  75628. toArray(array: FloatArray, index?: number): Vector3;
  75629. /**
  75630. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  75631. * @returns a new Quaternion object, computed from the Vector3 coordinates
  75632. */
  75633. toQuaternion(): Quaternion;
  75634. /**
  75635. * Adds the given vector to the current Vector3
  75636. * @param otherVector defines the second operand
  75637. * @returns the current updated Vector3
  75638. */
  75639. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75640. /**
  75641. * Adds the given coordinates to the current Vector3
  75642. * @param x defines the x coordinate of the operand
  75643. * @param y defines the y coordinate of the operand
  75644. * @param z defines the z coordinate of the operand
  75645. * @returns the current updated Vector3
  75646. */
  75647. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75648. /**
  75649. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  75650. * @param otherVector defines the second operand
  75651. * @returns the resulting Vector3
  75652. */
  75653. add(otherVector: DeepImmutable<Vector3>): Vector3;
  75654. /**
  75655. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  75656. * @param otherVector defines the second operand
  75657. * @param result defines the Vector3 object where to store the result
  75658. * @returns the current Vector3
  75659. */
  75660. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75661. /**
  75662. * Subtract the given vector from the current Vector3
  75663. * @param otherVector defines the second operand
  75664. * @returns the current updated Vector3
  75665. */
  75666. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75667. /**
  75668. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  75669. * @param otherVector defines the second operand
  75670. * @returns the resulting Vector3
  75671. */
  75672. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  75673. /**
  75674. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  75675. * @param otherVector defines the second operand
  75676. * @param result defines the Vector3 object where to store the result
  75677. * @returns the current Vector3
  75678. */
  75679. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75680. /**
  75681. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  75682. * @param x defines the x coordinate of the operand
  75683. * @param y defines the y coordinate of the operand
  75684. * @param z defines the z coordinate of the operand
  75685. * @returns the resulting Vector3
  75686. */
  75687. subtractFromFloats(x: number, y: number, z: number): Vector3;
  75688. /**
  75689. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  75690. * @param x defines the x coordinate of the operand
  75691. * @param y defines the y coordinate of the operand
  75692. * @param z defines the z coordinate of the operand
  75693. * @param result defines the Vector3 object where to store the result
  75694. * @returns the current Vector3
  75695. */
  75696. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  75697. /**
  75698. * Gets a new Vector3 set with the current Vector3 negated coordinates
  75699. * @returns a new Vector3
  75700. */
  75701. negate(): Vector3;
  75702. /**
  75703. * Negate this vector in place
  75704. * @returns this
  75705. */
  75706. negateInPlace(): Vector3;
  75707. /**
  75708. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  75709. * @param result defines the Vector3 object where to store the result
  75710. * @returns the current Vector3
  75711. */
  75712. negateToRef(result: Vector3): Vector3;
  75713. /**
  75714. * Multiplies the Vector3 coordinates by the float "scale"
  75715. * @param scale defines the multiplier factor
  75716. * @returns the current updated Vector3
  75717. */
  75718. scaleInPlace(scale: number): Vector3;
  75719. /**
  75720. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  75721. * @param scale defines the multiplier factor
  75722. * @returns a new Vector3
  75723. */
  75724. scale(scale: number): Vector3;
  75725. /**
  75726. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  75727. * @param scale defines the multiplier factor
  75728. * @param result defines the Vector3 object where to store the result
  75729. * @returns the current Vector3
  75730. */
  75731. scaleToRef(scale: number, result: Vector3): Vector3;
  75732. /**
  75733. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  75734. * @param scale defines the scale factor
  75735. * @param result defines the Vector3 object where to store the result
  75736. * @returns the unmodified current Vector3
  75737. */
  75738. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  75739. /**
  75740. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  75741. * @param otherVector defines the second operand
  75742. * @returns true if both vectors are equals
  75743. */
  75744. equals(otherVector: DeepImmutable<Vector3>): boolean;
  75745. /**
  75746. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  75747. * @param otherVector defines the second operand
  75748. * @param epsilon defines the minimal distance to define values as equals
  75749. * @returns true if both vectors are distant less than epsilon
  75750. */
  75751. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  75752. /**
  75753. * Returns true if the current Vector3 coordinates equals the given floats
  75754. * @param x defines the x coordinate of the operand
  75755. * @param y defines the y coordinate of the operand
  75756. * @param z defines the z coordinate of the operand
  75757. * @returns true if both vectors are equals
  75758. */
  75759. equalsToFloats(x: number, y: number, z: number): boolean;
  75760. /**
  75761. * Multiplies the current Vector3 coordinates by the given ones
  75762. * @param otherVector defines the second operand
  75763. * @returns the current updated Vector3
  75764. */
  75765. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75766. /**
  75767. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  75768. * @param otherVector defines the second operand
  75769. * @returns the new Vector3
  75770. */
  75771. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  75772. /**
  75773. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  75774. * @param otherVector defines the second operand
  75775. * @param result defines the Vector3 object where to store the result
  75776. * @returns the current Vector3
  75777. */
  75778. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75779. /**
  75780. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  75781. * @param x defines the x coordinate of the operand
  75782. * @param y defines the y coordinate of the operand
  75783. * @param z defines the z coordinate of the operand
  75784. * @returns the new Vector3
  75785. */
  75786. multiplyByFloats(x: number, y: number, z: number): Vector3;
  75787. /**
  75788. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  75789. * @param otherVector defines the second operand
  75790. * @returns the new Vector3
  75791. */
  75792. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  75793. /**
  75794. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  75795. * @param otherVector defines the second operand
  75796. * @param result defines the Vector3 object where to store the result
  75797. * @returns the current Vector3
  75798. */
  75799. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75800. /**
  75801. * Divides the current Vector3 coordinates by the given ones.
  75802. * @param otherVector defines the second operand
  75803. * @returns the current updated Vector3
  75804. */
  75805. divideInPlace(otherVector: Vector3): Vector3;
  75806. /**
  75807. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  75808. * @param other defines the second operand
  75809. * @returns the current updated Vector3
  75810. */
  75811. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  75812. /**
  75813. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  75814. * @param other defines the second operand
  75815. * @returns the current updated Vector3
  75816. */
  75817. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  75818. /**
  75819. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  75820. * @param x defines the x coordinate of the operand
  75821. * @param y defines the y coordinate of the operand
  75822. * @param z defines the z coordinate of the operand
  75823. * @returns the current updated Vector3
  75824. */
  75825. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75826. /**
  75827. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  75828. * @param x defines the x coordinate of the operand
  75829. * @param y defines the y coordinate of the operand
  75830. * @param z defines the z coordinate of the operand
  75831. * @returns the current updated Vector3
  75832. */
  75833. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75834. /**
  75835. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  75836. * Check if is non uniform within a certain amount of decimal places to account for this
  75837. * @param epsilon the amount the values can differ
  75838. * @returns if the the vector is non uniform to a certain number of decimal places
  75839. */
  75840. isNonUniformWithinEpsilon(epsilon: number): boolean;
  75841. /**
  75842. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  75843. */
  75844. get isNonUniform(): boolean;
  75845. /**
  75846. * Gets a new Vector3 from current Vector3 floored values
  75847. * @returns a new Vector3
  75848. */
  75849. floor(): Vector3;
  75850. /**
  75851. * Gets a new Vector3 from current Vector3 floored values
  75852. * @returns a new Vector3
  75853. */
  75854. fract(): Vector3;
  75855. /**
  75856. * Gets the length of the Vector3
  75857. * @returns the length of the Vector3
  75858. */
  75859. length(): number;
  75860. /**
  75861. * Gets the squared length of the Vector3
  75862. * @returns squared length of the Vector3
  75863. */
  75864. lengthSquared(): number;
  75865. /**
  75866. * Normalize the current Vector3.
  75867. * Please note that this is an in place operation.
  75868. * @returns the current updated Vector3
  75869. */
  75870. normalize(): Vector3;
  75871. /**
  75872. * Reorders the x y z properties of the vector in place
  75873. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  75874. * @returns the current updated vector
  75875. */
  75876. reorderInPlace(order: string): this;
  75877. /**
  75878. * Rotates the vector around 0,0,0 by a quaternion
  75879. * @param quaternion the rotation quaternion
  75880. * @param result vector to store the result
  75881. * @returns the resulting vector
  75882. */
  75883. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  75884. /**
  75885. * Rotates a vector around a given point
  75886. * @param quaternion the rotation quaternion
  75887. * @param point the point to rotate around
  75888. * @param result vector to store the result
  75889. * @returns the resulting vector
  75890. */
  75891. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  75892. /**
  75893. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  75894. * The cross product is then orthogonal to both current and "other"
  75895. * @param other defines the right operand
  75896. * @returns the cross product
  75897. */
  75898. cross(other: Vector3): Vector3;
  75899. /**
  75900. * Normalize the current Vector3 with the given input length.
  75901. * Please note that this is an in place operation.
  75902. * @param len the length of the vector
  75903. * @returns the current updated Vector3
  75904. */
  75905. normalizeFromLength(len: number): Vector3;
  75906. /**
  75907. * Normalize the current Vector3 to a new vector
  75908. * @returns the new Vector3
  75909. */
  75910. normalizeToNew(): Vector3;
  75911. /**
  75912. * Normalize the current Vector3 to the reference
  75913. * @param reference define the Vector3 to update
  75914. * @returns the updated Vector3
  75915. */
  75916. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  75917. /**
  75918. * Creates a new Vector3 copied from the current Vector3
  75919. * @returns the new Vector3
  75920. */
  75921. clone(): Vector3;
  75922. /**
  75923. * Copies the given vector coordinates to the current Vector3 ones
  75924. * @param source defines the source Vector3
  75925. * @returns the current updated Vector3
  75926. */
  75927. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  75928. /**
  75929. * Copies the given floats to the current Vector3 coordinates
  75930. * @param x defines the x coordinate of the operand
  75931. * @param y defines the y coordinate of the operand
  75932. * @param z defines the z coordinate of the operand
  75933. * @returns the current updated Vector3
  75934. */
  75935. copyFromFloats(x: number, y: number, z: number): Vector3;
  75936. /**
  75937. * Copies the given floats to the current Vector3 coordinates
  75938. * @param x defines the x coordinate of the operand
  75939. * @param y defines the y coordinate of the operand
  75940. * @param z defines the z coordinate of the operand
  75941. * @returns the current updated Vector3
  75942. */
  75943. set(x: number, y: number, z: number): Vector3;
  75944. /**
  75945. * Copies the given float to the current Vector3 coordinates
  75946. * @param v defines the x, y and z coordinates of the operand
  75947. * @returns the current updated Vector3
  75948. */
  75949. setAll(v: number): Vector3;
  75950. /**
  75951. * Get the clip factor between two vectors
  75952. * @param vector0 defines the first operand
  75953. * @param vector1 defines the second operand
  75954. * @param axis defines the axis to use
  75955. * @param size defines the size along the axis
  75956. * @returns the clip factor
  75957. */
  75958. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  75959. /**
  75960. * Get angle between two vectors
  75961. * @param vector0 angle between vector0 and vector1
  75962. * @param vector1 angle between vector0 and vector1
  75963. * @param normal direction of the normal
  75964. * @return the angle between vector0 and vector1
  75965. */
  75966. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  75967. /**
  75968. * Returns a new Vector3 set from the index "offset" of the given array
  75969. * @param array defines the source array
  75970. * @param offset defines the offset in the source array
  75971. * @returns the new Vector3
  75972. */
  75973. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  75974. /**
  75975. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  75976. * @param array defines the source array
  75977. * @param offset defines the offset in the source array
  75978. * @returns the new Vector3
  75979. * @deprecated Please use FromArray instead.
  75980. */
  75981. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  75982. /**
  75983. * Sets the given vector "result" with the element values from the index "offset" of the given array
  75984. * @param array defines the source array
  75985. * @param offset defines the offset in the source array
  75986. * @param result defines the Vector3 where to store the result
  75987. */
  75988. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  75989. /**
  75990. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  75991. * @param array defines the source array
  75992. * @param offset defines the offset in the source array
  75993. * @param result defines the Vector3 where to store the result
  75994. * @deprecated Please use FromArrayToRef instead.
  75995. */
  75996. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  75997. /**
  75998. * Sets the given vector "result" with the given floats.
  75999. * @param x defines the x coordinate of the source
  76000. * @param y defines the y coordinate of the source
  76001. * @param z defines the z coordinate of the source
  76002. * @param result defines the Vector3 where to store the result
  76003. */
  76004. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  76005. /**
  76006. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  76007. * @returns a new empty Vector3
  76008. */
  76009. static Zero(): Vector3;
  76010. /**
  76011. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  76012. * @returns a new unit Vector3
  76013. */
  76014. static One(): Vector3;
  76015. /**
  76016. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  76017. * @returns a new up Vector3
  76018. */
  76019. static Up(): Vector3;
  76020. /**
  76021. * Gets a up Vector3 that must not be updated
  76022. */
  76023. static get UpReadOnly(): DeepImmutable<Vector3>;
  76024. /**
  76025. * Gets a zero Vector3 that must not be updated
  76026. */
  76027. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  76028. /**
  76029. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  76030. * @returns a new down Vector3
  76031. */
  76032. static Down(): Vector3;
  76033. /**
  76034. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  76035. * @returns a new forward Vector3
  76036. */
  76037. static Forward(): Vector3;
  76038. /**
  76039. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  76040. * @returns a new forward Vector3
  76041. */
  76042. static Backward(): Vector3;
  76043. /**
  76044. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  76045. * @returns a new right Vector3
  76046. */
  76047. static Right(): Vector3;
  76048. /**
  76049. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  76050. * @returns a new left Vector3
  76051. */
  76052. static Left(): Vector3;
  76053. /**
  76054. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  76055. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  76056. * @param vector defines the Vector3 to transform
  76057. * @param transformation defines the transformation matrix
  76058. * @returns the transformed Vector3
  76059. */
  76060. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  76061. /**
  76062. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  76063. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  76064. * @param vector defines the Vector3 to transform
  76065. * @param transformation defines the transformation matrix
  76066. * @param result defines the Vector3 where to store the result
  76067. */
  76068. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76069. /**
  76070. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  76071. * This method computes tranformed coordinates only, not transformed direction vectors
  76072. * @param x define the x coordinate of the source vector
  76073. * @param y define the y coordinate of the source vector
  76074. * @param z define the z coordinate of the source vector
  76075. * @param transformation defines the transformation matrix
  76076. * @param result defines the Vector3 where to store the result
  76077. */
  76078. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76079. /**
  76080. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  76081. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  76082. * @param vector defines the Vector3 to transform
  76083. * @param transformation defines the transformation matrix
  76084. * @returns the new Vector3
  76085. */
  76086. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  76087. /**
  76088. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  76089. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  76090. * @param vector defines the Vector3 to transform
  76091. * @param transformation defines the transformation matrix
  76092. * @param result defines the Vector3 where to store the result
  76093. */
  76094. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76095. /**
  76096. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  76097. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  76098. * @param x define the x coordinate of the source vector
  76099. * @param y define the y coordinate of the source vector
  76100. * @param z define the z coordinate of the source vector
  76101. * @param transformation defines the transformation matrix
  76102. * @param result defines the Vector3 where to store the result
  76103. */
  76104. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76105. /**
  76106. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  76107. * @param value1 defines the first control point
  76108. * @param value2 defines the second control point
  76109. * @param value3 defines the third control point
  76110. * @param value4 defines the fourth control point
  76111. * @param amount defines the amount on the spline to use
  76112. * @returns the new Vector3
  76113. */
  76114. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  76115. /**
  76116. * 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"
  76117. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  76118. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  76119. * @param value defines the current value
  76120. * @param min defines the lower range value
  76121. * @param max defines the upper range value
  76122. * @returns the new Vector3
  76123. */
  76124. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  76125. /**
  76126. * 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"
  76127. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  76128. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  76129. * @param value defines the current value
  76130. * @param min defines the lower range value
  76131. * @param max defines the upper range value
  76132. * @param result defines the Vector3 where to store the result
  76133. */
  76134. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  76135. /**
  76136. * Checks if a given vector is inside a specific range
  76137. * @param v defines the vector to test
  76138. * @param min defines the minimum range
  76139. * @param max defines the maximum range
  76140. */
  76141. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  76142. /**
  76143. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  76144. * @param value1 defines the first control point
  76145. * @param tangent1 defines the first tangent vector
  76146. * @param value2 defines the second control point
  76147. * @param tangent2 defines the second tangent vector
  76148. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  76149. * @returns the new Vector3
  76150. */
  76151. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  76152. /**
  76153. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  76154. * @param start defines the start value
  76155. * @param end defines the end value
  76156. * @param amount max defines amount between both (between 0 and 1)
  76157. * @returns the new Vector3
  76158. */
  76159. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  76160. /**
  76161. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  76162. * @param start defines the start value
  76163. * @param end defines the end value
  76164. * @param amount max defines amount between both (between 0 and 1)
  76165. * @param result defines the Vector3 where to store the result
  76166. */
  76167. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  76168. /**
  76169. * Returns the dot product (float) between the vectors "left" and "right"
  76170. * @param left defines the left operand
  76171. * @param right defines the right operand
  76172. * @returns the dot product
  76173. */
  76174. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  76175. /**
  76176. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  76177. * The cross product is then orthogonal to both "left" and "right"
  76178. * @param left defines the left operand
  76179. * @param right defines the right operand
  76180. * @returns the cross product
  76181. */
  76182. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  76183. /**
  76184. * Sets the given vector "result" with the cross product of "left" and "right"
  76185. * The cross product is then orthogonal to both "left" and "right"
  76186. * @param left defines the left operand
  76187. * @param right defines the right operand
  76188. * @param result defines the Vector3 where to store the result
  76189. */
  76190. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  76191. /**
  76192. * Returns a new Vector3 as the normalization of the given vector
  76193. * @param vector defines the Vector3 to normalize
  76194. * @returns the new Vector3
  76195. */
  76196. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  76197. /**
  76198. * Sets the given vector "result" with the normalization of the given first vector
  76199. * @param vector defines the Vector3 to normalize
  76200. * @param result defines the Vector3 where to store the result
  76201. */
  76202. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  76203. /**
  76204. * Project a Vector3 onto screen space
  76205. * @param vector defines the Vector3 to project
  76206. * @param world defines the world matrix to use
  76207. * @param transform defines the transform (view x projection) matrix to use
  76208. * @param viewport defines the screen viewport to use
  76209. * @returns the new Vector3
  76210. */
  76211. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  76212. /** @hidden */
  76213. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  76214. /**
  76215. * Unproject from screen space to object space
  76216. * @param source defines the screen space Vector3 to use
  76217. * @param viewportWidth defines the current width of the viewport
  76218. * @param viewportHeight defines the current height of the viewport
  76219. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76220. * @param transform defines the transform (view x projection) matrix to use
  76221. * @returns the new Vector3
  76222. */
  76223. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  76224. /**
  76225. * Unproject from screen space to object space
  76226. * @param source defines the screen space Vector3 to use
  76227. * @param viewportWidth defines the current width of the viewport
  76228. * @param viewportHeight defines the current height of the viewport
  76229. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76230. * @param view defines the view matrix to use
  76231. * @param projection defines the projection matrix to use
  76232. * @returns the new Vector3
  76233. */
  76234. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  76235. /**
  76236. * Unproject from screen space to object space
  76237. * @param source defines the screen space Vector3 to use
  76238. * @param viewportWidth defines the current width of the viewport
  76239. * @param viewportHeight defines the current height of the viewport
  76240. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76241. * @param view defines the view matrix to use
  76242. * @param projection defines the projection matrix to use
  76243. * @param result defines the Vector3 where to store the result
  76244. */
  76245. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  76246. /**
  76247. * Unproject from screen space to object space
  76248. * @param sourceX defines the screen space x coordinate to use
  76249. * @param sourceY defines the screen space y coordinate to use
  76250. * @param sourceZ defines the screen space z coordinate to use
  76251. * @param viewportWidth defines the current width of the viewport
  76252. * @param viewportHeight defines the current height of the viewport
  76253. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76254. * @param view defines the view matrix to use
  76255. * @param projection defines the projection matrix to use
  76256. * @param result defines the Vector3 where to store the result
  76257. */
  76258. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  76259. /**
  76260. * Gets the minimal coordinate values between two Vector3
  76261. * @param left defines the first operand
  76262. * @param right defines the second operand
  76263. * @returns the new Vector3
  76264. */
  76265. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  76266. /**
  76267. * Gets the maximal coordinate values between two Vector3
  76268. * @param left defines the first operand
  76269. * @param right defines the second operand
  76270. * @returns the new Vector3
  76271. */
  76272. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  76273. /**
  76274. * Returns the distance between the vectors "value1" and "value2"
  76275. * @param value1 defines the first operand
  76276. * @param value2 defines the second operand
  76277. * @returns the distance
  76278. */
  76279. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  76280. /**
  76281. * Returns the squared distance between the vectors "value1" and "value2"
  76282. * @param value1 defines the first operand
  76283. * @param value2 defines the second operand
  76284. * @returns the squared distance
  76285. */
  76286. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  76287. /**
  76288. * Returns a new Vector3 located at the center between "value1" and "value2"
  76289. * @param value1 defines the first operand
  76290. * @param value2 defines the second operand
  76291. * @returns the new Vector3
  76292. */
  76293. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  76294. /**
  76295. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  76296. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  76297. * to something in order to rotate it from its local system to the given target system
  76298. * Note: axis1, axis2 and axis3 are normalized during this operation
  76299. * @param axis1 defines the first axis
  76300. * @param axis2 defines the second axis
  76301. * @param axis3 defines the third axis
  76302. * @returns a new Vector3
  76303. */
  76304. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  76305. /**
  76306. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  76307. * @param axis1 defines the first axis
  76308. * @param axis2 defines the second axis
  76309. * @param axis3 defines the third axis
  76310. * @param ref defines the Vector3 where to store the result
  76311. */
  76312. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  76313. }
  76314. /**
  76315. * Vector4 class created for EulerAngle class conversion to Quaternion
  76316. */
  76317. export class Vector4 {
  76318. /** x value of the vector */
  76319. x: number;
  76320. /** y value of the vector */
  76321. y: number;
  76322. /** z value of the vector */
  76323. z: number;
  76324. /** w value of the vector */
  76325. w: number;
  76326. /**
  76327. * Creates a Vector4 object from the given floats.
  76328. * @param x x value of the vector
  76329. * @param y y value of the vector
  76330. * @param z z value of the vector
  76331. * @param w w value of the vector
  76332. */
  76333. constructor(
  76334. /** x value of the vector */
  76335. x: number,
  76336. /** y value of the vector */
  76337. y: number,
  76338. /** z value of the vector */
  76339. z: number,
  76340. /** w value of the vector */
  76341. w: number);
  76342. /**
  76343. * Returns the string with the Vector4 coordinates.
  76344. * @returns a string containing all the vector values
  76345. */
  76346. toString(): string;
  76347. /**
  76348. * Returns the string "Vector4".
  76349. * @returns "Vector4"
  76350. */
  76351. getClassName(): string;
  76352. /**
  76353. * Returns the Vector4 hash code.
  76354. * @returns a unique hash code
  76355. */
  76356. getHashCode(): number;
  76357. /**
  76358. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  76359. * @returns the resulting array
  76360. */
  76361. asArray(): number[];
  76362. /**
  76363. * Populates the given array from the given index with the Vector4 coordinates.
  76364. * @param array array to populate
  76365. * @param index index of the array to start at (default: 0)
  76366. * @returns the Vector4.
  76367. */
  76368. toArray(array: FloatArray, index?: number): Vector4;
  76369. /**
  76370. * Adds the given vector to the current Vector4.
  76371. * @param otherVector the vector to add
  76372. * @returns the updated Vector4.
  76373. */
  76374. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  76375. /**
  76376. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  76377. * @param otherVector the vector to add
  76378. * @returns the resulting vector
  76379. */
  76380. add(otherVector: DeepImmutable<Vector4>): Vector4;
  76381. /**
  76382. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  76383. * @param otherVector the vector to add
  76384. * @param result the vector to store the result
  76385. * @returns the current Vector4.
  76386. */
  76387. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76388. /**
  76389. * Subtract in place the given vector from the current Vector4.
  76390. * @param otherVector the vector to subtract
  76391. * @returns the updated Vector4.
  76392. */
  76393. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  76394. /**
  76395. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  76396. * @param otherVector the vector to add
  76397. * @returns the new vector with the result
  76398. */
  76399. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  76400. /**
  76401. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  76402. * @param otherVector the vector to subtract
  76403. * @param result the vector to store the result
  76404. * @returns the current Vector4.
  76405. */
  76406. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76407. /**
  76408. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  76409. */
  76410. /**
  76411. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  76412. * @param x value to subtract
  76413. * @param y value to subtract
  76414. * @param z value to subtract
  76415. * @param w value to subtract
  76416. * @returns new vector containing the result
  76417. */
  76418. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  76419. /**
  76420. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  76421. * @param x value to subtract
  76422. * @param y value to subtract
  76423. * @param z value to subtract
  76424. * @param w value to subtract
  76425. * @param result the vector to store the result in
  76426. * @returns the current Vector4.
  76427. */
  76428. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  76429. /**
  76430. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  76431. * @returns a new vector with the negated values
  76432. */
  76433. negate(): Vector4;
  76434. /**
  76435. * Negate this vector in place
  76436. * @returns this
  76437. */
  76438. negateInPlace(): Vector4;
  76439. /**
  76440. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  76441. * @param result defines the Vector3 object where to store the result
  76442. * @returns the current Vector4
  76443. */
  76444. negateToRef(result: Vector4): Vector4;
  76445. /**
  76446. * Multiplies the current Vector4 coordinates by scale (float).
  76447. * @param scale the number to scale with
  76448. * @returns the updated Vector4.
  76449. */
  76450. scaleInPlace(scale: number): Vector4;
  76451. /**
  76452. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  76453. * @param scale the number to scale with
  76454. * @returns a new vector with the result
  76455. */
  76456. scale(scale: number): Vector4;
  76457. /**
  76458. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  76459. * @param scale the number to scale with
  76460. * @param result a vector to store the result in
  76461. * @returns the current Vector4.
  76462. */
  76463. scaleToRef(scale: number, result: Vector4): Vector4;
  76464. /**
  76465. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  76466. * @param scale defines the scale factor
  76467. * @param result defines the Vector4 object where to store the result
  76468. * @returns the unmodified current Vector4
  76469. */
  76470. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  76471. /**
  76472. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  76473. * @param otherVector the vector to compare against
  76474. * @returns true if they are equal
  76475. */
  76476. equals(otherVector: DeepImmutable<Vector4>): boolean;
  76477. /**
  76478. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  76479. * @param otherVector vector to compare against
  76480. * @param epsilon (Default: very small number)
  76481. * @returns true if they are equal
  76482. */
  76483. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  76484. /**
  76485. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  76486. * @param x x value to compare against
  76487. * @param y y value to compare against
  76488. * @param z z value to compare against
  76489. * @param w w value to compare against
  76490. * @returns true if equal
  76491. */
  76492. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  76493. /**
  76494. * Multiplies in place the current Vector4 by the given one.
  76495. * @param otherVector vector to multiple with
  76496. * @returns the updated Vector4.
  76497. */
  76498. multiplyInPlace(otherVector: Vector4): Vector4;
  76499. /**
  76500. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  76501. * @param otherVector vector to multiple with
  76502. * @returns resulting new vector
  76503. */
  76504. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  76505. /**
  76506. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  76507. * @param otherVector vector to multiple with
  76508. * @param result vector to store the result
  76509. * @returns the current Vector4.
  76510. */
  76511. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76512. /**
  76513. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  76514. * @param x x value multiply with
  76515. * @param y y value multiply with
  76516. * @param z z value multiply with
  76517. * @param w w value multiply with
  76518. * @returns resulting new vector
  76519. */
  76520. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  76521. /**
  76522. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  76523. * @param otherVector vector to devide with
  76524. * @returns resulting new vector
  76525. */
  76526. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  76527. /**
  76528. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  76529. * @param otherVector vector to devide with
  76530. * @param result vector to store the result
  76531. * @returns the current Vector4.
  76532. */
  76533. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76534. /**
  76535. * Divides the current Vector3 coordinates by the given ones.
  76536. * @param otherVector vector to devide with
  76537. * @returns the updated Vector3.
  76538. */
  76539. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  76540. /**
  76541. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  76542. * @param other defines the second operand
  76543. * @returns the current updated Vector4
  76544. */
  76545. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  76546. /**
  76547. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  76548. * @param other defines the second operand
  76549. * @returns the current updated Vector4
  76550. */
  76551. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  76552. /**
  76553. * Gets a new Vector4 from current Vector4 floored values
  76554. * @returns a new Vector4
  76555. */
  76556. floor(): Vector4;
  76557. /**
  76558. * Gets a new Vector4 from current Vector3 floored values
  76559. * @returns a new Vector4
  76560. */
  76561. fract(): Vector4;
  76562. /**
  76563. * Returns the Vector4 length (float).
  76564. * @returns the length
  76565. */
  76566. length(): number;
  76567. /**
  76568. * Returns the Vector4 squared length (float).
  76569. * @returns the length squared
  76570. */
  76571. lengthSquared(): number;
  76572. /**
  76573. * Normalizes in place the Vector4.
  76574. * @returns the updated Vector4.
  76575. */
  76576. normalize(): Vector4;
  76577. /**
  76578. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  76579. * @returns this converted to a new vector3
  76580. */
  76581. toVector3(): Vector3;
  76582. /**
  76583. * Returns a new Vector4 copied from the current one.
  76584. * @returns the new cloned vector
  76585. */
  76586. clone(): Vector4;
  76587. /**
  76588. * Updates the current Vector4 with the given one coordinates.
  76589. * @param source the source vector to copy from
  76590. * @returns the updated Vector4.
  76591. */
  76592. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  76593. /**
  76594. * Updates the current Vector4 coordinates with the given floats.
  76595. * @param x float to copy from
  76596. * @param y float to copy from
  76597. * @param z float to copy from
  76598. * @param w float to copy from
  76599. * @returns the updated Vector4.
  76600. */
  76601. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  76602. /**
  76603. * Updates the current Vector4 coordinates with the given floats.
  76604. * @param x float to set from
  76605. * @param y float to set from
  76606. * @param z float to set from
  76607. * @param w float to set from
  76608. * @returns the updated Vector4.
  76609. */
  76610. set(x: number, y: number, z: number, w: number): Vector4;
  76611. /**
  76612. * Copies the given float to the current Vector3 coordinates
  76613. * @param v defines the x, y, z and w coordinates of the operand
  76614. * @returns the current updated Vector3
  76615. */
  76616. setAll(v: number): Vector4;
  76617. /**
  76618. * Returns a new Vector4 set from the starting index of the given array.
  76619. * @param array the array to pull values from
  76620. * @param offset the offset into the array to start at
  76621. * @returns the new vector
  76622. */
  76623. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  76624. /**
  76625. * Updates the given vector "result" from the starting index of the given array.
  76626. * @param array the array to pull values from
  76627. * @param offset the offset into the array to start at
  76628. * @param result the vector to store the result in
  76629. */
  76630. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  76631. /**
  76632. * Updates the given vector "result" from the starting index of the given Float32Array.
  76633. * @param array the array to pull values from
  76634. * @param offset the offset into the array to start at
  76635. * @param result the vector to store the result in
  76636. */
  76637. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  76638. /**
  76639. * Updates the given vector "result" coordinates from the given floats.
  76640. * @param x float to set from
  76641. * @param y float to set from
  76642. * @param z float to set from
  76643. * @param w float to set from
  76644. * @param result the vector to the floats in
  76645. */
  76646. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  76647. /**
  76648. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  76649. * @returns the new vector
  76650. */
  76651. static Zero(): Vector4;
  76652. /**
  76653. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  76654. * @returns the new vector
  76655. */
  76656. static One(): Vector4;
  76657. /**
  76658. * Returns a new normalized Vector4 from the given one.
  76659. * @param vector the vector to normalize
  76660. * @returns the vector
  76661. */
  76662. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  76663. /**
  76664. * Updates the given vector "result" from the normalization of the given one.
  76665. * @param vector the vector to normalize
  76666. * @param result the vector to store the result in
  76667. */
  76668. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  76669. /**
  76670. * Returns a vector with the minimum values from the left and right vectors
  76671. * @param left left vector to minimize
  76672. * @param right right vector to minimize
  76673. * @returns a new vector with the minimum of the left and right vector values
  76674. */
  76675. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  76676. /**
  76677. * Returns a vector with the maximum values from the left and right vectors
  76678. * @param left left vector to maximize
  76679. * @param right right vector to maximize
  76680. * @returns a new vector with the maximum of the left and right vector values
  76681. */
  76682. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  76683. /**
  76684. * Returns the distance (float) between the vectors "value1" and "value2".
  76685. * @param value1 value to calulate the distance between
  76686. * @param value2 value to calulate the distance between
  76687. * @return the distance between the two vectors
  76688. */
  76689. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  76690. /**
  76691. * Returns the squared distance (float) between the vectors "value1" and "value2".
  76692. * @param value1 value to calulate the distance between
  76693. * @param value2 value to calulate the distance between
  76694. * @return the distance between the two vectors squared
  76695. */
  76696. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  76697. /**
  76698. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  76699. * @param value1 value to calulate the center between
  76700. * @param value2 value to calulate the center between
  76701. * @return the center between the two vectors
  76702. */
  76703. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  76704. /**
  76705. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  76706. * This methods computes transformed normalized direction vectors only.
  76707. * @param vector the vector to transform
  76708. * @param transformation the transformation matrix to apply
  76709. * @returns the new vector
  76710. */
  76711. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  76712. /**
  76713. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  76714. * This methods computes transformed normalized direction vectors only.
  76715. * @param vector the vector to transform
  76716. * @param transformation the transformation matrix to apply
  76717. * @param result the vector to store the result in
  76718. */
  76719. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  76720. /**
  76721. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  76722. * This methods computes transformed normalized direction vectors only.
  76723. * @param x value to transform
  76724. * @param y value to transform
  76725. * @param z value to transform
  76726. * @param w value to transform
  76727. * @param transformation the transformation matrix to apply
  76728. * @param result the vector to store the results in
  76729. */
  76730. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  76731. /**
  76732. * Creates a new Vector4 from a Vector3
  76733. * @param source defines the source data
  76734. * @param w defines the 4th component (default is 0)
  76735. * @returns a new Vector4
  76736. */
  76737. static FromVector3(source: Vector3, w?: number): Vector4;
  76738. }
  76739. /**
  76740. * Class used to store quaternion data
  76741. * @see https://en.wikipedia.org/wiki/Quaternion
  76742. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  76743. */
  76744. export class Quaternion {
  76745. /** defines the first component (0 by default) */
  76746. x: number;
  76747. /** defines the second component (0 by default) */
  76748. y: number;
  76749. /** defines the third component (0 by default) */
  76750. z: number;
  76751. /** defines the fourth component (1.0 by default) */
  76752. w: number;
  76753. /**
  76754. * Creates a new Quaternion from the given floats
  76755. * @param x defines the first component (0 by default)
  76756. * @param y defines the second component (0 by default)
  76757. * @param z defines the third component (0 by default)
  76758. * @param w defines the fourth component (1.0 by default)
  76759. */
  76760. constructor(
  76761. /** defines the first component (0 by default) */
  76762. x?: number,
  76763. /** defines the second component (0 by default) */
  76764. y?: number,
  76765. /** defines the third component (0 by default) */
  76766. z?: number,
  76767. /** defines the fourth component (1.0 by default) */
  76768. w?: number);
  76769. /**
  76770. * Gets a string representation for the current quaternion
  76771. * @returns a string with the Quaternion coordinates
  76772. */
  76773. toString(): string;
  76774. /**
  76775. * Gets the class name of the quaternion
  76776. * @returns the string "Quaternion"
  76777. */
  76778. getClassName(): string;
  76779. /**
  76780. * Gets a hash code for this quaternion
  76781. * @returns the quaternion hash code
  76782. */
  76783. getHashCode(): number;
  76784. /**
  76785. * Copy the quaternion to an array
  76786. * @returns a new array populated with 4 elements from the quaternion coordinates
  76787. */
  76788. asArray(): number[];
  76789. /**
  76790. * Check if two quaternions are equals
  76791. * @param otherQuaternion defines the second operand
  76792. * @return true if the current quaternion and the given one coordinates are strictly equals
  76793. */
  76794. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  76795. /**
  76796. * Gets a boolean if two quaternions are equals (using an epsilon value)
  76797. * @param otherQuaternion defines the other quaternion
  76798. * @param epsilon defines the minimal distance to consider equality
  76799. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  76800. */
  76801. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  76802. /**
  76803. * Clone the current quaternion
  76804. * @returns a new quaternion copied from the current one
  76805. */
  76806. clone(): Quaternion;
  76807. /**
  76808. * Copy a quaternion to the current one
  76809. * @param other defines the other quaternion
  76810. * @returns the updated current quaternion
  76811. */
  76812. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  76813. /**
  76814. * Updates the current quaternion with the given float coordinates
  76815. * @param x defines the x coordinate
  76816. * @param y defines the y coordinate
  76817. * @param z defines the z coordinate
  76818. * @param w defines the w coordinate
  76819. * @returns the updated current quaternion
  76820. */
  76821. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  76822. /**
  76823. * Updates the current quaternion from the given float coordinates
  76824. * @param x defines the x coordinate
  76825. * @param y defines the y coordinate
  76826. * @param z defines the z coordinate
  76827. * @param w defines the w coordinate
  76828. * @returns the updated current quaternion
  76829. */
  76830. set(x: number, y: number, z: number, w: number): Quaternion;
  76831. /**
  76832. * Adds two quaternions
  76833. * @param other defines the second operand
  76834. * @returns a new quaternion as the addition result of the given one and the current quaternion
  76835. */
  76836. add(other: DeepImmutable<Quaternion>): Quaternion;
  76837. /**
  76838. * Add a quaternion to the current one
  76839. * @param other defines the quaternion to add
  76840. * @returns the current quaternion
  76841. */
  76842. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  76843. /**
  76844. * Subtract two quaternions
  76845. * @param other defines the second operand
  76846. * @returns a new quaternion as the subtraction result of the given one from the current one
  76847. */
  76848. subtract(other: Quaternion): Quaternion;
  76849. /**
  76850. * Multiplies the current quaternion by a scale factor
  76851. * @param value defines the scale factor
  76852. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  76853. */
  76854. scale(value: number): Quaternion;
  76855. /**
  76856. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  76857. * @param scale defines the scale factor
  76858. * @param result defines the Quaternion object where to store the result
  76859. * @returns the unmodified current quaternion
  76860. */
  76861. scaleToRef(scale: number, result: Quaternion): Quaternion;
  76862. /**
  76863. * Multiplies in place the current quaternion by a scale factor
  76864. * @param value defines the scale factor
  76865. * @returns the current modified quaternion
  76866. */
  76867. scaleInPlace(value: number): Quaternion;
  76868. /**
  76869. * Scale the current quaternion values by a factor and add the result to a given quaternion
  76870. * @param scale defines the scale factor
  76871. * @param result defines the Quaternion object where to store the result
  76872. * @returns the unmodified current quaternion
  76873. */
  76874. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  76875. /**
  76876. * Multiplies two quaternions
  76877. * @param q1 defines the second operand
  76878. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  76879. */
  76880. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  76881. /**
  76882. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  76883. * @param q1 defines the second operand
  76884. * @param result defines the target quaternion
  76885. * @returns the current quaternion
  76886. */
  76887. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  76888. /**
  76889. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  76890. * @param q1 defines the second operand
  76891. * @returns the currentupdated quaternion
  76892. */
  76893. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  76894. /**
  76895. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  76896. * @param ref defines the target quaternion
  76897. * @returns the current quaternion
  76898. */
  76899. conjugateToRef(ref: Quaternion): Quaternion;
  76900. /**
  76901. * Conjugates in place (1-q) the current quaternion
  76902. * @returns the current updated quaternion
  76903. */
  76904. conjugateInPlace(): Quaternion;
  76905. /**
  76906. * Conjugates in place (1-q) the current quaternion
  76907. * @returns a new quaternion
  76908. */
  76909. conjugate(): Quaternion;
  76910. /**
  76911. * Gets length of current quaternion
  76912. * @returns the quaternion length (float)
  76913. */
  76914. length(): number;
  76915. /**
  76916. * Normalize in place the current quaternion
  76917. * @returns the current updated quaternion
  76918. */
  76919. normalize(): Quaternion;
  76920. /**
  76921. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  76922. * @param order is a reserved parameter and is ignore for now
  76923. * @returns a new Vector3 containing the Euler angles
  76924. */
  76925. toEulerAngles(order?: string): Vector3;
  76926. /**
  76927. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  76928. * @param result defines the vector which will be filled with the Euler angles
  76929. * @param order is a reserved parameter and is ignore for now
  76930. * @returns the current unchanged quaternion
  76931. */
  76932. toEulerAnglesToRef(result: Vector3): Quaternion;
  76933. /**
  76934. * Updates the given rotation matrix with the current quaternion values
  76935. * @param result defines the target matrix
  76936. * @returns the current unchanged quaternion
  76937. */
  76938. toRotationMatrix(result: Matrix): Quaternion;
  76939. /**
  76940. * Updates the current quaternion from the given rotation matrix values
  76941. * @param matrix defines the source matrix
  76942. * @returns the current updated quaternion
  76943. */
  76944. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  76945. /**
  76946. * Creates a new quaternion from a rotation matrix
  76947. * @param matrix defines the source matrix
  76948. * @returns a new quaternion created from the given rotation matrix values
  76949. */
  76950. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  76951. /**
  76952. * Updates the given quaternion with the given rotation matrix values
  76953. * @param matrix defines the source matrix
  76954. * @param result defines the target quaternion
  76955. */
  76956. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  76957. /**
  76958. * Returns the dot product (float) between the quaternions "left" and "right"
  76959. * @param left defines the left operand
  76960. * @param right defines the right operand
  76961. * @returns the dot product
  76962. */
  76963. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  76964. /**
  76965. * Checks if the two quaternions are close to each other
  76966. * @param quat0 defines the first quaternion to check
  76967. * @param quat1 defines the second quaternion to check
  76968. * @returns true if the two quaternions are close to each other
  76969. */
  76970. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  76971. /**
  76972. * Creates an empty quaternion
  76973. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  76974. */
  76975. static Zero(): Quaternion;
  76976. /**
  76977. * Inverse a given quaternion
  76978. * @param q defines the source quaternion
  76979. * @returns a new quaternion as the inverted current quaternion
  76980. */
  76981. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  76982. /**
  76983. * Inverse a given quaternion
  76984. * @param q defines the source quaternion
  76985. * @param result the quaternion the result will be stored in
  76986. * @returns the result quaternion
  76987. */
  76988. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  76989. /**
  76990. * Creates an identity quaternion
  76991. * @returns the identity quaternion
  76992. */
  76993. static Identity(): Quaternion;
  76994. /**
  76995. * Gets a boolean indicating if the given quaternion is identity
  76996. * @param quaternion defines the quaternion to check
  76997. * @returns true if the quaternion is identity
  76998. */
  76999. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  77000. /**
  77001. * Creates a quaternion from a rotation around an axis
  77002. * @param axis defines the axis to use
  77003. * @param angle defines the angle to use
  77004. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  77005. */
  77006. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  77007. /**
  77008. * Creates a rotation around an axis and stores it into the given quaternion
  77009. * @param axis defines the axis to use
  77010. * @param angle defines the angle to use
  77011. * @param result defines the target quaternion
  77012. * @returns the target quaternion
  77013. */
  77014. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  77015. /**
  77016. * Creates a new quaternion from data stored into an array
  77017. * @param array defines the data source
  77018. * @param offset defines the offset in the source array where the data starts
  77019. * @returns a new quaternion
  77020. */
  77021. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  77022. /**
  77023. * Create a quaternion from Euler rotation angles
  77024. * @param x Pitch
  77025. * @param y Yaw
  77026. * @param z Roll
  77027. * @returns the new Quaternion
  77028. */
  77029. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  77030. /**
  77031. * Updates a quaternion from Euler rotation angles
  77032. * @param x Pitch
  77033. * @param y Yaw
  77034. * @param z Roll
  77035. * @param result the quaternion to store the result
  77036. * @returns the updated quaternion
  77037. */
  77038. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  77039. /**
  77040. * Create a quaternion from Euler rotation vector
  77041. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  77042. * @returns the new Quaternion
  77043. */
  77044. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  77045. /**
  77046. * Updates a quaternion from Euler rotation vector
  77047. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  77048. * @param result the quaternion to store the result
  77049. * @returns the updated quaternion
  77050. */
  77051. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  77052. /**
  77053. * Creates a new quaternion from the given Euler float angles (y, x, z)
  77054. * @param yaw defines the rotation around Y axis
  77055. * @param pitch defines the rotation around X axis
  77056. * @param roll defines the rotation around Z axis
  77057. * @returns the new quaternion
  77058. */
  77059. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  77060. /**
  77061. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  77062. * @param yaw defines the rotation around Y axis
  77063. * @param pitch defines the rotation around X axis
  77064. * @param roll defines the rotation around Z axis
  77065. * @param result defines the target quaternion
  77066. */
  77067. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  77068. /**
  77069. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  77070. * @param alpha defines the rotation around first axis
  77071. * @param beta defines the rotation around second axis
  77072. * @param gamma defines the rotation around third axis
  77073. * @returns the new quaternion
  77074. */
  77075. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  77076. /**
  77077. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  77078. * @param alpha defines the rotation around first axis
  77079. * @param beta defines the rotation around second axis
  77080. * @param gamma defines the rotation around third axis
  77081. * @param result defines the target quaternion
  77082. */
  77083. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  77084. /**
  77085. * 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)
  77086. * @param axis1 defines the first axis
  77087. * @param axis2 defines the second axis
  77088. * @param axis3 defines the third axis
  77089. * @returns the new quaternion
  77090. */
  77091. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  77092. /**
  77093. * 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
  77094. * @param axis1 defines the first axis
  77095. * @param axis2 defines the second axis
  77096. * @param axis3 defines the third axis
  77097. * @param ref defines the target quaternion
  77098. */
  77099. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  77100. /**
  77101. * Interpolates between two quaternions
  77102. * @param left defines first quaternion
  77103. * @param right defines second quaternion
  77104. * @param amount defines the gradient to use
  77105. * @returns the new interpolated quaternion
  77106. */
  77107. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  77108. /**
  77109. * Interpolates between two quaternions and stores it into a target quaternion
  77110. * @param left defines first quaternion
  77111. * @param right defines second quaternion
  77112. * @param amount defines the gradient to use
  77113. * @param result defines the target quaternion
  77114. */
  77115. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  77116. /**
  77117. * Interpolate between two quaternions using Hermite interpolation
  77118. * @param value1 defines first quaternion
  77119. * @param tangent1 defines the incoming tangent
  77120. * @param value2 defines second quaternion
  77121. * @param tangent2 defines the outgoing tangent
  77122. * @param amount defines the target quaternion
  77123. * @returns the new interpolated quaternion
  77124. */
  77125. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  77126. }
  77127. /**
  77128. * Class used to store matrix data (4x4)
  77129. */
  77130. export class Matrix {
  77131. private static _updateFlagSeed;
  77132. private static _identityReadOnly;
  77133. private _isIdentity;
  77134. private _isIdentityDirty;
  77135. private _isIdentity3x2;
  77136. private _isIdentity3x2Dirty;
  77137. /**
  77138. * Gets the update flag of the matrix which is an unique number for the matrix.
  77139. * It will be incremented every time the matrix data change.
  77140. * You can use it to speed the comparison between two versions of the same matrix.
  77141. */
  77142. updateFlag: number;
  77143. private readonly _m;
  77144. /**
  77145. * Gets the internal data of the matrix
  77146. */
  77147. get m(): DeepImmutable<Float32Array>;
  77148. /** @hidden */
  77149. _markAsUpdated(): void;
  77150. /** @hidden */
  77151. private _updateIdentityStatus;
  77152. /**
  77153. * Creates an empty matrix (filled with zeros)
  77154. */
  77155. constructor();
  77156. /**
  77157. * Check if the current matrix is identity
  77158. * @returns true is the matrix is the identity matrix
  77159. */
  77160. isIdentity(): boolean;
  77161. /**
  77162. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  77163. * @returns true is the matrix is the identity matrix
  77164. */
  77165. isIdentityAs3x2(): boolean;
  77166. /**
  77167. * Gets the determinant of the matrix
  77168. * @returns the matrix determinant
  77169. */
  77170. determinant(): number;
  77171. /**
  77172. * Returns the matrix as a Float32Array
  77173. * @returns the matrix underlying array
  77174. */
  77175. toArray(): DeepImmutable<Float32Array>;
  77176. /**
  77177. * Returns the matrix as a Float32Array
  77178. * @returns the matrix underlying array.
  77179. */
  77180. asArray(): DeepImmutable<Float32Array>;
  77181. /**
  77182. * Inverts the current matrix in place
  77183. * @returns the current inverted matrix
  77184. */
  77185. invert(): Matrix;
  77186. /**
  77187. * Sets all the matrix elements to zero
  77188. * @returns the current matrix
  77189. */
  77190. reset(): Matrix;
  77191. /**
  77192. * Adds the current matrix with a second one
  77193. * @param other defines the matrix to add
  77194. * @returns a new matrix as the addition of the current matrix and the given one
  77195. */
  77196. add(other: DeepImmutable<Matrix>): Matrix;
  77197. /**
  77198. * Sets the given matrix "result" to the addition of the current matrix and the given one
  77199. * @param other defines the matrix to add
  77200. * @param result defines the target matrix
  77201. * @returns the current matrix
  77202. */
  77203. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  77204. /**
  77205. * Adds in place the given matrix to the current matrix
  77206. * @param other defines the second operand
  77207. * @returns the current updated matrix
  77208. */
  77209. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  77210. /**
  77211. * Sets the given matrix to the current inverted Matrix
  77212. * @param other defines the target matrix
  77213. * @returns the unmodified current matrix
  77214. */
  77215. invertToRef(other: Matrix): Matrix;
  77216. /**
  77217. * add a value at the specified position in the current Matrix
  77218. * @param index the index of the value within the matrix. between 0 and 15.
  77219. * @param value the value to be added
  77220. * @returns the current updated matrix
  77221. */
  77222. addAtIndex(index: number, value: number): Matrix;
  77223. /**
  77224. * mutiply the specified position in the current Matrix by a value
  77225. * @param index the index of the value within the matrix. between 0 and 15.
  77226. * @param value the value to be added
  77227. * @returns the current updated matrix
  77228. */
  77229. multiplyAtIndex(index: number, value: number): Matrix;
  77230. /**
  77231. * Inserts the translation vector (using 3 floats) in the current matrix
  77232. * @param x defines the 1st component of the translation
  77233. * @param y defines the 2nd component of the translation
  77234. * @param z defines the 3rd component of the translation
  77235. * @returns the current updated matrix
  77236. */
  77237. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  77238. /**
  77239. * Adds the translation vector (using 3 floats) in the current matrix
  77240. * @param x defines the 1st component of the translation
  77241. * @param y defines the 2nd component of the translation
  77242. * @param z defines the 3rd component of the translation
  77243. * @returns the current updated matrix
  77244. */
  77245. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  77246. /**
  77247. * Inserts the translation vector in the current matrix
  77248. * @param vector3 defines the translation to insert
  77249. * @returns the current updated matrix
  77250. */
  77251. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  77252. /**
  77253. * Gets the translation value of the current matrix
  77254. * @returns a new Vector3 as the extracted translation from the matrix
  77255. */
  77256. getTranslation(): Vector3;
  77257. /**
  77258. * Fill a Vector3 with the extracted translation from the matrix
  77259. * @param result defines the Vector3 where to store the translation
  77260. * @returns the current matrix
  77261. */
  77262. getTranslationToRef(result: Vector3): Matrix;
  77263. /**
  77264. * Remove rotation and scaling part from the matrix
  77265. * @returns the updated matrix
  77266. */
  77267. removeRotationAndScaling(): Matrix;
  77268. /**
  77269. * Multiply two matrices
  77270. * @param other defines the second operand
  77271. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  77272. */
  77273. multiply(other: DeepImmutable<Matrix>): Matrix;
  77274. /**
  77275. * Copy the current matrix from the given one
  77276. * @param other defines the source matrix
  77277. * @returns the current updated matrix
  77278. */
  77279. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  77280. /**
  77281. * Populates the given array from the starting index with the current matrix values
  77282. * @param array defines the target array
  77283. * @param offset defines the offset in the target array where to start storing values
  77284. * @returns the current matrix
  77285. */
  77286. copyToArray(array: Float32Array, offset?: number): Matrix;
  77287. /**
  77288. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  77289. * @param other defines the second operand
  77290. * @param result defines the matrix where to store the multiplication
  77291. * @returns the current matrix
  77292. */
  77293. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  77294. /**
  77295. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  77296. * @param other defines the second operand
  77297. * @param result defines the array where to store the multiplication
  77298. * @param offset defines the offset in the target array where to start storing values
  77299. * @returns the current matrix
  77300. */
  77301. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  77302. /**
  77303. * Check equality between this matrix and a second one
  77304. * @param value defines the second matrix to compare
  77305. * @returns true is the current matrix and the given one values are strictly equal
  77306. */
  77307. equals(value: DeepImmutable<Matrix>): boolean;
  77308. /**
  77309. * Clone the current matrix
  77310. * @returns a new matrix from the current matrix
  77311. */
  77312. clone(): Matrix;
  77313. /**
  77314. * Returns the name of the current matrix class
  77315. * @returns the string "Matrix"
  77316. */
  77317. getClassName(): string;
  77318. /**
  77319. * Gets the hash code of the current matrix
  77320. * @returns the hash code
  77321. */
  77322. getHashCode(): number;
  77323. /**
  77324. * Decomposes the current Matrix into a translation, rotation and scaling components
  77325. * @param scale defines the scale vector3 given as a reference to update
  77326. * @param rotation defines the rotation quaternion given as a reference to update
  77327. * @param translation defines the translation vector3 given as a reference to update
  77328. * @returns true if operation was successful
  77329. */
  77330. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  77331. /**
  77332. * Gets specific row of the matrix
  77333. * @param index defines the number of the row to get
  77334. * @returns the index-th row of the current matrix as a new Vector4
  77335. */
  77336. getRow(index: number): Nullable<Vector4>;
  77337. /**
  77338. * Sets the index-th row of the current matrix to the vector4 values
  77339. * @param index defines the number of the row to set
  77340. * @param row defines the target vector4
  77341. * @returns the updated current matrix
  77342. */
  77343. setRow(index: number, row: Vector4): Matrix;
  77344. /**
  77345. * Compute the transpose of the matrix
  77346. * @returns the new transposed matrix
  77347. */
  77348. transpose(): Matrix;
  77349. /**
  77350. * Compute the transpose of the matrix and store it in a given matrix
  77351. * @param result defines the target matrix
  77352. * @returns the current matrix
  77353. */
  77354. transposeToRef(result: Matrix): Matrix;
  77355. /**
  77356. * Sets the index-th row of the current matrix with the given 4 x float values
  77357. * @param index defines the row index
  77358. * @param x defines the x component to set
  77359. * @param y defines the y component to set
  77360. * @param z defines the z component to set
  77361. * @param w defines the w component to set
  77362. * @returns the updated current matrix
  77363. */
  77364. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  77365. /**
  77366. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  77367. * @param scale defines the scale factor
  77368. * @returns a new matrix
  77369. */
  77370. scale(scale: number): Matrix;
  77371. /**
  77372. * Scale the current matrix values by a factor to a given result matrix
  77373. * @param scale defines the scale factor
  77374. * @param result defines the matrix to store the result
  77375. * @returns the current matrix
  77376. */
  77377. scaleToRef(scale: number, result: Matrix): Matrix;
  77378. /**
  77379. * Scale the current matrix values by a factor and add the result to a given matrix
  77380. * @param scale defines the scale factor
  77381. * @param result defines the Matrix to store the result
  77382. * @returns the current matrix
  77383. */
  77384. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  77385. /**
  77386. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  77387. * @param ref matrix to store the result
  77388. */
  77389. toNormalMatrix(ref: Matrix): void;
  77390. /**
  77391. * Gets only rotation part of the current matrix
  77392. * @returns a new matrix sets to the extracted rotation matrix from the current one
  77393. */
  77394. getRotationMatrix(): Matrix;
  77395. /**
  77396. * Extracts the rotation matrix from the current one and sets it as the given "result"
  77397. * @param result defines the target matrix to store data to
  77398. * @returns the current matrix
  77399. */
  77400. getRotationMatrixToRef(result: Matrix): Matrix;
  77401. /**
  77402. * Toggles model matrix from being right handed to left handed in place and vice versa
  77403. */
  77404. toggleModelMatrixHandInPlace(): void;
  77405. /**
  77406. * Toggles projection matrix from being right handed to left handed in place and vice versa
  77407. */
  77408. toggleProjectionMatrixHandInPlace(): void;
  77409. /**
  77410. * Creates a matrix from an array
  77411. * @param array defines the source array
  77412. * @param offset defines an offset in the source array
  77413. * @returns a new Matrix set from the starting index of the given array
  77414. */
  77415. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  77416. /**
  77417. * Copy the content of an array into a given matrix
  77418. * @param array defines the source array
  77419. * @param offset defines an offset in the source array
  77420. * @param result defines the target matrix
  77421. */
  77422. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  77423. /**
  77424. * Stores an array into a matrix after having multiplied each component by a given factor
  77425. * @param array defines the source array
  77426. * @param offset defines the offset in the source array
  77427. * @param scale defines the scaling factor
  77428. * @param result defines the target matrix
  77429. */
  77430. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  77431. /**
  77432. * Gets an identity matrix that must not be updated
  77433. */
  77434. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  77435. /**
  77436. * Stores a list of values (16) inside a given matrix
  77437. * @param initialM11 defines 1st value of 1st row
  77438. * @param initialM12 defines 2nd value of 1st row
  77439. * @param initialM13 defines 3rd value of 1st row
  77440. * @param initialM14 defines 4th value of 1st row
  77441. * @param initialM21 defines 1st value of 2nd row
  77442. * @param initialM22 defines 2nd value of 2nd row
  77443. * @param initialM23 defines 3rd value of 2nd row
  77444. * @param initialM24 defines 4th value of 2nd row
  77445. * @param initialM31 defines 1st value of 3rd row
  77446. * @param initialM32 defines 2nd value of 3rd row
  77447. * @param initialM33 defines 3rd value of 3rd row
  77448. * @param initialM34 defines 4th value of 3rd row
  77449. * @param initialM41 defines 1st value of 4th row
  77450. * @param initialM42 defines 2nd value of 4th row
  77451. * @param initialM43 defines 3rd value of 4th row
  77452. * @param initialM44 defines 4th value of 4th row
  77453. * @param result defines the target matrix
  77454. */
  77455. 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;
  77456. /**
  77457. * Creates new matrix from a list of values (16)
  77458. * @param initialM11 defines 1st value of 1st row
  77459. * @param initialM12 defines 2nd value of 1st row
  77460. * @param initialM13 defines 3rd value of 1st row
  77461. * @param initialM14 defines 4th value of 1st row
  77462. * @param initialM21 defines 1st value of 2nd row
  77463. * @param initialM22 defines 2nd value of 2nd row
  77464. * @param initialM23 defines 3rd value of 2nd row
  77465. * @param initialM24 defines 4th value of 2nd row
  77466. * @param initialM31 defines 1st value of 3rd row
  77467. * @param initialM32 defines 2nd value of 3rd row
  77468. * @param initialM33 defines 3rd value of 3rd row
  77469. * @param initialM34 defines 4th value of 3rd row
  77470. * @param initialM41 defines 1st value of 4th row
  77471. * @param initialM42 defines 2nd value of 4th row
  77472. * @param initialM43 defines 3rd value of 4th row
  77473. * @param initialM44 defines 4th value of 4th row
  77474. * @returns the new matrix
  77475. */
  77476. 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;
  77477. /**
  77478. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  77479. * @param scale defines the scale vector3
  77480. * @param rotation defines the rotation quaternion
  77481. * @param translation defines the translation vector3
  77482. * @returns a new matrix
  77483. */
  77484. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  77485. /**
  77486. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  77487. * @param scale defines the scale vector3
  77488. * @param rotation defines the rotation quaternion
  77489. * @param translation defines the translation vector3
  77490. * @param result defines the target matrix
  77491. */
  77492. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  77493. /**
  77494. * Creates a new identity matrix
  77495. * @returns a new identity matrix
  77496. */
  77497. static Identity(): Matrix;
  77498. /**
  77499. * Creates a new identity matrix and stores the result in a given matrix
  77500. * @param result defines the target matrix
  77501. */
  77502. static IdentityToRef(result: Matrix): void;
  77503. /**
  77504. * Creates a new zero matrix
  77505. * @returns a new zero matrix
  77506. */
  77507. static Zero(): Matrix;
  77508. /**
  77509. * Creates a new rotation matrix for "angle" radians around the X axis
  77510. * @param angle defines the angle (in radians) to use
  77511. * @return the new matrix
  77512. */
  77513. static RotationX(angle: number): Matrix;
  77514. /**
  77515. * Creates a new matrix as the invert of a given matrix
  77516. * @param source defines the source matrix
  77517. * @returns the new matrix
  77518. */
  77519. static Invert(source: DeepImmutable<Matrix>): Matrix;
  77520. /**
  77521. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  77522. * @param angle defines the angle (in radians) to use
  77523. * @param result defines the target matrix
  77524. */
  77525. static RotationXToRef(angle: number, result: Matrix): void;
  77526. /**
  77527. * Creates a new rotation matrix for "angle" radians around the Y axis
  77528. * @param angle defines the angle (in radians) to use
  77529. * @return the new matrix
  77530. */
  77531. static RotationY(angle: number): Matrix;
  77532. /**
  77533. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  77534. * @param angle defines the angle (in radians) to use
  77535. * @param result defines the target matrix
  77536. */
  77537. static RotationYToRef(angle: number, result: Matrix): void;
  77538. /**
  77539. * Creates a new rotation matrix for "angle" radians around the Z axis
  77540. * @param angle defines the angle (in radians) to use
  77541. * @return the new matrix
  77542. */
  77543. static RotationZ(angle: number): Matrix;
  77544. /**
  77545. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  77546. * @param angle defines the angle (in radians) to use
  77547. * @param result defines the target matrix
  77548. */
  77549. static RotationZToRef(angle: number, result: Matrix): void;
  77550. /**
  77551. * Creates a new rotation matrix for "angle" radians around the given axis
  77552. * @param axis defines the axis to use
  77553. * @param angle defines the angle (in radians) to use
  77554. * @return the new matrix
  77555. */
  77556. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  77557. /**
  77558. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  77559. * @param axis defines the axis to use
  77560. * @param angle defines the angle (in radians) to use
  77561. * @param result defines the target matrix
  77562. */
  77563. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  77564. /**
  77565. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  77566. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  77567. * @param from defines the vector to align
  77568. * @param to defines the vector to align to
  77569. * @param result defines the target matrix
  77570. */
  77571. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  77572. /**
  77573. * Creates a rotation matrix
  77574. * @param yaw defines the yaw angle in radians (Y axis)
  77575. * @param pitch defines the pitch angle in radians (X axis)
  77576. * @param roll defines the roll angle in radians (X axis)
  77577. * @returns the new rotation matrix
  77578. */
  77579. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  77580. /**
  77581. * Creates a rotation matrix and stores it in a given matrix
  77582. * @param yaw defines the yaw angle in radians (Y axis)
  77583. * @param pitch defines the pitch angle in radians (X axis)
  77584. * @param roll defines the roll angle in radians (X axis)
  77585. * @param result defines the target matrix
  77586. */
  77587. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  77588. /**
  77589. * Creates a scaling matrix
  77590. * @param x defines the scale factor on X axis
  77591. * @param y defines the scale factor on Y axis
  77592. * @param z defines the scale factor on Z axis
  77593. * @returns the new matrix
  77594. */
  77595. static Scaling(x: number, y: number, z: number): Matrix;
  77596. /**
  77597. * Creates a scaling matrix and stores it in a given matrix
  77598. * @param x defines the scale factor on X axis
  77599. * @param y defines the scale factor on Y axis
  77600. * @param z defines the scale factor on Z axis
  77601. * @param result defines the target matrix
  77602. */
  77603. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  77604. /**
  77605. * Creates a translation matrix
  77606. * @param x defines the translation on X axis
  77607. * @param y defines the translation on Y axis
  77608. * @param z defines the translationon Z axis
  77609. * @returns the new matrix
  77610. */
  77611. static Translation(x: number, y: number, z: number): Matrix;
  77612. /**
  77613. * Creates a translation matrix and stores it in a given matrix
  77614. * @param x defines the translation on X axis
  77615. * @param y defines the translation on Y axis
  77616. * @param z defines the translationon Z axis
  77617. * @param result defines the target matrix
  77618. */
  77619. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  77620. /**
  77621. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  77622. * @param startValue defines the start value
  77623. * @param endValue defines the end value
  77624. * @param gradient defines the gradient factor
  77625. * @returns the new matrix
  77626. */
  77627. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  77628. /**
  77629. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  77630. * @param startValue defines the start value
  77631. * @param endValue defines the end value
  77632. * @param gradient defines the gradient factor
  77633. * @param result defines the Matrix object where to store data
  77634. */
  77635. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  77636. /**
  77637. * Builds a new matrix whose values are computed by:
  77638. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  77639. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  77640. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  77641. * @param startValue defines the first matrix
  77642. * @param endValue defines the second matrix
  77643. * @param gradient defines the gradient between the two matrices
  77644. * @returns the new matrix
  77645. */
  77646. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  77647. /**
  77648. * Update a matrix to values which are computed by:
  77649. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  77650. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  77651. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  77652. * @param startValue defines the first matrix
  77653. * @param endValue defines the second matrix
  77654. * @param gradient defines the gradient between the two matrices
  77655. * @param result defines the target matrix
  77656. */
  77657. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  77658. /**
  77659. * 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"
  77660. * This function works in left handed mode
  77661. * @param eye defines the final position of the entity
  77662. * @param target defines where the entity should look at
  77663. * @param up defines the up vector for the entity
  77664. * @returns the new matrix
  77665. */
  77666. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  77667. /**
  77668. * 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".
  77669. * This function works in left handed mode
  77670. * @param eye defines the final position of the entity
  77671. * @param target defines where the entity should look at
  77672. * @param up defines the up vector for the entity
  77673. * @param result defines the target matrix
  77674. */
  77675. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  77676. /**
  77677. * 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"
  77678. * This function works in right handed mode
  77679. * @param eye defines the final position of the entity
  77680. * @param target defines where the entity should look at
  77681. * @param up defines the up vector for the entity
  77682. * @returns the new matrix
  77683. */
  77684. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  77685. /**
  77686. * 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".
  77687. * This function works in right handed mode
  77688. * @param eye defines the final position of the entity
  77689. * @param target defines where the entity should look at
  77690. * @param up defines the up vector for the entity
  77691. * @param result defines the target matrix
  77692. */
  77693. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  77694. /**
  77695. * Create a left-handed orthographic projection matrix
  77696. * @param width defines the viewport width
  77697. * @param height defines the viewport height
  77698. * @param znear defines the near clip plane
  77699. * @param zfar defines the far clip plane
  77700. * @returns a new matrix as a left-handed orthographic projection matrix
  77701. */
  77702. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  77703. /**
  77704. * Store a left-handed orthographic projection to a given matrix
  77705. * @param width defines the viewport width
  77706. * @param height defines the viewport height
  77707. * @param znear defines the near clip plane
  77708. * @param zfar defines the far clip plane
  77709. * @param result defines the target matrix
  77710. */
  77711. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  77712. /**
  77713. * Create a left-handed orthographic projection matrix
  77714. * @param left defines the viewport left coordinate
  77715. * @param right defines the viewport right coordinate
  77716. * @param bottom defines the viewport bottom coordinate
  77717. * @param top defines the viewport top coordinate
  77718. * @param znear defines the near clip plane
  77719. * @param zfar defines the far clip plane
  77720. * @returns a new matrix as a left-handed orthographic projection matrix
  77721. */
  77722. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  77723. /**
  77724. * Stores a left-handed orthographic projection into a given matrix
  77725. * @param left defines the viewport left coordinate
  77726. * @param right defines the viewport right coordinate
  77727. * @param bottom defines the viewport bottom coordinate
  77728. * @param top defines the viewport top coordinate
  77729. * @param znear defines the near clip plane
  77730. * @param zfar defines the far clip plane
  77731. * @param result defines the target matrix
  77732. */
  77733. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  77734. /**
  77735. * Creates a right-handed orthographic projection matrix
  77736. * @param left defines the viewport left coordinate
  77737. * @param right defines the viewport right coordinate
  77738. * @param bottom defines the viewport bottom coordinate
  77739. * @param top defines the viewport top coordinate
  77740. * @param znear defines the near clip plane
  77741. * @param zfar defines the far clip plane
  77742. * @returns a new matrix as a right-handed orthographic projection matrix
  77743. */
  77744. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  77745. /**
  77746. * Stores a right-handed orthographic projection into a given matrix
  77747. * @param left defines the viewport left coordinate
  77748. * @param right defines the viewport right coordinate
  77749. * @param bottom defines the viewport bottom coordinate
  77750. * @param top defines the viewport top coordinate
  77751. * @param znear defines the near clip plane
  77752. * @param zfar defines the far clip plane
  77753. * @param result defines the target matrix
  77754. */
  77755. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  77756. /**
  77757. * Creates a left-handed perspective projection matrix
  77758. * @param width defines the viewport width
  77759. * @param height defines the viewport height
  77760. * @param znear defines the near clip plane
  77761. * @param zfar defines the far clip plane
  77762. * @returns a new matrix as a left-handed perspective projection matrix
  77763. */
  77764. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  77765. /**
  77766. * Creates a left-handed perspective projection matrix
  77767. * @param fov defines the horizontal field of view
  77768. * @param aspect defines the aspect ratio
  77769. * @param znear defines the near clip plane
  77770. * @param zfar defines the far clip plane
  77771. * @returns a new matrix as a left-handed perspective projection matrix
  77772. */
  77773. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  77774. /**
  77775. * Stores a left-handed perspective projection into a given matrix
  77776. * @param fov defines the horizontal field of view
  77777. * @param aspect defines the aspect ratio
  77778. * @param znear defines the near clip plane
  77779. * @param zfar defines the far clip plane
  77780. * @param result defines the target matrix
  77781. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77782. */
  77783. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77784. /**
  77785. * Stores a left-handed perspective projection into a given matrix with depth reversed
  77786. * @param fov defines the horizontal field of view
  77787. * @param aspect defines the aspect ratio
  77788. * @param znear defines the near clip plane
  77789. * @param zfar not used as infinity is used as far clip
  77790. * @param result defines the target matrix
  77791. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77792. */
  77793. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77794. /**
  77795. * Creates a right-handed perspective projection matrix
  77796. * @param fov defines the horizontal field of view
  77797. * @param aspect defines the aspect ratio
  77798. * @param znear defines the near clip plane
  77799. * @param zfar defines the far clip plane
  77800. * @returns a new matrix as a right-handed perspective projection matrix
  77801. */
  77802. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  77803. /**
  77804. * Stores a right-handed perspective projection into a given matrix
  77805. * @param fov defines the horizontal field of view
  77806. * @param aspect defines the aspect ratio
  77807. * @param znear defines the near clip plane
  77808. * @param zfar defines the far clip plane
  77809. * @param result defines the target matrix
  77810. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77811. */
  77812. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77813. /**
  77814. * Stores a right-handed perspective projection into a given matrix
  77815. * @param fov defines the horizontal field of view
  77816. * @param aspect defines the aspect ratio
  77817. * @param znear defines the near clip plane
  77818. * @param zfar not used as infinity is used as far clip
  77819. * @param result defines the target matrix
  77820. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77821. */
  77822. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77823. /**
  77824. * Stores a perspective projection for WebVR info a given matrix
  77825. * @param fov defines the field of view
  77826. * @param znear defines the near clip plane
  77827. * @param zfar defines the far clip plane
  77828. * @param result defines the target matrix
  77829. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  77830. */
  77831. static PerspectiveFovWebVRToRef(fov: {
  77832. upDegrees: number;
  77833. downDegrees: number;
  77834. leftDegrees: number;
  77835. rightDegrees: number;
  77836. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  77837. /**
  77838. * Computes a complete transformation matrix
  77839. * @param viewport defines the viewport to use
  77840. * @param world defines the world matrix
  77841. * @param view defines the view matrix
  77842. * @param projection defines the projection matrix
  77843. * @param zmin defines the near clip plane
  77844. * @param zmax defines the far clip plane
  77845. * @returns the transformation matrix
  77846. */
  77847. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  77848. /**
  77849. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  77850. * @param matrix defines the matrix to use
  77851. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  77852. */
  77853. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  77854. /**
  77855. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  77856. * @param matrix defines the matrix to use
  77857. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  77858. */
  77859. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  77860. /**
  77861. * Compute the transpose of a given matrix
  77862. * @param matrix defines the matrix to transpose
  77863. * @returns the new matrix
  77864. */
  77865. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  77866. /**
  77867. * Compute the transpose of a matrix and store it in a target matrix
  77868. * @param matrix defines the matrix to transpose
  77869. * @param result defines the target matrix
  77870. */
  77871. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  77872. /**
  77873. * Computes a reflection matrix from a plane
  77874. * @param plane defines the reflection plane
  77875. * @returns a new matrix
  77876. */
  77877. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  77878. /**
  77879. * Computes a reflection matrix from a plane
  77880. * @param plane defines the reflection plane
  77881. * @param result defines the target matrix
  77882. */
  77883. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  77884. /**
  77885. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  77886. * @param xaxis defines the value of the 1st axis
  77887. * @param yaxis defines the value of the 2nd axis
  77888. * @param zaxis defines the value of the 3rd axis
  77889. * @param result defines the target matrix
  77890. */
  77891. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  77892. /**
  77893. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  77894. * @param quat defines the quaternion to use
  77895. * @param result defines the target matrix
  77896. */
  77897. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  77898. }
  77899. /**
  77900. * @hidden
  77901. */
  77902. export class TmpVectors {
  77903. static Vector2: Vector2[];
  77904. static Vector3: Vector3[];
  77905. static Vector4: Vector4[];
  77906. static Quaternion: Quaternion[];
  77907. static Matrix: Matrix[];
  77908. }
  77909. }
  77910. declare module BABYLON {
  77911. /**
  77912. * Defines potential orientation for back face culling
  77913. */
  77914. export enum Orientation {
  77915. /**
  77916. * Clockwise
  77917. */
  77918. CW = 0,
  77919. /** Counter clockwise */
  77920. CCW = 1
  77921. }
  77922. /** Class used to represent a Bezier curve */
  77923. export class BezierCurve {
  77924. /**
  77925. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  77926. * @param t defines the time
  77927. * @param x1 defines the left coordinate on X axis
  77928. * @param y1 defines the left coordinate on Y axis
  77929. * @param x2 defines the right coordinate on X axis
  77930. * @param y2 defines the right coordinate on Y axis
  77931. * @returns the interpolated value
  77932. */
  77933. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  77934. }
  77935. /**
  77936. * Defines angle representation
  77937. */
  77938. export class Angle {
  77939. private _radians;
  77940. /**
  77941. * Creates an Angle object of "radians" radians (float).
  77942. * @param radians the angle in radians
  77943. */
  77944. constructor(radians: number);
  77945. /**
  77946. * Get value in degrees
  77947. * @returns the Angle value in degrees (float)
  77948. */
  77949. degrees(): number;
  77950. /**
  77951. * Get value in radians
  77952. * @returns the Angle value in radians (float)
  77953. */
  77954. radians(): number;
  77955. /**
  77956. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  77957. * @param a defines first vector
  77958. * @param b defines second vector
  77959. * @returns a new Angle
  77960. */
  77961. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  77962. /**
  77963. * Gets a new Angle object from the given float in radians
  77964. * @param radians defines the angle value in radians
  77965. * @returns a new Angle
  77966. */
  77967. static FromRadians(radians: number): Angle;
  77968. /**
  77969. * Gets a new Angle object from the given float in degrees
  77970. * @param degrees defines the angle value in degrees
  77971. * @returns a new Angle
  77972. */
  77973. static FromDegrees(degrees: number): Angle;
  77974. }
  77975. /**
  77976. * This represents an arc in a 2d space.
  77977. */
  77978. export class Arc2 {
  77979. /** Defines the start point of the arc */
  77980. startPoint: Vector2;
  77981. /** Defines the mid point of the arc */
  77982. midPoint: Vector2;
  77983. /** Defines the end point of the arc */
  77984. endPoint: Vector2;
  77985. /**
  77986. * Defines the center point of the arc.
  77987. */
  77988. centerPoint: Vector2;
  77989. /**
  77990. * Defines the radius of the arc.
  77991. */
  77992. radius: number;
  77993. /**
  77994. * Defines the angle of the arc (from mid point to end point).
  77995. */
  77996. angle: Angle;
  77997. /**
  77998. * Defines the start angle of the arc (from start point to middle point).
  77999. */
  78000. startAngle: Angle;
  78001. /**
  78002. * Defines the orientation of the arc (clock wise/counter clock wise).
  78003. */
  78004. orientation: Orientation;
  78005. /**
  78006. * Creates an Arc object from the three given points : start, middle and end.
  78007. * @param startPoint Defines the start point of the arc
  78008. * @param midPoint Defines the midlle point of the arc
  78009. * @param endPoint Defines the end point of the arc
  78010. */
  78011. constructor(
  78012. /** Defines the start point of the arc */
  78013. startPoint: Vector2,
  78014. /** Defines the mid point of the arc */
  78015. midPoint: Vector2,
  78016. /** Defines the end point of the arc */
  78017. endPoint: Vector2);
  78018. }
  78019. /**
  78020. * Represents a 2D path made up of multiple 2D points
  78021. */
  78022. export class Path2 {
  78023. private _points;
  78024. private _length;
  78025. /**
  78026. * If the path start and end point are the same
  78027. */
  78028. closed: boolean;
  78029. /**
  78030. * Creates a Path2 object from the starting 2D coordinates x and y.
  78031. * @param x the starting points x value
  78032. * @param y the starting points y value
  78033. */
  78034. constructor(x: number, y: number);
  78035. /**
  78036. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  78037. * @param x the added points x value
  78038. * @param y the added points y value
  78039. * @returns the updated Path2.
  78040. */
  78041. addLineTo(x: number, y: number): Path2;
  78042. /**
  78043. * 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.
  78044. * @param midX middle point x value
  78045. * @param midY middle point y value
  78046. * @param endX end point x value
  78047. * @param endY end point y value
  78048. * @param numberOfSegments (default: 36)
  78049. * @returns the updated Path2.
  78050. */
  78051. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  78052. /**
  78053. * Closes the Path2.
  78054. * @returns the Path2.
  78055. */
  78056. close(): Path2;
  78057. /**
  78058. * Gets the sum of the distance between each sequential point in the path
  78059. * @returns the Path2 total length (float).
  78060. */
  78061. length(): number;
  78062. /**
  78063. * Gets the points which construct the path
  78064. * @returns the Path2 internal array of points.
  78065. */
  78066. getPoints(): Vector2[];
  78067. /**
  78068. * Retreives the point at the distance aways from the starting point
  78069. * @param normalizedLengthPosition the length along the path to retreive the point from
  78070. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  78071. */
  78072. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  78073. /**
  78074. * Creates a new path starting from an x and y position
  78075. * @param x starting x value
  78076. * @param y starting y value
  78077. * @returns a new Path2 starting at the coordinates (x, y).
  78078. */
  78079. static StartingAt(x: number, y: number): Path2;
  78080. }
  78081. /**
  78082. * Represents a 3D path made up of multiple 3D points
  78083. */
  78084. export class Path3D {
  78085. /**
  78086. * an array of Vector3, the curve axis of the Path3D
  78087. */
  78088. path: Vector3[];
  78089. private _curve;
  78090. private _distances;
  78091. private _tangents;
  78092. private _normals;
  78093. private _binormals;
  78094. private _raw;
  78095. private _alignTangentsWithPath;
  78096. private readonly _pointAtData;
  78097. /**
  78098. * new Path3D(path, normal, raw)
  78099. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  78100. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  78101. * @param path an array of Vector3, the curve axis of the Path3D
  78102. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  78103. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  78104. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  78105. */
  78106. constructor(
  78107. /**
  78108. * an array of Vector3, the curve axis of the Path3D
  78109. */
  78110. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  78111. /**
  78112. * Returns the Path3D array of successive Vector3 designing its curve.
  78113. * @returns the Path3D array of successive Vector3 designing its curve.
  78114. */
  78115. getCurve(): Vector3[];
  78116. /**
  78117. * Returns the Path3D array of successive Vector3 designing its curve.
  78118. * @returns the Path3D array of successive Vector3 designing its curve.
  78119. */
  78120. getPoints(): Vector3[];
  78121. /**
  78122. * @returns the computed length (float) of the path.
  78123. */
  78124. length(): number;
  78125. /**
  78126. * Returns an array populated with tangent vectors on each Path3D curve point.
  78127. * @returns an array populated with tangent vectors on each Path3D curve point.
  78128. */
  78129. getTangents(): Vector3[];
  78130. /**
  78131. * Returns an array populated with normal vectors on each Path3D curve point.
  78132. * @returns an array populated with normal vectors on each Path3D curve point.
  78133. */
  78134. getNormals(): Vector3[];
  78135. /**
  78136. * Returns an array populated with binormal vectors on each Path3D curve point.
  78137. * @returns an array populated with binormal vectors on each Path3D curve point.
  78138. */
  78139. getBinormals(): Vector3[];
  78140. /**
  78141. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  78142. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  78143. */
  78144. getDistances(): number[];
  78145. /**
  78146. * Returns an interpolated point along this path
  78147. * @param position the position of the point along this path, from 0.0 to 1.0
  78148. * @returns a new Vector3 as the point
  78149. */
  78150. getPointAt(position: number): Vector3;
  78151. /**
  78152. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  78153. * @param position the position of the point along this path, from 0.0 to 1.0
  78154. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  78155. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  78156. */
  78157. getTangentAt(position: number, interpolated?: boolean): Vector3;
  78158. /**
  78159. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  78160. * @param position the position of the point along this path, from 0.0 to 1.0
  78161. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  78162. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  78163. */
  78164. getNormalAt(position: number, interpolated?: boolean): Vector3;
  78165. /**
  78166. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  78167. * @param position the position of the point along this path, from 0.0 to 1.0
  78168. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  78169. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  78170. */
  78171. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  78172. /**
  78173. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  78174. * @param position the position of the point along this path, from 0.0 to 1.0
  78175. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  78176. */
  78177. getDistanceAt(position: number): number;
  78178. /**
  78179. * Returns the array index of the previous point of an interpolated point along this path
  78180. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  78181. * @returns the array index
  78182. */
  78183. getPreviousPointIndexAt(position: number): number;
  78184. /**
  78185. * 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)
  78186. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  78187. * @returns the sub position
  78188. */
  78189. getSubPositionAt(position: number): number;
  78190. /**
  78191. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  78192. * @param target the vector of which to get the closest position to
  78193. * @returns the position of the closest virtual point on this path to the target vector
  78194. */
  78195. getClosestPositionTo(target: Vector3): number;
  78196. /**
  78197. * Returns a sub path (slice) of this path
  78198. * @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
  78199. * @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
  78200. * @returns a sub path (slice) of this path
  78201. */
  78202. slice(start?: number, end?: number): Path3D;
  78203. /**
  78204. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  78205. * @param path path which all values are copied into the curves points
  78206. * @param firstNormal which should be projected onto the curve
  78207. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  78208. * @returns the same object updated.
  78209. */
  78210. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  78211. private _compute;
  78212. private _getFirstNonNullVector;
  78213. private _getLastNonNullVector;
  78214. private _normalVector;
  78215. /**
  78216. * Updates the point at data for an interpolated point along this curve
  78217. * @param position the position of the point along this curve, from 0.0 to 1.0
  78218. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  78219. * @returns the (updated) point at data
  78220. */
  78221. private _updatePointAtData;
  78222. /**
  78223. * Updates the point at data from the specified parameters
  78224. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  78225. * @param point the interpolated point
  78226. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  78227. */
  78228. private _setPointAtData;
  78229. /**
  78230. * Updates the point at interpolation matrix for the tangents, normals and binormals
  78231. */
  78232. private _updateInterpolationMatrix;
  78233. }
  78234. /**
  78235. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  78236. * A Curve3 is designed from a series of successive Vector3.
  78237. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  78238. */
  78239. export class Curve3 {
  78240. private _points;
  78241. private _length;
  78242. /**
  78243. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  78244. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  78245. * @param v1 (Vector3) the control point
  78246. * @param v2 (Vector3) the end point of the Quadratic Bezier
  78247. * @param nbPoints (integer) the wanted number of points in the curve
  78248. * @returns the created Curve3
  78249. */
  78250. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  78251. /**
  78252. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  78253. * @param v0 (Vector3) the origin point of the Cubic Bezier
  78254. * @param v1 (Vector3) the first control point
  78255. * @param v2 (Vector3) the second control point
  78256. * @param v3 (Vector3) the end point of the Cubic Bezier
  78257. * @param nbPoints (integer) the wanted number of points in the curve
  78258. * @returns the created Curve3
  78259. */
  78260. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  78261. /**
  78262. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  78263. * @param p1 (Vector3) the origin point of the Hermite Spline
  78264. * @param t1 (Vector3) the tangent vector at the origin point
  78265. * @param p2 (Vector3) the end point of the Hermite Spline
  78266. * @param t2 (Vector3) the tangent vector at the end point
  78267. * @param nbPoints (integer) the wanted number of points in the curve
  78268. * @returns the created Curve3
  78269. */
  78270. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  78271. /**
  78272. * Returns a Curve3 object along a CatmullRom Spline curve :
  78273. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  78274. * @param nbPoints (integer) the wanted number of points between each curve control points
  78275. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  78276. * @returns the created Curve3
  78277. */
  78278. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  78279. /**
  78280. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  78281. * A Curve3 is designed from a series of successive Vector3.
  78282. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  78283. * @param points points which make up the curve
  78284. */
  78285. constructor(points: Vector3[]);
  78286. /**
  78287. * @returns the Curve3 stored array of successive Vector3
  78288. */
  78289. getPoints(): Vector3[];
  78290. /**
  78291. * @returns the computed length (float) of the curve.
  78292. */
  78293. length(): number;
  78294. /**
  78295. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  78296. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  78297. * curveA and curveB keep unchanged.
  78298. * @param curve the curve to continue from this curve
  78299. * @returns the newly constructed curve
  78300. */
  78301. continue(curve: DeepImmutable<Curve3>): Curve3;
  78302. private _computeLength;
  78303. }
  78304. }
  78305. declare module BABYLON {
  78306. /**
  78307. * This represents the main contract an easing function should follow.
  78308. * Easing functions are used throughout the animation system.
  78309. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78310. */
  78311. export interface IEasingFunction {
  78312. /**
  78313. * Given an input gradient between 0 and 1, this returns the corrseponding value
  78314. * of the easing function.
  78315. * The link below provides some of the most common examples of easing functions.
  78316. * @see https://easings.net/
  78317. * @param gradient Defines the value between 0 and 1 we want the easing value for
  78318. * @returns the corresponding value on the curve defined by the easing function
  78319. */
  78320. ease(gradient: number): number;
  78321. }
  78322. /**
  78323. * Base class used for every default easing function.
  78324. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78325. */
  78326. export class EasingFunction implements IEasingFunction {
  78327. /**
  78328. * Interpolation follows the mathematical formula associated with the easing function.
  78329. */
  78330. static readonly EASINGMODE_EASEIN: number;
  78331. /**
  78332. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  78333. */
  78334. static readonly EASINGMODE_EASEOUT: number;
  78335. /**
  78336. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  78337. */
  78338. static readonly EASINGMODE_EASEINOUT: number;
  78339. private _easingMode;
  78340. /**
  78341. * Sets the easing mode of the current function.
  78342. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  78343. */
  78344. setEasingMode(easingMode: number): void;
  78345. /**
  78346. * Gets the current easing mode.
  78347. * @returns the easing mode
  78348. */
  78349. getEasingMode(): number;
  78350. /**
  78351. * @hidden
  78352. */
  78353. easeInCore(gradient: number): number;
  78354. /**
  78355. * Given an input gradient between 0 and 1, this returns the corresponding value
  78356. * of the easing function.
  78357. * @param gradient Defines the value between 0 and 1 we want the easing value for
  78358. * @returns the corresponding value on the curve defined by the easing function
  78359. */
  78360. ease(gradient: number): number;
  78361. }
  78362. /**
  78363. * Easing function with a circle shape (see link below).
  78364. * @see https://easings.net/#easeInCirc
  78365. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78366. */
  78367. export class CircleEase extends EasingFunction implements IEasingFunction {
  78368. /** @hidden */
  78369. easeInCore(gradient: number): number;
  78370. }
  78371. /**
  78372. * Easing function with a ease back shape (see link below).
  78373. * @see https://easings.net/#easeInBack
  78374. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78375. */
  78376. export class BackEase extends EasingFunction implements IEasingFunction {
  78377. /** Defines the amplitude of the function */
  78378. amplitude: number;
  78379. /**
  78380. * Instantiates a back ease easing
  78381. * @see https://easings.net/#easeInBack
  78382. * @param amplitude Defines the amplitude of the function
  78383. */
  78384. constructor(
  78385. /** Defines the amplitude of the function */
  78386. amplitude?: number);
  78387. /** @hidden */
  78388. easeInCore(gradient: number): number;
  78389. }
  78390. /**
  78391. * Easing function with a bouncing shape (see link below).
  78392. * @see https://easings.net/#easeInBounce
  78393. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78394. */
  78395. export class BounceEase extends EasingFunction implements IEasingFunction {
  78396. /** Defines the number of bounces */
  78397. bounces: number;
  78398. /** Defines the amplitude of the bounce */
  78399. bounciness: number;
  78400. /**
  78401. * Instantiates a bounce easing
  78402. * @see https://easings.net/#easeInBounce
  78403. * @param bounces Defines the number of bounces
  78404. * @param bounciness Defines the amplitude of the bounce
  78405. */
  78406. constructor(
  78407. /** Defines the number of bounces */
  78408. bounces?: number,
  78409. /** Defines the amplitude of the bounce */
  78410. bounciness?: number);
  78411. /** @hidden */
  78412. easeInCore(gradient: number): number;
  78413. }
  78414. /**
  78415. * Easing function with a power of 3 shape (see link below).
  78416. * @see https://easings.net/#easeInCubic
  78417. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78418. */
  78419. export class CubicEase extends EasingFunction implements IEasingFunction {
  78420. /** @hidden */
  78421. easeInCore(gradient: number): number;
  78422. }
  78423. /**
  78424. * Easing function with an elastic shape (see link below).
  78425. * @see https://easings.net/#easeInElastic
  78426. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78427. */
  78428. export class ElasticEase extends EasingFunction implements IEasingFunction {
  78429. /** Defines the number of oscillations*/
  78430. oscillations: number;
  78431. /** Defines the amplitude of the oscillations*/
  78432. springiness: number;
  78433. /**
  78434. * Instantiates an elastic easing function
  78435. * @see https://easings.net/#easeInElastic
  78436. * @param oscillations Defines the number of oscillations
  78437. * @param springiness Defines the amplitude of the oscillations
  78438. */
  78439. constructor(
  78440. /** Defines the number of oscillations*/
  78441. oscillations?: number,
  78442. /** Defines the amplitude of the oscillations*/
  78443. springiness?: number);
  78444. /** @hidden */
  78445. easeInCore(gradient: number): number;
  78446. }
  78447. /**
  78448. * Easing function with an exponential shape (see link below).
  78449. * @see https://easings.net/#easeInExpo
  78450. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78451. */
  78452. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  78453. /** Defines the exponent of the function */
  78454. exponent: number;
  78455. /**
  78456. * Instantiates an exponential easing function
  78457. * @see https://easings.net/#easeInExpo
  78458. * @param exponent Defines the exponent of the function
  78459. */
  78460. constructor(
  78461. /** Defines the exponent of the function */
  78462. exponent?: number);
  78463. /** @hidden */
  78464. easeInCore(gradient: number): number;
  78465. }
  78466. /**
  78467. * Easing function with a power shape (see link below).
  78468. * @see https://easings.net/#easeInQuad
  78469. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78470. */
  78471. export class PowerEase extends EasingFunction implements IEasingFunction {
  78472. /** Defines the power of the function */
  78473. power: number;
  78474. /**
  78475. * Instantiates an power base easing function
  78476. * @see https://easings.net/#easeInQuad
  78477. * @param power Defines the power of the function
  78478. */
  78479. constructor(
  78480. /** Defines the power of the function */
  78481. power?: number);
  78482. /** @hidden */
  78483. easeInCore(gradient: number): number;
  78484. }
  78485. /**
  78486. * Easing function with a power of 2 shape (see link below).
  78487. * @see https://easings.net/#easeInQuad
  78488. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78489. */
  78490. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  78491. /** @hidden */
  78492. easeInCore(gradient: number): number;
  78493. }
  78494. /**
  78495. * Easing function with a power of 4 shape (see link below).
  78496. * @see https://easings.net/#easeInQuart
  78497. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78498. */
  78499. export class QuarticEase extends EasingFunction implements IEasingFunction {
  78500. /** @hidden */
  78501. easeInCore(gradient: number): number;
  78502. }
  78503. /**
  78504. * Easing function with a power of 5 shape (see link below).
  78505. * @see https://easings.net/#easeInQuint
  78506. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78507. */
  78508. export class QuinticEase extends EasingFunction implements IEasingFunction {
  78509. /** @hidden */
  78510. easeInCore(gradient: number): number;
  78511. }
  78512. /**
  78513. * Easing function with a sin shape (see link below).
  78514. * @see https://easings.net/#easeInSine
  78515. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78516. */
  78517. export class SineEase extends EasingFunction implements IEasingFunction {
  78518. /** @hidden */
  78519. easeInCore(gradient: number): number;
  78520. }
  78521. /**
  78522. * Easing function with a bezier shape (see link below).
  78523. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  78524. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78525. */
  78526. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  78527. /** Defines the x component of the start tangent in the bezier curve */
  78528. x1: number;
  78529. /** Defines the y component of the start tangent in the bezier curve */
  78530. y1: number;
  78531. /** Defines the x component of the end tangent in the bezier curve */
  78532. x2: number;
  78533. /** Defines the y component of the end tangent in the bezier curve */
  78534. y2: number;
  78535. /**
  78536. * Instantiates a bezier function
  78537. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  78538. * @param x1 Defines the x component of the start tangent in the bezier curve
  78539. * @param y1 Defines the y component of the start tangent in the bezier curve
  78540. * @param x2 Defines the x component of the end tangent in the bezier curve
  78541. * @param y2 Defines the y component of the end tangent in the bezier curve
  78542. */
  78543. constructor(
  78544. /** Defines the x component of the start tangent in the bezier curve */
  78545. x1?: number,
  78546. /** Defines the y component of the start tangent in the bezier curve */
  78547. y1?: number,
  78548. /** Defines the x component of the end tangent in the bezier curve */
  78549. x2?: number,
  78550. /** Defines the y component of the end tangent in the bezier curve */
  78551. y2?: number);
  78552. /** @hidden */
  78553. easeInCore(gradient: number): number;
  78554. }
  78555. }
  78556. declare module BABYLON {
  78557. /**
  78558. * Class used to hold a RBG color
  78559. */
  78560. export class Color3 {
  78561. /**
  78562. * Defines the red component (between 0 and 1, default is 0)
  78563. */
  78564. r: number;
  78565. /**
  78566. * Defines the green component (between 0 and 1, default is 0)
  78567. */
  78568. g: number;
  78569. /**
  78570. * Defines the blue component (between 0 and 1, default is 0)
  78571. */
  78572. b: number;
  78573. /**
  78574. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  78575. * @param r defines the red component (between 0 and 1, default is 0)
  78576. * @param g defines the green component (between 0 and 1, default is 0)
  78577. * @param b defines the blue component (between 0 and 1, default is 0)
  78578. */
  78579. constructor(
  78580. /**
  78581. * Defines the red component (between 0 and 1, default is 0)
  78582. */
  78583. r?: number,
  78584. /**
  78585. * Defines the green component (between 0 and 1, default is 0)
  78586. */
  78587. g?: number,
  78588. /**
  78589. * Defines the blue component (between 0 and 1, default is 0)
  78590. */
  78591. b?: number);
  78592. /**
  78593. * Creates a string with the Color3 current values
  78594. * @returns the string representation of the Color3 object
  78595. */
  78596. toString(): string;
  78597. /**
  78598. * Returns the string "Color3"
  78599. * @returns "Color3"
  78600. */
  78601. getClassName(): string;
  78602. /**
  78603. * Compute the Color3 hash code
  78604. * @returns an unique number that can be used to hash Color3 objects
  78605. */
  78606. getHashCode(): number;
  78607. /**
  78608. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  78609. * @param array defines the array where to store the r,g,b components
  78610. * @param index defines an optional index in the target array to define where to start storing values
  78611. * @returns the current Color3 object
  78612. */
  78613. toArray(array: FloatArray, index?: number): Color3;
  78614. /**
  78615. * Returns a new Color4 object from the current Color3 and the given alpha
  78616. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  78617. * @returns a new Color4 object
  78618. */
  78619. toColor4(alpha?: number): Color4;
  78620. /**
  78621. * Returns a new array populated with 3 numeric elements : red, green and blue values
  78622. * @returns the new array
  78623. */
  78624. asArray(): number[];
  78625. /**
  78626. * Returns the luminance value
  78627. * @returns a float value
  78628. */
  78629. toLuminance(): number;
  78630. /**
  78631. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  78632. * @param otherColor defines the second operand
  78633. * @returns the new Color3 object
  78634. */
  78635. multiply(otherColor: DeepImmutable<Color3>): Color3;
  78636. /**
  78637. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  78638. * @param otherColor defines the second operand
  78639. * @param result defines the Color3 object where to store the result
  78640. * @returns the current Color3
  78641. */
  78642. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78643. /**
  78644. * Determines equality between Color3 objects
  78645. * @param otherColor defines the second operand
  78646. * @returns true if the rgb values are equal to the given ones
  78647. */
  78648. equals(otherColor: DeepImmutable<Color3>): boolean;
  78649. /**
  78650. * Determines equality between the current Color3 object and a set of r,b,g values
  78651. * @param r defines the red component to check
  78652. * @param g defines the green component to check
  78653. * @param b defines the blue component to check
  78654. * @returns true if the rgb values are equal to the given ones
  78655. */
  78656. equalsFloats(r: number, g: number, b: number): boolean;
  78657. /**
  78658. * Multiplies in place each rgb value by scale
  78659. * @param scale defines the scaling factor
  78660. * @returns the updated Color3
  78661. */
  78662. scale(scale: number): Color3;
  78663. /**
  78664. * Multiplies the rgb values by scale and stores the result into "result"
  78665. * @param scale defines the scaling factor
  78666. * @param result defines the Color3 object where to store the result
  78667. * @returns the unmodified current Color3
  78668. */
  78669. scaleToRef(scale: number, result: Color3): Color3;
  78670. /**
  78671. * Scale the current Color3 values by a factor and add the result to a given Color3
  78672. * @param scale defines the scale factor
  78673. * @param result defines color to store the result into
  78674. * @returns the unmodified current Color3
  78675. */
  78676. scaleAndAddToRef(scale: number, result: Color3): Color3;
  78677. /**
  78678. * Clamps the rgb values by the min and max values and stores the result into "result"
  78679. * @param min defines minimum clamping value (default is 0)
  78680. * @param max defines maximum clamping value (default is 1)
  78681. * @param result defines color to store the result into
  78682. * @returns the original Color3
  78683. */
  78684. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  78685. /**
  78686. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  78687. * @param otherColor defines the second operand
  78688. * @returns the new Color3
  78689. */
  78690. add(otherColor: DeepImmutable<Color3>): Color3;
  78691. /**
  78692. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  78693. * @param otherColor defines the second operand
  78694. * @param result defines Color3 object to store the result into
  78695. * @returns the unmodified current Color3
  78696. */
  78697. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78698. /**
  78699. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  78700. * @param otherColor defines the second operand
  78701. * @returns the new Color3
  78702. */
  78703. subtract(otherColor: DeepImmutable<Color3>): Color3;
  78704. /**
  78705. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  78706. * @param otherColor defines the second operand
  78707. * @param result defines Color3 object to store the result into
  78708. * @returns the unmodified current Color3
  78709. */
  78710. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78711. /**
  78712. * Copy the current object
  78713. * @returns a new Color3 copied the current one
  78714. */
  78715. clone(): Color3;
  78716. /**
  78717. * Copies the rgb values from the source in the current Color3
  78718. * @param source defines the source Color3 object
  78719. * @returns the updated Color3 object
  78720. */
  78721. copyFrom(source: DeepImmutable<Color3>): Color3;
  78722. /**
  78723. * Updates the Color3 rgb values from the given floats
  78724. * @param r defines the red component to read from
  78725. * @param g defines the green component to read from
  78726. * @param b defines the blue component to read from
  78727. * @returns the current Color3 object
  78728. */
  78729. copyFromFloats(r: number, g: number, b: number): Color3;
  78730. /**
  78731. * Updates the Color3 rgb values from the given floats
  78732. * @param r defines the red component to read from
  78733. * @param g defines the green component to read from
  78734. * @param b defines the blue component to read from
  78735. * @returns the current Color3 object
  78736. */
  78737. set(r: number, g: number, b: number): Color3;
  78738. /**
  78739. * Compute the Color3 hexadecimal code as a string
  78740. * @returns a string containing the hexadecimal representation of the Color3 object
  78741. */
  78742. toHexString(): string;
  78743. /**
  78744. * Computes a new Color3 converted from the current one to linear space
  78745. * @returns a new Color3 object
  78746. */
  78747. toLinearSpace(): Color3;
  78748. /**
  78749. * Converts current color in rgb space to HSV values
  78750. * @returns a new color3 representing the HSV values
  78751. */
  78752. toHSV(): Color3;
  78753. /**
  78754. * Converts current color in rgb space to HSV values
  78755. * @param result defines the Color3 where to store the HSV values
  78756. */
  78757. toHSVToRef(result: Color3): void;
  78758. /**
  78759. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  78760. * @param convertedColor defines the Color3 object where to store the linear space version
  78761. * @returns the unmodified Color3
  78762. */
  78763. toLinearSpaceToRef(convertedColor: Color3): Color3;
  78764. /**
  78765. * Computes a new Color3 converted from the current one to gamma space
  78766. * @returns a new Color3 object
  78767. */
  78768. toGammaSpace(): Color3;
  78769. /**
  78770. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  78771. * @param convertedColor defines the Color3 object where to store the gamma space version
  78772. * @returns the unmodified Color3
  78773. */
  78774. toGammaSpaceToRef(convertedColor: Color3): Color3;
  78775. private static _BlackReadOnly;
  78776. /**
  78777. * Convert Hue, saturation and value to a Color3 (RGB)
  78778. * @param hue defines the hue
  78779. * @param saturation defines the saturation
  78780. * @param value defines the value
  78781. * @param result defines the Color3 where to store the RGB values
  78782. */
  78783. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  78784. /**
  78785. * Creates a new Color3 from the string containing valid hexadecimal values
  78786. * @param hex defines a string containing valid hexadecimal values
  78787. * @returns a new Color3 object
  78788. */
  78789. static FromHexString(hex: string): Color3;
  78790. /**
  78791. * Creates a new Color3 from the starting index of the given array
  78792. * @param array defines the source array
  78793. * @param offset defines an offset in the source array
  78794. * @returns a new Color3 object
  78795. */
  78796. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  78797. /**
  78798. * Creates a new Color3 from integer values (< 256)
  78799. * @param r defines the red component to read from (value between 0 and 255)
  78800. * @param g defines the green component to read from (value between 0 and 255)
  78801. * @param b defines the blue component to read from (value between 0 and 255)
  78802. * @returns a new Color3 object
  78803. */
  78804. static FromInts(r: number, g: number, b: number): Color3;
  78805. /**
  78806. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  78807. * @param start defines the start Color3 value
  78808. * @param end defines the end Color3 value
  78809. * @param amount defines the gradient value between start and end
  78810. * @returns a new Color3 object
  78811. */
  78812. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  78813. /**
  78814. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  78815. * @param left defines the start value
  78816. * @param right defines the end value
  78817. * @param amount defines the gradient factor
  78818. * @param result defines the Color3 object where to store the result
  78819. */
  78820. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  78821. /**
  78822. * Returns a Color3 value containing a red color
  78823. * @returns a new Color3 object
  78824. */
  78825. static Red(): Color3;
  78826. /**
  78827. * Returns a Color3 value containing a green color
  78828. * @returns a new Color3 object
  78829. */
  78830. static Green(): Color3;
  78831. /**
  78832. * Returns a Color3 value containing a blue color
  78833. * @returns a new Color3 object
  78834. */
  78835. static Blue(): Color3;
  78836. /**
  78837. * Returns a Color3 value containing a black color
  78838. * @returns a new Color3 object
  78839. */
  78840. static Black(): Color3;
  78841. /**
  78842. * Gets a Color3 value containing a black color that must not be updated
  78843. */
  78844. static get BlackReadOnly(): DeepImmutable<Color3>;
  78845. /**
  78846. * Returns a Color3 value containing a white color
  78847. * @returns a new Color3 object
  78848. */
  78849. static White(): Color3;
  78850. /**
  78851. * Returns a Color3 value containing a purple color
  78852. * @returns a new Color3 object
  78853. */
  78854. static Purple(): Color3;
  78855. /**
  78856. * Returns a Color3 value containing a magenta color
  78857. * @returns a new Color3 object
  78858. */
  78859. static Magenta(): Color3;
  78860. /**
  78861. * Returns a Color3 value containing a yellow color
  78862. * @returns a new Color3 object
  78863. */
  78864. static Yellow(): Color3;
  78865. /**
  78866. * Returns a Color3 value containing a gray color
  78867. * @returns a new Color3 object
  78868. */
  78869. static Gray(): Color3;
  78870. /**
  78871. * Returns a Color3 value containing a teal color
  78872. * @returns a new Color3 object
  78873. */
  78874. static Teal(): Color3;
  78875. /**
  78876. * Returns a Color3 value containing a random color
  78877. * @returns a new Color3 object
  78878. */
  78879. static Random(): Color3;
  78880. }
  78881. /**
  78882. * Class used to hold a RBGA color
  78883. */
  78884. export class Color4 {
  78885. /**
  78886. * Defines the red component (between 0 and 1, default is 0)
  78887. */
  78888. r: number;
  78889. /**
  78890. * Defines the green component (between 0 and 1, default is 0)
  78891. */
  78892. g: number;
  78893. /**
  78894. * Defines the blue component (between 0 and 1, default is 0)
  78895. */
  78896. b: number;
  78897. /**
  78898. * Defines the alpha component (between 0 and 1, default is 1)
  78899. */
  78900. a: number;
  78901. /**
  78902. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  78903. * @param r defines the red component (between 0 and 1, default is 0)
  78904. * @param g defines the green component (between 0 and 1, default is 0)
  78905. * @param b defines the blue component (between 0 and 1, default is 0)
  78906. * @param a defines the alpha component (between 0 and 1, default is 1)
  78907. */
  78908. constructor(
  78909. /**
  78910. * Defines the red component (between 0 and 1, default is 0)
  78911. */
  78912. r?: number,
  78913. /**
  78914. * Defines the green component (between 0 and 1, default is 0)
  78915. */
  78916. g?: number,
  78917. /**
  78918. * Defines the blue component (between 0 and 1, default is 0)
  78919. */
  78920. b?: number,
  78921. /**
  78922. * Defines the alpha component (between 0 and 1, default is 1)
  78923. */
  78924. a?: number);
  78925. /**
  78926. * Adds in place the given Color4 values to the current Color4 object
  78927. * @param right defines the second operand
  78928. * @returns the current updated Color4 object
  78929. */
  78930. addInPlace(right: DeepImmutable<Color4>): Color4;
  78931. /**
  78932. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  78933. * @returns the new array
  78934. */
  78935. asArray(): number[];
  78936. /**
  78937. * Stores from the starting index in the given array the Color4 successive values
  78938. * @param array defines the array where to store the r,g,b components
  78939. * @param index defines an optional index in the target array to define where to start storing values
  78940. * @returns the current Color4 object
  78941. */
  78942. toArray(array: number[], index?: number): Color4;
  78943. /**
  78944. * Determines equality between Color4 objects
  78945. * @param otherColor defines the second operand
  78946. * @returns true if the rgba values are equal to the given ones
  78947. */
  78948. equals(otherColor: DeepImmutable<Color4>): boolean;
  78949. /**
  78950. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  78951. * @param right defines the second operand
  78952. * @returns a new Color4 object
  78953. */
  78954. add(right: DeepImmutable<Color4>): Color4;
  78955. /**
  78956. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  78957. * @param right defines the second operand
  78958. * @returns a new Color4 object
  78959. */
  78960. subtract(right: DeepImmutable<Color4>): Color4;
  78961. /**
  78962. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  78963. * @param right defines the second operand
  78964. * @param result defines the Color4 object where to store the result
  78965. * @returns the current Color4 object
  78966. */
  78967. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  78968. /**
  78969. * Creates a new Color4 with the current Color4 values multiplied by scale
  78970. * @param scale defines the scaling factor to apply
  78971. * @returns a new Color4 object
  78972. */
  78973. scale(scale: number): Color4;
  78974. /**
  78975. * Multiplies the current Color4 values by scale and stores the result in "result"
  78976. * @param scale defines the scaling factor to apply
  78977. * @param result defines the Color4 object where to store the result
  78978. * @returns the current unmodified Color4
  78979. */
  78980. scaleToRef(scale: number, result: Color4): Color4;
  78981. /**
  78982. * Scale the current Color4 values by a factor and add the result to a given Color4
  78983. * @param scale defines the scale factor
  78984. * @param result defines the Color4 object where to store the result
  78985. * @returns the unmodified current Color4
  78986. */
  78987. scaleAndAddToRef(scale: number, result: Color4): Color4;
  78988. /**
  78989. * Clamps the rgb values by the min and max values and stores the result into "result"
  78990. * @param min defines minimum clamping value (default is 0)
  78991. * @param max defines maximum clamping value (default is 1)
  78992. * @param result defines color to store the result into.
  78993. * @returns the cuurent Color4
  78994. */
  78995. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  78996. /**
  78997. * Multipy an Color4 value by another and return a new Color4 object
  78998. * @param color defines the Color4 value to multiply by
  78999. * @returns a new Color4 object
  79000. */
  79001. multiply(color: Color4): Color4;
  79002. /**
  79003. * Multipy a Color4 value by another and push the result in a reference value
  79004. * @param color defines the Color4 value to multiply by
  79005. * @param result defines the Color4 to fill the result in
  79006. * @returns the result Color4
  79007. */
  79008. multiplyToRef(color: Color4, result: Color4): Color4;
  79009. /**
  79010. * Creates a string with the Color4 current values
  79011. * @returns the string representation of the Color4 object
  79012. */
  79013. toString(): string;
  79014. /**
  79015. * Returns the string "Color4"
  79016. * @returns "Color4"
  79017. */
  79018. getClassName(): string;
  79019. /**
  79020. * Compute the Color4 hash code
  79021. * @returns an unique number that can be used to hash Color4 objects
  79022. */
  79023. getHashCode(): number;
  79024. /**
  79025. * Creates a new Color4 copied from the current one
  79026. * @returns a new Color4 object
  79027. */
  79028. clone(): Color4;
  79029. /**
  79030. * Copies the given Color4 values into the current one
  79031. * @param source defines the source Color4 object
  79032. * @returns the current updated Color4 object
  79033. */
  79034. copyFrom(source: Color4): Color4;
  79035. /**
  79036. * Copies the given float values into the current one
  79037. * @param r defines the red component to read from
  79038. * @param g defines the green component to read from
  79039. * @param b defines the blue component to read from
  79040. * @param a defines the alpha component to read from
  79041. * @returns the current updated Color4 object
  79042. */
  79043. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  79044. /**
  79045. * Copies the given float values into the current one
  79046. * @param r defines the red component to read from
  79047. * @param g defines the green component to read from
  79048. * @param b defines the blue component to read from
  79049. * @param a defines the alpha component to read from
  79050. * @returns the current updated Color4 object
  79051. */
  79052. set(r: number, g: number, b: number, a: number): Color4;
  79053. /**
  79054. * Compute the Color4 hexadecimal code as a string
  79055. * @returns a string containing the hexadecimal representation of the Color4 object
  79056. */
  79057. toHexString(): string;
  79058. /**
  79059. * Computes a new Color4 converted from the current one to linear space
  79060. * @returns a new Color4 object
  79061. */
  79062. toLinearSpace(): Color4;
  79063. /**
  79064. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  79065. * @param convertedColor defines the Color4 object where to store the linear space version
  79066. * @returns the unmodified Color4
  79067. */
  79068. toLinearSpaceToRef(convertedColor: Color4): Color4;
  79069. /**
  79070. * Computes a new Color4 converted from the current one to gamma space
  79071. * @returns a new Color4 object
  79072. */
  79073. toGammaSpace(): Color4;
  79074. /**
  79075. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  79076. * @param convertedColor defines the Color4 object where to store the gamma space version
  79077. * @returns the unmodified Color4
  79078. */
  79079. toGammaSpaceToRef(convertedColor: Color4): Color4;
  79080. /**
  79081. * Creates a new Color4 from the string containing valid hexadecimal values
  79082. * @param hex defines a string containing valid hexadecimal values
  79083. * @returns a new Color4 object
  79084. */
  79085. static FromHexString(hex: string): Color4;
  79086. /**
  79087. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  79088. * @param left defines the start value
  79089. * @param right defines the end value
  79090. * @param amount defines the gradient factor
  79091. * @returns a new Color4 object
  79092. */
  79093. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  79094. /**
  79095. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  79096. * @param left defines the start value
  79097. * @param right defines the end value
  79098. * @param amount defines the gradient factor
  79099. * @param result defines the Color4 object where to store data
  79100. */
  79101. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  79102. /**
  79103. * Creates a new Color4 from a Color3 and an alpha value
  79104. * @param color3 defines the source Color3 to read from
  79105. * @param alpha defines the alpha component (1.0 by default)
  79106. * @returns a new Color4 object
  79107. */
  79108. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  79109. /**
  79110. * Creates a new Color4 from the starting index element of the given array
  79111. * @param array defines the source array to read from
  79112. * @param offset defines the offset in the source array
  79113. * @returns a new Color4 object
  79114. */
  79115. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  79116. /**
  79117. * Creates a new Color3 from integer values (< 256)
  79118. * @param r defines the red component to read from (value between 0 and 255)
  79119. * @param g defines the green component to read from (value between 0 and 255)
  79120. * @param b defines the blue component to read from (value between 0 and 255)
  79121. * @param a defines the alpha component to read from (value between 0 and 255)
  79122. * @returns a new Color3 object
  79123. */
  79124. static FromInts(r: number, g: number, b: number, a: number): Color4;
  79125. /**
  79126. * Check the content of a given array and convert it to an array containing RGBA data
  79127. * If the original array was already containing count * 4 values then it is returned directly
  79128. * @param colors defines the array to check
  79129. * @param count defines the number of RGBA data to expect
  79130. * @returns an array containing count * 4 values (RGBA)
  79131. */
  79132. static CheckColors4(colors: number[], count: number): number[];
  79133. }
  79134. /**
  79135. * @hidden
  79136. */
  79137. export class TmpColors {
  79138. static Color3: Color3[];
  79139. static Color4: Color4[];
  79140. }
  79141. }
  79142. declare module BABYLON {
  79143. /**
  79144. * Defines an interface which represents an animation key frame
  79145. */
  79146. export interface IAnimationKey {
  79147. /**
  79148. * Frame of the key frame
  79149. */
  79150. frame: number;
  79151. /**
  79152. * Value at the specifies key frame
  79153. */
  79154. value: any;
  79155. /**
  79156. * The input tangent for the cubic hermite spline
  79157. */
  79158. inTangent?: any;
  79159. /**
  79160. * The output tangent for the cubic hermite spline
  79161. */
  79162. outTangent?: any;
  79163. /**
  79164. * The animation interpolation type
  79165. */
  79166. interpolation?: AnimationKeyInterpolation;
  79167. }
  79168. /**
  79169. * Enum for the animation key frame interpolation type
  79170. */
  79171. export enum AnimationKeyInterpolation {
  79172. /**
  79173. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  79174. */
  79175. STEP = 1
  79176. }
  79177. }
  79178. declare module BABYLON {
  79179. /**
  79180. * Represents the range of an animation
  79181. */
  79182. export class AnimationRange {
  79183. /**The name of the animation range**/
  79184. name: string;
  79185. /**The starting frame of the animation */
  79186. from: number;
  79187. /**The ending frame of the animation*/
  79188. to: number;
  79189. /**
  79190. * Initializes the range of an animation
  79191. * @param name The name of the animation range
  79192. * @param from The starting frame of the animation
  79193. * @param to The ending frame of the animation
  79194. */
  79195. constructor(
  79196. /**The name of the animation range**/
  79197. name: string,
  79198. /**The starting frame of the animation */
  79199. from: number,
  79200. /**The ending frame of the animation*/
  79201. to: number);
  79202. /**
  79203. * Makes a copy of the animation range
  79204. * @returns A copy of the animation range
  79205. */
  79206. clone(): AnimationRange;
  79207. }
  79208. }
  79209. declare module BABYLON {
  79210. /**
  79211. * Composed of a frame, and an action function
  79212. */
  79213. export class AnimationEvent {
  79214. /** The frame for which the event is triggered **/
  79215. frame: number;
  79216. /** The event to perform when triggered **/
  79217. action: (currentFrame: number) => void;
  79218. /** Specifies if the event should be triggered only once**/
  79219. onlyOnce?: boolean | undefined;
  79220. /**
  79221. * Specifies if the animation event is done
  79222. */
  79223. isDone: boolean;
  79224. /**
  79225. * Initializes the animation event
  79226. * @param frame The frame for which the event is triggered
  79227. * @param action The event to perform when triggered
  79228. * @param onlyOnce Specifies if the event should be triggered only once
  79229. */
  79230. constructor(
  79231. /** The frame for which the event is triggered **/
  79232. frame: number,
  79233. /** The event to perform when triggered **/
  79234. action: (currentFrame: number) => void,
  79235. /** Specifies if the event should be triggered only once**/
  79236. onlyOnce?: boolean | undefined);
  79237. /** @hidden */
  79238. _clone(): AnimationEvent;
  79239. }
  79240. }
  79241. declare module BABYLON {
  79242. /**
  79243. * Interface used to define a behavior
  79244. */
  79245. export interface Behavior<T> {
  79246. /** gets or sets behavior's name */
  79247. name: string;
  79248. /**
  79249. * Function called when the behavior needs to be initialized (after attaching it to a target)
  79250. */
  79251. init(): void;
  79252. /**
  79253. * Called when the behavior is attached to a target
  79254. * @param target defines the target where the behavior is attached to
  79255. */
  79256. attach(target: T): void;
  79257. /**
  79258. * Called when the behavior is detached from its target
  79259. */
  79260. detach(): void;
  79261. }
  79262. /**
  79263. * Interface implemented by classes supporting behaviors
  79264. */
  79265. export interface IBehaviorAware<T> {
  79266. /**
  79267. * Attach a behavior
  79268. * @param behavior defines the behavior to attach
  79269. * @returns the current host
  79270. */
  79271. addBehavior(behavior: Behavior<T>): T;
  79272. /**
  79273. * Remove a behavior from the current object
  79274. * @param behavior defines the behavior to detach
  79275. * @returns the current host
  79276. */
  79277. removeBehavior(behavior: Behavior<T>): T;
  79278. /**
  79279. * Gets a behavior using its name to search
  79280. * @param name defines the name to search
  79281. * @returns the behavior or null if not found
  79282. */
  79283. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  79284. }
  79285. }
  79286. declare module BABYLON {
  79287. /**
  79288. * Defines an array and its length.
  79289. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  79290. */
  79291. export interface ISmartArrayLike<T> {
  79292. /**
  79293. * The data of the array.
  79294. */
  79295. data: Array<T>;
  79296. /**
  79297. * The active length of the array.
  79298. */
  79299. length: number;
  79300. }
  79301. /**
  79302. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  79303. */
  79304. export class SmartArray<T> implements ISmartArrayLike<T> {
  79305. /**
  79306. * The full set of data from the array.
  79307. */
  79308. data: Array<T>;
  79309. /**
  79310. * The active length of the array.
  79311. */
  79312. length: number;
  79313. protected _id: number;
  79314. /**
  79315. * Instantiates a Smart Array.
  79316. * @param capacity defines the default capacity of the array.
  79317. */
  79318. constructor(capacity: number);
  79319. /**
  79320. * Pushes a value at the end of the active data.
  79321. * @param value defines the object to push in the array.
  79322. */
  79323. push(value: T): void;
  79324. /**
  79325. * Iterates over the active data and apply the lambda to them.
  79326. * @param func defines the action to apply on each value.
  79327. */
  79328. forEach(func: (content: T) => void): void;
  79329. /**
  79330. * Sorts the full sets of data.
  79331. * @param compareFn defines the comparison function to apply.
  79332. */
  79333. sort(compareFn: (a: T, b: T) => number): void;
  79334. /**
  79335. * Resets the active data to an empty array.
  79336. */
  79337. reset(): void;
  79338. /**
  79339. * Releases all the data from the array as well as the array.
  79340. */
  79341. dispose(): void;
  79342. /**
  79343. * Concats the active data with a given array.
  79344. * @param array defines the data to concatenate with.
  79345. */
  79346. concat(array: any): void;
  79347. /**
  79348. * Returns the position of a value in the active data.
  79349. * @param value defines the value to find the index for
  79350. * @returns the index if found in the active data otherwise -1
  79351. */
  79352. indexOf(value: T): number;
  79353. /**
  79354. * Returns whether an element is part of the active data.
  79355. * @param value defines the value to look for
  79356. * @returns true if found in the active data otherwise false
  79357. */
  79358. contains(value: T): boolean;
  79359. private static _GlobalId;
  79360. }
  79361. /**
  79362. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  79363. * The data in this array can only be present once
  79364. */
  79365. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  79366. private _duplicateId;
  79367. /**
  79368. * Pushes a value at the end of the active data.
  79369. * THIS DOES NOT PREVENT DUPPLICATE DATA
  79370. * @param value defines the object to push in the array.
  79371. */
  79372. push(value: T): void;
  79373. /**
  79374. * Pushes a value at the end of the active data.
  79375. * If the data is already present, it won t be added again
  79376. * @param value defines the object to push in the array.
  79377. * @returns true if added false if it was already present
  79378. */
  79379. pushNoDuplicate(value: T): boolean;
  79380. /**
  79381. * Resets the active data to an empty array.
  79382. */
  79383. reset(): void;
  79384. /**
  79385. * Concats the active data with a given array.
  79386. * This ensures no dupplicate will be present in the result.
  79387. * @param array defines the data to concatenate with.
  79388. */
  79389. concatWithNoDuplicate(array: any): void;
  79390. }
  79391. }
  79392. declare module BABYLON {
  79393. /**
  79394. * @ignore
  79395. * This is a list of all the different input types that are available in the application.
  79396. * Fo instance: ArcRotateCameraGamepadInput...
  79397. */
  79398. export var CameraInputTypes: {};
  79399. /**
  79400. * This is the contract to implement in order to create a new input class.
  79401. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  79402. */
  79403. export interface ICameraInput<TCamera extends Camera> {
  79404. /**
  79405. * Defines the camera the input is attached to.
  79406. */
  79407. camera: Nullable<TCamera>;
  79408. /**
  79409. * Gets the class name of the current intput.
  79410. * @returns the class name
  79411. */
  79412. getClassName(): string;
  79413. /**
  79414. * Get the friendly name associated with the input class.
  79415. * @returns the input friendly name
  79416. */
  79417. getSimpleName(): string;
  79418. /**
  79419. * Attach the input controls to a specific dom element to get the input from.
  79420. * @param element Defines the element the controls should be listened from
  79421. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79422. */
  79423. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79424. /**
  79425. * Detach the current controls from the specified dom element.
  79426. * @param element Defines the element to stop listening the inputs from
  79427. */
  79428. detachControl(element: Nullable<HTMLElement>): void;
  79429. /**
  79430. * Update the current camera state depending on the inputs that have been used this frame.
  79431. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79432. */
  79433. checkInputs?: () => void;
  79434. }
  79435. /**
  79436. * Represents a map of input types to input instance or input index to input instance.
  79437. */
  79438. export interface CameraInputsMap<TCamera extends Camera> {
  79439. /**
  79440. * Accessor to the input by input type.
  79441. */
  79442. [name: string]: ICameraInput<TCamera>;
  79443. /**
  79444. * Accessor to the input by input index.
  79445. */
  79446. [idx: number]: ICameraInput<TCamera>;
  79447. }
  79448. /**
  79449. * This represents the input manager used within a camera.
  79450. * It helps dealing with all the different kind of input attached to a camera.
  79451. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79452. */
  79453. export class CameraInputsManager<TCamera extends Camera> {
  79454. /**
  79455. * Defines the list of inputs attahed to the camera.
  79456. */
  79457. attached: CameraInputsMap<TCamera>;
  79458. /**
  79459. * Defines the dom element the camera is collecting inputs from.
  79460. * This is null if the controls have not been attached.
  79461. */
  79462. attachedElement: Nullable<HTMLElement>;
  79463. /**
  79464. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79465. */
  79466. noPreventDefault: boolean;
  79467. /**
  79468. * Defined the camera the input manager belongs to.
  79469. */
  79470. camera: TCamera;
  79471. /**
  79472. * Update the current camera state depending on the inputs that have been used this frame.
  79473. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79474. */
  79475. checkInputs: () => void;
  79476. /**
  79477. * Instantiate a new Camera Input Manager.
  79478. * @param camera Defines the camera the input manager blongs to
  79479. */
  79480. constructor(camera: TCamera);
  79481. /**
  79482. * Add an input method to a camera
  79483. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79484. * @param input camera input method
  79485. */
  79486. add(input: ICameraInput<TCamera>): void;
  79487. /**
  79488. * Remove a specific input method from a camera
  79489. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  79490. * @param inputToRemove camera input method
  79491. */
  79492. remove(inputToRemove: ICameraInput<TCamera>): void;
  79493. /**
  79494. * Remove a specific input type from a camera
  79495. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  79496. * @param inputType the type of the input to remove
  79497. */
  79498. removeByType(inputType: string): void;
  79499. private _addCheckInputs;
  79500. /**
  79501. * Attach the input controls to the currently attached dom element to listen the events from.
  79502. * @param input Defines the input to attach
  79503. */
  79504. attachInput(input: ICameraInput<TCamera>): void;
  79505. /**
  79506. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  79507. * @param element Defines the dom element to collect the events from
  79508. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79509. */
  79510. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  79511. /**
  79512. * Detach the current manager inputs controls from a specific dom element.
  79513. * @param element Defines the dom element to collect the events from
  79514. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  79515. */
  79516. detachElement(element: HTMLElement, disconnect?: boolean): void;
  79517. /**
  79518. * Rebuild the dynamic inputCheck function from the current list of
  79519. * defined inputs in the manager.
  79520. */
  79521. rebuildInputCheck(): void;
  79522. /**
  79523. * Remove all attached input methods from a camera
  79524. */
  79525. clear(): void;
  79526. /**
  79527. * Serialize the current input manager attached to a camera.
  79528. * This ensures than once parsed,
  79529. * the input associated to the camera will be identical to the current ones
  79530. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  79531. */
  79532. serialize(serializedCamera: any): void;
  79533. /**
  79534. * Parses an input manager serialized JSON to restore the previous list of inputs
  79535. * and states associated to a camera.
  79536. * @param parsedCamera Defines the JSON to parse
  79537. */
  79538. parse(parsedCamera: any): void;
  79539. }
  79540. }
  79541. declare module BABYLON {
  79542. /**
  79543. * Class used to store data that will be store in GPU memory
  79544. */
  79545. export class Buffer {
  79546. private _engine;
  79547. private _buffer;
  79548. /** @hidden */
  79549. _data: Nullable<DataArray>;
  79550. private _updatable;
  79551. private _instanced;
  79552. private _divisor;
  79553. /**
  79554. * Gets the byte stride.
  79555. */
  79556. readonly byteStride: number;
  79557. /**
  79558. * Constructor
  79559. * @param engine the engine
  79560. * @param data the data to use for this buffer
  79561. * @param updatable whether the data is updatable
  79562. * @param stride the stride (optional)
  79563. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  79564. * @param instanced whether the buffer is instanced (optional)
  79565. * @param useBytes set to true if the stride in in bytes (optional)
  79566. * @param divisor sets an optional divisor for instances (1 by default)
  79567. */
  79568. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  79569. /**
  79570. * Create a new VertexBuffer based on the current buffer
  79571. * @param kind defines the vertex buffer kind (position, normal, etc.)
  79572. * @param offset defines offset in the buffer (0 by default)
  79573. * @param size defines the size in floats of attributes (position is 3 for instance)
  79574. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  79575. * @param instanced defines if the vertex buffer contains indexed data
  79576. * @param useBytes defines if the offset and stride are in bytes *
  79577. * @param divisor sets an optional divisor for instances (1 by default)
  79578. * @returns the new vertex buffer
  79579. */
  79580. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  79581. /**
  79582. * Gets a boolean indicating if the Buffer is updatable?
  79583. * @returns true if the buffer is updatable
  79584. */
  79585. isUpdatable(): boolean;
  79586. /**
  79587. * Gets current buffer's data
  79588. * @returns a DataArray or null
  79589. */
  79590. getData(): Nullable<DataArray>;
  79591. /**
  79592. * Gets underlying native buffer
  79593. * @returns underlying native buffer
  79594. */
  79595. getBuffer(): Nullable<DataBuffer>;
  79596. /**
  79597. * Gets the stride in float32 units (i.e. byte stride / 4).
  79598. * May not be an integer if the byte stride is not divisible by 4.
  79599. * @returns the stride in float32 units
  79600. * @deprecated Please use byteStride instead.
  79601. */
  79602. getStrideSize(): number;
  79603. /**
  79604. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  79605. * @param data defines the data to store
  79606. */
  79607. create(data?: Nullable<DataArray>): void;
  79608. /** @hidden */
  79609. _rebuild(): void;
  79610. /**
  79611. * Update current buffer data
  79612. * @param data defines the data to store
  79613. */
  79614. update(data: DataArray): void;
  79615. /**
  79616. * Updates the data directly.
  79617. * @param data the new data
  79618. * @param offset the new offset
  79619. * @param vertexCount the vertex count (optional)
  79620. * @param useBytes set to true if the offset is in bytes
  79621. */
  79622. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  79623. /**
  79624. * Release all resources
  79625. */
  79626. dispose(): void;
  79627. }
  79628. /**
  79629. * Specialized buffer used to store vertex data
  79630. */
  79631. export class VertexBuffer {
  79632. /** @hidden */
  79633. _buffer: Buffer;
  79634. private _kind;
  79635. private _size;
  79636. private _ownsBuffer;
  79637. private _instanced;
  79638. private _instanceDivisor;
  79639. /**
  79640. * The byte type.
  79641. */
  79642. static readonly BYTE: number;
  79643. /**
  79644. * The unsigned byte type.
  79645. */
  79646. static readonly UNSIGNED_BYTE: number;
  79647. /**
  79648. * The short type.
  79649. */
  79650. static readonly SHORT: number;
  79651. /**
  79652. * The unsigned short type.
  79653. */
  79654. static readonly UNSIGNED_SHORT: number;
  79655. /**
  79656. * The integer type.
  79657. */
  79658. static readonly INT: number;
  79659. /**
  79660. * The unsigned integer type.
  79661. */
  79662. static readonly UNSIGNED_INT: number;
  79663. /**
  79664. * The float type.
  79665. */
  79666. static readonly FLOAT: number;
  79667. /**
  79668. * Gets or sets the instance divisor when in instanced mode
  79669. */
  79670. get instanceDivisor(): number;
  79671. set instanceDivisor(value: number);
  79672. /**
  79673. * Gets the byte stride.
  79674. */
  79675. readonly byteStride: number;
  79676. /**
  79677. * Gets the byte offset.
  79678. */
  79679. readonly byteOffset: number;
  79680. /**
  79681. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  79682. */
  79683. readonly normalized: boolean;
  79684. /**
  79685. * Gets the data type of each component in the array.
  79686. */
  79687. readonly type: number;
  79688. /**
  79689. * Constructor
  79690. * @param engine the engine
  79691. * @param data the data to use for this vertex buffer
  79692. * @param kind the vertex buffer kind
  79693. * @param updatable whether the data is updatable
  79694. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  79695. * @param stride the stride (optional)
  79696. * @param instanced whether the buffer is instanced (optional)
  79697. * @param offset the offset of the data (optional)
  79698. * @param size the number of components (optional)
  79699. * @param type the type of the component (optional)
  79700. * @param normalized whether the data contains normalized data (optional)
  79701. * @param useBytes set to true if stride and offset are in bytes (optional)
  79702. * @param divisor defines the instance divisor to use (1 by default)
  79703. */
  79704. 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);
  79705. /** @hidden */
  79706. _rebuild(): void;
  79707. /**
  79708. * Returns the kind of the VertexBuffer (string)
  79709. * @returns a string
  79710. */
  79711. getKind(): string;
  79712. /**
  79713. * Gets a boolean indicating if the VertexBuffer is updatable?
  79714. * @returns true if the buffer is updatable
  79715. */
  79716. isUpdatable(): boolean;
  79717. /**
  79718. * Gets current buffer's data
  79719. * @returns a DataArray or null
  79720. */
  79721. getData(): Nullable<DataArray>;
  79722. /**
  79723. * Gets underlying native buffer
  79724. * @returns underlying native buffer
  79725. */
  79726. getBuffer(): Nullable<DataBuffer>;
  79727. /**
  79728. * Gets the stride in float32 units (i.e. byte stride / 4).
  79729. * May not be an integer if the byte stride is not divisible by 4.
  79730. * @returns the stride in float32 units
  79731. * @deprecated Please use byteStride instead.
  79732. */
  79733. getStrideSize(): number;
  79734. /**
  79735. * Returns the offset as a multiple of the type byte length.
  79736. * @returns the offset in bytes
  79737. * @deprecated Please use byteOffset instead.
  79738. */
  79739. getOffset(): number;
  79740. /**
  79741. * Returns the number of components per vertex attribute (integer)
  79742. * @returns the size in float
  79743. */
  79744. getSize(): number;
  79745. /**
  79746. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  79747. * @returns true if this buffer is instanced
  79748. */
  79749. getIsInstanced(): boolean;
  79750. /**
  79751. * Returns the instancing divisor, zero for non-instanced (integer).
  79752. * @returns a number
  79753. */
  79754. getInstanceDivisor(): number;
  79755. /**
  79756. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  79757. * @param data defines the data to store
  79758. */
  79759. create(data?: DataArray): void;
  79760. /**
  79761. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  79762. * This function will create a new buffer if the current one is not updatable
  79763. * @param data defines the data to store
  79764. */
  79765. update(data: DataArray): void;
  79766. /**
  79767. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  79768. * Returns the directly updated WebGLBuffer.
  79769. * @param data the new data
  79770. * @param offset the new offset
  79771. * @param useBytes set to true if the offset is in bytes
  79772. */
  79773. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  79774. /**
  79775. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  79776. */
  79777. dispose(): void;
  79778. /**
  79779. * Enumerates each value of this vertex buffer as numbers.
  79780. * @param count the number of values to enumerate
  79781. * @param callback the callback function called for each value
  79782. */
  79783. forEach(count: number, callback: (value: number, index: number) => void): void;
  79784. /**
  79785. * Positions
  79786. */
  79787. static readonly PositionKind: string;
  79788. /**
  79789. * Normals
  79790. */
  79791. static readonly NormalKind: string;
  79792. /**
  79793. * Tangents
  79794. */
  79795. static readonly TangentKind: string;
  79796. /**
  79797. * Texture coordinates
  79798. */
  79799. static readonly UVKind: string;
  79800. /**
  79801. * Texture coordinates 2
  79802. */
  79803. static readonly UV2Kind: string;
  79804. /**
  79805. * Texture coordinates 3
  79806. */
  79807. static readonly UV3Kind: string;
  79808. /**
  79809. * Texture coordinates 4
  79810. */
  79811. static readonly UV4Kind: string;
  79812. /**
  79813. * Texture coordinates 5
  79814. */
  79815. static readonly UV5Kind: string;
  79816. /**
  79817. * Texture coordinates 6
  79818. */
  79819. static readonly UV6Kind: string;
  79820. /**
  79821. * Colors
  79822. */
  79823. static readonly ColorKind: string;
  79824. /**
  79825. * Matrix indices (for bones)
  79826. */
  79827. static readonly MatricesIndicesKind: string;
  79828. /**
  79829. * Matrix weights (for bones)
  79830. */
  79831. static readonly MatricesWeightsKind: string;
  79832. /**
  79833. * Additional matrix indices (for bones)
  79834. */
  79835. static readonly MatricesIndicesExtraKind: string;
  79836. /**
  79837. * Additional matrix weights (for bones)
  79838. */
  79839. static readonly MatricesWeightsExtraKind: string;
  79840. /**
  79841. * Deduces the stride given a kind.
  79842. * @param kind The kind string to deduce
  79843. * @returns The deduced stride
  79844. */
  79845. static DeduceStride(kind: string): number;
  79846. /**
  79847. * Gets the byte length of the given type.
  79848. * @param type the type
  79849. * @returns the number of bytes
  79850. */
  79851. static GetTypeByteLength(type: number): number;
  79852. /**
  79853. * Enumerates each value of the given parameters as numbers.
  79854. * @param data the data to enumerate
  79855. * @param byteOffset the byte offset of the data
  79856. * @param byteStride the byte stride of the data
  79857. * @param componentCount the number of components per element
  79858. * @param componentType the type of the component
  79859. * @param count the number of values to enumerate
  79860. * @param normalized whether the data is normalized
  79861. * @param callback the callback function called for each value
  79862. */
  79863. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  79864. private static _GetFloatValue;
  79865. }
  79866. }
  79867. declare module BABYLON {
  79868. /**
  79869. * @hidden
  79870. */
  79871. export class IntersectionInfo {
  79872. bu: Nullable<number>;
  79873. bv: Nullable<number>;
  79874. distance: number;
  79875. faceId: number;
  79876. subMeshId: number;
  79877. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  79878. }
  79879. }
  79880. declare module BABYLON {
  79881. /**
  79882. * Represens a plane by the equation ax + by + cz + d = 0
  79883. */
  79884. export class Plane {
  79885. private static _TmpMatrix;
  79886. /**
  79887. * Normal of the plane (a,b,c)
  79888. */
  79889. normal: Vector3;
  79890. /**
  79891. * d component of the plane
  79892. */
  79893. d: number;
  79894. /**
  79895. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  79896. * @param a a component of the plane
  79897. * @param b b component of the plane
  79898. * @param c c component of the plane
  79899. * @param d d component of the plane
  79900. */
  79901. constructor(a: number, b: number, c: number, d: number);
  79902. /**
  79903. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  79904. */
  79905. asArray(): number[];
  79906. /**
  79907. * @returns a new plane copied from the current Plane.
  79908. */
  79909. clone(): Plane;
  79910. /**
  79911. * @returns the string "Plane".
  79912. */
  79913. getClassName(): string;
  79914. /**
  79915. * @returns the Plane hash code.
  79916. */
  79917. getHashCode(): number;
  79918. /**
  79919. * Normalize the current Plane in place.
  79920. * @returns the updated Plane.
  79921. */
  79922. normalize(): Plane;
  79923. /**
  79924. * Applies a transformation the plane and returns the result
  79925. * @param transformation the transformation matrix to be applied to the plane
  79926. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  79927. */
  79928. transform(transformation: DeepImmutable<Matrix>): Plane;
  79929. /**
  79930. * Calcualtte the dot product between the point and the plane normal
  79931. * @param point point to calculate the dot product with
  79932. * @returns the dot product (float) of the point coordinates and the plane normal.
  79933. */
  79934. dotCoordinate(point: DeepImmutable<Vector3>): number;
  79935. /**
  79936. * Updates the current Plane from the plane defined by the three given points.
  79937. * @param point1 one of the points used to contruct the plane
  79938. * @param point2 one of the points used to contruct the plane
  79939. * @param point3 one of the points used to contruct the plane
  79940. * @returns the updated Plane.
  79941. */
  79942. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  79943. /**
  79944. * Checks if the plane is facing a given direction
  79945. * @param direction the direction to check if the plane is facing
  79946. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  79947. * @returns True is the vector "direction" is the same side than the plane normal.
  79948. */
  79949. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  79950. /**
  79951. * Calculates the distance to a point
  79952. * @param point point to calculate distance to
  79953. * @returns the signed distance (float) from the given point to the Plane.
  79954. */
  79955. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  79956. /**
  79957. * Creates a plane from an array
  79958. * @param array the array to create a plane from
  79959. * @returns a new Plane from the given array.
  79960. */
  79961. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  79962. /**
  79963. * Creates a plane from three points
  79964. * @param point1 point used to create the plane
  79965. * @param point2 point used to create the plane
  79966. * @param point3 point used to create the plane
  79967. * @returns a new Plane defined by the three given points.
  79968. */
  79969. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  79970. /**
  79971. * Creates a plane from an origin point and a normal
  79972. * @param origin origin of the plane to be constructed
  79973. * @param normal normal of the plane to be constructed
  79974. * @returns a new Plane the normal vector to this plane at the given origin point.
  79975. * Note : the vector "normal" is updated because normalized.
  79976. */
  79977. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  79978. /**
  79979. * Calculates the distance from a plane and a point
  79980. * @param origin origin of the plane to be constructed
  79981. * @param normal normal of the plane to be constructed
  79982. * @param point point to calculate distance to
  79983. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  79984. */
  79985. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  79986. }
  79987. }
  79988. declare module BABYLON {
  79989. /**
  79990. * Class used to store bounding sphere information
  79991. */
  79992. export class BoundingSphere {
  79993. /**
  79994. * Gets the center of the bounding sphere in local space
  79995. */
  79996. readonly center: Vector3;
  79997. /**
  79998. * Radius of the bounding sphere in local space
  79999. */
  80000. radius: number;
  80001. /**
  80002. * Gets the center of the bounding sphere in world space
  80003. */
  80004. readonly centerWorld: Vector3;
  80005. /**
  80006. * Radius of the bounding sphere in world space
  80007. */
  80008. radiusWorld: number;
  80009. /**
  80010. * Gets the minimum vector in local space
  80011. */
  80012. readonly minimum: Vector3;
  80013. /**
  80014. * Gets the maximum vector in local space
  80015. */
  80016. readonly maximum: Vector3;
  80017. private _worldMatrix;
  80018. private static readonly TmpVector3;
  80019. /**
  80020. * Creates a new bounding sphere
  80021. * @param min defines the minimum vector (in local space)
  80022. * @param max defines the maximum vector (in local space)
  80023. * @param worldMatrix defines the new world matrix
  80024. */
  80025. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  80026. /**
  80027. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  80028. * @param min defines the new minimum vector (in local space)
  80029. * @param max defines the new maximum vector (in local space)
  80030. * @param worldMatrix defines the new world matrix
  80031. */
  80032. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  80033. /**
  80034. * Scale the current bounding sphere by applying a scale factor
  80035. * @param factor defines the scale factor to apply
  80036. * @returns the current bounding box
  80037. */
  80038. scale(factor: number): BoundingSphere;
  80039. /**
  80040. * Gets the world matrix of the bounding box
  80041. * @returns a matrix
  80042. */
  80043. getWorldMatrix(): DeepImmutable<Matrix>;
  80044. /** @hidden */
  80045. _update(worldMatrix: DeepImmutable<Matrix>): void;
  80046. /**
  80047. * Tests if the bounding sphere is intersecting the frustum planes
  80048. * @param frustumPlanes defines the frustum planes to test
  80049. * @returns true if there is an intersection
  80050. */
  80051. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80052. /**
  80053. * Tests if the bounding sphere center is in between the frustum planes.
  80054. * Used for optimistic fast inclusion.
  80055. * @param frustumPlanes defines the frustum planes to test
  80056. * @returns true if the sphere center is in between the frustum planes
  80057. */
  80058. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80059. /**
  80060. * Tests if a point is inside the bounding sphere
  80061. * @param point defines the point to test
  80062. * @returns true if the point is inside the bounding sphere
  80063. */
  80064. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  80065. /**
  80066. * Checks if two sphere intersct
  80067. * @param sphere0 sphere 0
  80068. * @param sphere1 sphere 1
  80069. * @returns true if the speres intersect
  80070. */
  80071. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  80072. }
  80073. }
  80074. declare module BABYLON {
  80075. /**
  80076. * Class used to store bounding box information
  80077. */
  80078. export class BoundingBox implements ICullable {
  80079. /**
  80080. * Gets the 8 vectors representing the bounding box in local space
  80081. */
  80082. readonly vectors: Vector3[];
  80083. /**
  80084. * Gets the center of the bounding box in local space
  80085. */
  80086. readonly center: Vector3;
  80087. /**
  80088. * Gets the center of the bounding box in world space
  80089. */
  80090. readonly centerWorld: Vector3;
  80091. /**
  80092. * Gets the extend size in local space
  80093. */
  80094. readonly extendSize: Vector3;
  80095. /**
  80096. * Gets the extend size in world space
  80097. */
  80098. readonly extendSizeWorld: Vector3;
  80099. /**
  80100. * Gets the OBB (object bounding box) directions
  80101. */
  80102. readonly directions: Vector3[];
  80103. /**
  80104. * Gets the 8 vectors representing the bounding box in world space
  80105. */
  80106. readonly vectorsWorld: Vector3[];
  80107. /**
  80108. * Gets the minimum vector in world space
  80109. */
  80110. readonly minimumWorld: Vector3;
  80111. /**
  80112. * Gets the maximum vector in world space
  80113. */
  80114. readonly maximumWorld: Vector3;
  80115. /**
  80116. * Gets the minimum vector in local space
  80117. */
  80118. readonly minimum: Vector3;
  80119. /**
  80120. * Gets the maximum vector in local space
  80121. */
  80122. readonly maximum: Vector3;
  80123. private _worldMatrix;
  80124. private static readonly TmpVector3;
  80125. /**
  80126. * @hidden
  80127. */
  80128. _tag: number;
  80129. /**
  80130. * Creates a new bounding box
  80131. * @param min defines the minimum vector (in local space)
  80132. * @param max defines the maximum vector (in local space)
  80133. * @param worldMatrix defines the new world matrix
  80134. */
  80135. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  80136. /**
  80137. * Recreates the entire bounding box from scratch as if we call the constructor in place
  80138. * @param min defines the new minimum vector (in local space)
  80139. * @param max defines the new maximum vector (in local space)
  80140. * @param worldMatrix defines the new world matrix
  80141. */
  80142. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  80143. /**
  80144. * Scale the current bounding box by applying a scale factor
  80145. * @param factor defines the scale factor to apply
  80146. * @returns the current bounding box
  80147. */
  80148. scale(factor: number): BoundingBox;
  80149. /**
  80150. * Gets the world matrix of the bounding box
  80151. * @returns a matrix
  80152. */
  80153. getWorldMatrix(): DeepImmutable<Matrix>;
  80154. /** @hidden */
  80155. _update(world: DeepImmutable<Matrix>): void;
  80156. /**
  80157. * Tests if the bounding box is intersecting the frustum planes
  80158. * @param frustumPlanes defines the frustum planes to test
  80159. * @returns true if there is an intersection
  80160. */
  80161. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80162. /**
  80163. * Tests if the bounding box is entirely inside the frustum planes
  80164. * @param frustumPlanes defines the frustum planes to test
  80165. * @returns true if there is an inclusion
  80166. */
  80167. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80168. /**
  80169. * Tests if a point is inside the bounding box
  80170. * @param point defines the point to test
  80171. * @returns true if the point is inside the bounding box
  80172. */
  80173. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  80174. /**
  80175. * Tests if the bounding box intersects with a bounding sphere
  80176. * @param sphere defines the sphere to test
  80177. * @returns true if there is an intersection
  80178. */
  80179. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  80180. /**
  80181. * Tests if the bounding box intersects with a box defined by a min and max vectors
  80182. * @param min defines the min vector to use
  80183. * @param max defines the max vector to use
  80184. * @returns true if there is an intersection
  80185. */
  80186. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  80187. /**
  80188. * Tests if two bounding boxes are intersections
  80189. * @param box0 defines the first box to test
  80190. * @param box1 defines the second box to test
  80191. * @returns true if there is an intersection
  80192. */
  80193. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  80194. /**
  80195. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  80196. * @param minPoint defines the minimum vector of the bounding box
  80197. * @param maxPoint defines the maximum vector of the bounding box
  80198. * @param sphereCenter defines the sphere center
  80199. * @param sphereRadius defines the sphere radius
  80200. * @returns true if there is an intersection
  80201. */
  80202. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  80203. /**
  80204. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  80205. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  80206. * @param frustumPlanes defines the frustum planes to test
  80207. * @return true if there is an inclusion
  80208. */
  80209. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80210. /**
  80211. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  80212. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  80213. * @param frustumPlanes defines the frustum planes to test
  80214. * @return true if there is an intersection
  80215. */
  80216. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80217. }
  80218. }
  80219. declare module BABYLON {
  80220. /** @hidden */
  80221. export class Collider {
  80222. /** Define if a collision was found */
  80223. collisionFound: boolean;
  80224. /**
  80225. * Define last intersection point in local space
  80226. */
  80227. intersectionPoint: Vector3;
  80228. /**
  80229. * Define last collided mesh
  80230. */
  80231. collidedMesh: Nullable<AbstractMesh>;
  80232. private _collisionPoint;
  80233. private _planeIntersectionPoint;
  80234. private _tempVector;
  80235. private _tempVector2;
  80236. private _tempVector3;
  80237. private _tempVector4;
  80238. private _edge;
  80239. private _baseToVertex;
  80240. private _destinationPoint;
  80241. private _slidePlaneNormal;
  80242. private _displacementVector;
  80243. /** @hidden */
  80244. _radius: Vector3;
  80245. /** @hidden */
  80246. _retry: number;
  80247. private _velocity;
  80248. private _basePoint;
  80249. private _epsilon;
  80250. /** @hidden */
  80251. _velocityWorldLength: number;
  80252. /** @hidden */
  80253. _basePointWorld: Vector3;
  80254. private _velocityWorld;
  80255. private _normalizedVelocity;
  80256. /** @hidden */
  80257. _initialVelocity: Vector3;
  80258. /** @hidden */
  80259. _initialPosition: Vector3;
  80260. private _nearestDistance;
  80261. private _collisionMask;
  80262. get collisionMask(): number;
  80263. set collisionMask(mask: number);
  80264. /**
  80265. * Gets the plane normal used to compute the sliding response (in local space)
  80266. */
  80267. get slidePlaneNormal(): Vector3;
  80268. /** @hidden */
  80269. _initialize(source: Vector3, dir: Vector3, e: number): void;
  80270. /** @hidden */
  80271. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  80272. /** @hidden */
  80273. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  80274. /** @hidden */
  80275. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  80276. /** @hidden */
  80277. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  80278. /** @hidden */
  80279. _getResponse(pos: Vector3, vel: Vector3): void;
  80280. }
  80281. }
  80282. declare module BABYLON {
  80283. /**
  80284. * Interface for cullable objects
  80285. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  80286. */
  80287. export interface ICullable {
  80288. /**
  80289. * Checks if the object or part of the object is in the frustum
  80290. * @param frustumPlanes Camera near/planes
  80291. * @returns true if the object is in frustum otherwise false
  80292. */
  80293. isInFrustum(frustumPlanes: Plane[]): boolean;
  80294. /**
  80295. * Checks if a cullable object (mesh...) is in the camera frustum
  80296. * Unlike isInFrustum this cheks the full bounding box
  80297. * @param frustumPlanes Camera near/planes
  80298. * @returns true if the object is in frustum otherwise false
  80299. */
  80300. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  80301. }
  80302. /**
  80303. * Info for a bounding data of a mesh
  80304. */
  80305. export class BoundingInfo implements ICullable {
  80306. /**
  80307. * Bounding box for the mesh
  80308. */
  80309. readonly boundingBox: BoundingBox;
  80310. /**
  80311. * Bounding sphere for the mesh
  80312. */
  80313. readonly boundingSphere: BoundingSphere;
  80314. private _isLocked;
  80315. private static readonly TmpVector3;
  80316. /**
  80317. * Constructs bounding info
  80318. * @param minimum min vector of the bounding box/sphere
  80319. * @param maximum max vector of the bounding box/sphere
  80320. * @param worldMatrix defines the new world matrix
  80321. */
  80322. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  80323. /**
  80324. * Recreates the entire bounding info from scratch as if we call the constructor in place
  80325. * @param min defines the new minimum vector (in local space)
  80326. * @param max defines the new maximum vector (in local space)
  80327. * @param worldMatrix defines the new world matrix
  80328. */
  80329. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  80330. /**
  80331. * min vector of the bounding box/sphere
  80332. */
  80333. get minimum(): Vector3;
  80334. /**
  80335. * max vector of the bounding box/sphere
  80336. */
  80337. get maximum(): Vector3;
  80338. /**
  80339. * If the info is locked and won't be updated to avoid perf overhead
  80340. */
  80341. get isLocked(): boolean;
  80342. set isLocked(value: boolean);
  80343. /**
  80344. * Updates the bounding sphere and box
  80345. * @param world world matrix to be used to update
  80346. */
  80347. update(world: DeepImmutable<Matrix>): void;
  80348. /**
  80349. * Recreate the bounding info to be centered around a specific point given a specific extend.
  80350. * @param center New center of the bounding info
  80351. * @param extend New extend of the bounding info
  80352. * @returns the current bounding info
  80353. */
  80354. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  80355. /**
  80356. * Scale the current bounding info by applying a scale factor
  80357. * @param factor defines the scale factor to apply
  80358. * @returns the current bounding info
  80359. */
  80360. scale(factor: number): BoundingInfo;
  80361. /**
  80362. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  80363. * @param frustumPlanes defines the frustum to test
  80364. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  80365. * @returns true if the bounding info is in the frustum planes
  80366. */
  80367. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  80368. /**
  80369. * Gets the world distance between the min and max points of the bounding box
  80370. */
  80371. get diagonalLength(): number;
  80372. /**
  80373. * Checks if a cullable object (mesh...) is in the camera frustum
  80374. * Unlike isInFrustum this cheks the full bounding box
  80375. * @param frustumPlanes Camera near/planes
  80376. * @returns true if the object is in frustum otherwise false
  80377. */
  80378. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80379. /** @hidden */
  80380. _checkCollision(collider: Collider): boolean;
  80381. /**
  80382. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  80383. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  80384. * @param point the point to check intersection with
  80385. * @returns if the point intersects
  80386. */
  80387. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  80388. /**
  80389. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  80390. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  80391. * @param boundingInfo the bounding info to check intersection with
  80392. * @param precise if the intersection should be done using OBB
  80393. * @returns if the bounding info intersects
  80394. */
  80395. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  80396. }
  80397. }
  80398. declare module BABYLON {
  80399. /**
  80400. * Extracts minimum and maximum values from a list of indexed positions
  80401. * @param positions defines the positions to use
  80402. * @param indices defines the indices to the positions
  80403. * @param indexStart defines the start index
  80404. * @param indexCount defines the end index
  80405. * @param bias defines bias value to add to the result
  80406. * @return minimum and maximum values
  80407. */
  80408. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  80409. minimum: Vector3;
  80410. maximum: Vector3;
  80411. };
  80412. /**
  80413. * Extracts minimum and maximum values from a list of positions
  80414. * @param positions defines the positions to use
  80415. * @param start defines the start index in the positions array
  80416. * @param count defines the number of positions to handle
  80417. * @param bias defines bias value to add to the result
  80418. * @param stride defines the stride size to use (distance between two positions in the positions array)
  80419. * @return minimum and maximum values
  80420. */
  80421. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  80422. minimum: Vector3;
  80423. maximum: Vector3;
  80424. };
  80425. }
  80426. declare module BABYLON {
  80427. /** @hidden */
  80428. export class WebGLDataBuffer extends DataBuffer {
  80429. private _buffer;
  80430. constructor(resource: WebGLBuffer);
  80431. get underlyingResource(): any;
  80432. }
  80433. }
  80434. declare module BABYLON {
  80435. /** @hidden */
  80436. export class WebGLPipelineContext implements IPipelineContext {
  80437. engine: ThinEngine;
  80438. program: Nullable<WebGLProgram>;
  80439. context?: WebGLRenderingContext;
  80440. vertexShader?: WebGLShader;
  80441. fragmentShader?: WebGLShader;
  80442. isParallelCompiled: boolean;
  80443. onCompiled?: () => void;
  80444. transformFeedback?: WebGLTransformFeedback | null;
  80445. vertexCompilationError: Nullable<string>;
  80446. fragmentCompilationError: Nullable<string>;
  80447. programLinkError: Nullable<string>;
  80448. programValidationError: Nullable<string>;
  80449. get isAsync(): boolean;
  80450. get isReady(): boolean;
  80451. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  80452. }
  80453. }
  80454. declare module BABYLON {
  80455. interface ThinEngine {
  80456. /**
  80457. * Create an uniform buffer
  80458. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80459. * @param elements defines the content of the uniform buffer
  80460. * @returns the webGL uniform buffer
  80461. */
  80462. createUniformBuffer(elements: FloatArray): DataBuffer;
  80463. /**
  80464. * Create a dynamic uniform buffer
  80465. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80466. * @param elements defines the content of the uniform buffer
  80467. * @returns the webGL uniform buffer
  80468. */
  80469. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  80470. /**
  80471. * Update an existing uniform buffer
  80472. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80473. * @param uniformBuffer defines the target uniform buffer
  80474. * @param elements defines the content to update
  80475. * @param offset defines the offset in the uniform buffer where update should start
  80476. * @param count defines the size of the data to update
  80477. */
  80478. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  80479. /**
  80480. * Bind an uniform buffer to the current webGL context
  80481. * @param buffer defines the buffer to bind
  80482. */
  80483. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  80484. /**
  80485. * Bind a buffer to the current webGL context at a given location
  80486. * @param buffer defines the buffer to bind
  80487. * @param location defines the index where to bind the buffer
  80488. */
  80489. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  80490. /**
  80491. * Bind a specific block at a given index in a specific shader program
  80492. * @param pipelineContext defines the pipeline context to use
  80493. * @param blockName defines the block name
  80494. * @param index defines the index where to bind the block
  80495. */
  80496. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  80497. }
  80498. }
  80499. declare module BABYLON {
  80500. /**
  80501. * Uniform buffer objects.
  80502. *
  80503. * Handles blocks of uniform on the GPU.
  80504. *
  80505. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  80506. *
  80507. * For more information, please refer to :
  80508. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  80509. */
  80510. export class UniformBuffer {
  80511. private _engine;
  80512. private _buffer;
  80513. private _data;
  80514. private _bufferData;
  80515. private _dynamic?;
  80516. private _uniformLocations;
  80517. private _uniformSizes;
  80518. private _uniformLocationPointer;
  80519. private _needSync;
  80520. private _noUBO;
  80521. private _currentEffect;
  80522. /** @hidden */
  80523. _alreadyBound: boolean;
  80524. private static _MAX_UNIFORM_SIZE;
  80525. private static _tempBuffer;
  80526. /**
  80527. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  80528. * This is dynamic to allow compat with webgl 1 and 2.
  80529. * You will need to pass the name of the uniform as well as the value.
  80530. */
  80531. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  80532. /**
  80533. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  80534. * This is dynamic to allow compat with webgl 1 and 2.
  80535. * You will need to pass the name of the uniform as well as the value.
  80536. */
  80537. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  80538. /**
  80539. * Lambda to Update a single float in a uniform buffer.
  80540. * This is dynamic to allow compat with webgl 1 and 2.
  80541. * You will need to pass the name of the uniform as well as the value.
  80542. */
  80543. updateFloat: (name: string, x: number) => void;
  80544. /**
  80545. * Lambda to Update a vec2 of float in a uniform buffer.
  80546. * This is dynamic to allow compat with webgl 1 and 2.
  80547. * You will need to pass the name of the uniform as well as the value.
  80548. */
  80549. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  80550. /**
  80551. * Lambda to Update a vec3 of float in a uniform buffer.
  80552. * This is dynamic to allow compat with webgl 1 and 2.
  80553. * You will need to pass the name of the uniform as well as the value.
  80554. */
  80555. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  80556. /**
  80557. * Lambda to Update a vec4 of float in a uniform buffer.
  80558. * This is dynamic to allow compat with webgl 1 and 2.
  80559. * You will need to pass the name of the uniform as well as the value.
  80560. */
  80561. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  80562. /**
  80563. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  80564. * This is dynamic to allow compat with webgl 1 and 2.
  80565. * You will need to pass the name of the uniform as well as the value.
  80566. */
  80567. updateMatrix: (name: string, mat: Matrix) => void;
  80568. /**
  80569. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  80570. * This is dynamic to allow compat with webgl 1 and 2.
  80571. * You will need to pass the name of the uniform as well as the value.
  80572. */
  80573. updateVector3: (name: string, vector: Vector3) => void;
  80574. /**
  80575. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  80576. * This is dynamic to allow compat with webgl 1 and 2.
  80577. * You will need to pass the name of the uniform as well as the value.
  80578. */
  80579. updateVector4: (name: string, vector: Vector4) => void;
  80580. /**
  80581. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  80582. * This is dynamic to allow compat with webgl 1 and 2.
  80583. * You will need to pass the name of the uniform as well as the value.
  80584. */
  80585. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  80586. /**
  80587. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  80588. * This is dynamic to allow compat with webgl 1 and 2.
  80589. * You will need to pass the name of the uniform as well as the value.
  80590. */
  80591. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  80592. /**
  80593. * Instantiates a new Uniform buffer objects.
  80594. *
  80595. * Handles blocks of uniform on the GPU.
  80596. *
  80597. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  80598. *
  80599. * For more information, please refer to :
  80600. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  80601. * @param engine Define the engine the buffer is associated with
  80602. * @param data Define the data contained in the buffer
  80603. * @param dynamic Define if the buffer is updatable
  80604. */
  80605. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  80606. /**
  80607. * Indicates if the buffer is using the WebGL2 UBO implementation,
  80608. * or just falling back on setUniformXXX calls.
  80609. */
  80610. get useUbo(): boolean;
  80611. /**
  80612. * Indicates if the WebGL underlying uniform buffer is in sync
  80613. * with the javascript cache data.
  80614. */
  80615. get isSync(): boolean;
  80616. /**
  80617. * Indicates if the WebGL underlying uniform buffer is dynamic.
  80618. * Also, a dynamic UniformBuffer will disable cache verification and always
  80619. * update the underlying WebGL uniform buffer to the GPU.
  80620. * @returns if Dynamic, otherwise false
  80621. */
  80622. isDynamic(): boolean;
  80623. /**
  80624. * The data cache on JS side.
  80625. * @returns the underlying data as a float array
  80626. */
  80627. getData(): Float32Array;
  80628. /**
  80629. * The underlying WebGL Uniform buffer.
  80630. * @returns the webgl buffer
  80631. */
  80632. getBuffer(): Nullable<DataBuffer>;
  80633. /**
  80634. * std140 layout specifies how to align data within an UBO structure.
  80635. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  80636. * for specs.
  80637. */
  80638. private _fillAlignment;
  80639. /**
  80640. * Adds an uniform in the buffer.
  80641. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  80642. * for the layout to be correct !
  80643. * @param name Name of the uniform, as used in the uniform block in the shader.
  80644. * @param size Data size, or data directly.
  80645. */
  80646. addUniform(name: string, size: number | number[]): void;
  80647. /**
  80648. * Adds a Matrix 4x4 to the uniform buffer.
  80649. * @param name Name of the uniform, as used in the uniform block in the shader.
  80650. * @param mat A 4x4 matrix.
  80651. */
  80652. addMatrix(name: string, mat: Matrix): void;
  80653. /**
  80654. * Adds a vec2 to the uniform buffer.
  80655. * @param name Name of the uniform, as used in the uniform block in the shader.
  80656. * @param x Define the x component value of the vec2
  80657. * @param y Define the y component value of the vec2
  80658. */
  80659. addFloat2(name: string, x: number, y: number): void;
  80660. /**
  80661. * Adds a vec3 to the uniform buffer.
  80662. * @param name Name of the uniform, as used in the uniform block in the shader.
  80663. * @param x Define the x component value of the vec3
  80664. * @param y Define the y component value of the vec3
  80665. * @param z Define the z component value of the vec3
  80666. */
  80667. addFloat3(name: string, x: number, y: number, z: number): void;
  80668. /**
  80669. * Adds a vec3 to the uniform buffer.
  80670. * @param name Name of the uniform, as used in the uniform block in the shader.
  80671. * @param color Define the vec3 from a Color
  80672. */
  80673. addColor3(name: string, color: Color3): void;
  80674. /**
  80675. * Adds a vec4 to the uniform buffer.
  80676. * @param name Name of the uniform, as used in the uniform block in the shader.
  80677. * @param color Define the rgb components from a Color
  80678. * @param alpha Define the a component of the vec4
  80679. */
  80680. addColor4(name: string, color: Color3, alpha: number): void;
  80681. /**
  80682. * Adds a vec3 to the uniform buffer.
  80683. * @param name Name of the uniform, as used in the uniform block in the shader.
  80684. * @param vector Define the vec3 components from a Vector
  80685. */
  80686. addVector3(name: string, vector: Vector3): void;
  80687. /**
  80688. * Adds a Matrix 3x3 to the uniform buffer.
  80689. * @param name Name of the uniform, as used in the uniform block in the shader.
  80690. */
  80691. addMatrix3x3(name: string): void;
  80692. /**
  80693. * Adds a Matrix 2x2 to the uniform buffer.
  80694. * @param name Name of the uniform, as used in the uniform block in the shader.
  80695. */
  80696. addMatrix2x2(name: string): void;
  80697. /**
  80698. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  80699. */
  80700. create(): void;
  80701. /** @hidden */
  80702. _rebuild(): void;
  80703. /**
  80704. * Updates the WebGL Uniform Buffer on the GPU.
  80705. * If the `dynamic` flag is set to true, no cache comparison is done.
  80706. * Otherwise, the buffer will be updated only if the cache differs.
  80707. */
  80708. update(): void;
  80709. /**
  80710. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  80711. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  80712. * @param data Define the flattened data
  80713. * @param size Define the size of the data.
  80714. */
  80715. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  80716. private _valueCache;
  80717. private _cacheMatrix;
  80718. private _updateMatrix3x3ForUniform;
  80719. private _updateMatrix3x3ForEffect;
  80720. private _updateMatrix2x2ForEffect;
  80721. private _updateMatrix2x2ForUniform;
  80722. private _updateFloatForEffect;
  80723. private _updateFloatForUniform;
  80724. private _updateFloat2ForEffect;
  80725. private _updateFloat2ForUniform;
  80726. private _updateFloat3ForEffect;
  80727. private _updateFloat3ForUniform;
  80728. private _updateFloat4ForEffect;
  80729. private _updateFloat4ForUniform;
  80730. private _updateMatrixForEffect;
  80731. private _updateMatrixForUniform;
  80732. private _updateVector3ForEffect;
  80733. private _updateVector3ForUniform;
  80734. private _updateVector4ForEffect;
  80735. private _updateVector4ForUniform;
  80736. private _updateColor3ForEffect;
  80737. private _updateColor3ForUniform;
  80738. private _updateColor4ForEffect;
  80739. private _updateColor4ForUniform;
  80740. /**
  80741. * Sets a sampler uniform on the effect.
  80742. * @param name Define the name of the sampler.
  80743. * @param texture Define the texture to set in the sampler
  80744. */
  80745. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  80746. /**
  80747. * Directly updates the value of the uniform in the cache AND on the GPU.
  80748. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  80749. * @param data Define the flattened data
  80750. */
  80751. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  80752. /**
  80753. * Binds this uniform buffer to an effect.
  80754. * @param effect Define the effect to bind the buffer to
  80755. * @param name Name of the uniform block in the shader.
  80756. */
  80757. bindToEffect(effect: Effect, name: string): void;
  80758. /**
  80759. * Disposes the uniform buffer.
  80760. */
  80761. dispose(): void;
  80762. }
  80763. }
  80764. declare module BABYLON {
  80765. /**
  80766. * Enum that determines the text-wrapping mode to use.
  80767. */
  80768. export enum InspectableType {
  80769. /**
  80770. * Checkbox for booleans
  80771. */
  80772. Checkbox = 0,
  80773. /**
  80774. * Sliders for numbers
  80775. */
  80776. Slider = 1,
  80777. /**
  80778. * Vector3
  80779. */
  80780. Vector3 = 2,
  80781. /**
  80782. * Quaternions
  80783. */
  80784. Quaternion = 3,
  80785. /**
  80786. * Color3
  80787. */
  80788. Color3 = 4,
  80789. /**
  80790. * String
  80791. */
  80792. String = 5
  80793. }
  80794. /**
  80795. * Interface used to define custom inspectable properties.
  80796. * This interface is used by the inspector to display custom property grids
  80797. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80798. */
  80799. export interface IInspectable {
  80800. /**
  80801. * Gets the label to display
  80802. */
  80803. label: string;
  80804. /**
  80805. * Gets the name of the property to edit
  80806. */
  80807. propertyName: string;
  80808. /**
  80809. * Gets the type of the editor to use
  80810. */
  80811. type: InspectableType;
  80812. /**
  80813. * Gets the minimum value of the property when using in "slider" mode
  80814. */
  80815. min?: number;
  80816. /**
  80817. * Gets the maximum value of the property when using in "slider" mode
  80818. */
  80819. max?: number;
  80820. /**
  80821. * Gets the setp to use when using in "slider" mode
  80822. */
  80823. step?: number;
  80824. }
  80825. }
  80826. declare module BABYLON {
  80827. /**
  80828. * Class used to provide helper for timing
  80829. */
  80830. export class TimingTools {
  80831. /**
  80832. * Polyfill for setImmediate
  80833. * @param action defines the action to execute after the current execution block
  80834. */
  80835. static SetImmediate(action: () => void): void;
  80836. }
  80837. }
  80838. declare module BABYLON {
  80839. /**
  80840. * Class used to enable instatition of objects by class name
  80841. */
  80842. export class InstantiationTools {
  80843. /**
  80844. * Use this object to register external classes like custom textures or material
  80845. * to allow the laoders to instantiate them
  80846. */
  80847. static RegisteredExternalClasses: {
  80848. [key: string]: Object;
  80849. };
  80850. /**
  80851. * Tries to instantiate a new object from a given class name
  80852. * @param className defines the class name to instantiate
  80853. * @returns the new object or null if the system was not able to do the instantiation
  80854. */
  80855. static Instantiate(className: string): any;
  80856. }
  80857. }
  80858. declare module BABYLON {
  80859. /**
  80860. * Define options used to create a depth texture
  80861. */
  80862. export class DepthTextureCreationOptions {
  80863. /** Specifies whether or not a stencil should be allocated in the texture */
  80864. generateStencil?: boolean;
  80865. /** Specifies whether or not bilinear filtering is enable on the texture */
  80866. bilinearFiltering?: boolean;
  80867. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  80868. comparisonFunction?: number;
  80869. /** Specifies if the created texture is a cube texture */
  80870. isCube?: boolean;
  80871. }
  80872. }
  80873. declare module BABYLON {
  80874. interface ThinEngine {
  80875. /**
  80876. * Creates a depth stencil cube texture.
  80877. * This is only available in WebGL 2.
  80878. * @param size The size of face edge in the cube texture.
  80879. * @param options The options defining the cube texture.
  80880. * @returns The cube texture
  80881. */
  80882. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  80883. /**
  80884. * Creates a cube texture
  80885. * @param rootUrl defines the url where the files to load is located
  80886. * @param scene defines the current scene
  80887. * @param files defines the list of files to load (1 per face)
  80888. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  80889. * @param onLoad defines an optional callback raised when the texture is loaded
  80890. * @param onError defines an optional callback raised if there is an issue to load the texture
  80891. * @param format defines the format of the data
  80892. * @param forcedExtension defines the extension to use to pick the right loader
  80893. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  80894. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  80895. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  80896. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  80897. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  80898. * @returns the cube texture as an InternalTexture
  80899. */
  80900. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  80901. /**
  80902. * Creates a cube texture
  80903. * @param rootUrl defines the url where the files to load is located
  80904. * @param scene defines the current scene
  80905. * @param files defines the list of files to load (1 per face)
  80906. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  80907. * @param onLoad defines an optional callback raised when the texture is loaded
  80908. * @param onError defines an optional callback raised if there is an issue to load the texture
  80909. * @param format defines the format of the data
  80910. * @param forcedExtension defines the extension to use to pick the right loader
  80911. * @returns the cube texture as an InternalTexture
  80912. */
  80913. 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;
  80914. /**
  80915. * Creates a cube texture
  80916. * @param rootUrl defines the url where the files to load is located
  80917. * @param scene defines the current scene
  80918. * @param files defines the list of files to load (1 per face)
  80919. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  80920. * @param onLoad defines an optional callback raised when the texture is loaded
  80921. * @param onError defines an optional callback raised if there is an issue to load the texture
  80922. * @param format defines the format of the data
  80923. * @param forcedExtension defines the extension to use to pick the right loader
  80924. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  80925. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  80926. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  80927. * @returns the cube texture as an InternalTexture
  80928. */
  80929. 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;
  80930. /** @hidden */
  80931. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  80932. /** @hidden */
  80933. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  80934. /** @hidden */
  80935. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  80936. /** @hidden */
  80937. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  80938. /**
  80939. * @hidden
  80940. */
  80941. _setCubeMapTextureParams(loadMipmap: boolean): void;
  80942. }
  80943. }
  80944. declare module BABYLON {
  80945. /**
  80946. * Class for creating a cube texture
  80947. */
  80948. export class CubeTexture extends BaseTexture {
  80949. private _delayedOnLoad;
  80950. /**
  80951. * Observable triggered once the texture has been loaded.
  80952. */
  80953. onLoadObservable: Observable<CubeTexture>;
  80954. /**
  80955. * The url of the texture
  80956. */
  80957. url: string;
  80958. /**
  80959. * Gets or sets the center of the bounding box associated with the cube texture.
  80960. * It must define where the camera used to render the texture was set
  80961. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  80962. */
  80963. boundingBoxPosition: Vector3;
  80964. private _boundingBoxSize;
  80965. /**
  80966. * Gets or sets the size of the bounding box associated with the cube texture
  80967. * When defined, the cubemap will switch to local mode
  80968. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  80969. * @example https://www.babylonjs-playground.com/#RNASML
  80970. */
  80971. set boundingBoxSize(value: Vector3);
  80972. /**
  80973. * Returns the bounding box size
  80974. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  80975. */
  80976. get boundingBoxSize(): Vector3;
  80977. protected _rotationY: number;
  80978. /**
  80979. * Sets texture matrix rotation angle around Y axis in radians.
  80980. */
  80981. set rotationY(value: number);
  80982. /**
  80983. * Gets texture matrix rotation angle around Y axis radians.
  80984. */
  80985. get rotationY(): number;
  80986. /**
  80987. * Are mip maps generated for this texture or not.
  80988. */
  80989. get noMipmap(): boolean;
  80990. private _noMipmap;
  80991. private _files;
  80992. protected _forcedExtension: Nullable<string>;
  80993. private _extensions;
  80994. private _textureMatrix;
  80995. private _format;
  80996. private _createPolynomials;
  80997. /** @hidden */
  80998. _prefiltered: boolean;
  80999. /**
  81000. * Creates a cube texture from an array of image urls
  81001. * @param files defines an array of image urls
  81002. * @param scene defines the hosting scene
  81003. * @param noMipmap specifies if mip maps are not used
  81004. * @returns a cube texture
  81005. */
  81006. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  81007. /**
  81008. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  81009. * @param url defines the url of the prefiltered texture
  81010. * @param scene defines the scene the texture is attached to
  81011. * @param forcedExtension defines the extension of the file if different from the url
  81012. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  81013. * @return the prefiltered texture
  81014. */
  81015. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  81016. /**
  81017. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  81018. * as prefiltered data.
  81019. * @param rootUrl defines the url of the texture or the root name of the six images
  81020. * @param scene defines the scene the texture is attached to
  81021. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  81022. * @param noMipmap defines if mipmaps should be created or not
  81023. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  81024. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  81025. * @param onError defines a callback triggered in case of error during load
  81026. * @param format defines the internal format to use for the texture once loaded
  81027. * @param prefiltered defines whether or not the texture is created from prefiltered data
  81028. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  81029. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  81030. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  81031. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  81032. * @return the cube texture
  81033. */
  81034. 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);
  81035. /**
  81036. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  81037. */
  81038. get isPrefiltered(): boolean;
  81039. /**
  81040. * Get the current class name of the texture useful for serialization or dynamic coding.
  81041. * @returns "CubeTexture"
  81042. */
  81043. getClassName(): string;
  81044. /**
  81045. * Update the url (and optional buffer) of this texture if url was null during construction.
  81046. * @param url the url of the texture
  81047. * @param forcedExtension defines the extension to use
  81048. * @param onLoad callback called when the texture is loaded (defaults to null)
  81049. * @param prefiltered Defines whether the updated texture is prefiltered or not
  81050. */
  81051. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  81052. /**
  81053. * Delays loading of the cube texture
  81054. * @param forcedExtension defines the extension to use
  81055. */
  81056. delayLoad(forcedExtension?: string): void;
  81057. /**
  81058. * Returns the reflection texture matrix
  81059. * @returns the reflection texture matrix
  81060. */
  81061. getReflectionTextureMatrix(): Matrix;
  81062. /**
  81063. * Sets the reflection texture matrix
  81064. * @param value Reflection texture matrix
  81065. */
  81066. setReflectionTextureMatrix(value: Matrix): void;
  81067. /**
  81068. * Parses text to create a cube texture
  81069. * @param parsedTexture define the serialized text to read from
  81070. * @param scene defines the hosting scene
  81071. * @param rootUrl defines the root url of the cube texture
  81072. * @returns a cube texture
  81073. */
  81074. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  81075. /**
  81076. * Makes a clone, or deep copy, of the cube texture
  81077. * @returns a new cube texture
  81078. */
  81079. clone(): CubeTexture;
  81080. }
  81081. }
  81082. declare module BABYLON {
  81083. /**
  81084. * Manages the defines for the Material
  81085. */
  81086. export class MaterialDefines {
  81087. /** @hidden */
  81088. protected _keys: string[];
  81089. private _isDirty;
  81090. /** @hidden */
  81091. _renderId: number;
  81092. /** @hidden */
  81093. _areLightsDirty: boolean;
  81094. /** @hidden */
  81095. _areLightsDisposed: boolean;
  81096. /** @hidden */
  81097. _areAttributesDirty: boolean;
  81098. /** @hidden */
  81099. _areTexturesDirty: boolean;
  81100. /** @hidden */
  81101. _areFresnelDirty: boolean;
  81102. /** @hidden */
  81103. _areMiscDirty: boolean;
  81104. /** @hidden */
  81105. _areImageProcessingDirty: boolean;
  81106. /** @hidden */
  81107. _normals: boolean;
  81108. /** @hidden */
  81109. _uvs: boolean;
  81110. /** @hidden */
  81111. _needNormals: boolean;
  81112. /** @hidden */
  81113. _needUVs: boolean;
  81114. [id: string]: any;
  81115. /**
  81116. * Specifies if the material needs to be re-calculated
  81117. */
  81118. get isDirty(): boolean;
  81119. /**
  81120. * Marks the material to indicate that it has been re-calculated
  81121. */
  81122. markAsProcessed(): void;
  81123. /**
  81124. * Marks the material to indicate that it needs to be re-calculated
  81125. */
  81126. markAsUnprocessed(): void;
  81127. /**
  81128. * Marks the material to indicate all of its defines need to be re-calculated
  81129. */
  81130. markAllAsDirty(): void;
  81131. /**
  81132. * Marks the material to indicate that image processing needs to be re-calculated
  81133. */
  81134. markAsImageProcessingDirty(): void;
  81135. /**
  81136. * Marks the material to indicate the lights need to be re-calculated
  81137. * @param disposed Defines whether the light is dirty due to dispose or not
  81138. */
  81139. markAsLightDirty(disposed?: boolean): void;
  81140. /**
  81141. * Marks the attribute state as changed
  81142. */
  81143. markAsAttributesDirty(): void;
  81144. /**
  81145. * Marks the texture state as changed
  81146. */
  81147. markAsTexturesDirty(): void;
  81148. /**
  81149. * Marks the fresnel state as changed
  81150. */
  81151. markAsFresnelDirty(): void;
  81152. /**
  81153. * Marks the misc state as changed
  81154. */
  81155. markAsMiscDirty(): void;
  81156. /**
  81157. * Rebuilds the material defines
  81158. */
  81159. rebuild(): void;
  81160. /**
  81161. * Specifies if two material defines are equal
  81162. * @param other - A material define instance to compare to
  81163. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  81164. */
  81165. isEqual(other: MaterialDefines): boolean;
  81166. /**
  81167. * Clones this instance's defines to another instance
  81168. * @param other - material defines to clone values to
  81169. */
  81170. cloneTo(other: MaterialDefines): void;
  81171. /**
  81172. * Resets the material define values
  81173. */
  81174. reset(): void;
  81175. /**
  81176. * Converts the material define values to a string
  81177. * @returns - String of material define information
  81178. */
  81179. toString(): string;
  81180. }
  81181. }
  81182. declare module BABYLON {
  81183. /**
  81184. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  81185. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  81186. * 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;
  81187. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  81188. */
  81189. export class ColorCurves {
  81190. private _dirty;
  81191. private _tempColor;
  81192. private _globalCurve;
  81193. private _highlightsCurve;
  81194. private _midtonesCurve;
  81195. private _shadowsCurve;
  81196. private _positiveCurve;
  81197. private _negativeCurve;
  81198. private _globalHue;
  81199. private _globalDensity;
  81200. private _globalSaturation;
  81201. private _globalExposure;
  81202. /**
  81203. * Gets the global Hue value.
  81204. * 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).
  81205. */
  81206. get globalHue(): number;
  81207. /**
  81208. * Sets the global Hue value.
  81209. * 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).
  81210. */
  81211. set globalHue(value: number);
  81212. /**
  81213. * Gets the global Density value.
  81214. * 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.
  81215. * Values less than zero provide a filter of opposite hue.
  81216. */
  81217. get globalDensity(): number;
  81218. /**
  81219. * Sets the global Density value.
  81220. * 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.
  81221. * Values less than zero provide a filter of opposite hue.
  81222. */
  81223. set globalDensity(value: number);
  81224. /**
  81225. * Gets the global Saturation value.
  81226. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  81227. */
  81228. get globalSaturation(): number;
  81229. /**
  81230. * Sets the global Saturation value.
  81231. * 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.
  81232. */
  81233. set globalSaturation(value: number);
  81234. /**
  81235. * Gets the global Exposure value.
  81236. * 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.
  81237. */
  81238. get globalExposure(): number;
  81239. /**
  81240. * Sets the global Exposure value.
  81241. * 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.
  81242. */
  81243. set globalExposure(value: number);
  81244. private _highlightsHue;
  81245. private _highlightsDensity;
  81246. private _highlightsSaturation;
  81247. private _highlightsExposure;
  81248. /**
  81249. * Gets the highlights Hue value.
  81250. * 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).
  81251. */
  81252. get highlightsHue(): number;
  81253. /**
  81254. * Sets the highlights Hue value.
  81255. * 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).
  81256. */
  81257. set highlightsHue(value: number);
  81258. /**
  81259. * Gets the highlights Density value.
  81260. * 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.
  81261. * Values less than zero provide a filter of opposite hue.
  81262. */
  81263. get highlightsDensity(): number;
  81264. /**
  81265. * Sets the highlights Density value.
  81266. * 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.
  81267. * Values less than zero provide a filter of opposite hue.
  81268. */
  81269. set highlightsDensity(value: number);
  81270. /**
  81271. * Gets the highlights Saturation value.
  81272. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  81273. */
  81274. get highlightsSaturation(): number;
  81275. /**
  81276. * Sets the highlights Saturation value.
  81277. * 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.
  81278. */
  81279. set highlightsSaturation(value: number);
  81280. /**
  81281. * Gets the highlights Exposure value.
  81282. * 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.
  81283. */
  81284. get highlightsExposure(): number;
  81285. /**
  81286. * Sets the highlights Exposure value.
  81287. * 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.
  81288. */
  81289. set highlightsExposure(value: number);
  81290. private _midtonesHue;
  81291. private _midtonesDensity;
  81292. private _midtonesSaturation;
  81293. private _midtonesExposure;
  81294. /**
  81295. * Gets the midtones Hue value.
  81296. * 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).
  81297. */
  81298. get midtonesHue(): number;
  81299. /**
  81300. * Sets the midtones Hue value.
  81301. * 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).
  81302. */
  81303. set midtonesHue(value: number);
  81304. /**
  81305. * Gets the midtones Density value.
  81306. * 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.
  81307. * Values less than zero provide a filter of opposite hue.
  81308. */
  81309. get midtonesDensity(): number;
  81310. /**
  81311. * Sets the midtones Density value.
  81312. * 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.
  81313. * Values less than zero provide a filter of opposite hue.
  81314. */
  81315. set midtonesDensity(value: number);
  81316. /**
  81317. * Gets the midtones Saturation value.
  81318. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  81319. */
  81320. get midtonesSaturation(): number;
  81321. /**
  81322. * Sets the midtones Saturation value.
  81323. * 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.
  81324. */
  81325. set midtonesSaturation(value: number);
  81326. /**
  81327. * Gets the midtones Exposure value.
  81328. * 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.
  81329. */
  81330. get midtonesExposure(): number;
  81331. /**
  81332. * Sets the midtones Exposure value.
  81333. * 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.
  81334. */
  81335. set midtonesExposure(value: number);
  81336. private _shadowsHue;
  81337. private _shadowsDensity;
  81338. private _shadowsSaturation;
  81339. private _shadowsExposure;
  81340. /**
  81341. * Gets the shadows Hue value.
  81342. * 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).
  81343. */
  81344. get shadowsHue(): number;
  81345. /**
  81346. * Sets the shadows Hue value.
  81347. * 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).
  81348. */
  81349. set shadowsHue(value: number);
  81350. /**
  81351. * Gets the shadows Density value.
  81352. * 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.
  81353. * Values less than zero provide a filter of opposite hue.
  81354. */
  81355. get shadowsDensity(): number;
  81356. /**
  81357. * Sets the shadows Density value.
  81358. * 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.
  81359. * Values less than zero provide a filter of opposite hue.
  81360. */
  81361. set shadowsDensity(value: number);
  81362. /**
  81363. * Gets the shadows Saturation value.
  81364. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  81365. */
  81366. get shadowsSaturation(): number;
  81367. /**
  81368. * Sets the shadows Saturation value.
  81369. * 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.
  81370. */
  81371. set shadowsSaturation(value: number);
  81372. /**
  81373. * Gets the shadows Exposure value.
  81374. * 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.
  81375. */
  81376. get shadowsExposure(): number;
  81377. /**
  81378. * Sets the shadows Exposure value.
  81379. * 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.
  81380. */
  81381. set shadowsExposure(value: number);
  81382. /**
  81383. * Returns the class name
  81384. * @returns The class name
  81385. */
  81386. getClassName(): string;
  81387. /**
  81388. * Binds the color curves to the shader.
  81389. * @param colorCurves The color curve to bind
  81390. * @param effect The effect to bind to
  81391. * @param positiveUniform The positive uniform shader parameter
  81392. * @param neutralUniform The neutral uniform shader parameter
  81393. * @param negativeUniform The negative uniform shader parameter
  81394. */
  81395. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  81396. /**
  81397. * Prepare the list of uniforms associated with the ColorCurves effects.
  81398. * @param uniformsList The list of uniforms used in the effect
  81399. */
  81400. static PrepareUniforms(uniformsList: string[]): void;
  81401. /**
  81402. * Returns color grading data based on a hue, density, saturation and exposure value.
  81403. * @param filterHue The hue of the color filter.
  81404. * @param filterDensity The density of the color filter.
  81405. * @param saturation The saturation.
  81406. * @param exposure The exposure.
  81407. * @param result The result data container.
  81408. */
  81409. private getColorGradingDataToRef;
  81410. /**
  81411. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  81412. * @param value The input slider value in range [-100,100].
  81413. * @returns Adjusted value.
  81414. */
  81415. private static applyColorGradingSliderNonlinear;
  81416. /**
  81417. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  81418. * @param hue The hue (H) input.
  81419. * @param saturation The saturation (S) input.
  81420. * @param brightness The brightness (B) input.
  81421. * @result An RGBA color represented as Vector4.
  81422. */
  81423. private static fromHSBToRef;
  81424. /**
  81425. * Returns a value clamped between min and max
  81426. * @param value The value to clamp
  81427. * @param min The minimum of value
  81428. * @param max The maximum of value
  81429. * @returns The clamped value.
  81430. */
  81431. private static clamp;
  81432. /**
  81433. * Clones the current color curve instance.
  81434. * @return The cloned curves
  81435. */
  81436. clone(): ColorCurves;
  81437. /**
  81438. * Serializes the current color curve instance to a json representation.
  81439. * @return a JSON representation
  81440. */
  81441. serialize(): any;
  81442. /**
  81443. * Parses the color curve from a json representation.
  81444. * @param source the JSON source to parse
  81445. * @return The parsed curves
  81446. */
  81447. static Parse(source: any): ColorCurves;
  81448. }
  81449. }
  81450. declare module BABYLON {
  81451. /**
  81452. * Interface to follow in your material defines to integrate easily the
  81453. * Image proccessing functions.
  81454. * @hidden
  81455. */
  81456. export interface IImageProcessingConfigurationDefines {
  81457. IMAGEPROCESSING: boolean;
  81458. VIGNETTE: boolean;
  81459. VIGNETTEBLENDMODEMULTIPLY: boolean;
  81460. VIGNETTEBLENDMODEOPAQUE: boolean;
  81461. TONEMAPPING: boolean;
  81462. TONEMAPPING_ACES: boolean;
  81463. CONTRAST: boolean;
  81464. EXPOSURE: boolean;
  81465. COLORCURVES: boolean;
  81466. COLORGRADING: boolean;
  81467. COLORGRADING3D: boolean;
  81468. SAMPLER3DGREENDEPTH: boolean;
  81469. SAMPLER3DBGRMAP: boolean;
  81470. IMAGEPROCESSINGPOSTPROCESS: boolean;
  81471. }
  81472. /**
  81473. * @hidden
  81474. */
  81475. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  81476. IMAGEPROCESSING: boolean;
  81477. VIGNETTE: boolean;
  81478. VIGNETTEBLENDMODEMULTIPLY: boolean;
  81479. VIGNETTEBLENDMODEOPAQUE: boolean;
  81480. TONEMAPPING: boolean;
  81481. TONEMAPPING_ACES: boolean;
  81482. CONTRAST: boolean;
  81483. COLORCURVES: boolean;
  81484. COLORGRADING: boolean;
  81485. COLORGRADING3D: boolean;
  81486. SAMPLER3DGREENDEPTH: boolean;
  81487. SAMPLER3DBGRMAP: boolean;
  81488. IMAGEPROCESSINGPOSTPROCESS: boolean;
  81489. EXPOSURE: boolean;
  81490. constructor();
  81491. }
  81492. /**
  81493. * This groups together the common properties used for image processing either in direct forward pass
  81494. * or through post processing effect depending on the use of the image processing pipeline in your scene
  81495. * or not.
  81496. */
  81497. export class ImageProcessingConfiguration {
  81498. /**
  81499. * Default tone mapping applied in BabylonJS.
  81500. */
  81501. static readonly TONEMAPPING_STANDARD: number;
  81502. /**
  81503. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  81504. * to other engines rendering to increase portability.
  81505. */
  81506. static readonly TONEMAPPING_ACES: number;
  81507. /**
  81508. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  81509. */
  81510. colorCurves: Nullable<ColorCurves>;
  81511. private _colorCurvesEnabled;
  81512. /**
  81513. * Gets wether the color curves effect is enabled.
  81514. */
  81515. get colorCurvesEnabled(): boolean;
  81516. /**
  81517. * Sets wether the color curves effect is enabled.
  81518. */
  81519. set colorCurvesEnabled(value: boolean);
  81520. private _colorGradingTexture;
  81521. /**
  81522. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  81523. */
  81524. get colorGradingTexture(): Nullable<BaseTexture>;
  81525. /**
  81526. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  81527. */
  81528. set colorGradingTexture(value: Nullable<BaseTexture>);
  81529. private _colorGradingEnabled;
  81530. /**
  81531. * Gets wether the color grading effect is enabled.
  81532. */
  81533. get colorGradingEnabled(): boolean;
  81534. /**
  81535. * Sets wether the color grading effect is enabled.
  81536. */
  81537. set colorGradingEnabled(value: boolean);
  81538. private _colorGradingWithGreenDepth;
  81539. /**
  81540. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  81541. */
  81542. get colorGradingWithGreenDepth(): boolean;
  81543. /**
  81544. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  81545. */
  81546. set colorGradingWithGreenDepth(value: boolean);
  81547. private _colorGradingBGR;
  81548. /**
  81549. * Gets wether the color grading texture contains BGR values.
  81550. */
  81551. get colorGradingBGR(): boolean;
  81552. /**
  81553. * Sets wether the color grading texture contains BGR values.
  81554. */
  81555. set colorGradingBGR(value: boolean);
  81556. /** @hidden */
  81557. _exposure: number;
  81558. /**
  81559. * Gets the Exposure used in the effect.
  81560. */
  81561. get exposure(): number;
  81562. /**
  81563. * Sets the Exposure used in the effect.
  81564. */
  81565. set exposure(value: number);
  81566. private _toneMappingEnabled;
  81567. /**
  81568. * Gets wether the tone mapping effect is enabled.
  81569. */
  81570. get toneMappingEnabled(): boolean;
  81571. /**
  81572. * Sets wether the tone mapping effect is enabled.
  81573. */
  81574. set toneMappingEnabled(value: boolean);
  81575. private _toneMappingType;
  81576. /**
  81577. * Gets the type of tone mapping effect.
  81578. */
  81579. get toneMappingType(): number;
  81580. /**
  81581. * Sets the type of tone mapping effect used in BabylonJS.
  81582. */
  81583. set toneMappingType(value: number);
  81584. protected _contrast: number;
  81585. /**
  81586. * Gets the contrast used in the effect.
  81587. */
  81588. get contrast(): number;
  81589. /**
  81590. * Sets the contrast used in the effect.
  81591. */
  81592. set contrast(value: number);
  81593. /**
  81594. * Vignette stretch size.
  81595. */
  81596. vignetteStretch: number;
  81597. /**
  81598. * Vignette centre X Offset.
  81599. */
  81600. vignetteCentreX: number;
  81601. /**
  81602. * Vignette centre Y Offset.
  81603. */
  81604. vignetteCentreY: number;
  81605. /**
  81606. * Vignette weight or intensity of the vignette effect.
  81607. */
  81608. vignetteWeight: number;
  81609. /**
  81610. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  81611. * if vignetteEnabled is set to true.
  81612. */
  81613. vignetteColor: Color4;
  81614. /**
  81615. * Camera field of view used by the Vignette effect.
  81616. */
  81617. vignetteCameraFov: number;
  81618. private _vignetteBlendMode;
  81619. /**
  81620. * Gets the vignette blend mode allowing different kind of effect.
  81621. */
  81622. get vignetteBlendMode(): number;
  81623. /**
  81624. * Sets the vignette blend mode allowing different kind of effect.
  81625. */
  81626. set vignetteBlendMode(value: number);
  81627. private _vignetteEnabled;
  81628. /**
  81629. * Gets wether the vignette effect is enabled.
  81630. */
  81631. get vignetteEnabled(): boolean;
  81632. /**
  81633. * Sets wether the vignette effect is enabled.
  81634. */
  81635. set vignetteEnabled(value: boolean);
  81636. private _applyByPostProcess;
  81637. /**
  81638. * Gets wether the image processing is applied through a post process or not.
  81639. */
  81640. get applyByPostProcess(): boolean;
  81641. /**
  81642. * Sets wether the image processing is applied through a post process or not.
  81643. */
  81644. set applyByPostProcess(value: boolean);
  81645. private _isEnabled;
  81646. /**
  81647. * Gets wether the image processing is enabled or not.
  81648. */
  81649. get isEnabled(): boolean;
  81650. /**
  81651. * Sets wether the image processing is enabled or not.
  81652. */
  81653. set isEnabled(value: boolean);
  81654. /**
  81655. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  81656. */
  81657. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  81658. /**
  81659. * Method called each time the image processing information changes requires to recompile the effect.
  81660. */
  81661. protected _updateParameters(): void;
  81662. /**
  81663. * Gets the current class name.
  81664. * @return "ImageProcessingConfiguration"
  81665. */
  81666. getClassName(): string;
  81667. /**
  81668. * Prepare the list of uniforms associated with the Image Processing effects.
  81669. * @param uniforms The list of uniforms used in the effect
  81670. * @param defines the list of defines currently in use
  81671. */
  81672. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  81673. /**
  81674. * Prepare the list of samplers associated with the Image Processing effects.
  81675. * @param samplersList The list of uniforms used in the effect
  81676. * @param defines the list of defines currently in use
  81677. */
  81678. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  81679. /**
  81680. * Prepare the list of defines associated to the shader.
  81681. * @param defines the list of defines to complete
  81682. * @param forPostProcess Define if we are currently in post process mode or not
  81683. */
  81684. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  81685. /**
  81686. * Returns true if all the image processing information are ready.
  81687. * @returns True if ready, otherwise, false
  81688. */
  81689. isReady(): boolean;
  81690. /**
  81691. * Binds the image processing to the shader.
  81692. * @param effect The effect to bind to
  81693. * @param overrideAspectRatio Override the aspect ratio of the effect
  81694. */
  81695. bind(effect: Effect, overrideAspectRatio?: number): void;
  81696. /**
  81697. * Clones the current image processing instance.
  81698. * @return The cloned image processing
  81699. */
  81700. clone(): ImageProcessingConfiguration;
  81701. /**
  81702. * Serializes the current image processing instance to a json representation.
  81703. * @return a JSON representation
  81704. */
  81705. serialize(): any;
  81706. /**
  81707. * Parses the image processing from a json representation.
  81708. * @param source the JSON source to parse
  81709. * @return The parsed image processing
  81710. */
  81711. static Parse(source: any): ImageProcessingConfiguration;
  81712. private static _VIGNETTEMODE_MULTIPLY;
  81713. private static _VIGNETTEMODE_OPAQUE;
  81714. /**
  81715. * Used to apply the vignette as a mix with the pixel color.
  81716. */
  81717. static get VIGNETTEMODE_MULTIPLY(): number;
  81718. /**
  81719. * Used to apply the vignette as a replacement of the pixel color.
  81720. */
  81721. static get VIGNETTEMODE_OPAQUE(): number;
  81722. }
  81723. }
  81724. declare module BABYLON {
  81725. /** @hidden */
  81726. export var postprocessVertexShader: {
  81727. name: string;
  81728. shader: string;
  81729. };
  81730. }
  81731. declare module BABYLON {
  81732. interface ThinEngine {
  81733. /**
  81734. * Creates a new render target texture
  81735. * @param size defines the size of the texture
  81736. * @param options defines the options used to create the texture
  81737. * @returns a new render target texture stored in an InternalTexture
  81738. */
  81739. createRenderTargetTexture(size: number | {
  81740. width: number;
  81741. height: number;
  81742. layers?: number;
  81743. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  81744. /**
  81745. * Creates a depth stencil texture.
  81746. * This is only available in WebGL 2 or with the depth texture extension available.
  81747. * @param size The size of face edge in the texture.
  81748. * @param options The options defining the texture.
  81749. * @returns The texture
  81750. */
  81751. createDepthStencilTexture(size: number | {
  81752. width: number;
  81753. height: number;
  81754. layers?: number;
  81755. }, options: DepthTextureCreationOptions): InternalTexture;
  81756. /** @hidden */
  81757. _createDepthStencilTexture(size: number | {
  81758. width: number;
  81759. height: number;
  81760. layers?: number;
  81761. }, options: DepthTextureCreationOptions): InternalTexture;
  81762. }
  81763. }
  81764. declare module BABYLON {
  81765. /** Defines supported spaces */
  81766. export enum Space {
  81767. /** Local (object) space */
  81768. LOCAL = 0,
  81769. /** World space */
  81770. WORLD = 1,
  81771. /** Bone space */
  81772. BONE = 2
  81773. }
  81774. /** Defines the 3 main axes */
  81775. export class Axis {
  81776. /** X axis */
  81777. static X: Vector3;
  81778. /** Y axis */
  81779. static Y: Vector3;
  81780. /** Z axis */
  81781. static Z: Vector3;
  81782. }
  81783. }
  81784. declare module BABYLON {
  81785. /**
  81786. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  81787. * This is the base of the follow, arc rotate cameras and Free camera
  81788. * @see http://doc.babylonjs.com/features/cameras
  81789. */
  81790. export class TargetCamera extends Camera {
  81791. private static _RigCamTransformMatrix;
  81792. private static _TargetTransformMatrix;
  81793. private static _TargetFocalPoint;
  81794. /**
  81795. * Define the current direction the camera is moving to
  81796. */
  81797. cameraDirection: Vector3;
  81798. /**
  81799. * Define the current rotation the camera is rotating to
  81800. */
  81801. cameraRotation: Vector2;
  81802. /**
  81803. * When set, the up vector of the camera will be updated by the rotation of the camera
  81804. */
  81805. updateUpVectorFromRotation: boolean;
  81806. private _tmpQuaternion;
  81807. /**
  81808. * Define the current rotation of the camera
  81809. */
  81810. rotation: Vector3;
  81811. /**
  81812. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  81813. */
  81814. rotationQuaternion: Quaternion;
  81815. /**
  81816. * Define the current speed of the camera
  81817. */
  81818. speed: number;
  81819. /**
  81820. * Add constraint to the camera to prevent it to move freely in all directions and
  81821. * around all axis.
  81822. */
  81823. noRotationConstraint: boolean;
  81824. /**
  81825. * Define the current target of the camera as an object or a position.
  81826. */
  81827. lockedTarget: any;
  81828. /** @hidden */
  81829. _currentTarget: Vector3;
  81830. /** @hidden */
  81831. _initialFocalDistance: number;
  81832. /** @hidden */
  81833. _viewMatrix: Matrix;
  81834. /** @hidden */
  81835. _camMatrix: Matrix;
  81836. /** @hidden */
  81837. _cameraTransformMatrix: Matrix;
  81838. /** @hidden */
  81839. _cameraRotationMatrix: Matrix;
  81840. /** @hidden */
  81841. _referencePoint: Vector3;
  81842. /** @hidden */
  81843. _transformedReferencePoint: Vector3;
  81844. protected _globalCurrentTarget: Vector3;
  81845. protected _globalCurrentUpVector: Vector3;
  81846. /** @hidden */
  81847. _reset: () => void;
  81848. private _defaultUp;
  81849. /**
  81850. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  81851. * This is the base of the follow, arc rotate cameras and Free camera
  81852. * @see http://doc.babylonjs.com/features/cameras
  81853. * @param name Defines the name of the camera in the scene
  81854. * @param position Defines the start position of the camera in the scene
  81855. * @param scene Defines the scene the camera belongs to
  81856. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  81857. */
  81858. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  81859. /**
  81860. * Gets the position in front of the camera at a given distance.
  81861. * @param distance The distance from the camera we want the position to be
  81862. * @returns the position
  81863. */
  81864. getFrontPosition(distance: number): Vector3;
  81865. /** @hidden */
  81866. _getLockedTargetPosition(): Nullable<Vector3>;
  81867. private _storedPosition;
  81868. private _storedRotation;
  81869. private _storedRotationQuaternion;
  81870. /**
  81871. * Store current camera state of the camera (fov, position, rotation, etc..)
  81872. * @returns the camera
  81873. */
  81874. storeState(): Camera;
  81875. /**
  81876. * Restored camera state. You must call storeState() first
  81877. * @returns whether it was successful or not
  81878. * @hidden
  81879. */
  81880. _restoreStateValues(): boolean;
  81881. /** @hidden */
  81882. _initCache(): void;
  81883. /** @hidden */
  81884. _updateCache(ignoreParentClass?: boolean): void;
  81885. /** @hidden */
  81886. _isSynchronizedViewMatrix(): boolean;
  81887. /** @hidden */
  81888. _computeLocalCameraSpeed(): number;
  81889. /**
  81890. * Defines the target the camera should look at.
  81891. * @param target Defines the new target as a Vector or a mesh
  81892. */
  81893. setTarget(target: Vector3): void;
  81894. /**
  81895. * Return the current target position of the camera. This value is expressed in local space.
  81896. * @returns the target position
  81897. */
  81898. getTarget(): Vector3;
  81899. /** @hidden */
  81900. _decideIfNeedsToMove(): boolean;
  81901. /** @hidden */
  81902. _updatePosition(): void;
  81903. /** @hidden */
  81904. _checkInputs(): void;
  81905. protected _updateCameraRotationMatrix(): void;
  81906. /**
  81907. * 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)
  81908. * @returns the current camera
  81909. */
  81910. private _rotateUpVectorWithCameraRotationMatrix;
  81911. private _cachedRotationZ;
  81912. private _cachedQuaternionRotationZ;
  81913. /** @hidden */
  81914. _getViewMatrix(): Matrix;
  81915. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  81916. /**
  81917. * @hidden
  81918. */
  81919. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  81920. /**
  81921. * @hidden
  81922. */
  81923. _updateRigCameras(): void;
  81924. private _getRigCamPositionAndTarget;
  81925. /**
  81926. * Gets the current object class name.
  81927. * @return the class name
  81928. */
  81929. getClassName(): string;
  81930. }
  81931. }
  81932. declare module BABYLON {
  81933. /**
  81934. * Gather the list of keyboard event types as constants.
  81935. */
  81936. export class KeyboardEventTypes {
  81937. /**
  81938. * The keydown event is fired when a key becomes active (pressed).
  81939. */
  81940. static readonly KEYDOWN: number;
  81941. /**
  81942. * The keyup event is fired when a key has been released.
  81943. */
  81944. static readonly KEYUP: number;
  81945. }
  81946. /**
  81947. * This class is used to store keyboard related info for the onKeyboardObservable event.
  81948. */
  81949. export class KeyboardInfo {
  81950. /**
  81951. * Defines the type of event (KeyboardEventTypes)
  81952. */
  81953. type: number;
  81954. /**
  81955. * Defines the related dom event
  81956. */
  81957. event: KeyboardEvent;
  81958. /**
  81959. * Instantiates a new keyboard info.
  81960. * This class is used to store keyboard related info for the onKeyboardObservable event.
  81961. * @param type Defines the type of event (KeyboardEventTypes)
  81962. * @param event Defines the related dom event
  81963. */
  81964. constructor(
  81965. /**
  81966. * Defines the type of event (KeyboardEventTypes)
  81967. */
  81968. type: number,
  81969. /**
  81970. * Defines the related dom event
  81971. */
  81972. event: KeyboardEvent);
  81973. }
  81974. /**
  81975. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  81976. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  81977. */
  81978. export class KeyboardInfoPre extends KeyboardInfo {
  81979. /**
  81980. * Defines the type of event (KeyboardEventTypes)
  81981. */
  81982. type: number;
  81983. /**
  81984. * Defines the related dom event
  81985. */
  81986. event: KeyboardEvent;
  81987. /**
  81988. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  81989. */
  81990. skipOnPointerObservable: boolean;
  81991. /**
  81992. * Instantiates a new keyboard pre info.
  81993. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  81994. * @param type Defines the type of event (KeyboardEventTypes)
  81995. * @param event Defines the related dom event
  81996. */
  81997. constructor(
  81998. /**
  81999. * Defines the type of event (KeyboardEventTypes)
  82000. */
  82001. type: number,
  82002. /**
  82003. * Defines the related dom event
  82004. */
  82005. event: KeyboardEvent);
  82006. }
  82007. }
  82008. declare module BABYLON {
  82009. /**
  82010. * Manage the keyboard inputs to control the movement of a free camera.
  82011. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  82012. */
  82013. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  82014. /**
  82015. * Defines the camera the input is attached to.
  82016. */
  82017. camera: FreeCamera;
  82018. /**
  82019. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  82020. */
  82021. keysUp: number[];
  82022. /**
  82023. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  82024. */
  82025. keysDown: number[];
  82026. /**
  82027. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  82028. */
  82029. keysLeft: number[];
  82030. /**
  82031. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  82032. */
  82033. keysRight: number[];
  82034. private _keys;
  82035. private _onCanvasBlurObserver;
  82036. private _onKeyboardObserver;
  82037. private _engine;
  82038. private _scene;
  82039. /**
  82040. * Attach the input controls to a specific dom element to get the input from.
  82041. * @param element Defines the element the controls should be listened from
  82042. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  82043. */
  82044. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  82045. /**
  82046. * Detach the current controls from the specified dom element.
  82047. * @param element Defines the element to stop listening the inputs from
  82048. */
  82049. detachControl(element: Nullable<HTMLElement>): void;
  82050. /**
  82051. * Update the current camera state depending on the inputs that have been used this frame.
  82052. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  82053. */
  82054. checkInputs(): void;
  82055. /**
  82056. * Gets the class name of the current intput.
  82057. * @returns the class name
  82058. */
  82059. getClassName(): string;
  82060. /** @hidden */
  82061. _onLostFocus(): void;
  82062. /**
  82063. * Get the friendly name associated with the input class.
  82064. * @returns the input friendly name
  82065. */
  82066. getSimpleName(): string;
  82067. }
  82068. }
  82069. declare module BABYLON {
  82070. /**
  82071. * Interface describing all the common properties and methods a shadow light needs to implement.
  82072. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  82073. * as well as binding the different shadow properties to the effects.
  82074. */
  82075. export interface IShadowLight extends Light {
  82076. /**
  82077. * The light id in the scene (used in scene.findLighById for instance)
  82078. */
  82079. id: string;
  82080. /**
  82081. * The position the shdow will be casted from.
  82082. */
  82083. position: Vector3;
  82084. /**
  82085. * In 2d mode (needCube being false), the direction used to cast the shadow.
  82086. */
  82087. direction: Vector3;
  82088. /**
  82089. * The transformed position. Position of the light in world space taking parenting in account.
  82090. */
  82091. transformedPosition: Vector3;
  82092. /**
  82093. * The transformed direction. Direction of the light in world space taking parenting in account.
  82094. */
  82095. transformedDirection: Vector3;
  82096. /**
  82097. * The friendly name of the light in the scene.
  82098. */
  82099. name: string;
  82100. /**
  82101. * Defines the shadow projection clipping minimum z value.
  82102. */
  82103. shadowMinZ: number;
  82104. /**
  82105. * Defines the shadow projection clipping maximum z value.
  82106. */
  82107. shadowMaxZ: number;
  82108. /**
  82109. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  82110. * @returns true if the information has been computed, false if it does not need to (no parenting)
  82111. */
  82112. computeTransformedInformation(): boolean;
  82113. /**
  82114. * Gets the scene the light belongs to.
  82115. * @returns The scene
  82116. */
  82117. getScene(): Scene;
  82118. /**
  82119. * Callback defining a custom Projection Matrix Builder.
  82120. * This can be used to override the default projection matrix computation.
  82121. */
  82122. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  82123. /**
  82124. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  82125. * @param matrix The materix to updated with the projection information
  82126. * @param viewMatrix The transform matrix of the light
  82127. * @param renderList The list of mesh to render in the map
  82128. * @returns The current light
  82129. */
  82130. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  82131. /**
  82132. * Gets the current depth scale used in ESM.
  82133. * @returns The scale
  82134. */
  82135. getDepthScale(): number;
  82136. /**
  82137. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  82138. * @returns true if a cube texture needs to be use
  82139. */
  82140. needCube(): boolean;
  82141. /**
  82142. * Detects if the projection matrix requires to be recomputed this frame.
  82143. * @returns true if it requires to be recomputed otherwise, false.
  82144. */
  82145. needProjectionMatrixCompute(): boolean;
  82146. /**
  82147. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  82148. */
  82149. forceProjectionMatrixCompute(): void;
  82150. /**
  82151. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  82152. * @param faceIndex The index of the face we are computed the direction to generate shadow
  82153. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  82154. */
  82155. getShadowDirection(faceIndex?: number): Vector3;
  82156. /**
  82157. * Gets the minZ used for shadow according to both the scene and the light.
  82158. * @param activeCamera The camera we are returning the min for
  82159. * @returns the depth min z
  82160. */
  82161. getDepthMinZ(activeCamera: Camera): number;
  82162. /**
  82163. * Gets the maxZ used for shadow according to both the scene and the light.
  82164. * @param activeCamera The camera we are returning the max for
  82165. * @returns the depth max z
  82166. */
  82167. getDepthMaxZ(activeCamera: Camera): number;
  82168. }
  82169. /**
  82170. * Base implementation IShadowLight
  82171. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  82172. */
  82173. export abstract class ShadowLight extends Light implements IShadowLight {
  82174. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  82175. protected _position: Vector3;
  82176. protected _setPosition(value: Vector3): void;
  82177. /**
  82178. * Sets the position the shadow will be casted from. Also use as the light position for both
  82179. * point and spot lights.
  82180. */
  82181. get position(): Vector3;
  82182. /**
  82183. * Sets the position the shadow will be casted from. Also use as the light position for both
  82184. * point and spot lights.
  82185. */
  82186. set position(value: Vector3);
  82187. protected _direction: Vector3;
  82188. protected _setDirection(value: Vector3): void;
  82189. /**
  82190. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  82191. * Also use as the light direction on spot and directional lights.
  82192. */
  82193. get direction(): Vector3;
  82194. /**
  82195. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  82196. * Also use as the light direction on spot and directional lights.
  82197. */
  82198. set direction(value: Vector3);
  82199. protected _shadowMinZ: number;
  82200. /**
  82201. * Gets the shadow projection clipping minimum z value.
  82202. */
  82203. get shadowMinZ(): number;
  82204. /**
  82205. * Sets the shadow projection clipping minimum z value.
  82206. */
  82207. set shadowMinZ(value: number);
  82208. protected _shadowMaxZ: number;
  82209. /**
  82210. * Sets the shadow projection clipping maximum z value.
  82211. */
  82212. get shadowMaxZ(): number;
  82213. /**
  82214. * Gets the shadow projection clipping maximum z value.
  82215. */
  82216. set shadowMaxZ(value: number);
  82217. /**
  82218. * Callback defining a custom Projection Matrix Builder.
  82219. * This can be used to override the default projection matrix computation.
  82220. */
  82221. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  82222. /**
  82223. * The transformed position. Position of the light in world space taking parenting in account.
  82224. */
  82225. transformedPosition: Vector3;
  82226. /**
  82227. * The transformed direction. Direction of the light in world space taking parenting in account.
  82228. */
  82229. transformedDirection: Vector3;
  82230. private _needProjectionMatrixCompute;
  82231. /**
  82232. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  82233. * @returns true if the information has been computed, false if it does not need to (no parenting)
  82234. */
  82235. computeTransformedInformation(): boolean;
  82236. /**
  82237. * Return the depth scale used for the shadow map.
  82238. * @returns the depth scale.
  82239. */
  82240. getDepthScale(): number;
  82241. /**
  82242. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  82243. * @param faceIndex The index of the face we are computed the direction to generate shadow
  82244. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  82245. */
  82246. getShadowDirection(faceIndex?: number): Vector3;
  82247. /**
  82248. * Returns the ShadowLight absolute position in the World.
  82249. * @returns the position vector in world space
  82250. */
  82251. getAbsolutePosition(): Vector3;
  82252. /**
  82253. * Sets the ShadowLight direction toward the passed target.
  82254. * @param target The point to target in local space
  82255. * @returns the updated ShadowLight direction
  82256. */
  82257. setDirectionToTarget(target: Vector3): Vector3;
  82258. /**
  82259. * Returns the light rotation in euler definition.
  82260. * @returns the x y z rotation in local space.
  82261. */
  82262. getRotation(): Vector3;
  82263. /**
  82264. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  82265. * @returns true if a cube texture needs to be use
  82266. */
  82267. needCube(): boolean;
  82268. /**
  82269. * Detects if the projection matrix requires to be recomputed this frame.
  82270. * @returns true if it requires to be recomputed otherwise, false.
  82271. */
  82272. needProjectionMatrixCompute(): boolean;
  82273. /**
  82274. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  82275. */
  82276. forceProjectionMatrixCompute(): void;
  82277. /** @hidden */
  82278. _initCache(): void;
  82279. /** @hidden */
  82280. _isSynchronized(): boolean;
  82281. /**
  82282. * Computes the world matrix of the node
  82283. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  82284. * @returns the world matrix
  82285. */
  82286. computeWorldMatrix(force?: boolean): Matrix;
  82287. /**
  82288. * Gets the minZ used for shadow according to both the scene and the light.
  82289. * @param activeCamera The camera we are returning the min for
  82290. * @returns the depth min z
  82291. */
  82292. getDepthMinZ(activeCamera: Camera): number;
  82293. /**
  82294. * Gets the maxZ used for shadow according to both the scene and the light.
  82295. * @param activeCamera The camera we are returning the max for
  82296. * @returns the depth max z
  82297. */
  82298. getDepthMaxZ(activeCamera: Camera): number;
  82299. /**
  82300. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  82301. * @param matrix The materix to updated with the projection information
  82302. * @param viewMatrix The transform matrix of the light
  82303. * @param renderList The list of mesh to render in the map
  82304. * @returns The current light
  82305. */
  82306. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  82307. }
  82308. }
  82309. declare module BABYLON {
  82310. /**
  82311. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  82312. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  82313. */
  82314. export class EffectFallbacks implements IEffectFallbacks {
  82315. private _defines;
  82316. private _currentRank;
  82317. private _maxRank;
  82318. private _mesh;
  82319. /**
  82320. * Removes the fallback from the bound mesh.
  82321. */
  82322. unBindMesh(): void;
  82323. /**
  82324. * Adds a fallback on the specified property.
  82325. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  82326. * @param define The name of the define in the shader
  82327. */
  82328. addFallback(rank: number, define: string): void;
  82329. /**
  82330. * Sets the mesh to use CPU skinning when needing to fallback.
  82331. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  82332. * @param mesh The mesh to use the fallbacks.
  82333. */
  82334. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  82335. /**
  82336. * Checks to see if more fallbacks are still availible.
  82337. */
  82338. get hasMoreFallbacks(): boolean;
  82339. /**
  82340. * Removes the defines that should be removed when falling back.
  82341. * @param currentDefines defines the current define statements for the shader.
  82342. * @param effect defines the current effect we try to compile
  82343. * @returns The resulting defines with defines of the current rank removed.
  82344. */
  82345. reduce(currentDefines: string, effect: Effect): string;
  82346. }
  82347. }
  82348. declare module BABYLON {
  82349. /**
  82350. * "Static Class" containing the most commonly used helper while dealing with material for
  82351. * rendering purpose.
  82352. *
  82353. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  82354. *
  82355. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  82356. */
  82357. export class MaterialHelper {
  82358. /**
  82359. * Bind the current view position to an effect.
  82360. * @param effect The effect to be bound
  82361. * @param scene The scene the eyes position is used from
  82362. */
  82363. static BindEyePosition(effect: Effect, scene: Scene): void;
  82364. /**
  82365. * Helps preparing the defines values about the UVs in used in the effect.
  82366. * UVs are shared as much as we can accross channels in the shaders.
  82367. * @param texture The texture we are preparing the UVs for
  82368. * @param defines The defines to update
  82369. * @param key The channel key "diffuse", "specular"... used in the shader
  82370. */
  82371. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  82372. /**
  82373. * Binds a texture matrix value to its corrsponding uniform
  82374. * @param texture The texture to bind the matrix for
  82375. * @param uniformBuffer The uniform buffer receivin the data
  82376. * @param key The channel key "diffuse", "specular"... used in the shader
  82377. */
  82378. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  82379. /**
  82380. * Gets the current status of the fog (should it be enabled?)
  82381. * @param mesh defines the mesh to evaluate for fog support
  82382. * @param scene defines the hosting scene
  82383. * @returns true if fog must be enabled
  82384. */
  82385. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  82386. /**
  82387. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  82388. * @param mesh defines the current mesh
  82389. * @param scene defines the current scene
  82390. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  82391. * @param pointsCloud defines if point cloud rendering has to be turned on
  82392. * @param fogEnabled defines if fog has to be turned on
  82393. * @param alphaTest defines if alpha testing has to be turned on
  82394. * @param defines defines the current list of defines
  82395. */
  82396. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  82397. /**
  82398. * Helper used to prepare the list of defines associated with frame values for shader compilation
  82399. * @param scene defines the current scene
  82400. * @param engine defines the current engine
  82401. * @param defines specifies the list of active defines
  82402. * @param useInstances defines if instances have to be turned on
  82403. * @param useClipPlane defines if clip plane have to be turned on
  82404. */
  82405. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  82406. /**
  82407. * Prepares the defines for bones
  82408. * @param mesh The mesh containing the geometry data we will draw
  82409. * @param defines The defines to update
  82410. */
  82411. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  82412. /**
  82413. * Prepares the defines for morph targets
  82414. * @param mesh The mesh containing the geometry data we will draw
  82415. * @param defines The defines to update
  82416. */
  82417. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  82418. /**
  82419. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  82420. * @param mesh The mesh containing the geometry data we will draw
  82421. * @param defines The defines to update
  82422. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  82423. * @param useBones Precise whether bones should be used or not (override mesh info)
  82424. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  82425. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  82426. * @returns false if defines are considered not dirty and have not been checked
  82427. */
  82428. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  82429. /**
  82430. * Prepares the defines related to multiview
  82431. * @param scene The scene we are intending to draw
  82432. * @param defines The defines to update
  82433. */
  82434. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  82435. /**
  82436. * Prepares the defines related to the light information passed in parameter
  82437. * @param scene The scene we are intending to draw
  82438. * @param mesh The mesh the effect is compiling for
  82439. * @param light The light the effect is compiling for
  82440. * @param lightIndex The index of the light
  82441. * @param defines The defines to update
  82442. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  82443. * @param state Defines the current state regarding what is needed (normals, etc...)
  82444. */
  82445. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  82446. needNormals: boolean;
  82447. needRebuild: boolean;
  82448. shadowEnabled: boolean;
  82449. specularEnabled: boolean;
  82450. lightmapMode: boolean;
  82451. }): void;
  82452. /**
  82453. * Prepares the defines related to the light information passed in parameter
  82454. * @param scene The scene we are intending to draw
  82455. * @param mesh The mesh the effect is compiling for
  82456. * @param defines The defines to update
  82457. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  82458. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  82459. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  82460. * @returns true if normals will be required for the rest of the effect
  82461. */
  82462. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  82463. /**
  82464. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  82465. * @param lightIndex defines the light index
  82466. * @param uniformsList The uniform list
  82467. * @param samplersList The sampler list
  82468. * @param projectedLightTexture defines if projected texture must be used
  82469. * @param uniformBuffersList defines an optional list of uniform buffers
  82470. */
  82471. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  82472. /**
  82473. * Prepares the uniforms and samplers list to be used in the effect
  82474. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  82475. * @param samplersList The sampler list
  82476. * @param defines The defines helping in the list generation
  82477. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  82478. */
  82479. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  82480. /**
  82481. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  82482. * @param defines The defines to update while falling back
  82483. * @param fallbacks The authorized effect fallbacks
  82484. * @param maxSimultaneousLights The maximum number of lights allowed
  82485. * @param rank the current rank of the Effect
  82486. * @returns The newly affected rank
  82487. */
  82488. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  82489. private static _TmpMorphInfluencers;
  82490. /**
  82491. * Prepares the list of attributes required for morph targets according to the effect defines.
  82492. * @param attribs The current list of supported attribs
  82493. * @param mesh The mesh to prepare the morph targets attributes for
  82494. * @param influencers The number of influencers
  82495. */
  82496. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  82497. /**
  82498. * Prepares the list of attributes required for morph targets according to the effect defines.
  82499. * @param attribs The current list of supported attribs
  82500. * @param mesh The mesh to prepare the morph targets attributes for
  82501. * @param defines The current Defines of the effect
  82502. */
  82503. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  82504. /**
  82505. * Prepares the list of attributes required for bones according to the effect defines.
  82506. * @param attribs The current list of supported attribs
  82507. * @param mesh The mesh to prepare the bones attributes for
  82508. * @param defines The current Defines of the effect
  82509. * @param fallbacks The current efffect fallback strategy
  82510. */
  82511. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  82512. /**
  82513. * Check and prepare the list of attributes required for instances according to the effect defines.
  82514. * @param attribs The current list of supported attribs
  82515. * @param defines The current MaterialDefines of the effect
  82516. */
  82517. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  82518. /**
  82519. * Add the list of attributes required for instances to the attribs array.
  82520. * @param attribs The current list of supported attribs
  82521. */
  82522. static PushAttributesForInstances(attribs: string[]): void;
  82523. /**
  82524. * Binds the light information to the effect.
  82525. * @param light The light containing the generator
  82526. * @param effect The effect we are binding the data to
  82527. * @param lightIndex The light index in the effect used to render
  82528. */
  82529. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  82530. /**
  82531. * Binds the lights information from the scene to the effect for the given mesh.
  82532. * @param light Light to bind
  82533. * @param lightIndex Light index
  82534. * @param scene The scene where the light belongs to
  82535. * @param effect The effect we are binding the data to
  82536. * @param useSpecular Defines if specular is supported
  82537. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  82538. */
  82539. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  82540. /**
  82541. * Binds the lights information from the scene to the effect for the given mesh.
  82542. * @param scene The scene the lights belongs to
  82543. * @param mesh The mesh we are binding the information to render
  82544. * @param effect The effect we are binding the data to
  82545. * @param defines The generated defines for the effect
  82546. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  82547. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  82548. */
  82549. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  82550. private static _tempFogColor;
  82551. /**
  82552. * Binds the fog information from the scene to the effect for the given mesh.
  82553. * @param scene The scene the lights belongs to
  82554. * @param mesh The mesh we are binding the information to render
  82555. * @param effect The effect we are binding the data to
  82556. * @param linearSpace Defines if the fog effect is applied in linear space
  82557. */
  82558. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  82559. /**
  82560. * Binds the bones information from the mesh to the effect.
  82561. * @param mesh The mesh we are binding the information to render
  82562. * @param effect The effect we are binding the data to
  82563. */
  82564. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  82565. /**
  82566. * Binds the morph targets information from the mesh to the effect.
  82567. * @param abstractMesh The mesh we are binding the information to render
  82568. * @param effect The effect we are binding the data to
  82569. */
  82570. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  82571. /**
  82572. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  82573. * @param defines The generated defines used in the effect
  82574. * @param effect The effect we are binding the data to
  82575. * @param scene The scene we are willing to render with logarithmic scale for
  82576. */
  82577. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  82578. /**
  82579. * Binds the clip plane information from the scene to the effect.
  82580. * @param scene The scene the clip plane information are extracted from
  82581. * @param effect The effect we are binding the data to
  82582. */
  82583. static BindClipPlane(effect: Effect, scene: Scene): void;
  82584. }
  82585. }
  82586. declare module BABYLON {
  82587. /** @hidden */
  82588. export var packingFunctions: {
  82589. name: string;
  82590. shader: string;
  82591. };
  82592. }
  82593. declare module BABYLON {
  82594. /** @hidden */
  82595. export var clipPlaneFragmentDeclaration: {
  82596. name: string;
  82597. shader: string;
  82598. };
  82599. }
  82600. declare module BABYLON {
  82601. /** @hidden */
  82602. export var clipPlaneFragment: {
  82603. name: string;
  82604. shader: string;
  82605. };
  82606. }
  82607. declare module BABYLON {
  82608. /** @hidden */
  82609. export var shadowMapPixelShader: {
  82610. name: string;
  82611. shader: string;
  82612. };
  82613. }
  82614. declare module BABYLON {
  82615. /** @hidden */
  82616. export var bonesDeclaration: {
  82617. name: string;
  82618. shader: string;
  82619. };
  82620. }
  82621. declare module BABYLON {
  82622. /** @hidden */
  82623. export var morphTargetsVertexGlobalDeclaration: {
  82624. name: string;
  82625. shader: string;
  82626. };
  82627. }
  82628. declare module BABYLON {
  82629. /** @hidden */
  82630. export var morphTargetsVertexDeclaration: {
  82631. name: string;
  82632. shader: string;
  82633. };
  82634. }
  82635. declare module BABYLON {
  82636. /** @hidden */
  82637. export var instancesDeclaration: {
  82638. name: string;
  82639. shader: string;
  82640. };
  82641. }
  82642. declare module BABYLON {
  82643. /** @hidden */
  82644. export var helperFunctions: {
  82645. name: string;
  82646. shader: string;
  82647. };
  82648. }
  82649. declare module BABYLON {
  82650. /** @hidden */
  82651. export var clipPlaneVertexDeclaration: {
  82652. name: string;
  82653. shader: string;
  82654. };
  82655. }
  82656. declare module BABYLON {
  82657. /** @hidden */
  82658. export var morphTargetsVertex: {
  82659. name: string;
  82660. shader: string;
  82661. };
  82662. }
  82663. declare module BABYLON {
  82664. /** @hidden */
  82665. export var instancesVertex: {
  82666. name: string;
  82667. shader: string;
  82668. };
  82669. }
  82670. declare module BABYLON {
  82671. /** @hidden */
  82672. export var bonesVertex: {
  82673. name: string;
  82674. shader: string;
  82675. };
  82676. }
  82677. declare module BABYLON {
  82678. /** @hidden */
  82679. export var clipPlaneVertex: {
  82680. name: string;
  82681. shader: string;
  82682. };
  82683. }
  82684. declare module BABYLON {
  82685. /** @hidden */
  82686. export var shadowMapVertexShader: {
  82687. name: string;
  82688. shader: string;
  82689. };
  82690. }
  82691. declare module BABYLON {
  82692. /** @hidden */
  82693. export var depthBoxBlurPixelShader: {
  82694. name: string;
  82695. shader: string;
  82696. };
  82697. }
  82698. declare module BABYLON {
  82699. /**
  82700. * Class representing a ray with position and direction
  82701. */
  82702. export class Ray {
  82703. /** origin point */
  82704. origin: Vector3;
  82705. /** direction */
  82706. direction: Vector3;
  82707. /** length of the ray */
  82708. length: number;
  82709. private static readonly TmpVector3;
  82710. private _tmpRay;
  82711. /**
  82712. * Creates a new ray
  82713. * @param origin origin point
  82714. * @param direction direction
  82715. * @param length length of the ray
  82716. */
  82717. constructor(
  82718. /** origin point */
  82719. origin: Vector3,
  82720. /** direction */
  82721. direction: Vector3,
  82722. /** length of the ray */
  82723. length?: number);
  82724. /**
  82725. * Checks if the ray intersects a box
  82726. * @param minimum bound of the box
  82727. * @param maximum bound of the box
  82728. * @param intersectionTreshold extra extend to be added to the box in all direction
  82729. * @returns if the box was hit
  82730. */
  82731. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  82732. /**
  82733. * Checks if the ray intersects a box
  82734. * @param box the bounding box to check
  82735. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  82736. * @returns if the box was hit
  82737. */
  82738. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  82739. /**
  82740. * If the ray hits a sphere
  82741. * @param sphere the bounding sphere to check
  82742. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  82743. * @returns true if it hits the sphere
  82744. */
  82745. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  82746. /**
  82747. * If the ray hits a triange
  82748. * @param vertex0 triangle vertex
  82749. * @param vertex1 triangle vertex
  82750. * @param vertex2 triangle vertex
  82751. * @returns intersection information if hit
  82752. */
  82753. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  82754. /**
  82755. * Checks if ray intersects a plane
  82756. * @param plane the plane to check
  82757. * @returns the distance away it was hit
  82758. */
  82759. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  82760. /**
  82761. * Calculate the intercept of a ray on a given axis
  82762. * @param axis to check 'x' | 'y' | 'z'
  82763. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  82764. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  82765. */
  82766. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  82767. /**
  82768. * Checks if ray intersects a mesh
  82769. * @param mesh the mesh to check
  82770. * @param fastCheck if only the bounding box should checked
  82771. * @returns picking info of the intersecton
  82772. */
  82773. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  82774. /**
  82775. * Checks if ray intersects a mesh
  82776. * @param meshes the meshes to check
  82777. * @param fastCheck if only the bounding box should checked
  82778. * @param results array to store result in
  82779. * @returns Array of picking infos
  82780. */
  82781. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  82782. private _comparePickingInfo;
  82783. private static smallnum;
  82784. private static rayl;
  82785. /**
  82786. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  82787. * @param sega the first point of the segment to test the intersection against
  82788. * @param segb the second point of the segment to test the intersection against
  82789. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  82790. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  82791. */
  82792. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  82793. /**
  82794. * Update the ray from viewport position
  82795. * @param x position
  82796. * @param y y position
  82797. * @param viewportWidth viewport width
  82798. * @param viewportHeight viewport height
  82799. * @param world world matrix
  82800. * @param view view matrix
  82801. * @param projection projection matrix
  82802. * @returns this ray updated
  82803. */
  82804. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  82805. /**
  82806. * Creates a ray with origin and direction of 0,0,0
  82807. * @returns the new ray
  82808. */
  82809. static Zero(): Ray;
  82810. /**
  82811. * Creates a new ray from screen space and viewport
  82812. * @param x position
  82813. * @param y y position
  82814. * @param viewportWidth viewport width
  82815. * @param viewportHeight viewport height
  82816. * @param world world matrix
  82817. * @param view view matrix
  82818. * @param projection projection matrix
  82819. * @returns new ray
  82820. */
  82821. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  82822. /**
  82823. * 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
  82824. * transformed to the given world matrix.
  82825. * @param origin The origin point
  82826. * @param end The end point
  82827. * @param world a matrix to transform the ray to. Default is the identity matrix.
  82828. * @returns the new ray
  82829. */
  82830. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  82831. /**
  82832. * Transforms a ray by a matrix
  82833. * @param ray ray to transform
  82834. * @param matrix matrix to apply
  82835. * @returns the resulting new ray
  82836. */
  82837. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  82838. /**
  82839. * Transforms a ray by a matrix
  82840. * @param ray ray to transform
  82841. * @param matrix matrix to apply
  82842. * @param result ray to store result in
  82843. */
  82844. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  82845. /**
  82846. * Unproject a ray from screen space to object space
  82847. * @param sourceX defines the screen space x coordinate to use
  82848. * @param sourceY defines the screen space y coordinate to use
  82849. * @param viewportWidth defines the current width of the viewport
  82850. * @param viewportHeight defines the current height of the viewport
  82851. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  82852. * @param view defines the view matrix to use
  82853. * @param projection defines the projection matrix to use
  82854. */
  82855. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  82856. }
  82857. /**
  82858. * Type used to define predicate used to select faces when a mesh intersection is detected
  82859. */
  82860. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  82861. interface Scene {
  82862. /** @hidden */
  82863. _tempPickingRay: Nullable<Ray>;
  82864. /** @hidden */
  82865. _cachedRayForTransform: Ray;
  82866. /** @hidden */
  82867. _pickWithRayInverseMatrix: Matrix;
  82868. /** @hidden */
  82869. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  82870. /** @hidden */
  82871. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  82872. }
  82873. }
  82874. declare module BABYLON {
  82875. /**
  82876. * Groups all the scene component constants in one place to ease maintenance.
  82877. * @hidden
  82878. */
  82879. export class SceneComponentConstants {
  82880. static readonly NAME_EFFECTLAYER: string;
  82881. static readonly NAME_LAYER: string;
  82882. static readonly NAME_LENSFLARESYSTEM: string;
  82883. static readonly NAME_BOUNDINGBOXRENDERER: string;
  82884. static readonly NAME_PARTICLESYSTEM: string;
  82885. static readonly NAME_GAMEPAD: string;
  82886. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  82887. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  82888. static readonly NAME_DEPTHRENDERER: string;
  82889. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  82890. static readonly NAME_SPRITE: string;
  82891. static readonly NAME_OUTLINERENDERER: string;
  82892. static readonly NAME_PROCEDURALTEXTURE: string;
  82893. static readonly NAME_SHADOWGENERATOR: string;
  82894. static readonly NAME_OCTREE: string;
  82895. static readonly NAME_PHYSICSENGINE: string;
  82896. static readonly NAME_AUDIO: string;
  82897. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  82898. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  82899. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  82900. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  82901. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  82902. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  82903. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  82904. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  82905. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  82906. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  82907. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  82908. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  82909. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  82910. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  82911. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  82912. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  82913. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  82914. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  82915. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  82916. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  82917. static readonly STEP_AFTERRENDER_AUDIO: number;
  82918. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  82919. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  82920. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  82921. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  82922. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  82923. static readonly STEP_POINTERMOVE_SPRITE: number;
  82924. static readonly STEP_POINTERDOWN_SPRITE: number;
  82925. static readonly STEP_POINTERUP_SPRITE: number;
  82926. }
  82927. /**
  82928. * This represents a scene component.
  82929. *
  82930. * This is used to decouple the dependency the scene is having on the different workloads like
  82931. * layers, post processes...
  82932. */
  82933. export interface ISceneComponent {
  82934. /**
  82935. * The name of the component. Each component must have a unique name.
  82936. */
  82937. name: string;
  82938. /**
  82939. * The scene the component belongs to.
  82940. */
  82941. scene: Scene;
  82942. /**
  82943. * Register the component to one instance of a scene.
  82944. */
  82945. register(): void;
  82946. /**
  82947. * Rebuilds the elements related to this component in case of
  82948. * context lost for instance.
  82949. */
  82950. rebuild(): void;
  82951. /**
  82952. * Disposes the component and the associated ressources.
  82953. */
  82954. dispose(): void;
  82955. }
  82956. /**
  82957. * This represents a SERIALIZABLE scene component.
  82958. *
  82959. * This extends Scene Component to add Serialization methods on top.
  82960. */
  82961. export interface ISceneSerializableComponent extends ISceneComponent {
  82962. /**
  82963. * Adds all the elements from the container to the scene
  82964. * @param container the container holding the elements
  82965. */
  82966. addFromContainer(container: AbstractScene): void;
  82967. /**
  82968. * Removes all the elements in the container from the scene
  82969. * @param container contains the elements to remove
  82970. * @param dispose if the removed element should be disposed (default: false)
  82971. */
  82972. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  82973. /**
  82974. * Serializes the component data to the specified json object
  82975. * @param serializationObject The object to serialize to
  82976. */
  82977. serialize(serializationObject: any): void;
  82978. }
  82979. /**
  82980. * Strong typing of a Mesh related stage step action
  82981. */
  82982. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  82983. /**
  82984. * Strong typing of a Evaluate Sub Mesh related stage step action
  82985. */
  82986. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  82987. /**
  82988. * Strong typing of a Active Mesh related stage step action
  82989. */
  82990. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  82991. /**
  82992. * Strong typing of a Camera related stage step action
  82993. */
  82994. export type CameraStageAction = (camera: Camera) => void;
  82995. /**
  82996. * Strong typing of a Camera Frame buffer related stage step action
  82997. */
  82998. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  82999. /**
  83000. * Strong typing of a Render Target related stage step action
  83001. */
  83002. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  83003. /**
  83004. * Strong typing of a RenderingGroup related stage step action
  83005. */
  83006. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  83007. /**
  83008. * Strong typing of a Mesh Render related stage step action
  83009. */
  83010. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  83011. /**
  83012. * Strong typing of a simple stage step action
  83013. */
  83014. export type SimpleStageAction = () => void;
  83015. /**
  83016. * Strong typing of a render target action.
  83017. */
  83018. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  83019. /**
  83020. * Strong typing of a pointer move action.
  83021. */
  83022. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  83023. /**
  83024. * Strong typing of a pointer up/down action.
  83025. */
  83026. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  83027. /**
  83028. * Representation of a stage in the scene (Basically a list of ordered steps)
  83029. * @hidden
  83030. */
  83031. export class Stage<T extends Function> extends Array<{
  83032. index: number;
  83033. component: ISceneComponent;
  83034. action: T;
  83035. }> {
  83036. /**
  83037. * Hide ctor from the rest of the world.
  83038. * @param items The items to add.
  83039. */
  83040. private constructor();
  83041. /**
  83042. * Creates a new Stage.
  83043. * @returns A new instance of a Stage
  83044. */
  83045. static Create<T extends Function>(): Stage<T>;
  83046. /**
  83047. * Registers a step in an ordered way in the targeted stage.
  83048. * @param index Defines the position to register the step in
  83049. * @param component Defines the component attached to the step
  83050. * @param action Defines the action to launch during the step
  83051. */
  83052. registerStep(index: number, component: ISceneComponent, action: T): void;
  83053. /**
  83054. * Clears all the steps from the stage.
  83055. */
  83056. clear(): void;
  83057. }
  83058. }
  83059. declare module BABYLON {
  83060. interface Scene {
  83061. /** @hidden */
  83062. _pointerOverSprite: Nullable<Sprite>;
  83063. /** @hidden */
  83064. _pickedDownSprite: Nullable<Sprite>;
  83065. /** @hidden */
  83066. _tempSpritePickingRay: Nullable<Ray>;
  83067. /**
  83068. * All of the sprite managers added to this scene
  83069. * @see http://doc.babylonjs.com/babylon101/sprites
  83070. */
  83071. spriteManagers: Array<ISpriteManager>;
  83072. /**
  83073. * An event triggered when sprites rendering is about to start
  83074. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  83075. */
  83076. onBeforeSpritesRenderingObservable: Observable<Scene>;
  83077. /**
  83078. * An event triggered when sprites rendering is done
  83079. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  83080. */
  83081. onAfterSpritesRenderingObservable: Observable<Scene>;
  83082. /** @hidden */
  83083. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83084. /** Launch a ray to try to pick a sprite in the scene
  83085. * @param x position on screen
  83086. * @param y position on screen
  83087. * @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
  83088. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  83089. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  83090. * @returns a PickingInfo
  83091. */
  83092. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83093. /** Use the given ray to pick a sprite in the scene
  83094. * @param ray The ray (in world space) to use to pick meshes
  83095. * @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
  83096. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  83097. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  83098. * @returns a PickingInfo
  83099. */
  83100. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83101. /** @hidden */
  83102. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  83103. /** Launch a ray to try to pick sprites in the scene
  83104. * @param x position on screen
  83105. * @param y position on screen
  83106. * @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
  83107. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  83108. * @returns a PickingInfo array
  83109. */
  83110. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  83111. /** Use the given ray to pick sprites in the scene
  83112. * @param ray The ray (in world space) to use to pick meshes
  83113. * @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
  83114. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  83115. * @returns a PickingInfo array
  83116. */
  83117. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  83118. /**
  83119. * Force the sprite under the pointer
  83120. * @param sprite defines the sprite to use
  83121. */
  83122. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  83123. /**
  83124. * Gets the sprite under the pointer
  83125. * @returns a Sprite or null if no sprite is under the pointer
  83126. */
  83127. getPointerOverSprite(): Nullable<Sprite>;
  83128. }
  83129. /**
  83130. * Defines the sprite scene component responsible to manage sprites
  83131. * in a given scene.
  83132. */
  83133. export class SpriteSceneComponent implements ISceneComponent {
  83134. /**
  83135. * The component name helpfull to identify the component in the list of scene components.
  83136. */
  83137. readonly name: string;
  83138. /**
  83139. * The scene the component belongs to.
  83140. */
  83141. scene: Scene;
  83142. /** @hidden */
  83143. private _spritePredicate;
  83144. /**
  83145. * Creates a new instance of the component for the given scene
  83146. * @param scene Defines the scene to register the component in
  83147. */
  83148. constructor(scene: Scene);
  83149. /**
  83150. * Registers the component in a given scene
  83151. */
  83152. register(): void;
  83153. /**
  83154. * Rebuilds the elements related to this component in case of
  83155. * context lost for instance.
  83156. */
  83157. rebuild(): void;
  83158. /**
  83159. * Disposes the component and the associated ressources.
  83160. */
  83161. dispose(): void;
  83162. private _pickSpriteButKeepRay;
  83163. private _pointerMove;
  83164. private _pointerDown;
  83165. private _pointerUp;
  83166. }
  83167. }
  83168. declare module BABYLON {
  83169. /** @hidden */
  83170. export var fogFragmentDeclaration: {
  83171. name: string;
  83172. shader: string;
  83173. };
  83174. }
  83175. declare module BABYLON {
  83176. /** @hidden */
  83177. export var fogFragment: {
  83178. name: string;
  83179. shader: string;
  83180. };
  83181. }
  83182. declare module BABYLON {
  83183. /** @hidden */
  83184. export var spritesPixelShader: {
  83185. name: string;
  83186. shader: string;
  83187. };
  83188. }
  83189. declare module BABYLON {
  83190. /** @hidden */
  83191. export var fogVertexDeclaration: {
  83192. name: string;
  83193. shader: string;
  83194. };
  83195. }
  83196. declare module BABYLON {
  83197. /** @hidden */
  83198. export var spritesVertexShader: {
  83199. name: string;
  83200. shader: string;
  83201. };
  83202. }
  83203. declare module BABYLON {
  83204. /**
  83205. * Defines the minimum interface to fullfil in order to be a sprite manager.
  83206. */
  83207. export interface ISpriteManager extends IDisposable {
  83208. /**
  83209. * Restricts the camera to viewing objects with the same layerMask.
  83210. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  83211. */
  83212. layerMask: number;
  83213. /**
  83214. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  83215. */
  83216. isPickable: boolean;
  83217. /**
  83218. * Specifies the rendering group id for this mesh (0 by default)
  83219. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  83220. */
  83221. renderingGroupId: number;
  83222. /**
  83223. * Defines the list of sprites managed by the manager.
  83224. */
  83225. sprites: Array<Sprite>;
  83226. /**
  83227. * Tests the intersection of a sprite with a specific ray.
  83228. * @param ray The ray we are sending to test the collision
  83229. * @param camera The camera space we are sending rays in
  83230. * @param predicate A predicate allowing excluding sprites from the list of object to test
  83231. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  83232. * @returns picking info or null.
  83233. */
  83234. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  83235. /**
  83236. * Intersects the sprites with a ray
  83237. * @param ray defines the ray to intersect with
  83238. * @param camera defines the current active camera
  83239. * @param predicate defines a predicate used to select candidate sprites
  83240. * @returns null if no hit or a PickingInfo array
  83241. */
  83242. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  83243. /**
  83244. * Renders the list of sprites on screen.
  83245. */
  83246. render(): void;
  83247. }
  83248. /**
  83249. * Class used to manage multiple sprites on the same spritesheet
  83250. * @see http://doc.babylonjs.com/babylon101/sprites
  83251. */
  83252. export class SpriteManager implements ISpriteManager {
  83253. /** defines the manager's name */
  83254. name: string;
  83255. /** Gets the list of sprites */
  83256. sprites: Sprite[];
  83257. /** Gets or sets the rendering group id (0 by default) */
  83258. renderingGroupId: number;
  83259. /** Gets or sets camera layer mask */
  83260. layerMask: number;
  83261. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  83262. fogEnabled: boolean;
  83263. /** Gets or sets a boolean indicating if the sprites are pickable */
  83264. isPickable: boolean;
  83265. /** Defines the default width of a cell in the spritesheet */
  83266. cellWidth: number;
  83267. /** Defines the default height of a cell in the spritesheet */
  83268. cellHeight: number;
  83269. /** Associative array from JSON sprite data file */
  83270. private _cellData;
  83271. /** Array of sprite names from JSON sprite data file */
  83272. private _spriteMap;
  83273. /** True when packed cell data from JSON file is ready*/
  83274. private _packedAndReady;
  83275. /**
  83276. * An event triggered when the manager is disposed.
  83277. */
  83278. onDisposeObservable: Observable<SpriteManager>;
  83279. private _onDisposeObserver;
  83280. /**
  83281. * Callback called when the manager is disposed
  83282. */
  83283. set onDispose(callback: () => void);
  83284. private _capacity;
  83285. private _fromPacked;
  83286. private _spriteTexture;
  83287. private _epsilon;
  83288. private _scene;
  83289. private _vertexData;
  83290. private _buffer;
  83291. private _vertexBuffers;
  83292. private _indexBuffer;
  83293. private _effectBase;
  83294. private _effectFog;
  83295. /**
  83296. * Gets or sets the spritesheet texture
  83297. */
  83298. get texture(): Texture;
  83299. set texture(value: Texture);
  83300. /**
  83301. * Creates a new sprite manager
  83302. * @param name defines the manager's name
  83303. * @param imgUrl defines the sprite sheet url
  83304. * @param capacity defines the maximum allowed number of sprites
  83305. * @param cellSize defines the size of a sprite cell
  83306. * @param scene defines the hosting scene
  83307. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  83308. * @param samplingMode defines the smapling mode to use with spritesheet
  83309. * @param fromPacked set to false; do not alter
  83310. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  83311. */
  83312. constructor(
  83313. /** defines the manager's name */
  83314. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  83315. private _makePacked;
  83316. private _appendSpriteVertex;
  83317. /**
  83318. * Intersects the sprites with a ray
  83319. * @param ray defines the ray to intersect with
  83320. * @param camera defines the current active camera
  83321. * @param predicate defines a predicate used to select candidate sprites
  83322. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  83323. * @returns null if no hit or a PickingInfo
  83324. */
  83325. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  83326. /**
  83327. * Intersects the sprites with a ray
  83328. * @param ray defines the ray to intersect with
  83329. * @param camera defines the current active camera
  83330. * @param predicate defines a predicate used to select candidate sprites
  83331. * @returns null if no hit or a PickingInfo array
  83332. */
  83333. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  83334. /**
  83335. * Render all child sprites
  83336. */
  83337. render(): void;
  83338. /**
  83339. * Release associated resources
  83340. */
  83341. dispose(): void;
  83342. }
  83343. }
  83344. declare module BABYLON {
  83345. /** Interface used by value gradients (color, factor, ...) */
  83346. export interface IValueGradient {
  83347. /**
  83348. * Gets or sets the gradient value (between 0 and 1)
  83349. */
  83350. gradient: number;
  83351. }
  83352. /** Class used to store color4 gradient */
  83353. export class ColorGradient implements IValueGradient {
  83354. /**
  83355. * Gets or sets the gradient value (between 0 and 1)
  83356. */
  83357. gradient: number;
  83358. /**
  83359. * Gets or sets first associated color
  83360. */
  83361. color1: Color4;
  83362. /**
  83363. * Gets or sets second associated color
  83364. */
  83365. color2?: Color4;
  83366. /**
  83367. * Will get a color picked randomly between color1 and color2.
  83368. * If color2 is undefined then color1 will be used
  83369. * @param result defines the target Color4 to store the result in
  83370. */
  83371. getColorToRef(result: Color4): void;
  83372. }
  83373. /** Class used to store color 3 gradient */
  83374. export class Color3Gradient implements IValueGradient {
  83375. /**
  83376. * Gets or sets the gradient value (between 0 and 1)
  83377. */
  83378. gradient: number;
  83379. /**
  83380. * Gets or sets the associated color
  83381. */
  83382. color: Color3;
  83383. }
  83384. /** Class used to store factor gradient */
  83385. export class FactorGradient implements IValueGradient {
  83386. /**
  83387. * Gets or sets the gradient value (between 0 and 1)
  83388. */
  83389. gradient: number;
  83390. /**
  83391. * Gets or sets first associated factor
  83392. */
  83393. factor1: number;
  83394. /**
  83395. * Gets or sets second associated factor
  83396. */
  83397. factor2?: number;
  83398. /**
  83399. * Will get a number picked randomly between factor1 and factor2.
  83400. * If factor2 is undefined then factor1 will be used
  83401. * @returns the picked number
  83402. */
  83403. getFactor(): number;
  83404. }
  83405. /**
  83406. * Helper used to simplify some generic gradient tasks
  83407. */
  83408. export class GradientHelper {
  83409. /**
  83410. * Gets the current gradient from an array of IValueGradient
  83411. * @param ratio defines the current ratio to get
  83412. * @param gradients defines the array of IValueGradient
  83413. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  83414. */
  83415. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  83416. }
  83417. }
  83418. declare module BABYLON {
  83419. /**
  83420. * Interface for the size containing width and height
  83421. */
  83422. export interface ISize {
  83423. /**
  83424. * Width
  83425. */
  83426. width: number;
  83427. /**
  83428. * Heighht
  83429. */
  83430. height: number;
  83431. }
  83432. /**
  83433. * Size containing widht and height
  83434. */
  83435. export class Size implements ISize {
  83436. /**
  83437. * Width
  83438. */
  83439. width: number;
  83440. /**
  83441. * Height
  83442. */
  83443. height: number;
  83444. /**
  83445. * Creates a Size object from the given width and height (floats).
  83446. * @param width width of the new size
  83447. * @param height height of the new size
  83448. */
  83449. constructor(width: number, height: number);
  83450. /**
  83451. * Returns a string with the Size width and height
  83452. * @returns a string with the Size width and height
  83453. */
  83454. toString(): string;
  83455. /**
  83456. * "Size"
  83457. * @returns the string "Size"
  83458. */
  83459. getClassName(): string;
  83460. /**
  83461. * Returns the Size hash code.
  83462. * @returns a hash code for a unique width and height
  83463. */
  83464. getHashCode(): number;
  83465. /**
  83466. * Updates the current size from the given one.
  83467. * @param src the given size
  83468. */
  83469. copyFrom(src: Size): void;
  83470. /**
  83471. * Updates in place the current Size from the given floats.
  83472. * @param width width of the new size
  83473. * @param height height of the new size
  83474. * @returns the updated Size.
  83475. */
  83476. copyFromFloats(width: number, height: number): Size;
  83477. /**
  83478. * Updates in place the current Size from the given floats.
  83479. * @param width width to set
  83480. * @param height height to set
  83481. * @returns the updated Size.
  83482. */
  83483. set(width: number, height: number): Size;
  83484. /**
  83485. * Multiplies the width and height by numbers
  83486. * @param w factor to multiple the width by
  83487. * @param h factor to multiple the height by
  83488. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  83489. */
  83490. multiplyByFloats(w: number, h: number): Size;
  83491. /**
  83492. * Clones the size
  83493. * @returns a new Size copied from the given one.
  83494. */
  83495. clone(): Size;
  83496. /**
  83497. * True if the current Size and the given one width and height are strictly equal.
  83498. * @param other the other size to compare against
  83499. * @returns True if the current Size and the given one width and height are strictly equal.
  83500. */
  83501. equals(other: Size): boolean;
  83502. /**
  83503. * The surface of the Size : width * height (float).
  83504. */
  83505. get surface(): number;
  83506. /**
  83507. * Create a new size of zero
  83508. * @returns a new Size set to (0.0, 0.0)
  83509. */
  83510. static Zero(): Size;
  83511. /**
  83512. * Sums the width and height of two sizes
  83513. * @param otherSize size to add to this size
  83514. * @returns a new Size set as the addition result of the current Size and the given one.
  83515. */
  83516. add(otherSize: Size): Size;
  83517. /**
  83518. * Subtracts the width and height of two
  83519. * @param otherSize size to subtract to this size
  83520. * @returns a new Size set as the subtraction result of the given one from the current Size.
  83521. */
  83522. subtract(otherSize: Size): Size;
  83523. /**
  83524. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  83525. * @param start starting size to lerp between
  83526. * @param end end size to lerp between
  83527. * @param amount amount to lerp between the start and end values
  83528. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  83529. */
  83530. static Lerp(start: Size, end: Size, amount: number): Size;
  83531. }
  83532. }
  83533. declare module BABYLON {
  83534. interface ThinEngine {
  83535. /**
  83536. * Creates a dynamic texture
  83537. * @param width defines the width of the texture
  83538. * @param height defines the height of the texture
  83539. * @param generateMipMaps defines if the engine should generate the mip levels
  83540. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  83541. * @returns the dynamic texture inside an InternalTexture
  83542. */
  83543. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  83544. /**
  83545. * Update the content of a dynamic texture
  83546. * @param texture defines the texture to update
  83547. * @param canvas defines the canvas containing the source
  83548. * @param invertY defines if data must be stored with Y axis inverted
  83549. * @param premulAlpha defines if alpha is stored as premultiplied
  83550. * @param format defines the format of the data
  83551. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  83552. */
  83553. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  83554. }
  83555. }
  83556. declare module BABYLON {
  83557. /**
  83558. * Helper class used to generate a canvas to manipulate images
  83559. */
  83560. export class CanvasGenerator {
  83561. /**
  83562. * Create a new canvas (or offscreen canvas depending on the context)
  83563. * @param width defines the expected width
  83564. * @param height defines the expected height
  83565. * @return a new canvas or offscreen canvas
  83566. */
  83567. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  83568. }
  83569. }
  83570. declare module BABYLON {
  83571. /**
  83572. * A class extending Texture allowing drawing on a texture
  83573. * @see http://doc.babylonjs.com/how_to/dynamictexture
  83574. */
  83575. export class DynamicTexture extends Texture {
  83576. private _generateMipMaps;
  83577. private _canvas;
  83578. private _context;
  83579. private _engine;
  83580. /**
  83581. * Creates a DynamicTexture
  83582. * @param name defines the name of the texture
  83583. * @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
  83584. * @param scene defines the scene where you want the texture
  83585. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  83586. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  83587. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  83588. */
  83589. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  83590. /**
  83591. * Get the current class name of the texture useful for serialization or dynamic coding.
  83592. * @returns "DynamicTexture"
  83593. */
  83594. getClassName(): string;
  83595. /**
  83596. * Gets the current state of canRescale
  83597. */
  83598. get canRescale(): boolean;
  83599. private _recreate;
  83600. /**
  83601. * Scales the texture
  83602. * @param ratio the scale factor to apply to both width and height
  83603. */
  83604. scale(ratio: number): void;
  83605. /**
  83606. * Resizes the texture
  83607. * @param width the new width
  83608. * @param height the new height
  83609. */
  83610. scaleTo(width: number, height: number): void;
  83611. /**
  83612. * Gets the context of the canvas used by the texture
  83613. * @returns the canvas context of the dynamic texture
  83614. */
  83615. getContext(): CanvasRenderingContext2D;
  83616. /**
  83617. * Clears the texture
  83618. */
  83619. clear(): void;
  83620. /**
  83621. * Updates the texture
  83622. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  83623. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  83624. */
  83625. update(invertY?: boolean, premulAlpha?: boolean): void;
  83626. /**
  83627. * Draws text onto the texture
  83628. * @param text defines the text to be drawn
  83629. * @param x defines the placement of the text from the left
  83630. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  83631. * @param font defines the font to be used with font-style, font-size, font-name
  83632. * @param color defines the color used for the text
  83633. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  83634. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  83635. * @param update defines whether texture is immediately update (default is true)
  83636. */
  83637. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  83638. /**
  83639. * Clones the texture
  83640. * @returns the clone of the texture.
  83641. */
  83642. clone(): DynamicTexture;
  83643. /**
  83644. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  83645. * @returns a serialized dynamic texture object
  83646. */
  83647. serialize(): any;
  83648. /** @hidden */
  83649. _rebuild(): void;
  83650. }
  83651. }
  83652. declare module BABYLON {
  83653. interface Engine {
  83654. /**
  83655. * Creates a raw texture
  83656. * @param data defines the data to store in the texture
  83657. * @param width defines the width of the texture
  83658. * @param height defines the height of the texture
  83659. * @param format defines the format of the data
  83660. * @param generateMipMaps defines if the engine should generate the mip levels
  83661. * @param invertY defines if data must be stored with Y axis inverted
  83662. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  83663. * @param compression defines the compression used (null by default)
  83664. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83665. * @returns the raw texture inside an InternalTexture
  83666. */
  83667. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  83668. /**
  83669. * Update a raw texture
  83670. * @param texture defines the texture to update
  83671. * @param data defines the data to store in the texture
  83672. * @param format defines the format of the data
  83673. * @param invertY defines if data must be stored with Y axis inverted
  83674. */
  83675. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83676. /**
  83677. * Update a raw texture
  83678. * @param texture defines the texture to update
  83679. * @param data defines the data to store in the texture
  83680. * @param format defines the format of the data
  83681. * @param invertY defines if data must be stored with Y axis inverted
  83682. * @param compression defines the compression used (null by default)
  83683. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83684. */
  83685. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  83686. /**
  83687. * Creates a new raw cube texture
  83688. * @param data defines the array of data to use to create each face
  83689. * @param size defines the size of the textures
  83690. * @param format defines the format of the data
  83691. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83692. * @param generateMipMaps defines if the engine should generate the mip levels
  83693. * @param invertY defines if data must be stored with Y axis inverted
  83694. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83695. * @param compression defines the compression used (null by default)
  83696. * @returns the cube texture as an InternalTexture
  83697. */
  83698. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  83699. /**
  83700. * Update a raw cube texture
  83701. * @param texture defines the texture to udpdate
  83702. * @param data defines the data to store
  83703. * @param format defines the data format
  83704. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83705. * @param invertY defines if data must be stored with Y axis inverted
  83706. */
  83707. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  83708. /**
  83709. * Update a raw cube texture
  83710. * @param texture defines the texture to udpdate
  83711. * @param data defines the data to store
  83712. * @param format defines the data format
  83713. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83714. * @param invertY defines if data must be stored with Y axis inverted
  83715. * @param compression defines the compression used (null by default)
  83716. */
  83717. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  83718. /**
  83719. * Update a raw cube texture
  83720. * @param texture defines the texture to udpdate
  83721. * @param data defines the data to store
  83722. * @param format defines the data format
  83723. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83724. * @param invertY defines if data must be stored with Y axis inverted
  83725. * @param compression defines the compression used (null by default)
  83726. * @param level defines which level of the texture to update
  83727. */
  83728. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  83729. /**
  83730. * Creates a new raw cube texture from a specified url
  83731. * @param url defines the url where the data is located
  83732. * @param scene defines the current scene
  83733. * @param size defines the size of the textures
  83734. * @param format defines the format of the data
  83735. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83736. * @param noMipmap defines if the engine should avoid generating the mip levels
  83737. * @param callback defines a callback used to extract texture data from loaded data
  83738. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  83739. * @param onLoad defines a callback called when texture is loaded
  83740. * @param onError defines a callback called if there is an error
  83741. * @returns the cube texture as an InternalTexture
  83742. */
  83743. 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;
  83744. /**
  83745. * Creates a new raw cube texture from a specified url
  83746. * @param url defines the url where the data is located
  83747. * @param scene defines the current scene
  83748. * @param size defines the size of the textures
  83749. * @param format defines the format of the data
  83750. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83751. * @param noMipmap defines if the engine should avoid generating the mip levels
  83752. * @param callback defines a callback used to extract texture data from loaded data
  83753. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  83754. * @param onLoad defines a callback called when texture is loaded
  83755. * @param onError defines a callback called if there is an error
  83756. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83757. * @param invertY defines if data must be stored with Y axis inverted
  83758. * @returns the cube texture as an InternalTexture
  83759. */
  83760. 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;
  83761. /**
  83762. * Creates a new raw 3D texture
  83763. * @param data defines the data used to create the texture
  83764. * @param width defines the width of the texture
  83765. * @param height defines the height of the texture
  83766. * @param depth defines the depth of the texture
  83767. * @param format defines the format of the texture
  83768. * @param generateMipMaps defines if the engine must generate mip levels
  83769. * @param invertY defines if data must be stored with Y axis inverted
  83770. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83771. * @param compression defines the compressed used (can be null)
  83772. * @param textureType defines the compressed used (can be null)
  83773. * @returns a new raw 3D texture (stored in an InternalTexture)
  83774. */
  83775. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  83776. /**
  83777. * Update a raw 3D texture
  83778. * @param texture defines the texture to update
  83779. * @param data defines the data to store
  83780. * @param format defines the data format
  83781. * @param invertY defines if data must be stored with Y axis inverted
  83782. */
  83783. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83784. /**
  83785. * Update a raw 3D texture
  83786. * @param texture defines the texture to update
  83787. * @param data defines the data to store
  83788. * @param format defines the data format
  83789. * @param invertY defines if data must be stored with Y axis inverted
  83790. * @param compression defines the used compression (can be null)
  83791. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  83792. */
  83793. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  83794. /**
  83795. * Creates a new raw 2D array texture
  83796. * @param data defines the data used to create the texture
  83797. * @param width defines the width of the texture
  83798. * @param height defines the height of the texture
  83799. * @param depth defines the number of layers of the texture
  83800. * @param format defines the format of the texture
  83801. * @param generateMipMaps defines if the engine must generate mip levels
  83802. * @param invertY defines if data must be stored with Y axis inverted
  83803. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83804. * @param compression defines the compressed used (can be null)
  83805. * @param textureType defines the compressed used (can be null)
  83806. * @returns a new raw 2D array texture (stored in an InternalTexture)
  83807. */
  83808. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  83809. /**
  83810. * Update a raw 2D array texture
  83811. * @param texture defines the texture to update
  83812. * @param data defines the data to store
  83813. * @param format defines the data format
  83814. * @param invertY defines if data must be stored with Y axis inverted
  83815. */
  83816. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83817. /**
  83818. * Update a raw 2D array texture
  83819. * @param texture defines the texture to update
  83820. * @param data defines the data to store
  83821. * @param format defines the data format
  83822. * @param invertY defines if data must be stored with Y axis inverted
  83823. * @param compression defines the used compression (can be null)
  83824. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  83825. */
  83826. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  83827. }
  83828. }
  83829. declare module BABYLON {
  83830. /**
  83831. * Raw texture can help creating a texture directly from an array of data.
  83832. * This can be super useful if you either get the data from an uncompressed source or
  83833. * if you wish to create your texture pixel by pixel.
  83834. */
  83835. export class RawTexture extends Texture {
  83836. /**
  83837. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83838. */
  83839. format: number;
  83840. private _engine;
  83841. /**
  83842. * Instantiates a new RawTexture.
  83843. * Raw texture can help creating a texture directly from an array of data.
  83844. * This can be super useful if you either get the data from an uncompressed source or
  83845. * if you wish to create your texture pixel by pixel.
  83846. * @param data define the array of data to use to create the texture
  83847. * @param width define the width of the texture
  83848. * @param height define the height of the texture
  83849. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83850. * @param scene define the scene the texture belongs to
  83851. * @param generateMipMaps define whether mip maps should be generated or not
  83852. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83853. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83854. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83855. */
  83856. constructor(data: ArrayBufferView, width: number, height: number,
  83857. /**
  83858. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83859. */
  83860. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  83861. /**
  83862. * Updates the texture underlying data.
  83863. * @param data Define the new data of the texture
  83864. */
  83865. update(data: ArrayBufferView): void;
  83866. /**
  83867. * Creates a luminance texture from some data.
  83868. * @param data Define the texture data
  83869. * @param width Define the width of the texture
  83870. * @param height Define the height of the texture
  83871. * @param scene Define the scene the texture belongs to
  83872. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83873. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83874. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83875. * @returns the luminance texture
  83876. */
  83877. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  83878. /**
  83879. * Creates a luminance alpha texture from some data.
  83880. * @param data Define the texture data
  83881. * @param width Define the width of the texture
  83882. * @param height Define the height of the texture
  83883. * @param scene Define the scene the texture belongs to
  83884. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83885. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83886. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83887. * @returns the luminance alpha texture
  83888. */
  83889. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  83890. /**
  83891. * Creates an alpha texture from some data.
  83892. * @param data Define the texture data
  83893. * @param width Define the width of the texture
  83894. * @param height Define the height of the texture
  83895. * @param scene Define the scene the texture belongs to
  83896. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83897. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83898. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83899. * @returns the alpha texture
  83900. */
  83901. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  83902. /**
  83903. * Creates a RGB texture from some data.
  83904. * @param data Define the texture data
  83905. * @param width Define the width of the texture
  83906. * @param height Define the height of the texture
  83907. * @param scene Define the scene the texture belongs to
  83908. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83909. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83910. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83911. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83912. * @returns the RGB alpha texture
  83913. */
  83914. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  83915. /**
  83916. * Creates a RGBA texture from some data.
  83917. * @param data Define the texture data
  83918. * @param width Define the width of the texture
  83919. * @param height Define the height of the texture
  83920. * @param scene Define the scene the texture belongs to
  83921. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83922. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83923. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83924. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83925. * @returns the RGBA texture
  83926. */
  83927. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  83928. /**
  83929. * Creates a R texture from some data.
  83930. * @param data Define the texture data
  83931. * @param width Define the width of the texture
  83932. * @param height Define the height of the texture
  83933. * @param scene Define the scene the texture belongs to
  83934. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83935. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83936. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83937. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83938. * @returns the R texture
  83939. */
  83940. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  83941. }
  83942. }
  83943. declare module BABYLON {
  83944. interface AbstractScene {
  83945. /**
  83946. * The list of procedural textures added to the scene
  83947. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  83948. */
  83949. proceduralTextures: Array<ProceduralTexture>;
  83950. }
  83951. /**
  83952. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  83953. * in a given scene.
  83954. */
  83955. export class ProceduralTextureSceneComponent implements ISceneComponent {
  83956. /**
  83957. * The component name helpfull to identify the component in the list of scene components.
  83958. */
  83959. readonly name: string;
  83960. /**
  83961. * The scene the component belongs to.
  83962. */
  83963. scene: Scene;
  83964. /**
  83965. * Creates a new instance of the component for the given scene
  83966. * @param scene Defines the scene to register the component in
  83967. */
  83968. constructor(scene: Scene);
  83969. /**
  83970. * Registers the component in a given scene
  83971. */
  83972. register(): void;
  83973. /**
  83974. * Rebuilds the elements related to this component in case of
  83975. * context lost for instance.
  83976. */
  83977. rebuild(): void;
  83978. /**
  83979. * Disposes the component and the associated ressources.
  83980. */
  83981. dispose(): void;
  83982. private _beforeClear;
  83983. }
  83984. }
  83985. declare module BABYLON {
  83986. interface ThinEngine {
  83987. /**
  83988. * Creates a new render target cube texture
  83989. * @param size defines the size of the texture
  83990. * @param options defines the options used to create the texture
  83991. * @returns a new render target cube texture stored in an InternalTexture
  83992. */
  83993. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  83994. }
  83995. }
  83996. declare module BABYLON {
  83997. /** @hidden */
  83998. export var proceduralVertexShader: {
  83999. name: string;
  84000. shader: string;
  84001. };
  84002. }
  84003. declare module BABYLON {
  84004. /**
  84005. * 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.
  84006. * This is the base class of any Procedural texture and contains most of the shareable code.
  84007. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84008. */
  84009. export class ProceduralTexture extends Texture {
  84010. isCube: boolean;
  84011. /**
  84012. * Define if the texture is enabled or not (disabled texture will not render)
  84013. */
  84014. isEnabled: boolean;
  84015. /**
  84016. * Define if the texture must be cleared before rendering (default is true)
  84017. */
  84018. autoClear: boolean;
  84019. /**
  84020. * Callback called when the texture is generated
  84021. */
  84022. onGenerated: () => void;
  84023. /**
  84024. * Event raised when the texture is generated
  84025. */
  84026. onGeneratedObservable: Observable<ProceduralTexture>;
  84027. /** @hidden */
  84028. _generateMipMaps: boolean;
  84029. /** @hidden **/
  84030. _effect: Effect;
  84031. /** @hidden */
  84032. _textures: {
  84033. [key: string]: Texture;
  84034. };
  84035. private _size;
  84036. private _currentRefreshId;
  84037. private _frameId;
  84038. private _refreshRate;
  84039. private _vertexBuffers;
  84040. private _indexBuffer;
  84041. private _uniforms;
  84042. private _samplers;
  84043. private _fragment;
  84044. private _floats;
  84045. private _ints;
  84046. private _floatsArrays;
  84047. private _colors3;
  84048. private _colors4;
  84049. private _vectors2;
  84050. private _vectors3;
  84051. private _matrices;
  84052. private _fallbackTexture;
  84053. private _fallbackTextureUsed;
  84054. private _engine;
  84055. private _cachedDefines;
  84056. private _contentUpdateId;
  84057. private _contentData;
  84058. /**
  84059. * Instantiates a new procedural texture.
  84060. * 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.
  84061. * This is the base class of any Procedural texture and contains most of the shareable code.
  84062. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84063. * @param name Define the name of the texture
  84064. * @param size Define the size of the texture to create
  84065. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  84066. * @param scene Define the scene the texture belongs to
  84067. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  84068. * @param generateMipMaps Define if the texture should creates mip maps or not
  84069. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  84070. */
  84071. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  84072. /**
  84073. * The effect that is created when initializing the post process.
  84074. * @returns The created effect corresponding the the postprocess.
  84075. */
  84076. getEffect(): Effect;
  84077. /**
  84078. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  84079. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  84080. */
  84081. getContent(): Nullable<ArrayBufferView>;
  84082. private _createIndexBuffer;
  84083. /** @hidden */
  84084. _rebuild(): void;
  84085. /**
  84086. * Resets the texture in order to recreate its associated resources.
  84087. * This can be called in case of context loss
  84088. */
  84089. reset(): void;
  84090. protected _getDefines(): string;
  84091. /**
  84092. * Is the texture ready to be used ? (rendered at least once)
  84093. * @returns true if ready, otherwise, false.
  84094. */
  84095. isReady(): boolean;
  84096. /**
  84097. * Resets the refresh counter of the texture and start bak from scratch.
  84098. * Could be useful to regenerate the texture if it is setup to render only once.
  84099. */
  84100. resetRefreshCounter(): void;
  84101. /**
  84102. * Set the fragment shader to use in order to render the texture.
  84103. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  84104. */
  84105. setFragment(fragment: any): void;
  84106. /**
  84107. * Define the refresh rate of the texture or the rendering frequency.
  84108. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  84109. */
  84110. get refreshRate(): number;
  84111. set refreshRate(value: number);
  84112. /** @hidden */
  84113. _shouldRender(): boolean;
  84114. /**
  84115. * Get the size the texture is rendering at.
  84116. * @returns the size (texture is always squared)
  84117. */
  84118. getRenderSize(): number;
  84119. /**
  84120. * Resize the texture to new value.
  84121. * @param size Define the new size the texture should have
  84122. * @param generateMipMaps Define whether the new texture should create mip maps
  84123. */
  84124. resize(size: number, generateMipMaps: boolean): void;
  84125. private _checkUniform;
  84126. /**
  84127. * Set a texture in the shader program used to render.
  84128. * @param name Define the name of the uniform samplers as defined in the shader
  84129. * @param texture Define the texture to bind to this sampler
  84130. * @return the texture itself allowing "fluent" like uniform updates
  84131. */
  84132. setTexture(name: string, texture: Texture): ProceduralTexture;
  84133. /**
  84134. * Set a float in the shader.
  84135. * @param name Define the name of the uniform as defined in the shader
  84136. * @param value Define the value to give to the uniform
  84137. * @return the texture itself allowing "fluent" like uniform updates
  84138. */
  84139. setFloat(name: string, value: number): ProceduralTexture;
  84140. /**
  84141. * Set a int in the shader.
  84142. * @param name Define the name of the uniform as defined in the shader
  84143. * @param value Define the value to give to the uniform
  84144. * @return the texture itself allowing "fluent" like uniform updates
  84145. */
  84146. setInt(name: string, value: number): ProceduralTexture;
  84147. /**
  84148. * Set an array of floats in the shader.
  84149. * @param name Define the name of the uniform as defined in the shader
  84150. * @param value Define the value to give to the uniform
  84151. * @return the texture itself allowing "fluent" like uniform updates
  84152. */
  84153. setFloats(name: string, value: number[]): ProceduralTexture;
  84154. /**
  84155. * Set a vec3 in the shader from a Color3.
  84156. * @param name Define the name of the uniform as defined in the shader
  84157. * @param value Define the value to give to the uniform
  84158. * @return the texture itself allowing "fluent" like uniform updates
  84159. */
  84160. setColor3(name: string, value: Color3): ProceduralTexture;
  84161. /**
  84162. * Set a vec4 in the shader from a Color4.
  84163. * @param name Define the name of the uniform as defined in the shader
  84164. * @param value Define the value to give to the uniform
  84165. * @return the texture itself allowing "fluent" like uniform updates
  84166. */
  84167. setColor4(name: string, value: Color4): ProceduralTexture;
  84168. /**
  84169. * Set a vec2 in the shader from a Vector2.
  84170. * @param name Define the name of the uniform as defined in the shader
  84171. * @param value Define the value to give to the uniform
  84172. * @return the texture itself allowing "fluent" like uniform updates
  84173. */
  84174. setVector2(name: string, value: Vector2): ProceduralTexture;
  84175. /**
  84176. * Set a vec3 in the shader from a Vector3.
  84177. * @param name Define the name of the uniform as defined in the shader
  84178. * @param value Define the value to give to the uniform
  84179. * @return the texture itself allowing "fluent" like uniform updates
  84180. */
  84181. setVector3(name: string, value: Vector3): ProceduralTexture;
  84182. /**
  84183. * Set a mat4 in the shader from a MAtrix.
  84184. * @param name Define the name of the uniform as defined in the shader
  84185. * @param value Define the value to give to the uniform
  84186. * @return the texture itself allowing "fluent" like uniform updates
  84187. */
  84188. setMatrix(name: string, value: Matrix): ProceduralTexture;
  84189. /**
  84190. * Render the texture to its associated render target.
  84191. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  84192. */
  84193. render(useCameraPostProcess?: boolean): void;
  84194. /**
  84195. * Clone the texture.
  84196. * @returns the cloned texture
  84197. */
  84198. clone(): ProceduralTexture;
  84199. /**
  84200. * Dispose the texture and release its asoociated resources.
  84201. */
  84202. dispose(): void;
  84203. }
  84204. }
  84205. declare module BABYLON {
  84206. /**
  84207. * This represents the base class for particle system in Babylon.
  84208. * 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.
  84209. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  84210. * @example https://doc.babylonjs.com/babylon101/particles
  84211. */
  84212. export class BaseParticleSystem {
  84213. /**
  84214. * Source color is added to the destination color without alpha affecting the result
  84215. */
  84216. static BLENDMODE_ONEONE: number;
  84217. /**
  84218. * Blend current color and particle color using particle’s alpha
  84219. */
  84220. static BLENDMODE_STANDARD: number;
  84221. /**
  84222. * Add current color and particle color multiplied by particle’s alpha
  84223. */
  84224. static BLENDMODE_ADD: number;
  84225. /**
  84226. * Multiply current color with particle color
  84227. */
  84228. static BLENDMODE_MULTIPLY: number;
  84229. /**
  84230. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  84231. */
  84232. static BLENDMODE_MULTIPLYADD: number;
  84233. /**
  84234. * List of animations used by the particle system.
  84235. */
  84236. animations: Animation[];
  84237. /**
  84238. * The id of the Particle system.
  84239. */
  84240. id: string;
  84241. /**
  84242. * The friendly name of the Particle system.
  84243. */
  84244. name: string;
  84245. /**
  84246. * The rendering group used by the Particle system to chose when to render.
  84247. */
  84248. renderingGroupId: number;
  84249. /**
  84250. * The emitter represents the Mesh or position we are attaching the particle system to.
  84251. */
  84252. emitter: Nullable<AbstractMesh | Vector3>;
  84253. /**
  84254. * The maximum number of particles to emit per frame
  84255. */
  84256. emitRate: number;
  84257. /**
  84258. * If you want to launch only a few particles at once, that can be done, as well.
  84259. */
  84260. manualEmitCount: number;
  84261. /**
  84262. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  84263. */
  84264. updateSpeed: number;
  84265. /**
  84266. * The amount of time the particle system is running (depends of the overall update speed).
  84267. */
  84268. targetStopDuration: number;
  84269. /**
  84270. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  84271. */
  84272. disposeOnStop: boolean;
  84273. /**
  84274. * Minimum power of emitting particles.
  84275. */
  84276. minEmitPower: number;
  84277. /**
  84278. * Maximum power of emitting particles.
  84279. */
  84280. maxEmitPower: number;
  84281. /**
  84282. * Minimum life time of emitting particles.
  84283. */
  84284. minLifeTime: number;
  84285. /**
  84286. * Maximum life time of emitting particles.
  84287. */
  84288. maxLifeTime: number;
  84289. /**
  84290. * Minimum Size of emitting particles.
  84291. */
  84292. minSize: number;
  84293. /**
  84294. * Maximum Size of emitting particles.
  84295. */
  84296. maxSize: number;
  84297. /**
  84298. * Minimum scale of emitting particles on X axis.
  84299. */
  84300. minScaleX: number;
  84301. /**
  84302. * Maximum scale of emitting particles on X axis.
  84303. */
  84304. maxScaleX: number;
  84305. /**
  84306. * Minimum scale of emitting particles on Y axis.
  84307. */
  84308. minScaleY: number;
  84309. /**
  84310. * Maximum scale of emitting particles on Y axis.
  84311. */
  84312. maxScaleY: number;
  84313. /**
  84314. * Gets or sets the minimal initial rotation in radians.
  84315. */
  84316. minInitialRotation: number;
  84317. /**
  84318. * Gets or sets the maximal initial rotation in radians.
  84319. */
  84320. maxInitialRotation: number;
  84321. /**
  84322. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  84323. */
  84324. minAngularSpeed: number;
  84325. /**
  84326. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  84327. */
  84328. maxAngularSpeed: number;
  84329. /**
  84330. * The texture used to render each particle. (this can be a spritesheet)
  84331. */
  84332. particleTexture: Nullable<Texture>;
  84333. /**
  84334. * The layer mask we are rendering the particles through.
  84335. */
  84336. layerMask: number;
  84337. /**
  84338. * This can help using your own shader to render the particle system.
  84339. * The according effect will be created
  84340. */
  84341. customShader: any;
  84342. /**
  84343. * By default particle system starts as soon as they are created. This prevents the
  84344. * automatic start to happen and let you decide when to start emitting particles.
  84345. */
  84346. preventAutoStart: boolean;
  84347. private _noiseTexture;
  84348. /**
  84349. * Gets or sets a texture used to add random noise to particle positions
  84350. */
  84351. get noiseTexture(): Nullable<ProceduralTexture>;
  84352. set noiseTexture(value: Nullable<ProceduralTexture>);
  84353. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  84354. noiseStrength: Vector3;
  84355. /**
  84356. * Callback triggered when the particle animation is ending.
  84357. */
  84358. onAnimationEnd: Nullable<() => void>;
  84359. /**
  84360. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  84361. */
  84362. blendMode: number;
  84363. /**
  84364. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  84365. * to override the particles.
  84366. */
  84367. forceDepthWrite: boolean;
  84368. /** 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 */
  84369. preWarmCycles: number;
  84370. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  84371. preWarmStepOffset: number;
  84372. /**
  84373. * 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)
  84374. */
  84375. spriteCellChangeSpeed: number;
  84376. /**
  84377. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  84378. */
  84379. startSpriteCellID: number;
  84380. /**
  84381. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  84382. */
  84383. endSpriteCellID: number;
  84384. /**
  84385. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  84386. */
  84387. spriteCellWidth: number;
  84388. /**
  84389. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  84390. */
  84391. spriteCellHeight: number;
  84392. /**
  84393. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  84394. */
  84395. spriteRandomStartCell: boolean;
  84396. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  84397. translationPivot: Vector2;
  84398. /** @hidden */
  84399. protected _isAnimationSheetEnabled: boolean;
  84400. /**
  84401. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  84402. */
  84403. beginAnimationOnStart: boolean;
  84404. /**
  84405. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  84406. */
  84407. beginAnimationFrom: number;
  84408. /**
  84409. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  84410. */
  84411. beginAnimationTo: number;
  84412. /**
  84413. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  84414. */
  84415. beginAnimationLoop: boolean;
  84416. /**
  84417. * Gets or sets a world offset applied to all particles
  84418. */
  84419. worldOffset: Vector3;
  84420. /**
  84421. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  84422. */
  84423. get isAnimationSheetEnabled(): boolean;
  84424. set isAnimationSheetEnabled(value: boolean);
  84425. /**
  84426. * Get hosting scene
  84427. * @returns the scene
  84428. */
  84429. getScene(): Scene;
  84430. /**
  84431. * You can use gravity if you want to give an orientation to your particles.
  84432. */
  84433. gravity: Vector3;
  84434. protected _colorGradients: Nullable<Array<ColorGradient>>;
  84435. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  84436. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  84437. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  84438. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  84439. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  84440. protected _dragGradients: Nullable<Array<FactorGradient>>;
  84441. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  84442. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  84443. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  84444. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  84445. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  84446. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  84447. /**
  84448. * Defines the delay in milliseconds before starting the system (0 by default)
  84449. */
  84450. startDelay: number;
  84451. /**
  84452. * Gets the current list of drag gradients.
  84453. * You must use addDragGradient and removeDragGradient to udpate this list
  84454. * @returns the list of drag gradients
  84455. */
  84456. getDragGradients(): Nullable<Array<FactorGradient>>;
  84457. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  84458. limitVelocityDamping: number;
  84459. /**
  84460. * Gets the current list of limit velocity gradients.
  84461. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  84462. * @returns the list of limit velocity gradients
  84463. */
  84464. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  84465. /**
  84466. * Gets the current list of color gradients.
  84467. * You must use addColorGradient and removeColorGradient to udpate this list
  84468. * @returns the list of color gradients
  84469. */
  84470. getColorGradients(): Nullable<Array<ColorGradient>>;
  84471. /**
  84472. * Gets the current list of size gradients.
  84473. * You must use addSizeGradient and removeSizeGradient to udpate this list
  84474. * @returns the list of size gradients
  84475. */
  84476. getSizeGradients(): Nullable<Array<FactorGradient>>;
  84477. /**
  84478. * Gets the current list of color remap gradients.
  84479. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  84480. * @returns the list of color remap gradients
  84481. */
  84482. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  84483. /**
  84484. * Gets the current list of alpha remap gradients.
  84485. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  84486. * @returns the list of alpha remap gradients
  84487. */
  84488. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  84489. /**
  84490. * Gets the current list of life time gradients.
  84491. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  84492. * @returns the list of life time gradients
  84493. */
  84494. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  84495. /**
  84496. * Gets the current list of angular speed gradients.
  84497. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  84498. * @returns the list of angular speed gradients
  84499. */
  84500. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  84501. /**
  84502. * Gets the current list of velocity gradients.
  84503. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  84504. * @returns the list of velocity gradients
  84505. */
  84506. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  84507. /**
  84508. * Gets the current list of start size gradients.
  84509. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  84510. * @returns the list of start size gradients
  84511. */
  84512. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  84513. /**
  84514. * Gets the current list of emit rate gradients.
  84515. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  84516. * @returns the list of emit rate gradients
  84517. */
  84518. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  84519. /**
  84520. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84521. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84522. */
  84523. get direction1(): Vector3;
  84524. set direction1(value: Vector3);
  84525. /**
  84526. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84527. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84528. */
  84529. get direction2(): Vector3;
  84530. set direction2(value: Vector3);
  84531. /**
  84532. * 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.
  84533. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84534. */
  84535. get minEmitBox(): Vector3;
  84536. set minEmitBox(value: Vector3);
  84537. /**
  84538. * 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.
  84539. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84540. */
  84541. get maxEmitBox(): Vector3;
  84542. set maxEmitBox(value: Vector3);
  84543. /**
  84544. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  84545. */
  84546. color1: Color4;
  84547. /**
  84548. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  84549. */
  84550. color2: Color4;
  84551. /**
  84552. * Color the particle will have at the end of its lifetime
  84553. */
  84554. colorDead: Color4;
  84555. /**
  84556. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  84557. */
  84558. textureMask: Color4;
  84559. /**
  84560. * The particle emitter type defines the emitter used by the particle system.
  84561. * It can be for example box, sphere, or cone...
  84562. */
  84563. particleEmitterType: IParticleEmitterType;
  84564. /** @hidden */
  84565. _isSubEmitter: boolean;
  84566. /**
  84567. * Gets or sets the billboard mode to use when isBillboardBased = true.
  84568. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  84569. */
  84570. billboardMode: number;
  84571. protected _isBillboardBased: boolean;
  84572. /**
  84573. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  84574. */
  84575. get isBillboardBased(): boolean;
  84576. set isBillboardBased(value: boolean);
  84577. /**
  84578. * The scene the particle system belongs to.
  84579. */
  84580. protected _scene: Scene;
  84581. /**
  84582. * Local cache of defines for image processing.
  84583. */
  84584. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  84585. /**
  84586. * Default configuration related to image processing available in the standard Material.
  84587. */
  84588. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  84589. /**
  84590. * Gets the image processing configuration used either in this material.
  84591. */
  84592. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  84593. /**
  84594. * Sets the Default image processing configuration used either in the this material.
  84595. *
  84596. * If sets to null, the scene one is in use.
  84597. */
  84598. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  84599. /**
  84600. * Attaches a new image processing configuration to the Standard Material.
  84601. * @param configuration
  84602. */
  84603. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  84604. /** @hidden */
  84605. protected _reset(): void;
  84606. /** @hidden */
  84607. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  84608. /**
  84609. * Instantiates a particle system.
  84610. * 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.
  84611. * @param name The name of the particle system
  84612. */
  84613. constructor(name: string);
  84614. /**
  84615. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  84616. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84617. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84618. * @returns the emitter
  84619. */
  84620. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  84621. /**
  84622. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  84623. * @param radius The radius of the hemisphere to emit from
  84624. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84625. * @returns the emitter
  84626. */
  84627. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  84628. /**
  84629. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  84630. * @param radius The radius of the sphere to emit from
  84631. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84632. * @returns the emitter
  84633. */
  84634. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  84635. /**
  84636. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  84637. * @param radius The radius of the sphere to emit from
  84638. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  84639. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  84640. * @returns the emitter
  84641. */
  84642. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  84643. /**
  84644. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  84645. * @param radius The radius of the emission cylinder
  84646. * @param height The height of the emission cylinder
  84647. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  84648. * @param directionRandomizer How much to randomize the particle direction [0-1]
  84649. * @returns the emitter
  84650. */
  84651. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  84652. /**
  84653. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  84654. * @param radius The radius of the cylinder to emit from
  84655. * @param height The height of the emission cylinder
  84656. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84657. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  84658. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  84659. * @returns the emitter
  84660. */
  84661. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  84662. /**
  84663. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  84664. * @param radius The radius of the cone to emit from
  84665. * @param angle The base angle of the cone
  84666. * @returns the emitter
  84667. */
  84668. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  84669. /**
  84670. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  84671. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84672. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84673. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84674. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84675. * @returns the emitter
  84676. */
  84677. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  84678. }
  84679. }
  84680. declare module BABYLON {
  84681. /**
  84682. * Type of sub emitter
  84683. */
  84684. export enum SubEmitterType {
  84685. /**
  84686. * Attached to the particle over it's lifetime
  84687. */
  84688. ATTACHED = 0,
  84689. /**
  84690. * Created when the particle dies
  84691. */
  84692. END = 1
  84693. }
  84694. /**
  84695. * Sub emitter class used to emit particles from an existing particle
  84696. */
  84697. export class SubEmitter {
  84698. /**
  84699. * the particle system to be used by the sub emitter
  84700. */
  84701. particleSystem: ParticleSystem;
  84702. /**
  84703. * Type of the submitter (Default: END)
  84704. */
  84705. type: SubEmitterType;
  84706. /**
  84707. * 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)
  84708. * Note: This only is supported when using an emitter of type Mesh
  84709. */
  84710. inheritDirection: boolean;
  84711. /**
  84712. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  84713. */
  84714. inheritedVelocityAmount: number;
  84715. /**
  84716. * Creates a sub emitter
  84717. * @param particleSystem the particle system to be used by the sub emitter
  84718. */
  84719. constructor(
  84720. /**
  84721. * the particle system to be used by the sub emitter
  84722. */
  84723. particleSystem: ParticleSystem);
  84724. /**
  84725. * Clones the sub emitter
  84726. * @returns the cloned sub emitter
  84727. */
  84728. clone(): SubEmitter;
  84729. /**
  84730. * Serialize current object to a JSON object
  84731. * @returns the serialized object
  84732. */
  84733. serialize(): any;
  84734. /** @hidden */
  84735. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  84736. /**
  84737. * Creates a new SubEmitter from a serialized JSON version
  84738. * @param serializationObject defines the JSON object to read from
  84739. * @param scene defines the hosting scene
  84740. * @param rootUrl defines the rootUrl for data loading
  84741. * @returns a new SubEmitter
  84742. */
  84743. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  84744. /** Release associated resources */
  84745. dispose(): void;
  84746. }
  84747. }
  84748. declare module BABYLON {
  84749. /** @hidden */
  84750. export var imageProcessingDeclaration: {
  84751. name: string;
  84752. shader: string;
  84753. };
  84754. }
  84755. declare module BABYLON {
  84756. /** @hidden */
  84757. export var imageProcessingFunctions: {
  84758. name: string;
  84759. shader: string;
  84760. };
  84761. }
  84762. declare module BABYLON {
  84763. /** @hidden */
  84764. export var particlesPixelShader: {
  84765. name: string;
  84766. shader: string;
  84767. };
  84768. }
  84769. declare module BABYLON {
  84770. /** @hidden */
  84771. export var particlesVertexShader: {
  84772. name: string;
  84773. shader: string;
  84774. };
  84775. }
  84776. declare module BABYLON {
  84777. /**
  84778. * This represents a particle system in Babylon.
  84779. * 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.
  84780. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  84781. * @example https://doc.babylonjs.com/babylon101/particles
  84782. */
  84783. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  84784. /**
  84785. * Billboard mode will only apply to Y axis
  84786. */
  84787. static readonly BILLBOARDMODE_Y: number;
  84788. /**
  84789. * Billboard mode will apply to all axes
  84790. */
  84791. static readonly BILLBOARDMODE_ALL: number;
  84792. /**
  84793. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  84794. */
  84795. static readonly BILLBOARDMODE_STRETCHED: number;
  84796. /**
  84797. * This function can be defined to provide custom update for active particles.
  84798. * This function will be called instead of regular update (age, position, color, etc.).
  84799. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  84800. */
  84801. updateFunction: (particles: Particle[]) => void;
  84802. private _emitterWorldMatrix;
  84803. /**
  84804. * This function can be defined to specify initial direction for every new particle.
  84805. * It by default use the emitterType defined function
  84806. */
  84807. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  84808. /**
  84809. * This function can be defined to specify initial position for every new particle.
  84810. * It by default use the emitterType defined function
  84811. */
  84812. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  84813. /**
  84814. * @hidden
  84815. */
  84816. _inheritedVelocityOffset: Vector3;
  84817. /**
  84818. * An event triggered when the system is disposed
  84819. */
  84820. onDisposeObservable: Observable<ParticleSystem>;
  84821. private _onDisposeObserver;
  84822. /**
  84823. * Sets a callback that will be triggered when the system is disposed
  84824. */
  84825. set onDispose(callback: () => void);
  84826. private _particles;
  84827. private _epsilon;
  84828. private _capacity;
  84829. private _stockParticles;
  84830. private _newPartsExcess;
  84831. private _vertexData;
  84832. private _vertexBuffer;
  84833. private _vertexBuffers;
  84834. private _spriteBuffer;
  84835. private _indexBuffer;
  84836. private _effect;
  84837. private _customEffect;
  84838. private _cachedDefines;
  84839. private _scaledColorStep;
  84840. private _colorDiff;
  84841. private _scaledDirection;
  84842. private _scaledGravity;
  84843. private _currentRenderId;
  84844. private _alive;
  84845. private _useInstancing;
  84846. private _started;
  84847. private _stopped;
  84848. private _actualFrame;
  84849. private _scaledUpdateSpeed;
  84850. private _vertexBufferSize;
  84851. /** @hidden */
  84852. _currentEmitRateGradient: Nullable<FactorGradient>;
  84853. /** @hidden */
  84854. _currentEmitRate1: number;
  84855. /** @hidden */
  84856. _currentEmitRate2: number;
  84857. /** @hidden */
  84858. _currentStartSizeGradient: Nullable<FactorGradient>;
  84859. /** @hidden */
  84860. _currentStartSize1: number;
  84861. /** @hidden */
  84862. _currentStartSize2: number;
  84863. private readonly _rawTextureWidth;
  84864. private _rampGradientsTexture;
  84865. private _useRampGradients;
  84866. /** Gets or sets a boolean indicating that ramp gradients must be used
  84867. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  84868. */
  84869. get useRampGradients(): boolean;
  84870. set useRampGradients(value: boolean);
  84871. /**
  84872. * 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.
  84873. * 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: [])
  84874. */
  84875. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  84876. private _subEmitters;
  84877. /**
  84878. * @hidden
  84879. * If the particle systems emitter should be disposed when the particle system is disposed
  84880. */
  84881. _disposeEmitterOnDispose: boolean;
  84882. /**
  84883. * The current active Sub-systems, this property is used by the root particle system only.
  84884. */
  84885. activeSubSystems: Array<ParticleSystem>;
  84886. private _rootParticleSystem;
  84887. /**
  84888. * Gets the current list of active particles
  84889. */
  84890. get particles(): Particle[];
  84891. /**
  84892. * Returns the string "ParticleSystem"
  84893. * @returns a string containing the class name
  84894. */
  84895. getClassName(): string;
  84896. /**
  84897. * Instantiates a particle system.
  84898. * 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.
  84899. * @param name The name of the particle system
  84900. * @param capacity The max number of particles alive at the same time
  84901. * @param scene The scene the particle system belongs to
  84902. * @param customEffect a custom effect used to change the way particles are rendered by default
  84903. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  84904. * @param epsilon Offset used to render the particles
  84905. */
  84906. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  84907. private _addFactorGradient;
  84908. private _removeFactorGradient;
  84909. /**
  84910. * Adds a new life time gradient
  84911. * @param gradient defines the gradient to use (between 0 and 1)
  84912. * @param factor defines the life time factor to affect to the specified gradient
  84913. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84914. * @returns the current particle system
  84915. */
  84916. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84917. /**
  84918. * Remove a specific life time gradient
  84919. * @param gradient defines the gradient to remove
  84920. * @returns the current particle system
  84921. */
  84922. removeLifeTimeGradient(gradient: number): IParticleSystem;
  84923. /**
  84924. * Adds a new size gradient
  84925. * @param gradient defines the gradient to use (between 0 and 1)
  84926. * @param factor defines the size factor to affect to the specified gradient
  84927. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84928. * @returns the current particle system
  84929. */
  84930. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84931. /**
  84932. * Remove a specific size gradient
  84933. * @param gradient defines the gradient to remove
  84934. * @returns the current particle system
  84935. */
  84936. removeSizeGradient(gradient: number): IParticleSystem;
  84937. /**
  84938. * Adds a new color remap gradient
  84939. * @param gradient defines the gradient to use (between 0 and 1)
  84940. * @param min defines the color remap minimal range
  84941. * @param max defines the color remap maximal range
  84942. * @returns the current particle system
  84943. */
  84944. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84945. /**
  84946. * Remove a specific color remap gradient
  84947. * @param gradient defines the gradient to remove
  84948. * @returns the current particle system
  84949. */
  84950. removeColorRemapGradient(gradient: number): IParticleSystem;
  84951. /**
  84952. * Adds a new alpha remap gradient
  84953. * @param gradient defines the gradient to use (between 0 and 1)
  84954. * @param min defines the alpha remap minimal range
  84955. * @param max defines the alpha remap maximal range
  84956. * @returns the current particle system
  84957. */
  84958. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84959. /**
  84960. * Remove a specific alpha remap gradient
  84961. * @param gradient defines the gradient to remove
  84962. * @returns the current particle system
  84963. */
  84964. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  84965. /**
  84966. * Adds a new angular speed gradient
  84967. * @param gradient defines the gradient to use (between 0 and 1)
  84968. * @param factor defines the angular speed to affect to the specified gradient
  84969. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84970. * @returns the current particle system
  84971. */
  84972. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84973. /**
  84974. * Remove a specific angular speed gradient
  84975. * @param gradient defines the gradient to remove
  84976. * @returns the current particle system
  84977. */
  84978. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  84979. /**
  84980. * Adds a new velocity gradient
  84981. * @param gradient defines the gradient to use (between 0 and 1)
  84982. * @param factor defines the velocity to affect to the specified gradient
  84983. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84984. * @returns the current particle system
  84985. */
  84986. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84987. /**
  84988. * Remove a specific velocity gradient
  84989. * @param gradient defines the gradient to remove
  84990. * @returns the current particle system
  84991. */
  84992. removeVelocityGradient(gradient: number): IParticleSystem;
  84993. /**
  84994. * Adds a new limit velocity gradient
  84995. * @param gradient defines the gradient to use (between 0 and 1)
  84996. * @param factor defines the limit velocity value to affect to the specified gradient
  84997. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84998. * @returns the current particle system
  84999. */
  85000. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85001. /**
  85002. * Remove a specific limit velocity gradient
  85003. * @param gradient defines the gradient to remove
  85004. * @returns the current particle system
  85005. */
  85006. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  85007. /**
  85008. * Adds a new drag gradient
  85009. * @param gradient defines the gradient to use (between 0 and 1)
  85010. * @param factor defines the drag value to affect to the specified gradient
  85011. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85012. * @returns the current particle system
  85013. */
  85014. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85015. /**
  85016. * Remove a specific drag gradient
  85017. * @param gradient defines the gradient to remove
  85018. * @returns the current particle system
  85019. */
  85020. removeDragGradient(gradient: number): IParticleSystem;
  85021. /**
  85022. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  85023. * @param gradient defines the gradient to use (between 0 and 1)
  85024. * @param factor defines the emit rate value to affect to the specified gradient
  85025. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85026. * @returns the current particle system
  85027. */
  85028. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85029. /**
  85030. * Remove a specific emit rate gradient
  85031. * @param gradient defines the gradient to remove
  85032. * @returns the current particle system
  85033. */
  85034. removeEmitRateGradient(gradient: number): IParticleSystem;
  85035. /**
  85036. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  85037. * @param gradient defines the gradient to use (between 0 and 1)
  85038. * @param factor defines the start size value to affect to the specified gradient
  85039. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85040. * @returns the current particle system
  85041. */
  85042. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85043. /**
  85044. * Remove a specific start size gradient
  85045. * @param gradient defines the gradient to remove
  85046. * @returns the current particle system
  85047. */
  85048. removeStartSizeGradient(gradient: number): IParticleSystem;
  85049. private _createRampGradientTexture;
  85050. /**
  85051. * Gets the current list of ramp gradients.
  85052. * You must use addRampGradient and removeRampGradient to udpate this list
  85053. * @returns the list of ramp gradients
  85054. */
  85055. getRampGradients(): Nullable<Array<Color3Gradient>>;
  85056. /**
  85057. * Adds a new ramp gradient used to remap particle colors
  85058. * @param gradient defines the gradient to use (between 0 and 1)
  85059. * @param color defines the color to affect to the specified gradient
  85060. * @returns the current particle system
  85061. */
  85062. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  85063. /**
  85064. * Remove a specific ramp gradient
  85065. * @param gradient defines the gradient to remove
  85066. * @returns the current particle system
  85067. */
  85068. removeRampGradient(gradient: number): ParticleSystem;
  85069. /**
  85070. * Adds a new color gradient
  85071. * @param gradient defines the gradient to use (between 0 and 1)
  85072. * @param color1 defines the color to affect to the specified gradient
  85073. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  85074. * @returns this particle system
  85075. */
  85076. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  85077. /**
  85078. * Remove a specific color gradient
  85079. * @param gradient defines the gradient to remove
  85080. * @returns this particle system
  85081. */
  85082. removeColorGradient(gradient: number): IParticleSystem;
  85083. private _fetchR;
  85084. protected _reset(): void;
  85085. private _resetEffect;
  85086. private _createVertexBuffers;
  85087. private _createIndexBuffer;
  85088. /**
  85089. * Gets the maximum number of particles active at the same time.
  85090. * @returns The max number of active particles.
  85091. */
  85092. getCapacity(): number;
  85093. /**
  85094. * Gets whether there are still active particles in the system.
  85095. * @returns True if it is alive, otherwise false.
  85096. */
  85097. isAlive(): boolean;
  85098. /**
  85099. * Gets if the system has been started. (Note: this will still be true after stop is called)
  85100. * @returns True if it has been started, otherwise false.
  85101. */
  85102. isStarted(): boolean;
  85103. private _prepareSubEmitterInternalArray;
  85104. /**
  85105. * Starts the particle system and begins to emit
  85106. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  85107. */
  85108. start(delay?: number): void;
  85109. /**
  85110. * Stops the particle system.
  85111. * @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.
  85112. */
  85113. stop(stopSubEmitters?: boolean): void;
  85114. /**
  85115. * Remove all active particles
  85116. */
  85117. reset(): void;
  85118. /**
  85119. * @hidden (for internal use only)
  85120. */
  85121. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  85122. /**
  85123. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  85124. * Its lifetime will start back at 0.
  85125. */
  85126. recycleParticle: (particle: Particle) => void;
  85127. private _stopSubEmitters;
  85128. private _createParticle;
  85129. private _removeFromRoot;
  85130. private _emitFromParticle;
  85131. private _update;
  85132. /** @hidden */
  85133. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  85134. /** @hidden */
  85135. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  85136. /** @hidden */
  85137. private _getEffect;
  85138. /**
  85139. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  85140. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  85141. */
  85142. animate(preWarmOnly?: boolean): void;
  85143. private _appendParticleVertices;
  85144. /**
  85145. * Rebuilds the particle system.
  85146. */
  85147. rebuild(): void;
  85148. /**
  85149. * Is this system ready to be used/rendered
  85150. * @return true if the system is ready
  85151. */
  85152. isReady(): boolean;
  85153. private _render;
  85154. /**
  85155. * Renders the particle system in its current state.
  85156. * @returns the current number of particles
  85157. */
  85158. render(): number;
  85159. /**
  85160. * Disposes the particle system and free the associated resources
  85161. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  85162. */
  85163. dispose(disposeTexture?: boolean): void;
  85164. /**
  85165. * Clones the particle system.
  85166. * @param name The name of the cloned object
  85167. * @param newEmitter The new emitter to use
  85168. * @returns the cloned particle system
  85169. */
  85170. clone(name: string, newEmitter: any): ParticleSystem;
  85171. /**
  85172. * Serializes the particle system to a JSON object.
  85173. * @returns the JSON object
  85174. */
  85175. serialize(): any;
  85176. /** @hidden */
  85177. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  85178. /** @hidden */
  85179. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  85180. /**
  85181. * Parses a JSON object to create a particle system.
  85182. * @param parsedParticleSystem The JSON object to parse
  85183. * @param scene The scene to create the particle system in
  85184. * @param rootUrl The root url to use to load external dependencies like texture
  85185. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  85186. * @returns the Parsed particle system
  85187. */
  85188. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  85189. }
  85190. }
  85191. declare module BABYLON {
  85192. /**
  85193. * A particle represents one of the element emitted by a particle system.
  85194. * This is mainly define by its coordinates, direction, velocity and age.
  85195. */
  85196. export class Particle {
  85197. /**
  85198. * The particle system the particle belongs to.
  85199. */
  85200. particleSystem: ParticleSystem;
  85201. private static _Count;
  85202. /**
  85203. * Unique ID of the particle
  85204. */
  85205. id: number;
  85206. /**
  85207. * The world position of the particle in the scene.
  85208. */
  85209. position: Vector3;
  85210. /**
  85211. * The world direction of the particle in the scene.
  85212. */
  85213. direction: Vector3;
  85214. /**
  85215. * The color of the particle.
  85216. */
  85217. color: Color4;
  85218. /**
  85219. * The color change of the particle per step.
  85220. */
  85221. colorStep: Color4;
  85222. /**
  85223. * Defines how long will the life of the particle be.
  85224. */
  85225. lifeTime: number;
  85226. /**
  85227. * The current age of the particle.
  85228. */
  85229. age: number;
  85230. /**
  85231. * The current size of the particle.
  85232. */
  85233. size: number;
  85234. /**
  85235. * The current scale of the particle.
  85236. */
  85237. scale: Vector2;
  85238. /**
  85239. * The current angle of the particle.
  85240. */
  85241. angle: number;
  85242. /**
  85243. * Defines how fast is the angle changing.
  85244. */
  85245. angularSpeed: number;
  85246. /**
  85247. * Defines the cell index used by the particle to be rendered from a sprite.
  85248. */
  85249. cellIndex: number;
  85250. /**
  85251. * The information required to support color remapping
  85252. */
  85253. remapData: Vector4;
  85254. /** @hidden */
  85255. _randomCellOffset?: number;
  85256. /** @hidden */
  85257. _initialDirection: Nullable<Vector3>;
  85258. /** @hidden */
  85259. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  85260. /** @hidden */
  85261. _initialStartSpriteCellID: number;
  85262. /** @hidden */
  85263. _initialEndSpriteCellID: number;
  85264. /** @hidden */
  85265. _currentColorGradient: Nullable<ColorGradient>;
  85266. /** @hidden */
  85267. _currentColor1: Color4;
  85268. /** @hidden */
  85269. _currentColor2: Color4;
  85270. /** @hidden */
  85271. _currentSizeGradient: Nullable<FactorGradient>;
  85272. /** @hidden */
  85273. _currentSize1: number;
  85274. /** @hidden */
  85275. _currentSize2: number;
  85276. /** @hidden */
  85277. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  85278. /** @hidden */
  85279. _currentAngularSpeed1: number;
  85280. /** @hidden */
  85281. _currentAngularSpeed2: number;
  85282. /** @hidden */
  85283. _currentVelocityGradient: Nullable<FactorGradient>;
  85284. /** @hidden */
  85285. _currentVelocity1: number;
  85286. /** @hidden */
  85287. _currentVelocity2: number;
  85288. /** @hidden */
  85289. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  85290. /** @hidden */
  85291. _currentLimitVelocity1: number;
  85292. /** @hidden */
  85293. _currentLimitVelocity2: number;
  85294. /** @hidden */
  85295. _currentDragGradient: Nullable<FactorGradient>;
  85296. /** @hidden */
  85297. _currentDrag1: number;
  85298. /** @hidden */
  85299. _currentDrag2: number;
  85300. /** @hidden */
  85301. _randomNoiseCoordinates1: Vector3;
  85302. /** @hidden */
  85303. _randomNoiseCoordinates2: Vector3;
  85304. /**
  85305. * Creates a new instance Particle
  85306. * @param particleSystem the particle system the particle belongs to
  85307. */
  85308. constructor(
  85309. /**
  85310. * The particle system the particle belongs to.
  85311. */
  85312. particleSystem: ParticleSystem);
  85313. private updateCellInfoFromSystem;
  85314. /**
  85315. * Defines how the sprite cell index is updated for the particle
  85316. */
  85317. updateCellIndex(): void;
  85318. /** @hidden */
  85319. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  85320. /** @hidden */
  85321. _inheritParticleInfoToSubEmitters(): void;
  85322. /** @hidden */
  85323. _reset(): void;
  85324. /**
  85325. * Copy the properties of particle to another one.
  85326. * @param other the particle to copy the information to.
  85327. */
  85328. copyTo(other: Particle): void;
  85329. }
  85330. }
  85331. declare module BABYLON {
  85332. /**
  85333. * Particle emitter represents a volume emitting particles.
  85334. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  85335. */
  85336. export interface IParticleEmitterType {
  85337. /**
  85338. * Called by the particle System when the direction is computed for the created particle.
  85339. * @param worldMatrix is the world matrix of the particle system
  85340. * @param directionToUpdate is the direction vector to update with the result
  85341. * @param particle is the particle we are computed the direction for
  85342. */
  85343. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85344. /**
  85345. * Called by the particle System when the position is computed for the created particle.
  85346. * @param worldMatrix is the world matrix of the particle system
  85347. * @param positionToUpdate is the position vector to update with the result
  85348. * @param particle is the particle we are computed the position for
  85349. */
  85350. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85351. /**
  85352. * Clones the current emitter and returns a copy of it
  85353. * @returns the new emitter
  85354. */
  85355. clone(): IParticleEmitterType;
  85356. /**
  85357. * Called by the GPUParticleSystem to setup the update shader
  85358. * @param effect defines the update shader
  85359. */
  85360. applyToShader(effect: Effect): void;
  85361. /**
  85362. * Returns a string to use to update the GPU particles update shader
  85363. * @returns the effect defines string
  85364. */
  85365. getEffectDefines(): string;
  85366. /**
  85367. * Returns a string representing the class name
  85368. * @returns a string containing the class name
  85369. */
  85370. getClassName(): string;
  85371. /**
  85372. * Serializes the particle system to a JSON object.
  85373. * @returns the JSON object
  85374. */
  85375. serialize(): any;
  85376. /**
  85377. * Parse properties from a JSON object
  85378. * @param serializationObject defines the JSON object
  85379. * @param scene defines the hosting scene
  85380. */
  85381. parse(serializationObject: any, scene: Scene): void;
  85382. }
  85383. }
  85384. declare module BABYLON {
  85385. /**
  85386. * Particle emitter emitting particles from the inside of a box.
  85387. * It emits the particles randomly between 2 given directions.
  85388. */
  85389. export class BoxParticleEmitter implements IParticleEmitterType {
  85390. /**
  85391. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85392. */
  85393. direction1: Vector3;
  85394. /**
  85395. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85396. */
  85397. direction2: Vector3;
  85398. /**
  85399. * 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.
  85400. */
  85401. minEmitBox: Vector3;
  85402. /**
  85403. * 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.
  85404. */
  85405. maxEmitBox: Vector3;
  85406. /**
  85407. * Creates a new instance BoxParticleEmitter
  85408. */
  85409. constructor();
  85410. /**
  85411. * Called by the particle System when the direction is computed for the created particle.
  85412. * @param worldMatrix is the world matrix of the particle system
  85413. * @param directionToUpdate is the direction vector to update with the result
  85414. * @param particle is the particle we are computed the direction for
  85415. */
  85416. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85417. /**
  85418. * Called by the particle System when the position is computed for the created particle.
  85419. * @param worldMatrix is the world matrix of the particle system
  85420. * @param positionToUpdate is the position vector to update with the result
  85421. * @param particle is the particle we are computed the position for
  85422. */
  85423. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85424. /**
  85425. * Clones the current emitter and returns a copy of it
  85426. * @returns the new emitter
  85427. */
  85428. clone(): BoxParticleEmitter;
  85429. /**
  85430. * Called by the GPUParticleSystem to setup the update shader
  85431. * @param effect defines the update shader
  85432. */
  85433. applyToShader(effect: Effect): void;
  85434. /**
  85435. * Returns a string to use to update the GPU particles update shader
  85436. * @returns a string containng the defines string
  85437. */
  85438. getEffectDefines(): string;
  85439. /**
  85440. * Returns the string "BoxParticleEmitter"
  85441. * @returns a string containing the class name
  85442. */
  85443. getClassName(): string;
  85444. /**
  85445. * Serializes the particle system to a JSON object.
  85446. * @returns the JSON object
  85447. */
  85448. serialize(): any;
  85449. /**
  85450. * Parse properties from a JSON object
  85451. * @param serializationObject defines the JSON object
  85452. */
  85453. parse(serializationObject: any): void;
  85454. }
  85455. }
  85456. declare module BABYLON {
  85457. /**
  85458. * Particle emitter emitting particles from the inside of a cone.
  85459. * It emits the particles alongside the cone volume from the base to the particle.
  85460. * The emission direction might be randomized.
  85461. */
  85462. export class ConeParticleEmitter implements IParticleEmitterType {
  85463. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  85464. directionRandomizer: number;
  85465. private _radius;
  85466. private _angle;
  85467. private _height;
  85468. /**
  85469. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  85470. */
  85471. radiusRange: number;
  85472. /**
  85473. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  85474. */
  85475. heightRange: number;
  85476. /**
  85477. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  85478. */
  85479. emitFromSpawnPointOnly: boolean;
  85480. /**
  85481. * Gets or sets the radius of the emission cone
  85482. */
  85483. get radius(): number;
  85484. set radius(value: number);
  85485. /**
  85486. * Gets or sets the angle of the emission cone
  85487. */
  85488. get angle(): number;
  85489. set angle(value: number);
  85490. private _buildHeight;
  85491. /**
  85492. * Creates a new instance ConeParticleEmitter
  85493. * @param radius the radius of the emission cone (1 by default)
  85494. * @param angle the cone base angle (PI by default)
  85495. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  85496. */
  85497. constructor(radius?: number, angle?: number,
  85498. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  85499. directionRandomizer?: number);
  85500. /**
  85501. * Called by the particle System when the direction is computed for the created particle.
  85502. * @param worldMatrix is the world matrix of the particle system
  85503. * @param directionToUpdate is the direction vector to update with the result
  85504. * @param particle is the particle we are computed the direction for
  85505. */
  85506. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85507. /**
  85508. * Called by the particle System when the position is computed for the created particle.
  85509. * @param worldMatrix is the world matrix of the particle system
  85510. * @param positionToUpdate is the position vector to update with the result
  85511. * @param particle is the particle we are computed the position for
  85512. */
  85513. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85514. /**
  85515. * Clones the current emitter and returns a copy of it
  85516. * @returns the new emitter
  85517. */
  85518. clone(): ConeParticleEmitter;
  85519. /**
  85520. * Called by the GPUParticleSystem to setup the update shader
  85521. * @param effect defines the update shader
  85522. */
  85523. applyToShader(effect: Effect): void;
  85524. /**
  85525. * Returns a string to use to update the GPU particles update shader
  85526. * @returns a string containng the defines string
  85527. */
  85528. getEffectDefines(): string;
  85529. /**
  85530. * Returns the string "ConeParticleEmitter"
  85531. * @returns a string containing the class name
  85532. */
  85533. getClassName(): string;
  85534. /**
  85535. * Serializes the particle system to a JSON object.
  85536. * @returns the JSON object
  85537. */
  85538. serialize(): any;
  85539. /**
  85540. * Parse properties from a JSON object
  85541. * @param serializationObject defines the JSON object
  85542. */
  85543. parse(serializationObject: any): void;
  85544. }
  85545. }
  85546. declare module BABYLON {
  85547. /**
  85548. * Particle emitter emitting particles from the inside of a cylinder.
  85549. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  85550. */
  85551. export class CylinderParticleEmitter implements IParticleEmitterType {
  85552. /**
  85553. * The radius of the emission cylinder.
  85554. */
  85555. radius: number;
  85556. /**
  85557. * The height of the emission cylinder.
  85558. */
  85559. height: number;
  85560. /**
  85561. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85562. */
  85563. radiusRange: number;
  85564. /**
  85565. * How much to randomize the particle direction [0-1].
  85566. */
  85567. directionRandomizer: number;
  85568. /**
  85569. * Creates a new instance CylinderParticleEmitter
  85570. * @param radius the radius of the emission cylinder (1 by default)
  85571. * @param height the height of the emission cylinder (1 by default)
  85572. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85573. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85574. */
  85575. constructor(
  85576. /**
  85577. * The radius of the emission cylinder.
  85578. */
  85579. radius?: number,
  85580. /**
  85581. * The height of the emission cylinder.
  85582. */
  85583. height?: number,
  85584. /**
  85585. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85586. */
  85587. radiusRange?: number,
  85588. /**
  85589. * How much to randomize the particle direction [0-1].
  85590. */
  85591. directionRandomizer?: number);
  85592. /**
  85593. * Called by the particle System when the direction is computed for the created particle.
  85594. * @param worldMatrix is the world matrix of the particle system
  85595. * @param directionToUpdate is the direction vector to update with the result
  85596. * @param particle is the particle we are computed the direction for
  85597. */
  85598. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85599. /**
  85600. * Called by the particle System when the position is computed for the created particle.
  85601. * @param worldMatrix is the world matrix of the particle system
  85602. * @param positionToUpdate is the position vector to update with the result
  85603. * @param particle is the particle we are computed the position for
  85604. */
  85605. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85606. /**
  85607. * Clones the current emitter and returns a copy of it
  85608. * @returns the new emitter
  85609. */
  85610. clone(): CylinderParticleEmitter;
  85611. /**
  85612. * Called by the GPUParticleSystem to setup the update shader
  85613. * @param effect defines the update shader
  85614. */
  85615. applyToShader(effect: Effect): void;
  85616. /**
  85617. * Returns a string to use to update the GPU particles update shader
  85618. * @returns a string containng the defines string
  85619. */
  85620. getEffectDefines(): string;
  85621. /**
  85622. * Returns the string "CylinderParticleEmitter"
  85623. * @returns a string containing the class name
  85624. */
  85625. getClassName(): string;
  85626. /**
  85627. * Serializes the particle system to a JSON object.
  85628. * @returns the JSON object
  85629. */
  85630. serialize(): any;
  85631. /**
  85632. * Parse properties from a JSON object
  85633. * @param serializationObject defines the JSON object
  85634. */
  85635. parse(serializationObject: any): void;
  85636. }
  85637. /**
  85638. * Particle emitter emitting particles from the inside of a cylinder.
  85639. * It emits the particles randomly between two vectors.
  85640. */
  85641. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  85642. /**
  85643. * The min limit of the emission direction.
  85644. */
  85645. direction1: Vector3;
  85646. /**
  85647. * The max limit of the emission direction.
  85648. */
  85649. direction2: Vector3;
  85650. /**
  85651. * Creates a new instance CylinderDirectedParticleEmitter
  85652. * @param radius the radius of the emission cylinder (1 by default)
  85653. * @param height the height of the emission cylinder (1 by default)
  85654. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85655. * @param direction1 the min limit of the emission direction (up vector by default)
  85656. * @param direction2 the max limit of the emission direction (up vector by default)
  85657. */
  85658. constructor(radius?: number, height?: number, radiusRange?: number,
  85659. /**
  85660. * The min limit of the emission direction.
  85661. */
  85662. direction1?: Vector3,
  85663. /**
  85664. * The max limit of the emission direction.
  85665. */
  85666. direction2?: Vector3);
  85667. /**
  85668. * Called by the particle System when the direction is computed for the created particle.
  85669. * @param worldMatrix is the world matrix of the particle system
  85670. * @param directionToUpdate is the direction vector to update with the result
  85671. * @param particle is the particle we are computed the direction for
  85672. */
  85673. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85674. /**
  85675. * Clones the current emitter and returns a copy of it
  85676. * @returns the new emitter
  85677. */
  85678. clone(): CylinderDirectedParticleEmitter;
  85679. /**
  85680. * Called by the GPUParticleSystem to setup the update shader
  85681. * @param effect defines the update shader
  85682. */
  85683. applyToShader(effect: Effect): void;
  85684. /**
  85685. * Returns a string to use to update the GPU particles update shader
  85686. * @returns a string containng the defines string
  85687. */
  85688. getEffectDefines(): string;
  85689. /**
  85690. * Returns the string "CylinderDirectedParticleEmitter"
  85691. * @returns a string containing the class name
  85692. */
  85693. getClassName(): string;
  85694. /**
  85695. * Serializes the particle system to a JSON object.
  85696. * @returns the JSON object
  85697. */
  85698. serialize(): any;
  85699. /**
  85700. * Parse properties from a JSON object
  85701. * @param serializationObject defines the JSON object
  85702. */
  85703. parse(serializationObject: any): void;
  85704. }
  85705. }
  85706. declare module BABYLON {
  85707. /**
  85708. * Particle emitter emitting particles from the inside of a hemisphere.
  85709. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  85710. */
  85711. export class HemisphericParticleEmitter implements IParticleEmitterType {
  85712. /**
  85713. * The radius of the emission hemisphere.
  85714. */
  85715. radius: number;
  85716. /**
  85717. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85718. */
  85719. radiusRange: number;
  85720. /**
  85721. * How much to randomize the particle direction [0-1].
  85722. */
  85723. directionRandomizer: number;
  85724. /**
  85725. * Creates a new instance HemisphericParticleEmitter
  85726. * @param radius the radius of the emission hemisphere (1 by default)
  85727. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85728. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85729. */
  85730. constructor(
  85731. /**
  85732. * The radius of the emission hemisphere.
  85733. */
  85734. radius?: number,
  85735. /**
  85736. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85737. */
  85738. radiusRange?: number,
  85739. /**
  85740. * How much to randomize the particle direction [0-1].
  85741. */
  85742. directionRandomizer?: number);
  85743. /**
  85744. * Called by the particle System when the direction is computed for the created particle.
  85745. * @param worldMatrix is the world matrix of the particle system
  85746. * @param directionToUpdate is the direction vector to update with the result
  85747. * @param particle is the particle we are computed the direction for
  85748. */
  85749. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85750. /**
  85751. * Called by the particle System when the position is computed for the created particle.
  85752. * @param worldMatrix is the world matrix of the particle system
  85753. * @param positionToUpdate is the position vector to update with the result
  85754. * @param particle is the particle we are computed the position for
  85755. */
  85756. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85757. /**
  85758. * Clones the current emitter and returns a copy of it
  85759. * @returns the new emitter
  85760. */
  85761. clone(): HemisphericParticleEmitter;
  85762. /**
  85763. * Called by the GPUParticleSystem to setup the update shader
  85764. * @param effect defines the update shader
  85765. */
  85766. applyToShader(effect: Effect): void;
  85767. /**
  85768. * Returns a string to use to update the GPU particles update shader
  85769. * @returns a string containng the defines string
  85770. */
  85771. getEffectDefines(): string;
  85772. /**
  85773. * Returns the string "HemisphericParticleEmitter"
  85774. * @returns a string containing the class name
  85775. */
  85776. getClassName(): string;
  85777. /**
  85778. * Serializes the particle system to a JSON object.
  85779. * @returns the JSON object
  85780. */
  85781. serialize(): any;
  85782. /**
  85783. * Parse properties from a JSON object
  85784. * @param serializationObject defines the JSON object
  85785. */
  85786. parse(serializationObject: any): void;
  85787. }
  85788. }
  85789. declare module BABYLON {
  85790. /**
  85791. * Particle emitter emitting particles from a point.
  85792. * It emits the particles randomly between 2 given directions.
  85793. */
  85794. export class PointParticleEmitter implements IParticleEmitterType {
  85795. /**
  85796. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85797. */
  85798. direction1: Vector3;
  85799. /**
  85800. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85801. */
  85802. direction2: Vector3;
  85803. /**
  85804. * Creates a new instance PointParticleEmitter
  85805. */
  85806. constructor();
  85807. /**
  85808. * Called by the particle System when the direction is computed for the created particle.
  85809. * @param worldMatrix is the world matrix of the particle system
  85810. * @param directionToUpdate is the direction vector to update with the result
  85811. * @param particle is the particle we are computed the direction for
  85812. */
  85813. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85814. /**
  85815. * Called by the particle System when the position is computed for the created particle.
  85816. * @param worldMatrix is the world matrix of the particle system
  85817. * @param positionToUpdate is the position vector to update with the result
  85818. * @param particle is the particle we are computed the position for
  85819. */
  85820. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85821. /**
  85822. * Clones the current emitter and returns a copy of it
  85823. * @returns the new emitter
  85824. */
  85825. clone(): PointParticleEmitter;
  85826. /**
  85827. * Called by the GPUParticleSystem to setup the update shader
  85828. * @param effect defines the update shader
  85829. */
  85830. applyToShader(effect: Effect): void;
  85831. /**
  85832. * Returns a string to use to update the GPU particles update shader
  85833. * @returns a string containng the defines string
  85834. */
  85835. getEffectDefines(): string;
  85836. /**
  85837. * Returns the string "PointParticleEmitter"
  85838. * @returns a string containing the class name
  85839. */
  85840. getClassName(): string;
  85841. /**
  85842. * Serializes the particle system to a JSON object.
  85843. * @returns the JSON object
  85844. */
  85845. serialize(): any;
  85846. /**
  85847. * Parse properties from a JSON object
  85848. * @param serializationObject defines the JSON object
  85849. */
  85850. parse(serializationObject: any): void;
  85851. }
  85852. }
  85853. declare module BABYLON {
  85854. /**
  85855. * Particle emitter emitting particles from the inside of a sphere.
  85856. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  85857. */
  85858. export class SphereParticleEmitter implements IParticleEmitterType {
  85859. /**
  85860. * The radius of the emission sphere.
  85861. */
  85862. radius: number;
  85863. /**
  85864. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85865. */
  85866. radiusRange: number;
  85867. /**
  85868. * How much to randomize the particle direction [0-1].
  85869. */
  85870. directionRandomizer: number;
  85871. /**
  85872. * Creates a new instance SphereParticleEmitter
  85873. * @param radius the radius of the emission sphere (1 by default)
  85874. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85875. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85876. */
  85877. constructor(
  85878. /**
  85879. * The radius of the emission sphere.
  85880. */
  85881. radius?: number,
  85882. /**
  85883. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85884. */
  85885. radiusRange?: number,
  85886. /**
  85887. * How much to randomize the particle direction [0-1].
  85888. */
  85889. directionRandomizer?: number);
  85890. /**
  85891. * Called by the particle System when the direction is computed for the created particle.
  85892. * @param worldMatrix is the world matrix of the particle system
  85893. * @param directionToUpdate is the direction vector to update with the result
  85894. * @param particle is the particle we are computed the direction for
  85895. */
  85896. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85897. /**
  85898. * Called by the particle System when the position is computed for the created particle.
  85899. * @param worldMatrix is the world matrix of the particle system
  85900. * @param positionToUpdate is the position vector to update with the result
  85901. * @param particle is the particle we are computed the position for
  85902. */
  85903. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85904. /**
  85905. * Clones the current emitter and returns a copy of it
  85906. * @returns the new emitter
  85907. */
  85908. clone(): SphereParticleEmitter;
  85909. /**
  85910. * Called by the GPUParticleSystem to setup the update shader
  85911. * @param effect defines the update shader
  85912. */
  85913. applyToShader(effect: Effect): void;
  85914. /**
  85915. * Returns a string to use to update the GPU particles update shader
  85916. * @returns a string containng the defines string
  85917. */
  85918. getEffectDefines(): string;
  85919. /**
  85920. * Returns the string "SphereParticleEmitter"
  85921. * @returns a string containing the class name
  85922. */
  85923. getClassName(): string;
  85924. /**
  85925. * Serializes the particle system to a JSON object.
  85926. * @returns the JSON object
  85927. */
  85928. serialize(): any;
  85929. /**
  85930. * Parse properties from a JSON object
  85931. * @param serializationObject defines the JSON object
  85932. */
  85933. parse(serializationObject: any): void;
  85934. }
  85935. /**
  85936. * Particle emitter emitting particles from the inside of a sphere.
  85937. * It emits the particles randomly between two vectors.
  85938. */
  85939. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  85940. /**
  85941. * The min limit of the emission direction.
  85942. */
  85943. direction1: Vector3;
  85944. /**
  85945. * The max limit of the emission direction.
  85946. */
  85947. direction2: Vector3;
  85948. /**
  85949. * Creates a new instance SphereDirectedParticleEmitter
  85950. * @param radius the radius of the emission sphere (1 by default)
  85951. * @param direction1 the min limit of the emission direction (up vector by default)
  85952. * @param direction2 the max limit of the emission direction (up vector by default)
  85953. */
  85954. constructor(radius?: number,
  85955. /**
  85956. * The min limit of the emission direction.
  85957. */
  85958. direction1?: Vector3,
  85959. /**
  85960. * The max limit of the emission direction.
  85961. */
  85962. direction2?: Vector3);
  85963. /**
  85964. * Called by the particle System when the direction is computed for the created particle.
  85965. * @param worldMatrix is the world matrix of the particle system
  85966. * @param directionToUpdate is the direction vector to update with the result
  85967. * @param particle is the particle we are computed the direction for
  85968. */
  85969. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85970. /**
  85971. * Clones the current emitter and returns a copy of it
  85972. * @returns the new emitter
  85973. */
  85974. clone(): SphereDirectedParticleEmitter;
  85975. /**
  85976. * Called by the GPUParticleSystem to setup the update shader
  85977. * @param effect defines the update shader
  85978. */
  85979. applyToShader(effect: Effect): void;
  85980. /**
  85981. * Returns a string to use to update the GPU particles update shader
  85982. * @returns a string containng the defines string
  85983. */
  85984. getEffectDefines(): string;
  85985. /**
  85986. * Returns the string "SphereDirectedParticleEmitter"
  85987. * @returns a string containing the class name
  85988. */
  85989. getClassName(): string;
  85990. /**
  85991. * Serializes the particle system to a JSON object.
  85992. * @returns the JSON object
  85993. */
  85994. serialize(): any;
  85995. /**
  85996. * Parse properties from a JSON object
  85997. * @param serializationObject defines the JSON object
  85998. */
  85999. parse(serializationObject: any): void;
  86000. }
  86001. }
  86002. declare module BABYLON {
  86003. /**
  86004. * Particle emitter emitting particles from a custom list of positions.
  86005. */
  86006. export class CustomParticleEmitter implements IParticleEmitterType {
  86007. /**
  86008. * Gets or sets the position generator that will create the inital position of each particle.
  86009. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  86010. */
  86011. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  86012. /**
  86013. * Gets or sets the destination generator that will create the final destination of each particle.
  86014. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  86015. */
  86016. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  86017. /**
  86018. * Creates a new instance CustomParticleEmitter
  86019. */
  86020. constructor();
  86021. /**
  86022. * Called by the particle System when the direction is computed for the created particle.
  86023. * @param worldMatrix is the world matrix of the particle system
  86024. * @param directionToUpdate is the direction vector to update with the result
  86025. * @param particle is the particle we are computed the direction for
  86026. */
  86027. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86028. /**
  86029. * Called by the particle System when the position is computed for the created particle.
  86030. * @param worldMatrix is the world matrix of the particle system
  86031. * @param positionToUpdate is the position vector to update with the result
  86032. * @param particle is the particle we are computed the position for
  86033. */
  86034. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86035. /**
  86036. * Clones the current emitter and returns a copy of it
  86037. * @returns the new emitter
  86038. */
  86039. clone(): CustomParticleEmitter;
  86040. /**
  86041. * Called by the GPUParticleSystem to setup the update shader
  86042. * @param effect defines the update shader
  86043. */
  86044. applyToShader(effect: Effect): void;
  86045. /**
  86046. * Returns a string to use to update the GPU particles update shader
  86047. * @returns a string containng the defines string
  86048. */
  86049. getEffectDefines(): string;
  86050. /**
  86051. * Returns the string "PointParticleEmitter"
  86052. * @returns a string containing the class name
  86053. */
  86054. getClassName(): string;
  86055. /**
  86056. * Serializes the particle system to a JSON object.
  86057. * @returns the JSON object
  86058. */
  86059. serialize(): any;
  86060. /**
  86061. * Parse properties from a JSON object
  86062. * @param serializationObject defines the JSON object
  86063. */
  86064. parse(serializationObject: any): void;
  86065. }
  86066. }
  86067. declare module BABYLON {
  86068. /**
  86069. * Particle emitter emitting particles from the inside of a box.
  86070. * It emits the particles randomly between 2 given directions.
  86071. */
  86072. export class MeshParticleEmitter implements IParticleEmitterType {
  86073. /** Defines the mesh to use as source */
  86074. mesh?: AbstractMesh | undefined;
  86075. private _indices;
  86076. private _positions;
  86077. private _normals;
  86078. private _storedNormal;
  86079. /**
  86080. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86081. */
  86082. direction1: Vector3;
  86083. /**
  86084. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86085. */
  86086. direction2: Vector3;
  86087. /**
  86088. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  86089. */
  86090. useMeshNormalsForDirection: boolean;
  86091. /**
  86092. * Creates a new instance MeshParticleEmitter
  86093. * @param mesh defines the mesh to use as source
  86094. */
  86095. constructor(
  86096. /** Defines the mesh to use as source */
  86097. mesh?: AbstractMesh | undefined);
  86098. /**
  86099. * Called by the particle System when the direction is computed for the created particle.
  86100. * @param worldMatrix is the world matrix of the particle system
  86101. * @param directionToUpdate is the direction vector to update with the result
  86102. * @param particle is the particle we are computed the direction for
  86103. */
  86104. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86105. /**
  86106. * Called by the particle System when the position is computed for the created particle.
  86107. * @param worldMatrix is the world matrix of the particle system
  86108. * @param positionToUpdate is the position vector to update with the result
  86109. * @param particle is the particle we are computed the position for
  86110. */
  86111. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86112. /**
  86113. * Clones the current emitter and returns a copy of it
  86114. * @returns the new emitter
  86115. */
  86116. clone(): MeshParticleEmitter;
  86117. /**
  86118. * Called by the GPUParticleSystem to setup the update shader
  86119. * @param effect defines the update shader
  86120. */
  86121. applyToShader(effect: Effect): void;
  86122. /**
  86123. * Returns a string to use to update the GPU particles update shader
  86124. * @returns a string containng the defines string
  86125. */
  86126. getEffectDefines(): string;
  86127. /**
  86128. * Returns the string "BoxParticleEmitter"
  86129. * @returns a string containing the class name
  86130. */
  86131. getClassName(): string;
  86132. /**
  86133. * Serializes the particle system to a JSON object.
  86134. * @returns the JSON object
  86135. */
  86136. serialize(): any;
  86137. /**
  86138. * Parse properties from a JSON object
  86139. * @param serializationObject defines the JSON object
  86140. * @param scene defines the hosting scene
  86141. */
  86142. parse(serializationObject: any, scene: Scene): void;
  86143. }
  86144. }
  86145. declare module BABYLON {
  86146. /**
  86147. * Interface representing a particle system in Babylon.js.
  86148. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  86149. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  86150. */
  86151. export interface IParticleSystem {
  86152. /**
  86153. * List of animations used by the particle system.
  86154. */
  86155. animations: Animation[];
  86156. /**
  86157. * The id of the Particle system.
  86158. */
  86159. id: string;
  86160. /**
  86161. * The name of the Particle system.
  86162. */
  86163. name: string;
  86164. /**
  86165. * The emitter represents the Mesh or position we are attaching the particle system to.
  86166. */
  86167. emitter: Nullable<AbstractMesh | Vector3>;
  86168. /**
  86169. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  86170. */
  86171. isBillboardBased: boolean;
  86172. /**
  86173. * The rendering group used by the Particle system to chose when to render.
  86174. */
  86175. renderingGroupId: number;
  86176. /**
  86177. * The layer mask we are rendering the particles through.
  86178. */
  86179. layerMask: number;
  86180. /**
  86181. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  86182. */
  86183. updateSpeed: number;
  86184. /**
  86185. * The amount of time the particle system is running (depends of the overall update speed).
  86186. */
  86187. targetStopDuration: number;
  86188. /**
  86189. * The texture used to render each particle. (this can be a spritesheet)
  86190. */
  86191. particleTexture: Nullable<Texture>;
  86192. /**
  86193. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  86194. */
  86195. blendMode: number;
  86196. /**
  86197. * Minimum life time of emitting particles.
  86198. */
  86199. minLifeTime: number;
  86200. /**
  86201. * Maximum life time of emitting particles.
  86202. */
  86203. maxLifeTime: number;
  86204. /**
  86205. * Minimum Size of emitting particles.
  86206. */
  86207. minSize: number;
  86208. /**
  86209. * Maximum Size of emitting particles.
  86210. */
  86211. maxSize: number;
  86212. /**
  86213. * Minimum scale of emitting particles on X axis.
  86214. */
  86215. minScaleX: number;
  86216. /**
  86217. * Maximum scale of emitting particles on X axis.
  86218. */
  86219. maxScaleX: number;
  86220. /**
  86221. * Minimum scale of emitting particles on Y axis.
  86222. */
  86223. minScaleY: number;
  86224. /**
  86225. * Maximum scale of emitting particles on Y axis.
  86226. */
  86227. maxScaleY: number;
  86228. /**
  86229. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86230. */
  86231. color1: Color4;
  86232. /**
  86233. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86234. */
  86235. color2: Color4;
  86236. /**
  86237. * Color the particle will have at the end of its lifetime.
  86238. */
  86239. colorDead: Color4;
  86240. /**
  86241. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  86242. */
  86243. emitRate: number;
  86244. /**
  86245. * You can use gravity if you want to give an orientation to your particles.
  86246. */
  86247. gravity: Vector3;
  86248. /**
  86249. * Minimum power of emitting particles.
  86250. */
  86251. minEmitPower: number;
  86252. /**
  86253. * Maximum power of emitting particles.
  86254. */
  86255. maxEmitPower: number;
  86256. /**
  86257. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  86258. */
  86259. minAngularSpeed: number;
  86260. /**
  86261. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  86262. */
  86263. maxAngularSpeed: number;
  86264. /**
  86265. * Gets or sets the minimal initial rotation in radians.
  86266. */
  86267. minInitialRotation: number;
  86268. /**
  86269. * Gets or sets the maximal initial rotation in radians.
  86270. */
  86271. maxInitialRotation: number;
  86272. /**
  86273. * The particle emitter type defines the emitter used by the particle system.
  86274. * It can be for example box, sphere, or cone...
  86275. */
  86276. particleEmitterType: Nullable<IParticleEmitterType>;
  86277. /**
  86278. * Defines the delay in milliseconds before starting the system (0 by default)
  86279. */
  86280. startDelay: number;
  86281. /**
  86282. * 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
  86283. */
  86284. preWarmCycles: number;
  86285. /**
  86286. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  86287. */
  86288. preWarmStepOffset: number;
  86289. /**
  86290. * 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)
  86291. */
  86292. spriteCellChangeSpeed: number;
  86293. /**
  86294. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  86295. */
  86296. startSpriteCellID: number;
  86297. /**
  86298. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  86299. */
  86300. endSpriteCellID: number;
  86301. /**
  86302. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  86303. */
  86304. spriteCellWidth: number;
  86305. /**
  86306. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  86307. */
  86308. spriteCellHeight: number;
  86309. /**
  86310. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  86311. */
  86312. spriteRandomStartCell: boolean;
  86313. /**
  86314. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  86315. */
  86316. isAnimationSheetEnabled: boolean;
  86317. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  86318. translationPivot: Vector2;
  86319. /**
  86320. * Gets or sets a texture used to add random noise to particle positions
  86321. */
  86322. noiseTexture: Nullable<BaseTexture>;
  86323. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  86324. noiseStrength: Vector3;
  86325. /**
  86326. * Gets or sets the billboard mode to use when isBillboardBased = true.
  86327. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  86328. */
  86329. billboardMode: number;
  86330. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  86331. limitVelocityDamping: number;
  86332. /**
  86333. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  86334. */
  86335. beginAnimationOnStart: boolean;
  86336. /**
  86337. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  86338. */
  86339. beginAnimationFrom: number;
  86340. /**
  86341. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  86342. */
  86343. beginAnimationTo: number;
  86344. /**
  86345. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  86346. */
  86347. beginAnimationLoop: boolean;
  86348. /**
  86349. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  86350. */
  86351. disposeOnStop: boolean;
  86352. /**
  86353. * Gets the maximum number of particles active at the same time.
  86354. * @returns The max number of active particles.
  86355. */
  86356. getCapacity(): number;
  86357. /**
  86358. * Gets if the system has been started. (Note: this will still be true after stop is called)
  86359. * @returns True if it has been started, otherwise false.
  86360. */
  86361. isStarted(): boolean;
  86362. /**
  86363. * Animates the particle system for this frame.
  86364. */
  86365. animate(): void;
  86366. /**
  86367. * Renders the particle system in its current state.
  86368. * @returns the current number of particles
  86369. */
  86370. render(): number;
  86371. /**
  86372. * Dispose the particle system and frees its associated resources.
  86373. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  86374. */
  86375. dispose(disposeTexture?: boolean): void;
  86376. /**
  86377. * Clones the particle system.
  86378. * @param name The name of the cloned object
  86379. * @param newEmitter The new emitter to use
  86380. * @returns the cloned particle system
  86381. */
  86382. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  86383. /**
  86384. * Serializes the particle system to a JSON object.
  86385. * @returns the JSON object
  86386. */
  86387. serialize(): any;
  86388. /**
  86389. * Rebuild the particle system
  86390. */
  86391. rebuild(): void;
  86392. /**
  86393. * Starts the particle system and begins to emit
  86394. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  86395. */
  86396. start(delay?: number): void;
  86397. /**
  86398. * Stops the particle system.
  86399. */
  86400. stop(): void;
  86401. /**
  86402. * Remove all active particles
  86403. */
  86404. reset(): void;
  86405. /**
  86406. * Is this system ready to be used/rendered
  86407. * @return true if the system is ready
  86408. */
  86409. isReady(): boolean;
  86410. /**
  86411. * Adds a new color gradient
  86412. * @param gradient defines the gradient to use (between 0 and 1)
  86413. * @param color1 defines the color to affect to the specified gradient
  86414. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  86415. * @returns the current particle system
  86416. */
  86417. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  86418. /**
  86419. * Remove a specific color gradient
  86420. * @param gradient defines the gradient to remove
  86421. * @returns the current particle system
  86422. */
  86423. removeColorGradient(gradient: number): IParticleSystem;
  86424. /**
  86425. * Adds a new size gradient
  86426. * @param gradient defines the gradient to use (between 0 and 1)
  86427. * @param factor defines the size factor to affect to the specified gradient
  86428. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86429. * @returns the current particle system
  86430. */
  86431. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86432. /**
  86433. * Remove a specific size gradient
  86434. * @param gradient defines the gradient to remove
  86435. * @returns the current particle system
  86436. */
  86437. removeSizeGradient(gradient: number): IParticleSystem;
  86438. /**
  86439. * Gets the current list of color gradients.
  86440. * You must use addColorGradient and removeColorGradient to udpate this list
  86441. * @returns the list of color gradients
  86442. */
  86443. getColorGradients(): Nullable<Array<ColorGradient>>;
  86444. /**
  86445. * Gets the current list of size gradients.
  86446. * You must use addSizeGradient and removeSizeGradient to udpate this list
  86447. * @returns the list of size gradients
  86448. */
  86449. getSizeGradients(): Nullable<Array<FactorGradient>>;
  86450. /**
  86451. * Gets the current list of angular speed gradients.
  86452. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  86453. * @returns the list of angular speed gradients
  86454. */
  86455. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  86456. /**
  86457. * Adds a new angular speed gradient
  86458. * @param gradient defines the gradient to use (between 0 and 1)
  86459. * @param factor defines the angular speed to affect to the specified gradient
  86460. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86461. * @returns the current particle system
  86462. */
  86463. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86464. /**
  86465. * Remove a specific angular speed gradient
  86466. * @param gradient defines the gradient to remove
  86467. * @returns the current particle system
  86468. */
  86469. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  86470. /**
  86471. * Gets the current list of velocity gradients.
  86472. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  86473. * @returns the list of velocity gradients
  86474. */
  86475. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  86476. /**
  86477. * Adds a new velocity gradient
  86478. * @param gradient defines the gradient to use (between 0 and 1)
  86479. * @param factor defines the velocity to affect to the specified gradient
  86480. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86481. * @returns the current particle system
  86482. */
  86483. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86484. /**
  86485. * Remove a specific velocity gradient
  86486. * @param gradient defines the gradient to remove
  86487. * @returns the current particle system
  86488. */
  86489. removeVelocityGradient(gradient: number): IParticleSystem;
  86490. /**
  86491. * Gets the current list of limit velocity gradients.
  86492. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  86493. * @returns the list of limit velocity gradients
  86494. */
  86495. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  86496. /**
  86497. * Adds a new limit velocity gradient
  86498. * @param gradient defines the gradient to use (between 0 and 1)
  86499. * @param factor defines the limit velocity to affect to the specified gradient
  86500. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86501. * @returns the current particle system
  86502. */
  86503. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86504. /**
  86505. * Remove a specific limit velocity gradient
  86506. * @param gradient defines the gradient to remove
  86507. * @returns the current particle system
  86508. */
  86509. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  86510. /**
  86511. * Adds a new drag gradient
  86512. * @param gradient defines the gradient to use (between 0 and 1)
  86513. * @param factor defines the drag to affect to the specified gradient
  86514. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86515. * @returns the current particle system
  86516. */
  86517. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86518. /**
  86519. * Remove a specific drag gradient
  86520. * @param gradient defines the gradient to remove
  86521. * @returns the current particle system
  86522. */
  86523. removeDragGradient(gradient: number): IParticleSystem;
  86524. /**
  86525. * Gets the current list of drag gradients.
  86526. * You must use addDragGradient and removeDragGradient to udpate this list
  86527. * @returns the list of drag gradients
  86528. */
  86529. getDragGradients(): Nullable<Array<FactorGradient>>;
  86530. /**
  86531. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  86532. * @param gradient defines the gradient to use (between 0 and 1)
  86533. * @param factor defines the emit rate to affect to the specified gradient
  86534. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86535. * @returns the current particle system
  86536. */
  86537. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86538. /**
  86539. * Remove a specific emit rate gradient
  86540. * @param gradient defines the gradient to remove
  86541. * @returns the current particle system
  86542. */
  86543. removeEmitRateGradient(gradient: number): IParticleSystem;
  86544. /**
  86545. * Gets the current list of emit rate gradients.
  86546. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  86547. * @returns the list of emit rate gradients
  86548. */
  86549. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  86550. /**
  86551. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  86552. * @param gradient defines the gradient to use (between 0 and 1)
  86553. * @param factor defines the start size to affect to the specified gradient
  86554. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86555. * @returns the current particle system
  86556. */
  86557. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86558. /**
  86559. * Remove a specific start size gradient
  86560. * @param gradient defines the gradient to remove
  86561. * @returns the current particle system
  86562. */
  86563. removeStartSizeGradient(gradient: number): IParticleSystem;
  86564. /**
  86565. * Gets the current list of start size gradients.
  86566. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  86567. * @returns the list of start size gradients
  86568. */
  86569. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  86570. /**
  86571. * Adds a new life time gradient
  86572. * @param gradient defines the gradient to use (between 0 and 1)
  86573. * @param factor defines the life time factor to affect to the specified gradient
  86574. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86575. * @returns the current particle system
  86576. */
  86577. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86578. /**
  86579. * Remove a specific life time gradient
  86580. * @param gradient defines the gradient to remove
  86581. * @returns the current particle system
  86582. */
  86583. removeLifeTimeGradient(gradient: number): IParticleSystem;
  86584. /**
  86585. * Gets the current list of life time gradients.
  86586. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  86587. * @returns the list of life time gradients
  86588. */
  86589. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  86590. /**
  86591. * Gets the current list of color gradients.
  86592. * You must use addColorGradient and removeColorGradient to udpate this list
  86593. * @returns the list of color gradients
  86594. */
  86595. getColorGradients(): Nullable<Array<ColorGradient>>;
  86596. /**
  86597. * Adds a new ramp gradient used to remap particle colors
  86598. * @param gradient defines the gradient to use (between 0 and 1)
  86599. * @param color defines the color to affect to the specified gradient
  86600. * @returns the current particle system
  86601. */
  86602. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  86603. /**
  86604. * Gets the current list of ramp gradients.
  86605. * You must use addRampGradient and removeRampGradient to udpate this list
  86606. * @returns the list of ramp gradients
  86607. */
  86608. getRampGradients(): Nullable<Array<Color3Gradient>>;
  86609. /** Gets or sets a boolean indicating that ramp gradients must be used
  86610. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  86611. */
  86612. useRampGradients: boolean;
  86613. /**
  86614. * Adds a new color remap gradient
  86615. * @param gradient defines the gradient to use (between 0 and 1)
  86616. * @param min defines the color remap minimal range
  86617. * @param max defines the color remap maximal range
  86618. * @returns the current particle system
  86619. */
  86620. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86621. /**
  86622. * Gets the current list of color remap gradients.
  86623. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  86624. * @returns the list of color remap gradients
  86625. */
  86626. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  86627. /**
  86628. * Adds a new alpha remap gradient
  86629. * @param gradient defines the gradient to use (between 0 and 1)
  86630. * @param min defines the alpha remap minimal range
  86631. * @param max defines the alpha remap maximal range
  86632. * @returns the current particle system
  86633. */
  86634. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86635. /**
  86636. * Gets the current list of alpha remap gradients.
  86637. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  86638. * @returns the list of alpha remap gradients
  86639. */
  86640. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  86641. /**
  86642. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  86643. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86644. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86645. * @returns the emitter
  86646. */
  86647. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  86648. /**
  86649. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  86650. * @param radius The radius of the hemisphere to emit from
  86651. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86652. * @returns the emitter
  86653. */
  86654. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  86655. /**
  86656. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  86657. * @param radius The radius of the sphere to emit from
  86658. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86659. * @returns the emitter
  86660. */
  86661. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  86662. /**
  86663. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  86664. * @param radius The radius of the sphere to emit from
  86665. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  86666. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  86667. * @returns the emitter
  86668. */
  86669. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  86670. /**
  86671. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  86672. * @param radius The radius of the emission cylinder
  86673. * @param height The height of the emission cylinder
  86674. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  86675. * @param directionRandomizer How much to randomize the particle direction [0-1]
  86676. * @returns the emitter
  86677. */
  86678. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  86679. /**
  86680. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  86681. * @param radius The radius of the cylinder to emit from
  86682. * @param height The height of the emission cylinder
  86683. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86684. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  86685. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  86686. * @returns the emitter
  86687. */
  86688. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  86689. /**
  86690. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  86691. * @param radius The radius of the cone to emit from
  86692. * @param angle The base angle of the cone
  86693. * @returns the emitter
  86694. */
  86695. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  86696. /**
  86697. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  86698. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86699. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86700. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86701. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86702. * @returns the emitter
  86703. */
  86704. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  86705. /**
  86706. * Get hosting scene
  86707. * @returns the scene
  86708. */
  86709. getScene(): Scene;
  86710. }
  86711. }
  86712. declare module BABYLON {
  86713. /**
  86714. * 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.
  86715. * @see https://doc.babylonjs.com/how_to/transformnode
  86716. */
  86717. export class TransformNode extends Node {
  86718. /**
  86719. * Object will not rotate to face the camera
  86720. */
  86721. static BILLBOARDMODE_NONE: number;
  86722. /**
  86723. * Object will rotate to face the camera but only on the x axis
  86724. */
  86725. static BILLBOARDMODE_X: number;
  86726. /**
  86727. * Object will rotate to face the camera but only on the y axis
  86728. */
  86729. static BILLBOARDMODE_Y: number;
  86730. /**
  86731. * Object will rotate to face the camera but only on the z axis
  86732. */
  86733. static BILLBOARDMODE_Z: number;
  86734. /**
  86735. * Object will rotate to face the camera
  86736. */
  86737. static BILLBOARDMODE_ALL: number;
  86738. /**
  86739. * Object will rotate to face the camera's position instead of orientation
  86740. */
  86741. static BILLBOARDMODE_USE_POSITION: number;
  86742. private _forward;
  86743. private _forwardInverted;
  86744. private _up;
  86745. private _right;
  86746. private _rightInverted;
  86747. private _position;
  86748. private _rotation;
  86749. private _rotationQuaternion;
  86750. protected _scaling: Vector3;
  86751. protected _isDirty: boolean;
  86752. private _transformToBoneReferal;
  86753. private _isAbsoluteSynced;
  86754. private _billboardMode;
  86755. /**
  86756. * Gets or sets the billboard mode. Default is 0.
  86757. *
  86758. * | Value | Type | Description |
  86759. * | --- | --- | --- |
  86760. * | 0 | BILLBOARDMODE_NONE | |
  86761. * | 1 | BILLBOARDMODE_X | |
  86762. * | 2 | BILLBOARDMODE_Y | |
  86763. * | 4 | BILLBOARDMODE_Z | |
  86764. * | 7 | BILLBOARDMODE_ALL | |
  86765. *
  86766. */
  86767. get billboardMode(): number;
  86768. set billboardMode(value: number);
  86769. private _preserveParentRotationForBillboard;
  86770. /**
  86771. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  86772. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  86773. */
  86774. get preserveParentRotationForBillboard(): boolean;
  86775. set preserveParentRotationForBillboard(value: boolean);
  86776. /**
  86777. * 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
  86778. */
  86779. scalingDeterminant: number;
  86780. private _infiniteDistance;
  86781. /**
  86782. * Gets or sets the distance of the object to max, often used by skybox
  86783. */
  86784. get infiniteDistance(): boolean;
  86785. set infiniteDistance(value: boolean);
  86786. /**
  86787. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  86788. * By default the system will update normals to compensate
  86789. */
  86790. ignoreNonUniformScaling: boolean;
  86791. /**
  86792. * 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
  86793. */
  86794. reIntegrateRotationIntoRotationQuaternion: boolean;
  86795. /** @hidden */
  86796. _poseMatrix: Nullable<Matrix>;
  86797. /** @hidden */
  86798. _localMatrix: Matrix;
  86799. private _usePivotMatrix;
  86800. private _absolutePosition;
  86801. private _absoluteScaling;
  86802. private _absoluteRotationQuaternion;
  86803. private _pivotMatrix;
  86804. private _pivotMatrixInverse;
  86805. protected _postMultiplyPivotMatrix: boolean;
  86806. protected _isWorldMatrixFrozen: boolean;
  86807. /** @hidden */
  86808. _indexInSceneTransformNodesArray: number;
  86809. /**
  86810. * An event triggered after the world matrix is updated
  86811. */
  86812. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  86813. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  86814. /**
  86815. * Gets a string identifying the name of the class
  86816. * @returns "TransformNode" string
  86817. */
  86818. getClassName(): string;
  86819. /**
  86820. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  86821. */
  86822. get position(): Vector3;
  86823. set position(newPosition: Vector3);
  86824. /**
  86825. * 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)).
  86826. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  86827. */
  86828. get rotation(): Vector3;
  86829. set rotation(newRotation: Vector3);
  86830. /**
  86831. * 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)).
  86832. */
  86833. get scaling(): Vector3;
  86834. set scaling(newScaling: Vector3);
  86835. /**
  86836. * 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).
  86837. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  86838. */
  86839. get rotationQuaternion(): Nullable<Quaternion>;
  86840. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  86841. /**
  86842. * The forward direction of that transform in world space.
  86843. */
  86844. get forward(): Vector3;
  86845. /**
  86846. * The up direction of that transform in world space.
  86847. */
  86848. get up(): Vector3;
  86849. /**
  86850. * The right direction of that transform in world space.
  86851. */
  86852. get right(): Vector3;
  86853. /**
  86854. * Copies the parameter passed Matrix into the mesh Pose matrix.
  86855. * @param matrix the matrix to copy the pose from
  86856. * @returns this TransformNode.
  86857. */
  86858. updatePoseMatrix(matrix: Matrix): TransformNode;
  86859. /**
  86860. * Returns the mesh Pose matrix.
  86861. * @returns the pose matrix
  86862. */
  86863. getPoseMatrix(): Matrix;
  86864. /** @hidden */
  86865. _isSynchronized(): boolean;
  86866. /** @hidden */
  86867. _initCache(): void;
  86868. /**
  86869. * Flag the transform node as dirty (Forcing it to update everything)
  86870. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  86871. * @returns this transform node
  86872. */
  86873. markAsDirty(property: string): TransformNode;
  86874. /**
  86875. * Returns the current mesh absolute position.
  86876. * Returns a Vector3.
  86877. */
  86878. get absolutePosition(): Vector3;
  86879. /**
  86880. * Returns the current mesh absolute scaling.
  86881. * Returns a Vector3.
  86882. */
  86883. get absoluteScaling(): Vector3;
  86884. /**
  86885. * Returns the current mesh absolute rotation.
  86886. * Returns a Quaternion.
  86887. */
  86888. get absoluteRotationQuaternion(): Quaternion;
  86889. /**
  86890. * Sets a new matrix to apply before all other transformation
  86891. * @param matrix defines the transform matrix
  86892. * @returns the current TransformNode
  86893. */
  86894. setPreTransformMatrix(matrix: Matrix): TransformNode;
  86895. /**
  86896. * Sets a new pivot matrix to the current node
  86897. * @param matrix defines the new pivot matrix to use
  86898. * @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
  86899. * @returns the current TransformNode
  86900. */
  86901. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  86902. /**
  86903. * Returns the mesh pivot matrix.
  86904. * Default : Identity.
  86905. * @returns the matrix
  86906. */
  86907. getPivotMatrix(): Matrix;
  86908. /**
  86909. * Instantiate (when possible) or clone that node with its hierarchy
  86910. * @param newParent defines the new parent to use for the instance (or clone)
  86911. * @param options defines options to configure how copy is done
  86912. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  86913. * @returns an instance (or a clone) of the current node with its hiearchy
  86914. */
  86915. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  86916. doNotInstantiate: boolean;
  86917. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  86918. /**
  86919. * Prevents the World matrix to be computed any longer
  86920. * @param newWorldMatrix defines an optional matrix to use as world matrix
  86921. * @returns the TransformNode.
  86922. */
  86923. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  86924. /**
  86925. * Allows back the World matrix computation.
  86926. * @returns the TransformNode.
  86927. */
  86928. unfreezeWorldMatrix(): this;
  86929. /**
  86930. * True if the World matrix has been frozen.
  86931. */
  86932. get isWorldMatrixFrozen(): boolean;
  86933. /**
  86934. * Retuns the mesh absolute position in the World.
  86935. * @returns a Vector3.
  86936. */
  86937. getAbsolutePosition(): Vector3;
  86938. /**
  86939. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  86940. * @param absolutePosition the absolute position to set
  86941. * @returns the TransformNode.
  86942. */
  86943. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  86944. /**
  86945. * Sets the mesh position in its local space.
  86946. * @param vector3 the position to set in localspace
  86947. * @returns the TransformNode.
  86948. */
  86949. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  86950. /**
  86951. * Returns the mesh position in the local space from the current World matrix values.
  86952. * @returns a new Vector3.
  86953. */
  86954. getPositionExpressedInLocalSpace(): Vector3;
  86955. /**
  86956. * Translates the mesh along the passed Vector3 in its local space.
  86957. * @param vector3 the distance to translate in localspace
  86958. * @returns the TransformNode.
  86959. */
  86960. locallyTranslate(vector3: Vector3): TransformNode;
  86961. private static _lookAtVectorCache;
  86962. /**
  86963. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  86964. * @param targetPoint the position (must be in same space as current mesh) to look at
  86965. * @param yawCor optional yaw (y-axis) correction in radians
  86966. * @param pitchCor optional pitch (x-axis) correction in radians
  86967. * @param rollCor optional roll (z-axis) correction in radians
  86968. * @param space the choosen space of the target
  86969. * @returns the TransformNode.
  86970. */
  86971. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  86972. /**
  86973. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  86974. * This Vector3 is expressed in the World space.
  86975. * @param localAxis axis to rotate
  86976. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  86977. */
  86978. getDirection(localAxis: Vector3): Vector3;
  86979. /**
  86980. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  86981. * localAxis is expressed in the mesh local space.
  86982. * result is computed in the Wordl space from the mesh World matrix.
  86983. * @param localAxis axis to rotate
  86984. * @param result the resulting transformnode
  86985. * @returns this TransformNode.
  86986. */
  86987. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  86988. /**
  86989. * Sets this transform node rotation to the given local axis.
  86990. * @param localAxis the axis in local space
  86991. * @param yawCor optional yaw (y-axis) correction in radians
  86992. * @param pitchCor optional pitch (x-axis) correction in radians
  86993. * @param rollCor optional roll (z-axis) correction in radians
  86994. * @returns this TransformNode
  86995. */
  86996. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  86997. /**
  86998. * Sets a new pivot point to the current node
  86999. * @param point defines the new pivot point to use
  87000. * @param space defines if the point is in world or local space (local by default)
  87001. * @returns the current TransformNode
  87002. */
  87003. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  87004. /**
  87005. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  87006. * @returns the pivot point
  87007. */
  87008. getPivotPoint(): Vector3;
  87009. /**
  87010. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  87011. * @param result the vector3 to store the result
  87012. * @returns this TransformNode.
  87013. */
  87014. getPivotPointToRef(result: Vector3): TransformNode;
  87015. /**
  87016. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  87017. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  87018. */
  87019. getAbsolutePivotPoint(): Vector3;
  87020. /**
  87021. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  87022. * @param result vector3 to store the result
  87023. * @returns this TransformNode.
  87024. */
  87025. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  87026. /**
  87027. * Defines the passed node as the parent of the current node.
  87028. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  87029. * @see https://doc.babylonjs.com/how_to/parenting
  87030. * @param node the node ot set as the parent
  87031. * @returns this TransformNode.
  87032. */
  87033. setParent(node: Nullable<Node>): TransformNode;
  87034. private _nonUniformScaling;
  87035. /**
  87036. * True if the scaling property of this object is non uniform eg. (1,2,1)
  87037. */
  87038. get nonUniformScaling(): boolean;
  87039. /** @hidden */
  87040. _updateNonUniformScalingState(value: boolean): boolean;
  87041. /**
  87042. * Attach the current TransformNode to another TransformNode associated with a bone
  87043. * @param bone Bone affecting the TransformNode
  87044. * @param affectedTransformNode TransformNode associated with the bone
  87045. * @returns this object
  87046. */
  87047. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  87048. /**
  87049. * Detach the transform node if its associated with a bone
  87050. * @returns this object
  87051. */
  87052. detachFromBone(): TransformNode;
  87053. private static _rotationAxisCache;
  87054. /**
  87055. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  87056. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  87057. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  87058. * The passed axis is also normalized.
  87059. * @param axis the axis to rotate around
  87060. * @param amount the amount to rotate in radians
  87061. * @param space Space to rotate in (Default: local)
  87062. * @returns the TransformNode.
  87063. */
  87064. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  87065. /**
  87066. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  87067. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  87068. * The passed axis is also normalized. .
  87069. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  87070. * @param point the point to rotate around
  87071. * @param axis the axis to rotate around
  87072. * @param amount the amount to rotate in radians
  87073. * @returns the TransformNode
  87074. */
  87075. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  87076. /**
  87077. * Translates the mesh along the axis vector for the passed distance in the given space.
  87078. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  87079. * @param axis the axis to translate in
  87080. * @param distance the distance to translate
  87081. * @param space Space to rotate in (Default: local)
  87082. * @returns the TransformNode.
  87083. */
  87084. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  87085. /**
  87086. * Adds a rotation step to the mesh current rotation.
  87087. * x, y, z are Euler angles expressed in radians.
  87088. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  87089. * This means this rotation is made in the mesh local space only.
  87090. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  87091. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  87092. * ```javascript
  87093. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  87094. * ```
  87095. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  87096. * 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.
  87097. * @param x Rotation to add
  87098. * @param y Rotation to add
  87099. * @param z Rotation to add
  87100. * @returns the TransformNode.
  87101. */
  87102. addRotation(x: number, y: number, z: number): TransformNode;
  87103. /**
  87104. * @hidden
  87105. */
  87106. protected _getEffectiveParent(): Nullable<Node>;
  87107. /**
  87108. * Computes the world matrix of the node
  87109. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  87110. * @returns the world matrix
  87111. */
  87112. computeWorldMatrix(force?: boolean): Matrix;
  87113. /**
  87114. * Resets this nodeTransform's local matrix to Matrix.Identity().
  87115. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  87116. */
  87117. resetLocalMatrix(independentOfChildren?: boolean): void;
  87118. protected _afterComputeWorldMatrix(): void;
  87119. /**
  87120. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  87121. * @param func callback function to add
  87122. *
  87123. * @returns the TransformNode.
  87124. */
  87125. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  87126. /**
  87127. * Removes a registered callback function.
  87128. * @param func callback function to remove
  87129. * @returns the TransformNode.
  87130. */
  87131. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  87132. /**
  87133. * Gets the position of the current mesh in camera space
  87134. * @param camera defines the camera to use
  87135. * @returns a position
  87136. */
  87137. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  87138. /**
  87139. * Returns the distance from the mesh to the active camera
  87140. * @param camera defines the camera to use
  87141. * @returns the distance
  87142. */
  87143. getDistanceToCamera(camera?: Nullable<Camera>): number;
  87144. /**
  87145. * Clone the current transform node
  87146. * @param name Name of the new clone
  87147. * @param newParent New parent for the clone
  87148. * @param doNotCloneChildren Do not clone children hierarchy
  87149. * @returns the new transform node
  87150. */
  87151. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  87152. /**
  87153. * Serializes the objects information.
  87154. * @param currentSerializationObject defines the object to serialize in
  87155. * @returns the serialized object
  87156. */
  87157. serialize(currentSerializationObject?: any): any;
  87158. /**
  87159. * Returns a new TransformNode object parsed from the source provided.
  87160. * @param parsedTransformNode is the source.
  87161. * @param scene the scne the object belongs to
  87162. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  87163. * @returns a new TransformNode object parsed from the source provided.
  87164. */
  87165. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  87166. /**
  87167. * Get all child-transformNodes of this node
  87168. * @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
  87169. * @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
  87170. * @returns an array of TransformNode
  87171. */
  87172. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  87173. /**
  87174. * Releases resources associated with this transform node.
  87175. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  87176. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  87177. */
  87178. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87179. /**
  87180. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  87181. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  87182. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  87183. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  87184. * @returns the current mesh
  87185. */
  87186. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  87187. private _syncAbsoluteScalingAndRotation;
  87188. }
  87189. }
  87190. declare module BABYLON {
  87191. /**
  87192. * Class used to override all child animations of a given target
  87193. */
  87194. export class AnimationPropertiesOverride {
  87195. /**
  87196. * Gets or sets a value indicating if animation blending must be used
  87197. */
  87198. enableBlending: boolean;
  87199. /**
  87200. * Gets or sets the blending speed to use when enableBlending is true
  87201. */
  87202. blendingSpeed: number;
  87203. /**
  87204. * Gets or sets the default loop mode to use
  87205. */
  87206. loopMode: number;
  87207. }
  87208. }
  87209. declare module BABYLON {
  87210. /**
  87211. * Class used to store bone information
  87212. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  87213. */
  87214. export class Bone extends Node {
  87215. /**
  87216. * defines the bone name
  87217. */
  87218. name: string;
  87219. private static _tmpVecs;
  87220. private static _tmpQuat;
  87221. private static _tmpMats;
  87222. /**
  87223. * Gets the list of child bones
  87224. */
  87225. children: Bone[];
  87226. /** Gets the animations associated with this bone */
  87227. animations: Animation[];
  87228. /**
  87229. * Gets or sets bone length
  87230. */
  87231. length: number;
  87232. /**
  87233. * @hidden Internal only
  87234. * Set this value to map this bone to a different index in the transform matrices
  87235. * Set this value to -1 to exclude the bone from the transform matrices
  87236. */
  87237. _index: Nullable<number>;
  87238. private _skeleton;
  87239. private _localMatrix;
  87240. private _restPose;
  87241. private _baseMatrix;
  87242. private _absoluteTransform;
  87243. private _invertedAbsoluteTransform;
  87244. private _parent;
  87245. private _scalingDeterminant;
  87246. private _worldTransform;
  87247. private _localScaling;
  87248. private _localRotation;
  87249. private _localPosition;
  87250. private _needToDecompose;
  87251. private _needToCompose;
  87252. /** @hidden */
  87253. _linkedTransformNode: Nullable<TransformNode>;
  87254. /** @hidden */
  87255. _waitingTransformNodeId: Nullable<string>;
  87256. /** @hidden */
  87257. get _matrix(): Matrix;
  87258. /** @hidden */
  87259. set _matrix(value: Matrix);
  87260. /**
  87261. * Create a new bone
  87262. * @param name defines the bone name
  87263. * @param skeleton defines the parent skeleton
  87264. * @param parentBone defines the parent (can be null if the bone is the root)
  87265. * @param localMatrix defines the local matrix
  87266. * @param restPose defines the rest pose matrix
  87267. * @param baseMatrix defines the base matrix
  87268. * @param index defines index of the bone in the hiearchy
  87269. */
  87270. constructor(
  87271. /**
  87272. * defines the bone name
  87273. */
  87274. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  87275. /**
  87276. * Gets the current object class name.
  87277. * @return the class name
  87278. */
  87279. getClassName(): string;
  87280. /**
  87281. * Gets the parent skeleton
  87282. * @returns a skeleton
  87283. */
  87284. getSkeleton(): Skeleton;
  87285. /**
  87286. * Gets parent bone
  87287. * @returns a bone or null if the bone is the root of the bone hierarchy
  87288. */
  87289. getParent(): Nullable<Bone>;
  87290. /**
  87291. * Returns an array containing the root bones
  87292. * @returns an array containing the root bones
  87293. */
  87294. getChildren(): Array<Bone>;
  87295. /**
  87296. * Gets the node index in matrix array generated for rendering
  87297. * @returns the node index
  87298. */
  87299. getIndex(): number;
  87300. /**
  87301. * Sets the parent bone
  87302. * @param parent defines the parent (can be null if the bone is the root)
  87303. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  87304. */
  87305. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  87306. /**
  87307. * Gets the local matrix
  87308. * @returns a matrix
  87309. */
  87310. getLocalMatrix(): Matrix;
  87311. /**
  87312. * Gets the base matrix (initial matrix which remains unchanged)
  87313. * @returns a matrix
  87314. */
  87315. getBaseMatrix(): Matrix;
  87316. /**
  87317. * Gets the rest pose matrix
  87318. * @returns a matrix
  87319. */
  87320. getRestPose(): Matrix;
  87321. /**
  87322. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  87323. */
  87324. getWorldMatrix(): Matrix;
  87325. /**
  87326. * Sets the local matrix to rest pose matrix
  87327. */
  87328. returnToRest(): void;
  87329. /**
  87330. * Gets the inverse of the absolute transform matrix.
  87331. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  87332. * @returns a matrix
  87333. */
  87334. getInvertedAbsoluteTransform(): Matrix;
  87335. /**
  87336. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  87337. * @returns a matrix
  87338. */
  87339. getAbsoluteTransform(): Matrix;
  87340. /**
  87341. * Links with the given transform node.
  87342. * The local matrix of this bone is copied from the transform node every frame.
  87343. * @param transformNode defines the transform node to link to
  87344. */
  87345. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  87346. /**
  87347. * Gets the node used to drive the bone's transformation
  87348. * @returns a transform node or null
  87349. */
  87350. getTransformNode(): Nullable<TransformNode>;
  87351. /** Gets or sets current position (in local space) */
  87352. get position(): Vector3;
  87353. set position(newPosition: Vector3);
  87354. /** Gets or sets current rotation (in local space) */
  87355. get rotation(): Vector3;
  87356. set rotation(newRotation: Vector3);
  87357. /** Gets or sets current rotation quaternion (in local space) */
  87358. get rotationQuaternion(): Quaternion;
  87359. set rotationQuaternion(newRotation: Quaternion);
  87360. /** Gets or sets current scaling (in local space) */
  87361. get scaling(): Vector3;
  87362. set scaling(newScaling: Vector3);
  87363. /**
  87364. * Gets the animation properties override
  87365. */
  87366. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  87367. private _decompose;
  87368. private _compose;
  87369. /**
  87370. * Update the base and local matrices
  87371. * @param matrix defines the new base or local matrix
  87372. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  87373. * @param updateLocalMatrix defines if the local matrix should be updated
  87374. */
  87375. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  87376. /** @hidden */
  87377. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  87378. /**
  87379. * Flag the bone as dirty (Forcing it to update everything)
  87380. */
  87381. markAsDirty(): void;
  87382. /** @hidden */
  87383. _markAsDirtyAndCompose(): void;
  87384. private _markAsDirtyAndDecompose;
  87385. /**
  87386. * Translate the bone in local or world space
  87387. * @param vec The amount to translate the bone
  87388. * @param space The space that the translation is in
  87389. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87390. */
  87391. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  87392. /**
  87393. * Set the postion of the bone in local or world space
  87394. * @param position The position to set the bone
  87395. * @param space The space that the position is in
  87396. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87397. */
  87398. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  87399. /**
  87400. * Set the absolute position of the bone (world space)
  87401. * @param position The position to set the bone
  87402. * @param mesh The mesh that this bone is attached to
  87403. */
  87404. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  87405. /**
  87406. * Scale the bone on the x, y and z axes (in local space)
  87407. * @param x The amount to scale the bone on the x axis
  87408. * @param y The amount to scale the bone on the y axis
  87409. * @param z The amount to scale the bone on the z axis
  87410. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  87411. */
  87412. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  87413. /**
  87414. * Set the bone scaling in local space
  87415. * @param scale defines the scaling vector
  87416. */
  87417. setScale(scale: Vector3): void;
  87418. /**
  87419. * Gets the current scaling in local space
  87420. * @returns the current scaling vector
  87421. */
  87422. getScale(): Vector3;
  87423. /**
  87424. * Gets the current scaling in local space and stores it in a target vector
  87425. * @param result defines the target vector
  87426. */
  87427. getScaleToRef(result: Vector3): void;
  87428. /**
  87429. * Set the yaw, pitch, and roll of the bone in local or world space
  87430. * @param yaw The rotation of the bone on the y axis
  87431. * @param pitch The rotation of the bone on the x axis
  87432. * @param roll The rotation of the bone on the z axis
  87433. * @param space The space that the axes of rotation are in
  87434. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87435. */
  87436. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  87437. /**
  87438. * Add a rotation to the bone on an axis in local or world space
  87439. * @param axis The axis to rotate the bone on
  87440. * @param amount The amount to rotate the bone
  87441. * @param space The space that the axis is in
  87442. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87443. */
  87444. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  87445. /**
  87446. * Set the rotation of the bone to a particular axis angle in local or world space
  87447. * @param axis The axis to rotate the bone on
  87448. * @param angle The angle that the bone should be rotated to
  87449. * @param space The space that the axis is in
  87450. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87451. */
  87452. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  87453. /**
  87454. * Set the euler rotation of the bone in local of world space
  87455. * @param rotation The euler rotation that the bone should be set to
  87456. * @param space The space that the rotation is in
  87457. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87458. */
  87459. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  87460. /**
  87461. * Set the quaternion rotation of the bone in local of world space
  87462. * @param quat The quaternion rotation that the bone should be set to
  87463. * @param space The space that the rotation is in
  87464. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87465. */
  87466. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  87467. /**
  87468. * Set the rotation matrix of the bone in local of world space
  87469. * @param rotMat The rotation matrix that the bone should be set to
  87470. * @param space The space that the rotation is in
  87471. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87472. */
  87473. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  87474. private _rotateWithMatrix;
  87475. private _getNegativeRotationToRef;
  87476. /**
  87477. * Get the position of the bone in local or world space
  87478. * @param space The space that the returned position is in
  87479. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87480. * @returns The position of the bone
  87481. */
  87482. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  87483. /**
  87484. * Copy the position of the bone to a vector3 in local or world space
  87485. * @param space The space that the returned position is in
  87486. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87487. * @param result The vector3 to copy the position to
  87488. */
  87489. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  87490. /**
  87491. * Get the absolute position of the bone (world space)
  87492. * @param mesh The mesh that this bone is attached to
  87493. * @returns The absolute position of the bone
  87494. */
  87495. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  87496. /**
  87497. * Copy the absolute position of the bone (world space) to the result param
  87498. * @param mesh The mesh that this bone is attached to
  87499. * @param result The vector3 to copy the absolute position to
  87500. */
  87501. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  87502. /**
  87503. * Compute the absolute transforms of this bone and its children
  87504. */
  87505. computeAbsoluteTransforms(): void;
  87506. /**
  87507. * Get the world direction from an axis that is in the local space of the bone
  87508. * @param localAxis The local direction that is used to compute the world direction
  87509. * @param mesh The mesh that this bone is attached to
  87510. * @returns The world direction
  87511. */
  87512. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  87513. /**
  87514. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  87515. * @param localAxis The local direction that is used to compute the world direction
  87516. * @param mesh The mesh that this bone is attached to
  87517. * @param result The vector3 that the world direction will be copied to
  87518. */
  87519. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87520. /**
  87521. * Get the euler rotation of the bone in local or world space
  87522. * @param space The space that the rotation should be in
  87523. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87524. * @returns The euler rotation
  87525. */
  87526. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  87527. /**
  87528. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  87529. * @param space The space that the rotation should be in
  87530. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87531. * @param result The vector3 that the rotation should be copied to
  87532. */
  87533. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87534. /**
  87535. * Get the quaternion rotation of the bone in either local or world space
  87536. * @param space The space that the rotation should be in
  87537. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87538. * @returns The quaternion rotation
  87539. */
  87540. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  87541. /**
  87542. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  87543. * @param space The space that the rotation should be in
  87544. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87545. * @param result The quaternion that the rotation should be copied to
  87546. */
  87547. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  87548. /**
  87549. * Get the rotation matrix of the bone in local or world space
  87550. * @param space The space that the rotation should be in
  87551. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87552. * @returns The rotation matrix
  87553. */
  87554. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  87555. /**
  87556. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  87557. * @param space The space that the rotation should be in
  87558. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87559. * @param result The quaternion that the rotation should be copied to
  87560. */
  87561. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  87562. /**
  87563. * Get the world position of a point that is in the local space of the bone
  87564. * @param position The local position
  87565. * @param mesh The mesh that this bone is attached to
  87566. * @returns The world position
  87567. */
  87568. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  87569. /**
  87570. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  87571. * @param position The local position
  87572. * @param mesh The mesh that this bone is attached to
  87573. * @param result The vector3 that the world position should be copied to
  87574. */
  87575. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87576. /**
  87577. * Get the local position of a point that is in world space
  87578. * @param position The world position
  87579. * @param mesh The mesh that this bone is attached to
  87580. * @returns The local position
  87581. */
  87582. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  87583. /**
  87584. * Get the local position of a point that is in world space and copy it to the result param
  87585. * @param position The world position
  87586. * @param mesh The mesh that this bone is attached to
  87587. * @param result The vector3 that the local position should be copied to
  87588. */
  87589. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87590. }
  87591. }
  87592. declare module BABYLON {
  87593. /**
  87594. * Defines a runtime animation
  87595. */
  87596. export class RuntimeAnimation {
  87597. private _events;
  87598. /**
  87599. * The current frame of the runtime animation
  87600. */
  87601. private _currentFrame;
  87602. /**
  87603. * The animation used by the runtime animation
  87604. */
  87605. private _animation;
  87606. /**
  87607. * The target of the runtime animation
  87608. */
  87609. private _target;
  87610. /**
  87611. * The initiating animatable
  87612. */
  87613. private _host;
  87614. /**
  87615. * The original value of the runtime animation
  87616. */
  87617. private _originalValue;
  87618. /**
  87619. * The original blend value of the runtime animation
  87620. */
  87621. private _originalBlendValue;
  87622. /**
  87623. * The offsets cache of the runtime animation
  87624. */
  87625. private _offsetsCache;
  87626. /**
  87627. * The high limits cache of the runtime animation
  87628. */
  87629. private _highLimitsCache;
  87630. /**
  87631. * Specifies if the runtime animation has been stopped
  87632. */
  87633. private _stopped;
  87634. /**
  87635. * The blending factor of the runtime animation
  87636. */
  87637. private _blendingFactor;
  87638. /**
  87639. * The BabylonJS scene
  87640. */
  87641. private _scene;
  87642. /**
  87643. * The current value of the runtime animation
  87644. */
  87645. private _currentValue;
  87646. /** @hidden */
  87647. _animationState: _IAnimationState;
  87648. /**
  87649. * The active target of the runtime animation
  87650. */
  87651. private _activeTargets;
  87652. private _currentActiveTarget;
  87653. private _directTarget;
  87654. /**
  87655. * The target path of the runtime animation
  87656. */
  87657. private _targetPath;
  87658. /**
  87659. * The weight of the runtime animation
  87660. */
  87661. private _weight;
  87662. /**
  87663. * The ratio offset of the runtime animation
  87664. */
  87665. private _ratioOffset;
  87666. /**
  87667. * The previous delay of the runtime animation
  87668. */
  87669. private _previousDelay;
  87670. /**
  87671. * The previous ratio of the runtime animation
  87672. */
  87673. private _previousRatio;
  87674. private _enableBlending;
  87675. private _keys;
  87676. private _minFrame;
  87677. private _maxFrame;
  87678. private _minValue;
  87679. private _maxValue;
  87680. private _targetIsArray;
  87681. /**
  87682. * Gets the current frame of the runtime animation
  87683. */
  87684. get currentFrame(): number;
  87685. /**
  87686. * Gets the weight of the runtime animation
  87687. */
  87688. get weight(): number;
  87689. /**
  87690. * Gets the current value of the runtime animation
  87691. */
  87692. get currentValue(): any;
  87693. /**
  87694. * Gets the target path of the runtime animation
  87695. */
  87696. get targetPath(): string;
  87697. /**
  87698. * Gets the actual target of the runtime animation
  87699. */
  87700. get target(): any;
  87701. /** @hidden */
  87702. _onLoop: () => void;
  87703. /**
  87704. * Create a new RuntimeAnimation object
  87705. * @param target defines the target of the animation
  87706. * @param animation defines the source animation object
  87707. * @param scene defines the hosting scene
  87708. * @param host defines the initiating Animatable
  87709. */
  87710. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  87711. private _preparePath;
  87712. /**
  87713. * Gets the animation from the runtime animation
  87714. */
  87715. get animation(): Animation;
  87716. /**
  87717. * Resets the runtime animation to the beginning
  87718. * @param restoreOriginal defines whether to restore the target property to the original value
  87719. */
  87720. reset(restoreOriginal?: boolean): void;
  87721. /**
  87722. * Specifies if the runtime animation is stopped
  87723. * @returns Boolean specifying if the runtime animation is stopped
  87724. */
  87725. isStopped(): boolean;
  87726. /**
  87727. * Disposes of the runtime animation
  87728. */
  87729. dispose(): void;
  87730. /**
  87731. * Apply the interpolated value to the target
  87732. * @param currentValue defines the value computed by the animation
  87733. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  87734. */
  87735. setValue(currentValue: any, weight: number): void;
  87736. private _getOriginalValues;
  87737. private _setValue;
  87738. /**
  87739. * Gets the loop pmode of the runtime animation
  87740. * @returns Loop Mode
  87741. */
  87742. private _getCorrectLoopMode;
  87743. /**
  87744. * Move the current animation to a given frame
  87745. * @param frame defines the frame to move to
  87746. */
  87747. goToFrame(frame: number): void;
  87748. /**
  87749. * @hidden Internal use only
  87750. */
  87751. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  87752. /**
  87753. * Execute the current animation
  87754. * @param delay defines the delay to add to the current frame
  87755. * @param from defines the lower bound of the animation range
  87756. * @param to defines the upper bound of the animation range
  87757. * @param loop defines if the current animation must loop
  87758. * @param speedRatio defines the current speed ratio
  87759. * @param weight defines the weight of the animation (default is -1 so no weight)
  87760. * @param onLoop optional callback called when animation loops
  87761. * @returns a boolean indicating if the animation is running
  87762. */
  87763. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  87764. }
  87765. }
  87766. declare module BABYLON {
  87767. /**
  87768. * Class used to store an actual running animation
  87769. */
  87770. export class Animatable {
  87771. /** defines the target object */
  87772. target: any;
  87773. /** defines the starting frame number (default is 0) */
  87774. fromFrame: number;
  87775. /** defines the ending frame number (default is 100) */
  87776. toFrame: number;
  87777. /** defines if the animation must loop (default is false) */
  87778. loopAnimation: boolean;
  87779. /** defines a callback to call when animation ends if it is not looping */
  87780. onAnimationEnd?: (() => void) | null | undefined;
  87781. /** defines a callback to call when animation loops */
  87782. onAnimationLoop?: (() => void) | null | undefined;
  87783. private _localDelayOffset;
  87784. private _pausedDelay;
  87785. private _runtimeAnimations;
  87786. private _paused;
  87787. private _scene;
  87788. private _speedRatio;
  87789. private _weight;
  87790. private _syncRoot;
  87791. /**
  87792. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  87793. * This will only apply for non looping animation (default is true)
  87794. */
  87795. disposeOnEnd: boolean;
  87796. /**
  87797. * Gets a boolean indicating if the animation has started
  87798. */
  87799. animationStarted: boolean;
  87800. /**
  87801. * Observer raised when the animation ends
  87802. */
  87803. onAnimationEndObservable: Observable<Animatable>;
  87804. /**
  87805. * Observer raised when the animation loops
  87806. */
  87807. onAnimationLoopObservable: Observable<Animatable>;
  87808. /**
  87809. * Gets the root Animatable used to synchronize and normalize animations
  87810. */
  87811. get syncRoot(): Nullable<Animatable>;
  87812. /**
  87813. * Gets the current frame of the first RuntimeAnimation
  87814. * Used to synchronize Animatables
  87815. */
  87816. get masterFrame(): number;
  87817. /**
  87818. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  87819. */
  87820. get weight(): number;
  87821. set weight(value: number);
  87822. /**
  87823. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  87824. */
  87825. get speedRatio(): number;
  87826. set speedRatio(value: number);
  87827. /**
  87828. * Creates a new Animatable
  87829. * @param scene defines the hosting scene
  87830. * @param target defines the target object
  87831. * @param fromFrame defines the starting frame number (default is 0)
  87832. * @param toFrame defines the ending frame number (default is 100)
  87833. * @param loopAnimation defines if the animation must loop (default is false)
  87834. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  87835. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  87836. * @param animations defines a group of animation to add to the new Animatable
  87837. * @param onAnimationLoop defines a callback to call when animation loops
  87838. */
  87839. constructor(scene: Scene,
  87840. /** defines the target object */
  87841. target: any,
  87842. /** defines the starting frame number (default is 0) */
  87843. fromFrame?: number,
  87844. /** defines the ending frame number (default is 100) */
  87845. toFrame?: number,
  87846. /** defines if the animation must loop (default is false) */
  87847. loopAnimation?: boolean, speedRatio?: number,
  87848. /** defines a callback to call when animation ends if it is not looping */
  87849. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  87850. /** defines a callback to call when animation loops */
  87851. onAnimationLoop?: (() => void) | null | undefined);
  87852. /**
  87853. * Synchronize and normalize current Animatable with a source Animatable
  87854. * This is useful when using animation weights and when animations are not of the same length
  87855. * @param root defines the root Animatable to synchronize with
  87856. * @returns the current Animatable
  87857. */
  87858. syncWith(root: Animatable): Animatable;
  87859. /**
  87860. * Gets the list of runtime animations
  87861. * @returns an array of RuntimeAnimation
  87862. */
  87863. getAnimations(): RuntimeAnimation[];
  87864. /**
  87865. * Adds more animations to the current animatable
  87866. * @param target defines the target of the animations
  87867. * @param animations defines the new animations to add
  87868. */
  87869. appendAnimations(target: any, animations: Animation[]): void;
  87870. /**
  87871. * Gets the source animation for a specific property
  87872. * @param property defines the propertyu to look for
  87873. * @returns null or the source animation for the given property
  87874. */
  87875. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  87876. /**
  87877. * Gets the runtime animation for a specific property
  87878. * @param property defines the propertyu to look for
  87879. * @returns null or the runtime animation for the given property
  87880. */
  87881. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  87882. /**
  87883. * Resets the animatable to its original state
  87884. */
  87885. reset(): void;
  87886. /**
  87887. * Allows the animatable to blend with current running animations
  87888. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  87889. * @param blendingSpeed defines the blending speed to use
  87890. */
  87891. enableBlending(blendingSpeed: number): void;
  87892. /**
  87893. * Disable animation blending
  87894. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  87895. */
  87896. disableBlending(): void;
  87897. /**
  87898. * Jump directly to a given frame
  87899. * @param frame defines the frame to jump to
  87900. */
  87901. goToFrame(frame: number): void;
  87902. /**
  87903. * Pause the animation
  87904. */
  87905. pause(): void;
  87906. /**
  87907. * Restart the animation
  87908. */
  87909. restart(): void;
  87910. private _raiseOnAnimationEnd;
  87911. /**
  87912. * Stop and delete the current animation
  87913. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  87914. * @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)
  87915. */
  87916. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  87917. /**
  87918. * Wait asynchronously for the animation to end
  87919. * @returns a promise which will be fullfilled when the animation ends
  87920. */
  87921. waitAsync(): Promise<Animatable>;
  87922. /** @hidden */
  87923. _animate(delay: number): boolean;
  87924. }
  87925. interface Scene {
  87926. /** @hidden */
  87927. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  87928. /** @hidden */
  87929. _processLateAnimationBindingsForMatrices(holder: {
  87930. totalWeight: number;
  87931. animations: RuntimeAnimation[];
  87932. originalValue: Matrix;
  87933. }): any;
  87934. /** @hidden */
  87935. _processLateAnimationBindingsForQuaternions(holder: {
  87936. totalWeight: number;
  87937. animations: RuntimeAnimation[];
  87938. originalValue: Quaternion;
  87939. }, refQuaternion: Quaternion): Quaternion;
  87940. /** @hidden */
  87941. _processLateAnimationBindings(): void;
  87942. /**
  87943. * Will start the animation sequence of a given target
  87944. * @param target defines the target
  87945. * @param from defines from which frame should animation start
  87946. * @param to defines until which frame should animation run.
  87947. * @param weight defines the weight to apply to the animation (1.0 by default)
  87948. * @param loop defines if the animation loops
  87949. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  87950. * @param onAnimationEnd defines the function to be executed when the animation ends
  87951. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  87952. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  87953. * @param onAnimationLoop defines the callback to call when an animation loops
  87954. * @returns the animatable object created for this animation
  87955. */
  87956. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  87957. /**
  87958. * Will start the animation sequence of a given target
  87959. * @param target defines the target
  87960. * @param from defines from which frame should animation start
  87961. * @param to defines until which frame should animation run.
  87962. * @param loop defines if the animation loops
  87963. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  87964. * @param onAnimationEnd defines the function to be executed when the animation ends
  87965. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  87966. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  87967. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  87968. * @param onAnimationLoop defines the callback to call when an animation loops
  87969. * @returns the animatable object created for this animation
  87970. */
  87971. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  87972. /**
  87973. * Will start the animation sequence of a given target and its hierarchy
  87974. * @param target defines the target
  87975. * @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.
  87976. * @param from defines from which frame should animation start
  87977. * @param to defines until which frame should animation run.
  87978. * @param loop defines if the animation loops
  87979. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  87980. * @param onAnimationEnd defines the function to be executed when the animation ends
  87981. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  87982. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  87983. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  87984. * @param onAnimationLoop defines the callback to call when an animation loops
  87985. * @returns the list of created animatables
  87986. */
  87987. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable[];
  87988. /**
  87989. * Begin a new animation on a given node
  87990. * @param target defines the target where the animation will take place
  87991. * @param animations defines the list of animations to start
  87992. * @param from defines the initial value
  87993. * @param to defines the final value
  87994. * @param loop defines if you want animation to loop (off by default)
  87995. * @param speedRatio defines the speed ratio to apply to all animations
  87996. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  87997. * @param onAnimationLoop defines the callback to call when an animation loops
  87998. * @returns the list of created animatables
  87999. */
  88000. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  88001. /**
  88002. * Begin a new animation on a given node and its hierarchy
  88003. * @param target defines the root node where the animation will take place
  88004. * @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.
  88005. * @param animations defines the list of animations to start
  88006. * @param from defines the initial value
  88007. * @param to defines the final value
  88008. * @param loop defines if you want animation to loop (off by default)
  88009. * @param speedRatio defines the speed ratio to apply to all animations
  88010. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  88011. * @param onAnimationLoop defines the callback to call when an animation loops
  88012. * @returns the list of animatables created for all nodes
  88013. */
  88014. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  88015. /**
  88016. * Gets the animatable associated with a specific target
  88017. * @param target defines the target of the animatable
  88018. * @returns the required animatable if found
  88019. */
  88020. getAnimatableByTarget(target: any): Nullable<Animatable>;
  88021. /**
  88022. * Gets all animatables associated with a given target
  88023. * @param target defines the target to look animatables for
  88024. * @returns an array of Animatables
  88025. */
  88026. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  88027. /**
  88028. * Stops and removes all animations that have been applied to the scene
  88029. */
  88030. stopAllAnimations(): void;
  88031. /**
  88032. * Gets the current delta time used by animation engine
  88033. */
  88034. deltaTime: number;
  88035. }
  88036. interface Bone {
  88037. /**
  88038. * Copy an animation range from another bone
  88039. * @param source defines the source bone
  88040. * @param rangeName defines the range name to copy
  88041. * @param frameOffset defines the frame offset
  88042. * @param rescaleAsRequired defines if rescaling must be applied if required
  88043. * @param skelDimensionsRatio defines the scaling ratio
  88044. * @returns true if operation was successful
  88045. */
  88046. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  88047. }
  88048. }
  88049. declare module BABYLON {
  88050. /**
  88051. * Class used to handle skinning animations
  88052. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  88053. */
  88054. export class Skeleton implements IAnimatable {
  88055. /** defines the skeleton name */
  88056. name: string;
  88057. /** defines the skeleton Id */
  88058. id: string;
  88059. /**
  88060. * Defines the list of child bones
  88061. */
  88062. bones: Bone[];
  88063. /**
  88064. * Defines an estimate of the dimension of the skeleton at rest
  88065. */
  88066. dimensionsAtRest: Vector3;
  88067. /**
  88068. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  88069. */
  88070. needInitialSkinMatrix: boolean;
  88071. /**
  88072. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  88073. */
  88074. overrideMesh: Nullable<AbstractMesh>;
  88075. /**
  88076. * Gets the list of animations attached to this skeleton
  88077. */
  88078. animations: Array<Animation>;
  88079. private _scene;
  88080. private _isDirty;
  88081. private _transformMatrices;
  88082. private _transformMatrixTexture;
  88083. private _meshesWithPoseMatrix;
  88084. private _animatables;
  88085. private _identity;
  88086. private _synchronizedWithMesh;
  88087. private _ranges;
  88088. private _lastAbsoluteTransformsUpdateId;
  88089. private _canUseTextureForBones;
  88090. private _uniqueId;
  88091. /** @hidden */
  88092. _numBonesWithLinkedTransformNode: number;
  88093. /** @hidden */
  88094. _hasWaitingData: Nullable<boolean>;
  88095. /**
  88096. * Specifies if the skeleton should be serialized
  88097. */
  88098. doNotSerialize: boolean;
  88099. private _useTextureToStoreBoneMatrices;
  88100. /**
  88101. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  88102. * Please note that this option is not available if the hardware does not support it
  88103. */
  88104. get useTextureToStoreBoneMatrices(): boolean;
  88105. set useTextureToStoreBoneMatrices(value: boolean);
  88106. private _animationPropertiesOverride;
  88107. /**
  88108. * Gets or sets the animation properties override
  88109. */
  88110. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  88111. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  88112. /**
  88113. * List of inspectable custom properties (used by the Inspector)
  88114. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88115. */
  88116. inspectableCustomProperties: IInspectable[];
  88117. /**
  88118. * An observable triggered before computing the skeleton's matrices
  88119. */
  88120. onBeforeComputeObservable: Observable<Skeleton>;
  88121. /**
  88122. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  88123. */
  88124. get isUsingTextureForMatrices(): boolean;
  88125. /**
  88126. * Gets the unique ID of this skeleton
  88127. */
  88128. get uniqueId(): number;
  88129. /**
  88130. * Creates a new skeleton
  88131. * @param name defines the skeleton name
  88132. * @param id defines the skeleton Id
  88133. * @param scene defines the hosting scene
  88134. */
  88135. constructor(
  88136. /** defines the skeleton name */
  88137. name: string,
  88138. /** defines the skeleton Id */
  88139. id: string, scene: Scene);
  88140. /**
  88141. * Gets the current object class name.
  88142. * @return the class name
  88143. */
  88144. getClassName(): string;
  88145. /**
  88146. * Returns an array containing the root bones
  88147. * @returns an array containing the root bones
  88148. */
  88149. getChildren(): Array<Bone>;
  88150. /**
  88151. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  88152. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  88153. * @returns a Float32Array containing matrices data
  88154. */
  88155. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  88156. /**
  88157. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  88158. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  88159. * @returns a raw texture containing the data
  88160. */
  88161. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  88162. /**
  88163. * Gets the current hosting scene
  88164. * @returns a scene object
  88165. */
  88166. getScene(): Scene;
  88167. /**
  88168. * Gets a string representing the current skeleton data
  88169. * @param fullDetails defines a boolean indicating if we want a verbose version
  88170. * @returns a string representing the current skeleton data
  88171. */
  88172. toString(fullDetails?: boolean): string;
  88173. /**
  88174. * Get bone's index searching by name
  88175. * @param name defines bone's name to search for
  88176. * @return the indice of the bone. Returns -1 if not found
  88177. */
  88178. getBoneIndexByName(name: string): number;
  88179. /**
  88180. * Creater a new animation range
  88181. * @param name defines the name of the range
  88182. * @param from defines the start key
  88183. * @param to defines the end key
  88184. */
  88185. createAnimationRange(name: string, from: number, to: number): void;
  88186. /**
  88187. * Delete a specific animation range
  88188. * @param name defines the name of the range
  88189. * @param deleteFrames defines if frames must be removed as well
  88190. */
  88191. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  88192. /**
  88193. * Gets a specific animation range
  88194. * @param name defines the name of the range to look for
  88195. * @returns the requested animation range or null if not found
  88196. */
  88197. getAnimationRange(name: string): Nullable<AnimationRange>;
  88198. /**
  88199. * Gets the list of all animation ranges defined on this skeleton
  88200. * @returns an array
  88201. */
  88202. getAnimationRanges(): Nullable<AnimationRange>[];
  88203. /**
  88204. * Copy animation range from a source skeleton.
  88205. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  88206. * @param source defines the source skeleton
  88207. * @param name defines the name of the range to copy
  88208. * @param rescaleAsRequired defines if rescaling must be applied if required
  88209. * @returns true if operation was successful
  88210. */
  88211. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  88212. /**
  88213. * Forces the skeleton to go to rest pose
  88214. */
  88215. returnToRest(): void;
  88216. private _getHighestAnimationFrame;
  88217. /**
  88218. * Begin a specific animation range
  88219. * @param name defines the name of the range to start
  88220. * @param loop defines if looping must be turned on (false by default)
  88221. * @param speedRatio defines the speed ratio to apply (1 by default)
  88222. * @param onAnimationEnd defines a callback which will be called when animation will end
  88223. * @returns a new animatable
  88224. */
  88225. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  88226. /** @hidden */
  88227. _markAsDirty(): void;
  88228. /** @hidden */
  88229. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  88230. /** @hidden */
  88231. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  88232. private _computeTransformMatrices;
  88233. /**
  88234. * Build all resources required to render a skeleton
  88235. */
  88236. prepare(): void;
  88237. /**
  88238. * Gets the list of animatables currently running for this skeleton
  88239. * @returns an array of animatables
  88240. */
  88241. getAnimatables(): IAnimatable[];
  88242. /**
  88243. * Clone the current skeleton
  88244. * @param name defines the name of the new skeleton
  88245. * @param id defines the id of the new skeleton
  88246. * @returns the new skeleton
  88247. */
  88248. clone(name: string, id?: string): Skeleton;
  88249. /**
  88250. * Enable animation blending for this skeleton
  88251. * @param blendingSpeed defines the blending speed to apply
  88252. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  88253. */
  88254. enableBlending(blendingSpeed?: number): void;
  88255. /**
  88256. * Releases all resources associated with the current skeleton
  88257. */
  88258. dispose(): void;
  88259. /**
  88260. * Serialize the skeleton in a JSON object
  88261. * @returns a JSON object
  88262. */
  88263. serialize(): any;
  88264. /**
  88265. * Creates a new skeleton from serialized data
  88266. * @param parsedSkeleton defines the serialized data
  88267. * @param scene defines the hosting scene
  88268. * @returns a new skeleton
  88269. */
  88270. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  88271. /**
  88272. * Compute all node absolute transforms
  88273. * @param forceUpdate defines if computation must be done even if cache is up to date
  88274. */
  88275. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  88276. /**
  88277. * Gets the root pose matrix
  88278. * @returns a matrix
  88279. */
  88280. getPoseMatrix(): Nullable<Matrix>;
  88281. /**
  88282. * Sorts bones per internal index
  88283. */
  88284. sortBones(): void;
  88285. private _sortBones;
  88286. }
  88287. }
  88288. declare module BABYLON {
  88289. /**
  88290. * Creates an instance based on a source mesh.
  88291. */
  88292. export class InstancedMesh extends AbstractMesh {
  88293. private _sourceMesh;
  88294. private _currentLOD;
  88295. /** @hidden */
  88296. _indexInSourceMeshInstanceArray: number;
  88297. constructor(name: string, source: Mesh);
  88298. /**
  88299. * Returns the string "InstancedMesh".
  88300. */
  88301. getClassName(): string;
  88302. /** Gets the list of lights affecting that mesh */
  88303. get lightSources(): Light[];
  88304. _resyncLightSources(): void;
  88305. _resyncLightSource(light: Light): void;
  88306. _removeLightSource(light: Light, dispose: boolean): void;
  88307. /**
  88308. * If the source mesh receives shadows
  88309. */
  88310. get receiveShadows(): boolean;
  88311. /**
  88312. * The material of the source mesh
  88313. */
  88314. get material(): Nullable<Material>;
  88315. /**
  88316. * Visibility of the source mesh
  88317. */
  88318. get visibility(): number;
  88319. /**
  88320. * Skeleton of the source mesh
  88321. */
  88322. get skeleton(): Nullable<Skeleton>;
  88323. /**
  88324. * Rendering ground id of the source mesh
  88325. */
  88326. get renderingGroupId(): number;
  88327. set renderingGroupId(value: number);
  88328. /**
  88329. * Returns the total number of vertices (integer).
  88330. */
  88331. getTotalVertices(): number;
  88332. /**
  88333. * Returns a positive integer : the total number of indices in this mesh geometry.
  88334. * @returns the numner of indices or zero if the mesh has no geometry.
  88335. */
  88336. getTotalIndices(): number;
  88337. /**
  88338. * The source mesh of the instance
  88339. */
  88340. get sourceMesh(): Mesh;
  88341. /**
  88342. * Is this node ready to be used/rendered
  88343. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  88344. * @return {boolean} is it ready
  88345. */
  88346. isReady(completeCheck?: boolean): boolean;
  88347. /**
  88348. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  88349. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  88350. * @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.
  88351. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  88352. */
  88353. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  88354. /**
  88355. * Sets the vertex data of the mesh geometry for the requested `kind`.
  88356. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  88357. * The `data` are either a numeric array either a Float32Array.
  88358. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  88359. * 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).
  88360. * Note that a new underlying VertexBuffer object is created each call.
  88361. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  88362. *
  88363. * Possible `kind` values :
  88364. * - VertexBuffer.PositionKind
  88365. * - VertexBuffer.UVKind
  88366. * - VertexBuffer.UV2Kind
  88367. * - VertexBuffer.UV3Kind
  88368. * - VertexBuffer.UV4Kind
  88369. * - VertexBuffer.UV5Kind
  88370. * - VertexBuffer.UV6Kind
  88371. * - VertexBuffer.ColorKind
  88372. * - VertexBuffer.MatricesIndicesKind
  88373. * - VertexBuffer.MatricesIndicesExtraKind
  88374. * - VertexBuffer.MatricesWeightsKind
  88375. * - VertexBuffer.MatricesWeightsExtraKind
  88376. *
  88377. * Returns the Mesh.
  88378. */
  88379. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  88380. /**
  88381. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  88382. * If the mesh has no geometry, it is simply returned as it is.
  88383. * The `data` are either a numeric array either a Float32Array.
  88384. * No new underlying VertexBuffer object is created.
  88385. * 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.
  88386. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  88387. *
  88388. * Possible `kind` values :
  88389. * - VertexBuffer.PositionKind
  88390. * - VertexBuffer.UVKind
  88391. * - VertexBuffer.UV2Kind
  88392. * - VertexBuffer.UV3Kind
  88393. * - VertexBuffer.UV4Kind
  88394. * - VertexBuffer.UV5Kind
  88395. * - VertexBuffer.UV6Kind
  88396. * - VertexBuffer.ColorKind
  88397. * - VertexBuffer.MatricesIndicesKind
  88398. * - VertexBuffer.MatricesIndicesExtraKind
  88399. * - VertexBuffer.MatricesWeightsKind
  88400. * - VertexBuffer.MatricesWeightsExtraKind
  88401. *
  88402. * Returns the Mesh.
  88403. */
  88404. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  88405. /**
  88406. * Sets the mesh indices.
  88407. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  88408. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  88409. * This method creates a new index buffer each call.
  88410. * Returns the Mesh.
  88411. */
  88412. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  88413. /**
  88414. * Boolean : True if the mesh owns the requested kind of data.
  88415. */
  88416. isVerticesDataPresent(kind: string): boolean;
  88417. /**
  88418. * Returns an array of indices (IndicesArray).
  88419. */
  88420. getIndices(): Nullable<IndicesArray>;
  88421. get _positions(): Nullable<Vector3[]>;
  88422. /**
  88423. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  88424. * This means the mesh underlying bounding box and sphere are recomputed.
  88425. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  88426. * @returns the current mesh
  88427. */
  88428. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  88429. /** @hidden */
  88430. _preActivate(): InstancedMesh;
  88431. /** @hidden */
  88432. _activate(renderId: number, intermediateRendering: boolean): boolean;
  88433. /** @hidden */
  88434. _postActivate(): void;
  88435. getWorldMatrix(): Matrix;
  88436. get isAnInstance(): boolean;
  88437. /**
  88438. * Returns the current associated LOD AbstractMesh.
  88439. */
  88440. getLOD(camera: Camera): AbstractMesh;
  88441. /** @hidden */
  88442. _syncSubMeshes(): InstancedMesh;
  88443. /** @hidden */
  88444. _generatePointsArray(): boolean;
  88445. /**
  88446. * Creates a new InstancedMesh from the current mesh.
  88447. * - name (string) : the cloned mesh name
  88448. * - newParent (optional Node) : the optional Node to parent the clone to.
  88449. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  88450. *
  88451. * Returns the clone.
  88452. */
  88453. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  88454. /**
  88455. * Disposes the InstancedMesh.
  88456. * Returns nothing.
  88457. */
  88458. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88459. }
  88460. interface Mesh {
  88461. /**
  88462. * Register a custom buffer that will be instanced
  88463. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  88464. * @param kind defines the buffer kind
  88465. * @param stride defines the stride in floats
  88466. */
  88467. registerInstancedBuffer(kind: string, stride: number): void;
  88468. /** @hidden */
  88469. _userInstancedBuffersStorage: {
  88470. data: {
  88471. [key: string]: Float32Array;
  88472. };
  88473. sizes: {
  88474. [key: string]: number;
  88475. };
  88476. vertexBuffers: {
  88477. [key: string]: Nullable<VertexBuffer>;
  88478. };
  88479. strides: {
  88480. [key: string]: number;
  88481. };
  88482. };
  88483. }
  88484. interface AbstractMesh {
  88485. /**
  88486. * Object used to store instanced buffers defined by user
  88487. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  88488. */
  88489. instancedBuffers: {
  88490. [key: string]: any;
  88491. };
  88492. }
  88493. }
  88494. declare module BABYLON {
  88495. /**
  88496. * Defines the options associated with the creation of a shader material.
  88497. */
  88498. export interface IShaderMaterialOptions {
  88499. /**
  88500. * Does the material work in alpha blend mode
  88501. */
  88502. needAlphaBlending: boolean;
  88503. /**
  88504. * Does the material work in alpha test mode
  88505. */
  88506. needAlphaTesting: boolean;
  88507. /**
  88508. * The list of attribute names used in the shader
  88509. */
  88510. attributes: string[];
  88511. /**
  88512. * The list of unifrom names used in the shader
  88513. */
  88514. uniforms: string[];
  88515. /**
  88516. * The list of UBO names used in the shader
  88517. */
  88518. uniformBuffers: string[];
  88519. /**
  88520. * The list of sampler names used in the shader
  88521. */
  88522. samplers: string[];
  88523. /**
  88524. * The list of defines used in the shader
  88525. */
  88526. defines: string[];
  88527. }
  88528. /**
  88529. * 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.
  88530. *
  88531. * This returned material effects how the mesh will look based on the code in the shaders.
  88532. *
  88533. * @see http://doc.babylonjs.com/how_to/shader_material
  88534. */
  88535. export class ShaderMaterial extends Material {
  88536. private _shaderPath;
  88537. private _options;
  88538. private _textures;
  88539. private _textureArrays;
  88540. private _floats;
  88541. private _ints;
  88542. private _floatsArrays;
  88543. private _colors3;
  88544. private _colors3Arrays;
  88545. private _colors4;
  88546. private _colors4Arrays;
  88547. private _vectors2;
  88548. private _vectors3;
  88549. private _vectors4;
  88550. private _matrices;
  88551. private _matrixArrays;
  88552. private _matrices3x3;
  88553. private _matrices2x2;
  88554. private _vectors2Arrays;
  88555. private _vectors3Arrays;
  88556. private _vectors4Arrays;
  88557. private _cachedWorldViewMatrix;
  88558. private _cachedWorldViewProjectionMatrix;
  88559. private _renderId;
  88560. private _multiview;
  88561. /**
  88562. * Instantiate a new shader material.
  88563. * 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.
  88564. * This returned material effects how the mesh will look based on the code in the shaders.
  88565. * @see http://doc.babylonjs.com/how_to/shader_material
  88566. * @param name Define the name of the material in the scene
  88567. * @param scene Define the scene the material belongs to
  88568. * @param shaderPath Defines the route to the shader code in one of three ways:
  88569. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  88570. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  88571. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  88572. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  88573. * @param options Define the options used to create the shader
  88574. */
  88575. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  88576. /**
  88577. * Gets the shader path used to define the shader code
  88578. * It can be modified to trigger a new compilation
  88579. */
  88580. get shaderPath(): any;
  88581. /**
  88582. * Sets the shader path used to define the shader code
  88583. * It can be modified to trigger a new compilation
  88584. */
  88585. set shaderPath(shaderPath: any);
  88586. /**
  88587. * Gets the options used to compile the shader.
  88588. * They can be modified to trigger a new compilation
  88589. */
  88590. get options(): IShaderMaterialOptions;
  88591. /**
  88592. * Gets the current class name of the material e.g. "ShaderMaterial"
  88593. * Mainly use in serialization.
  88594. * @returns the class name
  88595. */
  88596. getClassName(): string;
  88597. /**
  88598. * Specifies if the material will require alpha blending
  88599. * @returns a boolean specifying if alpha blending is needed
  88600. */
  88601. needAlphaBlending(): boolean;
  88602. /**
  88603. * Specifies if this material should be rendered in alpha test mode
  88604. * @returns a boolean specifying if an alpha test is needed.
  88605. */
  88606. needAlphaTesting(): boolean;
  88607. private _checkUniform;
  88608. /**
  88609. * Set a texture in the shader.
  88610. * @param name Define the name of the uniform samplers as defined in the shader
  88611. * @param texture Define the texture to bind to this sampler
  88612. * @return the material itself allowing "fluent" like uniform updates
  88613. */
  88614. setTexture(name: string, texture: Texture): ShaderMaterial;
  88615. /**
  88616. * Set a texture array in the shader.
  88617. * @param name Define the name of the uniform sampler array as defined in the shader
  88618. * @param textures Define the list of textures to bind to this sampler
  88619. * @return the material itself allowing "fluent" like uniform updates
  88620. */
  88621. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  88622. /**
  88623. * Set a float in the shader.
  88624. * @param name Define the name of the uniform as defined in the shader
  88625. * @param value Define the value to give to the uniform
  88626. * @return the material itself allowing "fluent" like uniform updates
  88627. */
  88628. setFloat(name: string, value: number): ShaderMaterial;
  88629. /**
  88630. * Set a int in the shader.
  88631. * @param name Define the name of the uniform as defined in the shader
  88632. * @param value Define the value to give to the uniform
  88633. * @return the material itself allowing "fluent" like uniform updates
  88634. */
  88635. setInt(name: string, value: number): ShaderMaterial;
  88636. /**
  88637. * Set an array of floats in the shader.
  88638. * @param name Define the name of the uniform as defined in the shader
  88639. * @param value Define the value to give to the uniform
  88640. * @return the material itself allowing "fluent" like uniform updates
  88641. */
  88642. setFloats(name: string, value: number[]): ShaderMaterial;
  88643. /**
  88644. * Set a vec3 in the shader from a Color3.
  88645. * @param name Define the name of the uniform as defined in the shader
  88646. * @param value Define the value to give to the uniform
  88647. * @return the material itself allowing "fluent" like uniform updates
  88648. */
  88649. setColor3(name: string, value: Color3): ShaderMaterial;
  88650. /**
  88651. * Set a vec3 array in the shader from a Color3 array.
  88652. * @param name Define the name of the uniform as defined in the shader
  88653. * @param value Define the value to give to the uniform
  88654. * @return the material itself allowing "fluent" like uniform updates
  88655. */
  88656. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  88657. /**
  88658. * Set a vec4 in the shader from a Color4.
  88659. * @param name Define the name of the uniform as defined in the shader
  88660. * @param value Define the value to give to the uniform
  88661. * @return the material itself allowing "fluent" like uniform updates
  88662. */
  88663. setColor4(name: string, value: Color4): ShaderMaterial;
  88664. /**
  88665. * Set a vec4 array in the shader from a Color4 array.
  88666. * @param name Define the name of the uniform as defined in the shader
  88667. * @param value Define the value to give to the uniform
  88668. * @return the material itself allowing "fluent" like uniform updates
  88669. */
  88670. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  88671. /**
  88672. * Set a vec2 in the shader from a Vector2.
  88673. * @param name Define the name of the uniform as defined in the shader
  88674. * @param value Define the value to give to the uniform
  88675. * @return the material itself allowing "fluent" like uniform updates
  88676. */
  88677. setVector2(name: string, value: Vector2): ShaderMaterial;
  88678. /**
  88679. * Set a vec3 in the shader from a Vector3.
  88680. * @param name Define the name of the uniform as defined in the shader
  88681. * @param value Define the value to give to the uniform
  88682. * @return the material itself allowing "fluent" like uniform updates
  88683. */
  88684. setVector3(name: string, value: Vector3): ShaderMaterial;
  88685. /**
  88686. * Set a vec4 in the shader from a Vector4.
  88687. * @param name Define the name of the uniform as defined in the shader
  88688. * @param value Define the value to give to the uniform
  88689. * @return the material itself allowing "fluent" like uniform updates
  88690. */
  88691. setVector4(name: string, value: Vector4): ShaderMaterial;
  88692. /**
  88693. * Set a mat4 in the shader from a Matrix.
  88694. * @param name Define the name of the uniform as defined in the shader
  88695. * @param value Define the value to give to the uniform
  88696. * @return the material itself allowing "fluent" like uniform updates
  88697. */
  88698. setMatrix(name: string, value: Matrix): ShaderMaterial;
  88699. /**
  88700. * Set a float32Array in the shader from a matrix array.
  88701. * @param name Define the name of the uniform as defined in the shader
  88702. * @param value Define the value to give to the uniform
  88703. * @return the material itself allowing "fluent" like uniform updates
  88704. */
  88705. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  88706. /**
  88707. * Set a mat3 in the shader from a Float32Array.
  88708. * @param name Define the name of the uniform as defined in the shader
  88709. * @param value Define the value to give to the uniform
  88710. * @return the material itself allowing "fluent" like uniform updates
  88711. */
  88712. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  88713. /**
  88714. * Set a mat2 in the shader from a Float32Array.
  88715. * @param name Define the name of the uniform as defined in the shader
  88716. * @param value Define the value to give to the uniform
  88717. * @return the material itself allowing "fluent" like uniform updates
  88718. */
  88719. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  88720. /**
  88721. * Set a vec2 array in the shader from a number array.
  88722. * @param name Define the name of the uniform as defined in the shader
  88723. * @param value Define the value to give to the uniform
  88724. * @return the material itself allowing "fluent" like uniform updates
  88725. */
  88726. setArray2(name: string, value: number[]): ShaderMaterial;
  88727. /**
  88728. * Set a vec3 array in the shader from a number array.
  88729. * @param name Define the name of the uniform as defined in the shader
  88730. * @param value Define the value to give to the uniform
  88731. * @return the material itself allowing "fluent" like uniform updates
  88732. */
  88733. setArray3(name: string, value: number[]): ShaderMaterial;
  88734. /**
  88735. * Set a vec4 array in the shader from a number array.
  88736. * @param name Define the name of the uniform as defined in the shader
  88737. * @param value Define the value to give to the uniform
  88738. * @return the material itself allowing "fluent" like uniform updates
  88739. */
  88740. setArray4(name: string, value: number[]): ShaderMaterial;
  88741. private _checkCache;
  88742. /**
  88743. * Specifies that the submesh is ready to be used
  88744. * @param mesh defines the mesh to check
  88745. * @param subMesh defines which submesh to check
  88746. * @param useInstances specifies that instances should be used
  88747. * @returns a boolean indicating that the submesh is ready or not
  88748. */
  88749. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  88750. /**
  88751. * Checks if the material is ready to render the requested mesh
  88752. * @param mesh Define the mesh to render
  88753. * @param useInstances Define whether or not the material is used with instances
  88754. * @returns true if ready, otherwise false
  88755. */
  88756. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  88757. /**
  88758. * Binds the world matrix to the material
  88759. * @param world defines the world transformation matrix
  88760. */
  88761. bindOnlyWorldMatrix(world: Matrix): void;
  88762. /**
  88763. * Binds the material to the mesh
  88764. * @param world defines the world transformation matrix
  88765. * @param mesh defines the mesh to bind the material to
  88766. */
  88767. bind(world: Matrix, mesh?: Mesh): void;
  88768. /**
  88769. * Gets the active textures from the material
  88770. * @returns an array of textures
  88771. */
  88772. getActiveTextures(): BaseTexture[];
  88773. /**
  88774. * Specifies if the material uses a texture
  88775. * @param texture defines the texture to check against the material
  88776. * @returns a boolean specifying if the material uses the texture
  88777. */
  88778. hasTexture(texture: BaseTexture): boolean;
  88779. /**
  88780. * Makes a duplicate of the material, and gives it a new name
  88781. * @param name defines the new name for the duplicated material
  88782. * @returns the cloned material
  88783. */
  88784. clone(name: string): ShaderMaterial;
  88785. /**
  88786. * Disposes the material
  88787. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  88788. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  88789. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  88790. */
  88791. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  88792. /**
  88793. * Serializes this material in a JSON representation
  88794. * @returns the serialized material object
  88795. */
  88796. serialize(): any;
  88797. /**
  88798. * Creates a shader material from parsed shader material data
  88799. * @param source defines the JSON represnetation of the material
  88800. * @param scene defines the hosting scene
  88801. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  88802. * @returns a new material
  88803. */
  88804. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  88805. }
  88806. }
  88807. declare module BABYLON {
  88808. /** @hidden */
  88809. export var colorPixelShader: {
  88810. name: string;
  88811. shader: string;
  88812. };
  88813. }
  88814. declare module BABYLON {
  88815. /** @hidden */
  88816. export var colorVertexShader: {
  88817. name: string;
  88818. shader: string;
  88819. };
  88820. }
  88821. declare module BABYLON {
  88822. /**
  88823. * Line mesh
  88824. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  88825. */
  88826. export class LinesMesh extends Mesh {
  88827. /**
  88828. * If vertex color should be applied to the mesh
  88829. */
  88830. readonly useVertexColor?: boolean | undefined;
  88831. /**
  88832. * If vertex alpha should be applied to the mesh
  88833. */
  88834. readonly useVertexAlpha?: boolean | undefined;
  88835. /**
  88836. * Color of the line (Default: White)
  88837. */
  88838. color: Color3;
  88839. /**
  88840. * Alpha of the line (Default: 1)
  88841. */
  88842. alpha: number;
  88843. /**
  88844. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  88845. * This margin is expressed in world space coordinates, so its value may vary.
  88846. * Default value is 0.1
  88847. */
  88848. intersectionThreshold: number;
  88849. private _colorShader;
  88850. private color4;
  88851. /**
  88852. * Creates a new LinesMesh
  88853. * @param name defines the name
  88854. * @param scene defines the hosting scene
  88855. * @param parent defines the parent mesh if any
  88856. * @param source defines the optional source LinesMesh used to clone data from
  88857. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  88858. * When false, achieved by calling a clone(), also passing False.
  88859. * This will make creation of children, recursive.
  88860. * @param useVertexColor defines if this LinesMesh supports vertex color
  88861. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  88862. */
  88863. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  88864. /**
  88865. * If vertex color should be applied to the mesh
  88866. */
  88867. useVertexColor?: boolean | undefined,
  88868. /**
  88869. * If vertex alpha should be applied to the mesh
  88870. */
  88871. useVertexAlpha?: boolean | undefined);
  88872. private _addClipPlaneDefine;
  88873. private _removeClipPlaneDefine;
  88874. isReady(): boolean;
  88875. /**
  88876. * Returns the string "LineMesh"
  88877. */
  88878. getClassName(): string;
  88879. /**
  88880. * @hidden
  88881. */
  88882. get material(): Material;
  88883. /**
  88884. * @hidden
  88885. */
  88886. set material(value: Material);
  88887. /**
  88888. * @hidden
  88889. */
  88890. get checkCollisions(): boolean;
  88891. /** @hidden */
  88892. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  88893. /** @hidden */
  88894. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  88895. /**
  88896. * Disposes of the line mesh
  88897. * @param doNotRecurse If children should be disposed
  88898. */
  88899. dispose(doNotRecurse?: boolean): void;
  88900. /**
  88901. * Returns a new LineMesh object cloned from the current one.
  88902. */
  88903. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  88904. /**
  88905. * Creates a new InstancedLinesMesh object from the mesh model.
  88906. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  88907. * @param name defines the name of the new instance
  88908. * @returns a new InstancedLinesMesh
  88909. */
  88910. createInstance(name: string): InstancedLinesMesh;
  88911. }
  88912. /**
  88913. * Creates an instance based on a source LinesMesh
  88914. */
  88915. export class InstancedLinesMesh extends InstancedMesh {
  88916. /**
  88917. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  88918. * This margin is expressed in world space coordinates, so its value may vary.
  88919. * Initilized with the intersectionThreshold value of the source LinesMesh
  88920. */
  88921. intersectionThreshold: number;
  88922. constructor(name: string, source: LinesMesh);
  88923. /**
  88924. * Returns the string "InstancedLinesMesh".
  88925. */
  88926. getClassName(): string;
  88927. }
  88928. }
  88929. declare module BABYLON {
  88930. /** @hidden */
  88931. export var linePixelShader: {
  88932. name: string;
  88933. shader: string;
  88934. };
  88935. }
  88936. declare module BABYLON {
  88937. /** @hidden */
  88938. export var lineVertexShader: {
  88939. name: string;
  88940. shader: string;
  88941. };
  88942. }
  88943. declare module BABYLON {
  88944. interface AbstractMesh {
  88945. /**
  88946. * Gets the edgesRenderer associated with the mesh
  88947. */
  88948. edgesRenderer: Nullable<EdgesRenderer>;
  88949. }
  88950. interface LinesMesh {
  88951. /**
  88952. * Enables the edge rendering mode on the mesh.
  88953. * This mode makes the mesh edges visible
  88954. * @param epsilon defines the maximal distance between two angles to detect a face
  88955. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  88956. * @returns the currentAbstractMesh
  88957. * @see https://www.babylonjs-playground.com/#19O9TU#0
  88958. */
  88959. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  88960. }
  88961. interface InstancedLinesMesh {
  88962. /**
  88963. * Enables the edge rendering mode on the mesh.
  88964. * This mode makes the mesh edges visible
  88965. * @param epsilon defines the maximal distance between two angles to detect a face
  88966. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  88967. * @returns the current InstancedLinesMesh
  88968. * @see https://www.babylonjs-playground.com/#19O9TU#0
  88969. */
  88970. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  88971. }
  88972. /**
  88973. * Defines the minimum contract an Edges renderer should follow.
  88974. */
  88975. export interface IEdgesRenderer extends IDisposable {
  88976. /**
  88977. * Gets or sets a boolean indicating if the edgesRenderer is active
  88978. */
  88979. isEnabled: boolean;
  88980. /**
  88981. * Renders the edges of the attached mesh,
  88982. */
  88983. render(): void;
  88984. /**
  88985. * Checks wether or not the edges renderer is ready to render.
  88986. * @return true if ready, otherwise false.
  88987. */
  88988. isReady(): boolean;
  88989. }
  88990. /**
  88991. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  88992. */
  88993. export class EdgesRenderer implements IEdgesRenderer {
  88994. /**
  88995. * Define the size of the edges with an orthographic camera
  88996. */
  88997. edgesWidthScalerForOrthographic: number;
  88998. /**
  88999. * Define the size of the edges with a perspective camera
  89000. */
  89001. edgesWidthScalerForPerspective: number;
  89002. protected _source: AbstractMesh;
  89003. protected _linesPositions: number[];
  89004. protected _linesNormals: number[];
  89005. protected _linesIndices: number[];
  89006. protected _epsilon: number;
  89007. protected _indicesCount: number;
  89008. protected _lineShader: ShaderMaterial;
  89009. protected _ib: DataBuffer;
  89010. protected _buffers: {
  89011. [key: string]: Nullable<VertexBuffer>;
  89012. };
  89013. protected _checkVerticesInsteadOfIndices: boolean;
  89014. private _meshRebuildObserver;
  89015. private _meshDisposeObserver;
  89016. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  89017. isEnabled: boolean;
  89018. /**
  89019. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  89020. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  89021. * @param source Mesh used to create edges
  89022. * @param epsilon sum of angles in adjacency to check for edge
  89023. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  89024. * @param generateEdgesLines - should generate Lines or only prepare resources.
  89025. */
  89026. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  89027. protected _prepareRessources(): void;
  89028. /** @hidden */
  89029. _rebuild(): void;
  89030. /**
  89031. * Releases the required resources for the edges renderer
  89032. */
  89033. dispose(): void;
  89034. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  89035. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  89036. /**
  89037. * Checks if the pair of p0 and p1 is en edge
  89038. * @param faceIndex
  89039. * @param edge
  89040. * @param faceNormals
  89041. * @param p0
  89042. * @param p1
  89043. * @private
  89044. */
  89045. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  89046. /**
  89047. * push line into the position, normal and index buffer
  89048. * @protected
  89049. */
  89050. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  89051. /**
  89052. * Generates lines edges from adjacencjes
  89053. * @private
  89054. */
  89055. _generateEdgesLines(): void;
  89056. /**
  89057. * Checks wether or not the edges renderer is ready to render.
  89058. * @return true if ready, otherwise false.
  89059. */
  89060. isReady(): boolean;
  89061. /**
  89062. * Renders the edges of the attached mesh,
  89063. */
  89064. render(): void;
  89065. }
  89066. /**
  89067. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  89068. */
  89069. export class LineEdgesRenderer extends EdgesRenderer {
  89070. /**
  89071. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  89072. * @param source LineMesh used to generate edges
  89073. * @param epsilon not important (specified angle for edge detection)
  89074. * @param checkVerticesInsteadOfIndices not important for LineMesh
  89075. */
  89076. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  89077. /**
  89078. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  89079. */
  89080. _generateEdgesLines(): void;
  89081. }
  89082. }
  89083. declare module BABYLON {
  89084. /**
  89085. * This represents the object necessary to create a rendering group.
  89086. * This is exclusively used and created by the rendering manager.
  89087. * To modify the behavior, you use the available helpers in your scene or meshes.
  89088. * @hidden
  89089. */
  89090. export class RenderingGroup {
  89091. index: number;
  89092. private static _zeroVector;
  89093. private _scene;
  89094. private _opaqueSubMeshes;
  89095. private _transparentSubMeshes;
  89096. private _alphaTestSubMeshes;
  89097. private _depthOnlySubMeshes;
  89098. private _particleSystems;
  89099. private _spriteManagers;
  89100. private _opaqueSortCompareFn;
  89101. private _alphaTestSortCompareFn;
  89102. private _transparentSortCompareFn;
  89103. private _renderOpaque;
  89104. private _renderAlphaTest;
  89105. private _renderTransparent;
  89106. /** @hidden */
  89107. _edgesRenderers: SmartArray<IEdgesRenderer>;
  89108. onBeforeTransparentRendering: () => void;
  89109. /**
  89110. * Set the opaque sort comparison function.
  89111. * If null the sub meshes will be render in the order they were created
  89112. */
  89113. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  89114. /**
  89115. * Set the alpha test sort comparison function.
  89116. * If null the sub meshes will be render in the order they were created
  89117. */
  89118. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  89119. /**
  89120. * Set the transparent sort comparison function.
  89121. * If null the sub meshes will be render in the order they were created
  89122. */
  89123. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  89124. /**
  89125. * Creates a new rendering group.
  89126. * @param index The rendering group index
  89127. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  89128. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  89129. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  89130. */
  89131. 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>);
  89132. /**
  89133. * Render all the sub meshes contained in the group.
  89134. * @param customRenderFunction Used to override the default render behaviour of the group.
  89135. * @returns true if rendered some submeshes.
  89136. */
  89137. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  89138. /**
  89139. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  89140. * @param subMeshes The submeshes to render
  89141. */
  89142. private renderOpaqueSorted;
  89143. /**
  89144. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  89145. * @param subMeshes The submeshes to render
  89146. */
  89147. private renderAlphaTestSorted;
  89148. /**
  89149. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  89150. * @param subMeshes The submeshes to render
  89151. */
  89152. private renderTransparentSorted;
  89153. /**
  89154. * Renders the submeshes in a specified order.
  89155. * @param subMeshes The submeshes to sort before render
  89156. * @param sortCompareFn The comparison function use to sort
  89157. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  89158. * @param transparent Specifies to activate blending if true
  89159. */
  89160. private static renderSorted;
  89161. /**
  89162. * Renders the submeshes in the order they were dispatched (no sort applied).
  89163. * @param subMeshes The submeshes to render
  89164. */
  89165. private static renderUnsorted;
  89166. /**
  89167. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89168. * are rendered back to front if in the same alpha index.
  89169. *
  89170. * @param a The first submesh
  89171. * @param b The second submesh
  89172. * @returns The result of the comparison
  89173. */
  89174. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  89175. /**
  89176. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89177. * are rendered back to front.
  89178. *
  89179. * @param a The first submesh
  89180. * @param b The second submesh
  89181. * @returns The result of the comparison
  89182. */
  89183. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  89184. /**
  89185. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89186. * are rendered front to back (prevent overdraw).
  89187. *
  89188. * @param a The first submesh
  89189. * @param b The second submesh
  89190. * @returns The result of the comparison
  89191. */
  89192. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  89193. /**
  89194. * Resets the different lists of submeshes to prepare a new frame.
  89195. */
  89196. prepare(): void;
  89197. dispose(): void;
  89198. /**
  89199. * Inserts the submesh in its correct queue depending on its material.
  89200. * @param subMesh The submesh to dispatch
  89201. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  89202. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  89203. */
  89204. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  89205. dispatchSprites(spriteManager: ISpriteManager): void;
  89206. dispatchParticles(particleSystem: IParticleSystem): void;
  89207. private _renderParticles;
  89208. private _renderSprites;
  89209. }
  89210. }
  89211. declare module BABYLON {
  89212. /**
  89213. * Interface describing the different options available in the rendering manager
  89214. * regarding Auto Clear between groups.
  89215. */
  89216. export interface IRenderingManagerAutoClearSetup {
  89217. /**
  89218. * Defines whether or not autoclear is enable.
  89219. */
  89220. autoClear: boolean;
  89221. /**
  89222. * Defines whether or not to autoclear the depth buffer.
  89223. */
  89224. depth: boolean;
  89225. /**
  89226. * Defines whether or not to autoclear the stencil buffer.
  89227. */
  89228. stencil: boolean;
  89229. }
  89230. /**
  89231. * This class is used by the onRenderingGroupObservable
  89232. */
  89233. export class RenderingGroupInfo {
  89234. /**
  89235. * The Scene that being rendered
  89236. */
  89237. scene: Scene;
  89238. /**
  89239. * The camera currently used for the rendering pass
  89240. */
  89241. camera: Nullable<Camera>;
  89242. /**
  89243. * The ID of the renderingGroup being processed
  89244. */
  89245. renderingGroupId: number;
  89246. }
  89247. /**
  89248. * This is the manager responsible of all the rendering for meshes sprites and particles.
  89249. * It is enable to manage the different groups as well as the different necessary sort functions.
  89250. * This should not be used directly aside of the few static configurations
  89251. */
  89252. export class RenderingManager {
  89253. /**
  89254. * The max id used for rendering groups (not included)
  89255. */
  89256. static MAX_RENDERINGGROUPS: number;
  89257. /**
  89258. * The min id used for rendering groups (included)
  89259. */
  89260. static MIN_RENDERINGGROUPS: number;
  89261. /**
  89262. * Used to globally prevent autoclearing scenes.
  89263. */
  89264. static AUTOCLEAR: boolean;
  89265. /**
  89266. * @hidden
  89267. */
  89268. _useSceneAutoClearSetup: boolean;
  89269. private _scene;
  89270. private _renderingGroups;
  89271. private _depthStencilBufferAlreadyCleaned;
  89272. private _autoClearDepthStencil;
  89273. private _customOpaqueSortCompareFn;
  89274. private _customAlphaTestSortCompareFn;
  89275. private _customTransparentSortCompareFn;
  89276. private _renderingGroupInfo;
  89277. /**
  89278. * Instantiates a new rendering group for a particular scene
  89279. * @param scene Defines the scene the groups belongs to
  89280. */
  89281. constructor(scene: Scene);
  89282. private _clearDepthStencilBuffer;
  89283. /**
  89284. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  89285. * @hidden
  89286. */
  89287. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  89288. /**
  89289. * Resets the different information of the group to prepare a new frame
  89290. * @hidden
  89291. */
  89292. reset(): void;
  89293. /**
  89294. * Dispose and release the group and its associated resources.
  89295. * @hidden
  89296. */
  89297. dispose(): void;
  89298. /**
  89299. * Clear the info related to rendering groups preventing retention points during dispose.
  89300. */
  89301. freeRenderingGroups(): void;
  89302. private _prepareRenderingGroup;
  89303. /**
  89304. * Add a sprite manager to the rendering manager in order to render it this frame.
  89305. * @param spriteManager Define the sprite manager to render
  89306. */
  89307. dispatchSprites(spriteManager: ISpriteManager): void;
  89308. /**
  89309. * Add a particle system to the rendering manager in order to render it this frame.
  89310. * @param particleSystem Define the particle system to render
  89311. */
  89312. dispatchParticles(particleSystem: IParticleSystem): void;
  89313. /**
  89314. * Add a submesh to the manager in order to render it this frame
  89315. * @param subMesh The submesh to dispatch
  89316. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  89317. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  89318. */
  89319. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  89320. /**
  89321. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  89322. * This allowed control for front to back rendering or reversly depending of the special needs.
  89323. *
  89324. * @param renderingGroupId The rendering group id corresponding to its index
  89325. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  89326. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  89327. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  89328. */
  89329. 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;
  89330. /**
  89331. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  89332. *
  89333. * @param renderingGroupId The rendering group id corresponding to its index
  89334. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  89335. * @param depth Automatically clears depth between groups if true and autoClear is true.
  89336. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  89337. */
  89338. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  89339. /**
  89340. * Gets the current auto clear configuration for one rendering group of the rendering
  89341. * manager.
  89342. * @param index the rendering group index to get the information for
  89343. * @returns The auto clear setup for the requested rendering group
  89344. */
  89345. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  89346. }
  89347. }
  89348. declare module BABYLON {
  89349. /**
  89350. * Defines the options associated with the creation of a custom shader for a shadow generator.
  89351. */
  89352. export interface ICustomShaderOptions {
  89353. /**
  89354. * Gets or sets the custom shader name to use
  89355. */
  89356. shaderName: string;
  89357. /**
  89358. * The list of attribute names used in the shader
  89359. */
  89360. attributes?: string[];
  89361. /**
  89362. * The list of unifrom names used in the shader
  89363. */
  89364. uniforms?: string[];
  89365. /**
  89366. * The list of sampler names used in the shader
  89367. */
  89368. samplers?: string[];
  89369. /**
  89370. * The list of defines used in the shader
  89371. */
  89372. defines?: string[];
  89373. }
  89374. /**
  89375. * Interface to implement to create a shadow generator compatible with BJS.
  89376. */
  89377. export interface IShadowGenerator {
  89378. /**
  89379. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  89380. * @returns The render target texture if present otherwise, null
  89381. */
  89382. getShadowMap(): Nullable<RenderTargetTexture>;
  89383. /**
  89384. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  89385. * @param subMesh The submesh we want to render in the shadow map
  89386. * @param useInstances Defines wether will draw in the map using instances
  89387. * @returns true if ready otherwise, false
  89388. */
  89389. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  89390. /**
  89391. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  89392. * @param defines Defines of the material we want to update
  89393. * @param lightIndex Index of the light in the enabled light list of the material
  89394. */
  89395. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  89396. /**
  89397. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  89398. * defined in the generator but impacting the effect).
  89399. * It implies the unifroms available on the materials are the standard BJS ones.
  89400. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  89401. * @param effect The effect we are binfing the information for
  89402. */
  89403. bindShadowLight(lightIndex: string, effect: Effect): void;
  89404. /**
  89405. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  89406. * (eq to shadow prjection matrix * light transform matrix)
  89407. * @returns The transform matrix used to create the shadow map
  89408. */
  89409. getTransformMatrix(): Matrix;
  89410. /**
  89411. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  89412. * Cube and 2D textures for instance.
  89413. */
  89414. recreateShadowMap(): void;
  89415. /**
  89416. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89417. * @param onCompiled Callback triggered at the and of the effects compilation
  89418. * @param options Sets of optional options forcing the compilation with different modes
  89419. */
  89420. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  89421. useInstances: boolean;
  89422. }>): void;
  89423. /**
  89424. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89425. * @param options Sets of optional options forcing the compilation with different modes
  89426. * @returns A promise that resolves when the compilation completes
  89427. */
  89428. forceCompilationAsync(options?: Partial<{
  89429. useInstances: boolean;
  89430. }>): Promise<void>;
  89431. /**
  89432. * Serializes the shadow generator setup to a json object.
  89433. * @returns The serialized JSON object
  89434. */
  89435. serialize(): any;
  89436. /**
  89437. * Disposes the Shadow map and related Textures and effects.
  89438. */
  89439. dispose(): void;
  89440. }
  89441. /**
  89442. * Default implementation IShadowGenerator.
  89443. * This is the main object responsible of generating shadows in the framework.
  89444. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  89445. */
  89446. export class ShadowGenerator implements IShadowGenerator {
  89447. /**
  89448. * Name of the shadow generator class
  89449. */
  89450. static CLASSNAME: string;
  89451. /**
  89452. * Shadow generator mode None: no filtering applied.
  89453. */
  89454. static readonly FILTER_NONE: number;
  89455. /**
  89456. * Shadow generator mode ESM: Exponential Shadow Mapping.
  89457. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89458. */
  89459. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  89460. /**
  89461. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  89462. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  89463. */
  89464. static readonly FILTER_POISSONSAMPLING: number;
  89465. /**
  89466. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  89467. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89468. */
  89469. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  89470. /**
  89471. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  89472. * edge artifacts on steep falloff.
  89473. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89474. */
  89475. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  89476. /**
  89477. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  89478. * edge artifacts on steep falloff.
  89479. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89480. */
  89481. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  89482. /**
  89483. * Shadow generator mode PCF: Percentage Closer Filtering
  89484. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  89485. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  89486. */
  89487. static readonly FILTER_PCF: number;
  89488. /**
  89489. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  89490. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  89491. * Contact Hardening
  89492. */
  89493. static readonly FILTER_PCSS: number;
  89494. /**
  89495. * Reserved for PCF and PCSS
  89496. * Highest Quality.
  89497. *
  89498. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  89499. *
  89500. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  89501. */
  89502. static readonly QUALITY_HIGH: number;
  89503. /**
  89504. * Reserved for PCF and PCSS
  89505. * Good tradeoff for quality/perf cross devices
  89506. *
  89507. * Execute PCF on a 3*3 kernel.
  89508. *
  89509. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  89510. */
  89511. static readonly QUALITY_MEDIUM: number;
  89512. /**
  89513. * Reserved for PCF and PCSS
  89514. * The lowest quality but the fastest.
  89515. *
  89516. * Execute PCF on a 1*1 kernel.
  89517. *
  89518. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  89519. */
  89520. static readonly QUALITY_LOW: number;
  89521. /** Gets or sets the custom shader name to use */
  89522. customShaderOptions: ICustomShaderOptions;
  89523. /**
  89524. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  89525. */
  89526. onBeforeShadowMapRenderObservable: Observable<Effect>;
  89527. /**
  89528. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  89529. */
  89530. onAfterShadowMapRenderObservable: Observable<Effect>;
  89531. /**
  89532. * Observable triggered before a mesh is rendered in the shadow map.
  89533. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  89534. */
  89535. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  89536. /**
  89537. * Observable triggered after a mesh is rendered in the shadow map.
  89538. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  89539. */
  89540. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  89541. protected _bias: number;
  89542. /**
  89543. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  89544. */
  89545. get bias(): number;
  89546. /**
  89547. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  89548. */
  89549. set bias(bias: number);
  89550. protected _normalBias: number;
  89551. /**
  89552. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  89553. */
  89554. get normalBias(): number;
  89555. /**
  89556. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  89557. */
  89558. set normalBias(normalBias: number);
  89559. protected _blurBoxOffset: number;
  89560. /**
  89561. * Gets the blur box offset: offset applied during the blur pass.
  89562. * Only useful if useKernelBlur = false
  89563. */
  89564. get blurBoxOffset(): number;
  89565. /**
  89566. * Sets the blur box offset: offset applied during the blur pass.
  89567. * Only useful if useKernelBlur = false
  89568. */
  89569. set blurBoxOffset(value: number);
  89570. protected _blurScale: number;
  89571. /**
  89572. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  89573. * 2 means half of the size.
  89574. */
  89575. get blurScale(): number;
  89576. /**
  89577. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  89578. * 2 means half of the size.
  89579. */
  89580. set blurScale(value: number);
  89581. protected _blurKernel: number;
  89582. /**
  89583. * Gets the blur kernel: kernel size of the blur pass.
  89584. * Only useful if useKernelBlur = true
  89585. */
  89586. get blurKernel(): number;
  89587. /**
  89588. * Sets the blur kernel: kernel size of the blur pass.
  89589. * Only useful if useKernelBlur = true
  89590. */
  89591. set blurKernel(value: number);
  89592. protected _useKernelBlur: boolean;
  89593. /**
  89594. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  89595. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  89596. */
  89597. get useKernelBlur(): boolean;
  89598. /**
  89599. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  89600. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  89601. */
  89602. set useKernelBlur(value: boolean);
  89603. protected _depthScale: number;
  89604. /**
  89605. * Gets the depth scale used in ESM mode.
  89606. */
  89607. get depthScale(): number;
  89608. /**
  89609. * Sets the depth scale used in ESM mode.
  89610. * This can override the scale stored on the light.
  89611. */
  89612. set depthScale(value: number);
  89613. protected _validateFilter(filter: number): number;
  89614. protected _filter: number;
  89615. /**
  89616. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  89617. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  89618. */
  89619. get filter(): number;
  89620. /**
  89621. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  89622. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  89623. */
  89624. set filter(value: number);
  89625. /**
  89626. * Gets if the current filter is set to Poisson Sampling.
  89627. */
  89628. get usePoissonSampling(): boolean;
  89629. /**
  89630. * Sets the current filter to Poisson Sampling.
  89631. */
  89632. set usePoissonSampling(value: boolean);
  89633. /**
  89634. * Gets if the current filter is set to ESM.
  89635. */
  89636. get useExponentialShadowMap(): boolean;
  89637. /**
  89638. * Sets the current filter is to ESM.
  89639. */
  89640. set useExponentialShadowMap(value: boolean);
  89641. /**
  89642. * Gets if the current filter is set to filtered ESM.
  89643. */
  89644. get useBlurExponentialShadowMap(): boolean;
  89645. /**
  89646. * Gets if the current filter is set to filtered ESM.
  89647. */
  89648. set useBlurExponentialShadowMap(value: boolean);
  89649. /**
  89650. * Gets if the current filter is set to "close ESM" (using the inverse of the
  89651. * exponential to prevent steep falloff artifacts).
  89652. */
  89653. get useCloseExponentialShadowMap(): boolean;
  89654. /**
  89655. * Sets the current filter to "close ESM" (using the inverse of the
  89656. * exponential to prevent steep falloff artifacts).
  89657. */
  89658. set useCloseExponentialShadowMap(value: boolean);
  89659. /**
  89660. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  89661. * exponential to prevent steep falloff artifacts).
  89662. */
  89663. get useBlurCloseExponentialShadowMap(): boolean;
  89664. /**
  89665. * Sets the current filter to filtered "close ESM" (using the inverse of the
  89666. * exponential to prevent steep falloff artifacts).
  89667. */
  89668. set useBlurCloseExponentialShadowMap(value: boolean);
  89669. /**
  89670. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  89671. */
  89672. get usePercentageCloserFiltering(): boolean;
  89673. /**
  89674. * Sets the current filter to "PCF" (percentage closer filtering).
  89675. */
  89676. set usePercentageCloserFiltering(value: boolean);
  89677. protected _filteringQuality: number;
  89678. /**
  89679. * Gets the PCF or PCSS Quality.
  89680. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  89681. */
  89682. get filteringQuality(): number;
  89683. /**
  89684. * Sets the PCF or PCSS Quality.
  89685. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  89686. */
  89687. set filteringQuality(filteringQuality: number);
  89688. /**
  89689. * Gets if the current filter is set to "PCSS" (contact hardening).
  89690. */
  89691. get useContactHardeningShadow(): boolean;
  89692. /**
  89693. * Sets the current filter to "PCSS" (contact hardening).
  89694. */
  89695. set useContactHardeningShadow(value: boolean);
  89696. protected _contactHardeningLightSizeUVRatio: number;
  89697. /**
  89698. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  89699. * Using a ratio helps keeping shape stability independently of the map size.
  89700. *
  89701. * It does not account for the light projection as it was having too much
  89702. * instability during the light setup or during light position changes.
  89703. *
  89704. * Only valid if useContactHardeningShadow is true.
  89705. */
  89706. get contactHardeningLightSizeUVRatio(): number;
  89707. /**
  89708. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  89709. * Using a ratio helps keeping shape stability independently of the map size.
  89710. *
  89711. * It does not account for the light projection as it was having too much
  89712. * instability during the light setup or during light position changes.
  89713. *
  89714. * Only valid if useContactHardeningShadow is true.
  89715. */
  89716. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  89717. protected _darkness: number;
  89718. /** Gets or sets the actual darkness of a shadow */
  89719. get darkness(): number;
  89720. set darkness(value: number);
  89721. /**
  89722. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  89723. * 0 means strongest and 1 would means no shadow.
  89724. * @returns the darkness.
  89725. */
  89726. getDarkness(): number;
  89727. /**
  89728. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  89729. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  89730. * @returns the shadow generator allowing fluent coding.
  89731. */
  89732. setDarkness(darkness: number): ShadowGenerator;
  89733. protected _transparencyShadow: boolean;
  89734. /** Gets or sets the ability to have transparent shadow */
  89735. get transparencyShadow(): boolean;
  89736. set transparencyShadow(value: boolean);
  89737. /**
  89738. * Sets the ability to have transparent shadow (boolean).
  89739. * @param transparent True if transparent else False
  89740. * @returns the shadow generator allowing fluent coding
  89741. */
  89742. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  89743. protected _shadowMap: Nullable<RenderTargetTexture>;
  89744. protected _shadowMap2: Nullable<RenderTargetTexture>;
  89745. /**
  89746. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  89747. * @returns The render target texture if present otherwise, null
  89748. */
  89749. getShadowMap(): Nullable<RenderTargetTexture>;
  89750. /**
  89751. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  89752. * @returns The render target texture if the shadow map is present otherwise, null
  89753. */
  89754. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  89755. /**
  89756. * Gets the class name of that object
  89757. * @returns "ShadowGenerator"
  89758. */
  89759. getClassName(): string;
  89760. /**
  89761. * Helper function to add a mesh and its descendants to the list of shadow casters.
  89762. * @param mesh Mesh to add
  89763. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  89764. * @returns the Shadow Generator itself
  89765. */
  89766. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  89767. /**
  89768. * Helper function to remove a mesh and its descendants from the list of shadow casters
  89769. * @param mesh Mesh to remove
  89770. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  89771. * @returns the Shadow Generator itself
  89772. */
  89773. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  89774. /**
  89775. * Controls the extent to which the shadows fade out at the edge of the frustum
  89776. */
  89777. frustumEdgeFalloff: number;
  89778. protected _light: IShadowLight;
  89779. /**
  89780. * Returns the associated light object.
  89781. * @returns the light generating the shadow
  89782. */
  89783. getLight(): IShadowLight;
  89784. /**
  89785. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  89786. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  89787. * It might on the other hand introduce peter panning.
  89788. */
  89789. forceBackFacesOnly: boolean;
  89790. protected _scene: Scene;
  89791. protected _lightDirection: Vector3;
  89792. protected _effect: Effect;
  89793. protected _viewMatrix: Matrix;
  89794. protected _projectionMatrix: Matrix;
  89795. protected _transformMatrix: Matrix;
  89796. protected _cachedPosition: Vector3;
  89797. protected _cachedDirection: Vector3;
  89798. protected _cachedDefines: string;
  89799. protected _currentRenderID: number;
  89800. protected _boxBlurPostprocess: Nullable<PostProcess>;
  89801. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  89802. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  89803. protected _blurPostProcesses: PostProcess[];
  89804. protected _mapSize: number;
  89805. protected _currentFaceIndex: number;
  89806. protected _currentFaceIndexCache: number;
  89807. protected _textureType: number;
  89808. protected _defaultTextureMatrix: Matrix;
  89809. protected _storedUniqueId: Nullable<number>;
  89810. /** @hidden */
  89811. static _SceneComponentInitialization: (scene: Scene) => void;
  89812. /**
  89813. * Creates a ShadowGenerator object.
  89814. * A ShadowGenerator is the required tool to use the shadows.
  89815. * Each light casting shadows needs to use its own ShadowGenerator.
  89816. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  89817. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  89818. * @param light The light object generating the shadows.
  89819. * @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.
  89820. */
  89821. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  89822. protected _initializeGenerator(): void;
  89823. protected _createTargetRenderTexture(): void;
  89824. protected _initializeShadowMap(): void;
  89825. protected _initializeBlurRTTAndPostProcesses(): void;
  89826. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  89827. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  89828. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  89829. protected _applyFilterValues(): void;
  89830. /**
  89831. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89832. * @param onCompiled Callback triggered at the and of the effects compilation
  89833. * @param options Sets of optional options forcing the compilation with different modes
  89834. */
  89835. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  89836. useInstances: boolean;
  89837. }>): void;
  89838. /**
  89839. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89840. * @param options Sets of optional options forcing the compilation with different modes
  89841. * @returns A promise that resolves when the compilation completes
  89842. */
  89843. forceCompilationAsync(options?: Partial<{
  89844. useInstances: boolean;
  89845. }>): Promise<void>;
  89846. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  89847. /**
  89848. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  89849. * @param subMesh The submesh we want to render in the shadow map
  89850. * @param useInstances Defines wether will draw in the map using instances
  89851. * @returns true if ready otherwise, false
  89852. */
  89853. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  89854. /**
  89855. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  89856. * @param defines Defines of the material we want to update
  89857. * @param lightIndex Index of the light in the enabled light list of the material
  89858. */
  89859. prepareDefines(defines: any, lightIndex: number): void;
  89860. /**
  89861. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  89862. * defined in the generator but impacting the effect).
  89863. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  89864. * @param effect The effect we are binfing the information for
  89865. */
  89866. bindShadowLight(lightIndex: string, effect: Effect): void;
  89867. /**
  89868. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  89869. * (eq to shadow prjection matrix * light transform matrix)
  89870. * @returns The transform matrix used to create the shadow map
  89871. */
  89872. getTransformMatrix(): Matrix;
  89873. /**
  89874. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  89875. * Cube and 2D textures for instance.
  89876. */
  89877. recreateShadowMap(): void;
  89878. protected _disposeBlurPostProcesses(): void;
  89879. protected _disposeRTTandPostProcesses(): void;
  89880. /**
  89881. * Disposes the ShadowGenerator.
  89882. * Returns nothing.
  89883. */
  89884. dispose(): void;
  89885. /**
  89886. * Serializes the shadow generator setup to a json object.
  89887. * @returns The serialized JSON object
  89888. */
  89889. serialize(): any;
  89890. /**
  89891. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  89892. * @param parsedShadowGenerator The JSON object to parse
  89893. * @param scene The scene to create the shadow map for
  89894. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  89895. * @returns The parsed shadow generator
  89896. */
  89897. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  89898. }
  89899. }
  89900. declare module BABYLON {
  89901. /**
  89902. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  89903. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  89904. * 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.
  89905. */
  89906. export abstract class Light extends Node {
  89907. /**
  89908. * Falloff Default: light is falling off following the material specification:
  89909. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  89910. */
  89911. static readonly FALLOFF_DEFAULT: number;
  89912. /**
  89913. * Falloff Physical: light is falling off following the inverse squared distance law.
  89914. */
  89915. static readonly FALLOFF_PHYSICAL: number;
  89916. /**
  89917. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  89918. * to enhance interoperability with other engines.
  89919. */
  89920. static readonly FALLOFF_GLTF: number;
  89921. /**
  89922. * Falloff Standard: light is falling off like in the standard material
  89923. * to enhance interoperability with other materials.
  89924. */
  89925. static readonly FALLOFF_STANDARD: number;
  89926. /**
  89927. * If every light affecting the material is in this lightmapMode,
  89928. * material.lightmapTexture adds or multiplies
  89929. * (depends on material.useLightmapAsShadowmap)
  89930. * after every other light calculations.
  89931. */
  89932. static readonly LIGHTMAP_DEFAULT: number;
  89933. /**
  89934. * material.lightmapTexture as only diffuse lighting from this light
  89935. * adds only specular lighting from this light
  89936. * adds dynamic shadows
  89937. */
  89938. static readonly LIGHTMAP_SPECULAR: number;
  89939. /**
  89940. * material.lightmapTexture as only lighting
  89941. * no light calculation from this light
  89942. * only adds dynamic shadows from this light
  89943. */
  89944. static readonly LIGHTMAP_SHADOWSONLY: number;
  89945. /**
  89946. * Each light type uses the default quantity according to its type:
  89947. * point/spot lights use luminous intensity
  89948. * directional lights use illuminance
  89949. */
  89950. static readonly INTENSITYMODE_AUTOMATIC: number;
  89951. /**
  89952. * lumen (lm)
  89953. */
  89954. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  89955. /**
  89956. * candela (lm/sr)
  89957. */
  89958. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  89959. /**
  89960. * lux (lm/m^2)
  89961. */
  89962. static readonly INTENSITYMODE_ILLUMINANCE: number;
  89963. /**
  89964. * nit (cd/m^2)
  89965. */
  89966. static readonly INTENSITYMODE_LUMINANCE: number;
  89967. /**
  89968. * Light type const id of the point light.
  89969. */
  89970. static readonly LIGHTTYPEID_POINTLIGHT: number;
  89971. /**
  89972. * Light type const id of the directional light.
  89973. */
  89974. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  89975. /**
  89976. * Light type const id of the spot light.
  89977. */
  89978. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  89979. /**
  89980. * Light type const id of the hemispheric light.
  89981. */
  89982. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  89983. /**
  89984. * Diffuse gives the basic color to an object.
  89985. */
  89986. diffuse: Color3;
  89987. /**
  89988. * Specular produces a highlight color on an object.
  89989. * Note: This is note affecting PBR materials.
  89990. */
  89991. specular: Color3;
  89992. /**
  89993. * Defines the falloff type for this light. This lets overrriding how punctual light are
  89994. * falling off base on range or angle.
  89995. * This can be set to any values in Light.FALLOFF_x.
  89996. *
  89997. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  89998. * other types of materials.
  89999. */
  90000. falloffType: number;
  90001. /**
  90002. * Strength of the light.
  90003. * Note: By default it is define in the framework own unit.
  90004. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  90005. */
  90006. intensity: number;
  90007. private _range;
  90008. protected _inverseSquaredRange: number;
  90009. /**
  90010. * Defines how far from the source the light is impacting in scene units.
  90011. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  90012. */
  90013. get range(): number;
  90014. /**
  90015. * Defines how far from the source the light is impacting in scene units.
  90016. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  90017. */
  90018. set range(value: number);
  90019. /**
  90020. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  90021. * of light.
  90022. */
  90023. private _photometricScale;
  90024. private _intensityMode;
  90025. /**
  90026. * Gets the photometric scale used to interpret the intensity.
  90027. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  90028. */
  90029. get intensityMode(): number;
  90030. /**
  90031. * Sets the photometric scale used to interpret the intensity.
  90032. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  90033. */
  90034. set intensityMode(value: number);
  90035. private _radius;
  90036. /**
  90037. * Gets the light radius used by PBR Materials to simulate soft area lights.
  90038. */
  90039. get radius(): number;
  90040. /**
  90041. * sets the light radius used by PBR Materials to simulate soft area lights.
  90042. */
  90043. set radius(value: number);
  90044. private _renderPriority;
  90045. /**
  90046. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  90047. * exceeding the number allowed of the materials.
  90048. */
  90049. renderPriority: number;
  90050. private _shadowEnabled;
  90051. /**
  90052. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  90053. * the current shadow generator.
  90054. */
  90055. get shadowEnabled(): boolean;
  90056. /**
  90057. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  90058. * the current shadow generator.
  90059. */
  90060. set shadowEnabled(value: boolean);
  90061. private _includedOnlyMeshes;
  90062. /**
  90063. * Gets the only meshes impacted by this light.
  90064. */
  90065. get includedOnlyMeshes(): AbstractMesh[];
  90066. /**
  90067. * Sets the only meshes impacted by this light.
  90068. */
  90069. set includedOnlyMeshes(value: AbstractMesh[]);
  90070. private _excludedMeshes;
  90071. /**
  90072. * Gets the meshes not impacted by this light.
  90073. */
  90074. get excludedMeshes(): AbstractMesh[];
  90075. /**
  90076. * Sets the meshes not impacted by this light.
  90077. */
  90078. set excludedMeshes(value: AbstractMesh[]);
  90079. private _excludeWithLayerMask;
  90080. /**
  90081. * Gets the layer id use to find what meshes are not impacted by the light.
  90082. * Inactive if 0
  90083. */
  90084. get excludeWithLayerMask(): number;
  90085. /**
  90086. * Sets the layer id use to find what meshes are not impacted by the light.
  90087. * Inactive if 0
  90088. */
  90089. set excludeWithLayerMask(value: number);
  90090. private _includeOnlyWithLayerMask;
  90091. /**
  90092. * Gets the layer id use to find what meshes are impacted by the light.
  90093. * Inactive if 0
  90094. */
  90095. get includeOnlyWithLayerMask(): number;
  90096. /**
  90097. * Sets the layer id use to find what meshes are impacted by the light.
  90098. * Inactive if 0
  90099. */
  90100. set includeOnlyWithLayerMask(value: number);
  90101. private _lightmapMode;
  90102. /**
  90103. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  90104. */
  90105. get lightmapMode(): number;
  90106. /**
  90107. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  90108. */
  90109. set lightmapMode(value: number);
  90110. /**
  90111. * Shadow generator associted to the light.
  90112. * @hidden Internal use only.
  90113. */
  90114. _shadowGenerator: Nullable<IShadowGenerator>;
  90115. /**
  90116. * @hidden Internal use only.
  90117. */
  90118. _excludedMeshesIds: string[];
  90119. /**
  90120. * @hidden Internal use only.
  90121. */
  90122. _includedOnlyMeshesIds: string[];
  90123. /**
  90124. * The current light unifom buffer.
  90125. * @hidden Internal use only.
  90126. */
  90127. _uniformBuffer: UniformBuffer;
  90128. /** @hidden */
  90129. _renderId: number;
  90130. /**
  90131. * Creates a Light object in the scene.
  90132. * Documentation : https://doc.babylonjs.com/babylon101/lights
  90133. * @param name The firendly name of the light
  90134. * @param scene The scene the light belongs too
  90135. */
  90136. constructor(name: string, scene: Scene);
  90137. protected abstract _buildUniformLayout(): void;
  90138. /**
  90139. * Sets the passed Effect "effect" with the Light information.
  90140. * @param effect The effect to update
  90141. * @param lightIndex The index of the light in the effect to update
  90142. * @returns The light
  90143. */
  90144. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  90145. /**
  90146. * Sets the passed Effect "effect" with the Light textures.
  90147. * @param effect The effect to update
  90148. * @param lightIndex The index of the light in the effect to update
  90149. * @returns The light
  90150. */
  90151. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  90152. /**
  90153. * Binds the lights information from the scene to the effect for the given mesh.
  90154. * @param lightIndex Light index
  90155. * @param scene The scene where the light belongs to
  90156. * @param effect The effect we are binding the data to
  90157. * @param useSpecular Defines if specular is supported
  90158. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  90159. */
  90160. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  90161. /**
  90162. * Sets the passed Effect "effect" with the Light information.
  90163. * @param effect The effect to update
  90164. * @param lightDataUniformName The uniform used to store light data (position or direction)
  90165. * @returns The light
  90166. */
  90167. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  90168. /**
  90169. * Returns the string "Light".
  90170. * @returns the class name
  90171. */
  90172. getClassName(): string;
  90173. /** @hidden */
  90174. readonly _isLight: boolean;
  90175. /**
  90176. * Converts the light information to a readable string for debug purpose.
  90177. * @param fullDetails Supports for multiple levels of logging within scene loading
  90178. * @returns the human readable light info
  90179. */
  90180. toString(fullDetails?: boolean): string;
  90181. /** @hidden */
  90182. protected _syncParentEnabledState(): void;
  90183. /**
  90184. * Set the enabled state of this node.
  90185. * @param value - the new enabled state
  90186. */
  90187. setEnabled(value: boolean): void;
  90188. /**
  90189. * Returns the Light associated shadow generator if any.
  90190. * @return the associated shadow generator.
  90191. */
  90192. getShadowGenerator(): Nullable<IShadowGenerator>;
  90193. /**
  90194. * Returns a Vector3, the absolute light position in the World.
  90195. * @returns the world space position of the light
  90196. */
  90197. getAbsolutePosition(): Vector3;
  90198. /**
  90199. * Specifies if the light will affect the passed mesh.
  90200. * @param mesh The mesh to test against the light
  90201. * @return true the mesh is affected otherwise, false.
  90202. */
  90203. canAffectMesh(mesh: AbstractMesh): boolean;
  90204. /**
  90205. * Sort function to order lights for rendering.
  90206. * @param a First Light object to compare to second.
  90207. * @param b Second Light object to compare first.
  90208. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  90209. */
  90210. static CompareLightsPriority(a: Light, b: Light): number;
  90211. /**
  90212. * Releases resources associated with this node.
  90213. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90214. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90215. */
  90216. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90217. /**
  90218. * Returns the light type ID (integer).
  90219. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  90220. */
  90221. getTypeID(): number;
  90222. /**
  90223. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  90224. * @returns the scaled intensity in intensity mode unit
  90225. */
  90226. getScaledIntensity(): number;
  90227. /**
  90228. * Returns a new Light object, named "name", from the current one.
  90229. * @param name The name of the cloned light
  90230. * @returns the new created light
  90231. */
  90232. clone(name: string): Nullable<Light>;
  90233. /**
  90234. * Serializes the current light into a Serialization object.
  90235. * @returns the serialized object.
  90236. */
  90237. serialize(): any;
  90238. /**
  90239. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  90240. * This new light is named "name" and added to the passed scene.
  90241. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  90242. * @param name The friendly name of the light
  90243. * @param scene The scene the new light will belong to
  90244. * @returns the constructor function
  90245. */
  90246. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  90247. /**
  90248. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  90249. * @param parsedLight The JSON representation of the light
  90250. * @param scene The scene to create the parsed light in
  90251. * @returns the created light after parsing
  90252. */
  90253. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  90254. private _hookArrayForExcluded;
  90255. private _hookArrayForIncludedOnly;
  90256. private _resyncMeshes;
  90257. /**
  90258. * Forces the meshes to update their light related information in their rendering used effects
  90259. * @hidden Internal Use Only
  90260. */
  90261. _markMeshesAsLightDirty(): void;
  90262. /**
  90263. * Recomputes the cached photometric scale if needed.
  90264. */
  90265. private _computePhotometricScale;
  90266. /**
  90267. * Returns the Photometric Scale according to the light type and intensity mode.
  90268. */
  90269. private _getPhotometricScale;
  90270. /**
  90271. * Reorder the light in the scene according to their defined priority.
  90272. * @hidden Internal Use Only
  90273. */
  90274. _reorderLightsInScene(): void;
  90275. /**
  90276. * Prepares the list of defines specific to the light type.
  90277. * @param defines the list of defines
  90278. * @param lightIndex defines the index of the light for the effect
  90279. */
  90280. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  90281. }
  90282. }
  90283. declare module BABYLON {
  90284. /**
  90285. * Interface used to define Action
  90286. */
  90287. export interface IAction {
  90288. /**
  90289. * Trigger for the action
  90290. */
  90291. trigger: number;
  90292. /** Options of the trigger */
  90293. triggerOptions: any;
  90294. /**
  90295. * Gets the trigger parameters
  90296. * @returns the trigger parameters
  90297. */
  90298. getTriggerParameter(): any;
  90299. /**
  90300. * Internal only - executes current action event
  90301. * @hidden
  90302. */
  90303. _executeCurrent(evt?: ActionEvent): void;
  90304. /**
  90305. * Serialize placeholder for child classes
  90306. * @param parent of child
  90307. * @returns the serialized object
  90308. */
  90309. serialize(parent: any): any;
  90310. /**
  90311. * Internal only
  90312. * @hidden
  90313. */
  90314. _prepare(): void;
  90315. /**
  90316. * Internal only - manager for action
  90317. * @hidden
  90318. */
  90319. _actionManager: AbstractActionManager;
  90320. /**
  90321. * Adds action to chain of actions, may be a DoNothingAction
  90322. * @param action defines the next action to execute
  90323. * @returns The action passed in
  90324. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90325. */
  90326. then(action: IAction): IAction;
  90327. }
  90328. /**
  90329. * The action to be carried out following a trigger
  90330. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  90331. */
  90332. export class Action implements IAction {
  90333. /** the trigger, with or without parameters, for the action */
  90334. triggerOptions: any;
  90335. /**
  90336. * Trigger for the action
  90337. */
  90338. trigger: number;
  90339. /**
  90340. * Internal only - manager for action
  90341. * @hidden
  90342. */
  90343. _actionManager: ActionManager;
  90344. private _nextActiveAction;
  90345. private _child;
  90346. private _condition?;
  90347. private _triggerParameter;
  90348. /**
  90349. * An event triggered prior to action being executed.
  90350. */
  90351. onBeforeExecuteObservable: Observable<Action>;
  90352. /**
  90353. * Creates a new Action
  90354. * @param triggerOptions the trigger, with or without parameters, for the action
  90355. * @param condition an optional determinant of action
  90356. */
  90357. constructor(
  90358. /** the trigger, with or without parameters, for the action */
  90359. triggerOptions: any, condition?: Condition);
  90360. /**
  90361. * Internal only
  90362. * @hidden
  90363. */
  90364. _prepare(): void;
  90365. /**
  90366. * Gets the trigger parameters
  90367. * @returns the trigger parameters
  90368. */
  90369. getTriggerParameter(): any;
  90370. /**
  90371. * Internal only - executes current action event
  90372. * @hidden
  90373. */
  90374. _executeCurrent(evt?: ActionEvent): void;
  90375. /**
  90376. * Execute placeholder for child classes
  90377. * @param evt optional action event
  90378. */
  90379. execute(evt?: ActionEvent): void;
  90380. /**
  90381. * Skips to next active action
  90382. */
  90383. skipToNextActiveAction(): void;
  90384. /**
  90385. * Adds action to chain of actions, may be a DoNothingAction
  90386. * @param action defines the next action to execute
  90387. * @returns The action passed in
  90388. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90389. */
  90390. then(action: Action): Action;
  90391. /**
  90392. * Internal only
  90393. * @hidden
  90394. */
  90395. _getProperty(propertyPath: string): string;
  90396. /**
  90397. * Internal only
  90398. * @hidden
  90399. */
  90400. _getEffectiveTarget(target: any, propertyPath: string): any;
  90401. /**
  90402. * Serialize placeholder for child classes
  90403. * @param parent of child
  90404. * @returns the serialized object
  90405. */
  90406. serialize(parent: any): any;
  90407. /**
  90408. * Internal only called by serialize
  90409. * @hidden
  90410. */
  90411. protected _serialize(serializedAction: any, parent?: any): any;
  90412. /**
  90413. * Internal only
  90414. * @hidden
  90415. */
  90416. static _SerializeValueAsString: (value: any) => string;
  90417. /**
  90418. * Internal only
  90419. * @hidden
  90420. */
  90421. static _GetTargetProperty: (target: Node | Scene) => {
  90422. name: string;
  90423. targetType: string;
  90424. value: string;
  90425. };
  90426. }
  90427. }
  90428. declare module BABYLON {
  90429. /**
  90430. * A Condition applied to an Action
  90431. */
  90432. export class Condition {
  90433. /**
  90434. * Internal only - manager for action
  90435. * @hidden
  90436. */
  90437. _actionManager: ActionManager;
  90438. /**
  90439. * Internal only
  90440. * @hidden
  90441. */
  90442. _evaluationId: number;
  90443. /**
  90444. * Internal only
  90445. * @hidden
  90446. */
  90447. _currentResult: boolean;
  90448. /**
  90449. * Creates a new Condition
  90450. * @param actionManager the manager of the action the condition is applied to
  90451. */
  90452. constructor(actionManager: ActionManager);
  90453. /**
  90454. * Check if the current condition is valid
  90455. * @returns a boolean
  90456. */
  90457. isValid(): boolean;
  90458. /**
  90459. * Internal only
  90460. * @hidden
  90461. */
  90462. _getProperty(propertyPath: string): string;
  90463. /**
  90464. * Internal only
  90465. * @hidden
  90466. */
  90467. _getEffectiveTarget(target: any, propertyPath: string): any;
  90468. /**
  90469. * Serialize placeholder for child classes
  90470. * @returns the serialized object
  90471. */
  90472. serialize(): any;
  90473. /**
  90474. * Internal only
  90475. * @hidden
  90476. */
  90477. protected _serialize(serializedCondition: any): any;
  90478. }
  90479. /**
  90480. * Defines specific conditional operators as extensions of Condition
  90481. */
  90482. export class ValueCondition extends Condition {
  90483. /** path to specify the property of the target the conditional operator uses */
  90484. propertyPath: string;
  90485. /** the value compared by the conditional operator against the current value of the property */
  90486. value: any;
  90487. /** the conditional operator, default ValueCondition.IsEqual */
  90488. operator: number;
  90489. /**
  90490. * Internal only
  90491. * @hidden
  90492. */
  90493. private static _IsEqual;
  90494. /**
  90495. * Internal only
  90496. * @hidden
  90497. */
  90498. private static _IsDifferent;
  90499. /**
  90500. * Internal only
  90501. * @hidden
  90502. */
  90503. private static _IsGreater;
  90504. /**
  90505. * Internal only
  90506. * @hidden
  90507. */
  90508. private static _IsLesser;
  90509. /**
  90510. * returns the number for IsEqual
  90511. */
  90512. static get IsEqual(): number;
  90513. /**
  90514. * Returns the number for IsDifferent
  90515. */
  90516. static get IsDifferent(): number;
  90517. /**
  90518. * Returns the number for IsGreater
  90519. */
  90520. static get IsGreater(): number;
  90521. /**
  90522. * Returns the number for IsLesser
  90523. */
  90524. static get IsLesser(): number;
  90525. /**
  90526. * Internal only The action manager for the condition
  90527. * @hidden
  90528. */
  90529. _actionManager: ActionManager;
  90530. /**
  90531. * Internal only
  90532. * @hidden
  90533. */
  90534. private _target;
  90535. /**
  90536. * Internal only
  90537. * @hidden
  90538. */
  90539. private _effectiveTarget;
  90540. /**
  90541. * Internal only
  90542. * @hidden
  90543. */
  90544. private _property;
  90545. /**
  90546. * Creates a new ValueCondition
  90547. * @param actionManager manager for the action the condition applies to
  90548. * @param target for the action
  90549. * @param propertyPath path to specify the property of the target the conditional operator uses
  90550. * @param value the value compared by the conditional operator against the current value of the property
  90551. * @param operator the conditional operator, default ValueCondition.IsEqual
  90552. */
  90553. constructor(actionManager: ActionManager, target: any,
  90554. /** path to specify the property of the target the conditional operator uses */
  90555. propertyPath: string,
  90556. /** the value compared by the conditional operator against the current value of the property */
  90557. value: any,
  90558. /** the conditional operator, default ValueCondition.IsEqual */
  90559. operator?: number);
  90560. /**
  90561. * Compares the given value with the property value for the specified conditional operator
  90562. * @returns the result of the comparison
  90563. */
  90564. isValid(): boolean;
  90565. /**
  90566. * Serialize the ValueCondition into a JSON compatible object
  90567. * @returns serialization object
  90568. */
  90569. serialize(): any;
  90570. /**
  90571. * Gets the name of the conditional operator for the ValueCondition
  90572. * @param operator the conditional operator
  90573. * @returns the name
  90574. */
  90575. static GetOperatorName(operator: number): string;
  90576. }
  90577. /**
  90578. * Defines a predicate condition as an extension of Condition
  90579. */
  90580. export class PredicateCondition extends Condition {
  90581. /** defines the predicate function used to validate the condition */
  90582. predicate: () => boolean;
  90583. /**
  90584. * Internal only - manager for action
  90585. * @hidden
  90586. */
  90587. _actionManager: ActionManager;
  90588. /**
  90589. * Creates a new PredicateCondition
  90590. * @param actionManager manager for the action the condition applies to
  90591. * @param predicate defines the predicate function used to validate the condition
  90592. */
  90593. constructor(actionManager: ActionManager,
  90594. /** defines the predicate function used to validate the condition */
  90595. predicate: () => boolean);
  90596. /**
  90597. * @returns the validity of the predicate condition
  90598. */
  90599. isValid(): boolean;
  90600. }
  90601. /**
  90602. * Defines a state condition as an extension of Condition
  90603. */
  90604. export class StateCondition extends Condition {
  90605. /** Value to compare with target state */
  90606. value: string;
  90607. /**
  90608. * Internal only - manager for action
  90609. * @hidden
  90610. */
  90611. _actionManager: ActionManager;
  90612. /**
  90613. * Internal only
  90614. * @hidden
  90615. */
  90616. private _target;
  90617. /**
  90618. * Creates a new StateCondition
  90619. * @param actionManager manager for the action the condition applies to
  90620. * @param target of the condition
  90621. * @param value to compare with target state
  90622. */
  90623. constructor(actionManager: ActionManager, target: any,
  90624. /** Value to compare with target state */
  90625. value: string);
  90626. /**
  90627. * Gets a boolean indicating if the current condition is met
  90628. * @returns the validity of the state
  90629. */
  90630. isValid(): boolean;
  90631. /**
  90632. * Serialize the StateCondition into a JSON compatible object
  90633. * @returns serialization object
  90634. */
  90635. serialize(): any;
  90636. }
  90637. }
  90638. declare module BABYLON {
  90639. /**
  90640. * This defines an action responsible to toggle a boolean once triggered.
  90641. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90642. */
  90643. export class SwitchBooleanAction extends Action {
  90644. /**
  90645. * The path to the boolean property in the target object
  90646. */
  90647. propertyPath: string;
  90648. private _target;
  90649. private _effectiveTarget;
  90650. private _property;
  90651. /**
  90652. * Instantiate the action
  90653. * @param triggerOptions defines the trigger options
  90654. * @param target defines the object containing the boolean
  90655. * @param propertyPath defines the path to the boolean property in the target object
  90656. * @param condition defines the trigger related conditions
  90657. */
  90658. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  90659. /** @hidden */
  90660. _prepare(): void;
  90661. /**
  90662. * Execute the action toggle the boolean value.
  90663. */
  90664. execute(): void;
  90665. /**
  90666. * Serializes the actions and its related information.
  90667. * @param parent defines the object to serialize in
  90668. * @returns the serialized object
  90669. */
  90670. serialize(parent: any): any;
  90671. }
  90672. /**
  90673. * This defines an action responsible to set a the state field of the target
  90674. * to a desired value once triggered.
  90675. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90676. */
  90677. export class SetStateAction extends Action {
  90678. /**
  90679. * The value to store in the state field.
  90680. */
  90681. value: string;
  90682. private _target;
  90683. /**
  90684. * Instantiate the action
  90685. * @param triggerOptions defines the trigger options
  90686. * @param target defines the object containing the state property
  90687. * @param value defines the value to store in the state field
  90688. * @param condition defines the trigger related conditions
  90689. */
  90690. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  90691. /**
  90692. * Execute the action and store the value on the target state property.
  90693. */
  90694. execute(): void;
  90695. /**
  90696. * Serializes the actions and its related information.
  90697. * @param parent defines the object to serialize in
  90698. * @returns the serialized object
  90699. */
  90700. serialize(parent: any): any;
  90701. }
  90702. /**
  90703. * This defines an action responsible to set a property of the target
  90704. * to a desired value once triggered.
  90705. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90706. */
  90707. export class SetValueAction extends Action {
  90708. /**
  90709. * The path of the property to set in the target.
  90710. */
  90711. propertyPath: string;
  90712. /**
  90713. * The value to set in the property
  90714. */
  90715. value: any;
  90716. private _target;
  90717. private _effectiveTarget;
  90718. private _property;
  90719. /**
  90720. * Instantiate the action
  90721. * @param triggerOptions defines the trigger options
  90722. * @param target defines the object containing the property
  90723. * @param propertyPath defines the path of the property to set in the target
  90724. * @param value defines the value to set in the property
  90725. * @param condition defines the trigger related conditions
  90726. */
  90727. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90728. /** @hidden */
  90729. _prepare(): void;
  90730. /**
  90731. * Execute the action and set the targetted property to the desired value.
  90732. */
  90733. execute(): void;
  90734. /**
  90735. * Serializes the actions and its related information.
  90736. * @param parent defines the object to serialize in
  90737. * @returns the serialized object
  90738. */
  90739. serialize(parent: any): any;
  90740. }
  90741. /**
  90742. * This defines an action responsible to increment the target value
  90743. * to a desired value once triggered.
  90744. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90745. */
  90746. export class IncrementValueAction extends Action {
  90747. /**
  90748. * The path of the property to increment in the target.
  90749. */
  90750. propertyPath: string;
  90751. /**
  90752. * The value we should increment the property by.
  90753. */
  90754. value: any;
  90755. private _target;
  90756. private _effectiveTarget;
  90757. private _property;
  90758. /**
  90759. * Instantiate the action
  90760. * @param triggerOptions defines the trigger options
  90761. * @param target defines the object containing the property
  90762. * @param propertyPath defines the path of the property to increment in the target
  90763. * @param value defines the value value we should increment the property by
  90764. * @param condition defines the trigger related conditions
  90765. */
  90766. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90767. /** @hidden */
  90768. _prepare(): void;
  90769. /**
  90770. * Execute the action and increment the target of the value amount.
  90771. */
  90772. execute(): void;
  90773. /**
  90774. * Serializes the actions and its related information.
  90775. * @param parent defines the object to serialize in
  90776. * @returns the serialized object
  90777. */
  90778. serialize(parent: any): any;
  90779. }
  90780. /**
  90781. * This defines an action responsible to start an animation once triggered.
  90782. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90783. */
  90784. export class PlayAnimationAction extends Action {
  90785. /**
  90786. * Where the animation should start (animation frame)
  90787. */
  90788. from: number;
  90789. /**
  90790. * Where the animation should stop (animation frame)
  90791. */
  90792. to: number;
  90793. /**
  90794. * Define if the animation should loop or stop after the first play.
  90795. */
  90796. loop?: boolean;
  90797. private _target;
  90798. /**
  90799. * Instantiate the action
  90800. * @param triggerOptions defines the trigger options
  90801. * @param target defines the target animation or animation name
  90802. * @param from defines from where the animation should start (animation frame)
  90803. * @param end defines where the animation should stop (animation frame)
  90804. * @param loop defines if the animation should loop or stop after the first play
  90805. * @param condition defines the trigger related conditions
  90806. */
  90807. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  90808. /** @hidden */
  90809. _prepare(): void;
  90810. /**
  90811. * Execute the action and play the animation.
  90812. */
  90813. execute(): void;
  90814. /**
  90815. * Serializes the actions and its related information.
  90816. * @param parent defines the object to serialize in
  90817. * @returns the serialized object
  90818. */
  90819. serialize(parent: any): any;
  90820. }
  90821. /**
  90822. * This defines an action responsible to stop an animation once triggered.
  90823. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90824. */
  90825. export class StopAnimationAction extends Action {
  90826. private _target;
  90827. /**
  90828. * Instantiate the action
  90829. * @param triggerOptions defines the trigger options
  90830. * @param target defines the target animation or animation name
  90831. * @param condition defines the trigger related conditions
  90832. */
  90833. constructor(triggerOptions: any, target: any, condition?: Condition);
  90834. /** @hidden */
  90835. _prepare(): void;
  90836. /**
  90837. * Execute the action and stop the animation.
  90838. */
  90839. execute(): void;
  90840. /**
  90841. * Serializes the actions and its related information.
  90842. * @param parent defines the object to serialize in
  90843. * @returns the serialized object
  90844. */
  90845. serialize(parent: any): any;
  90846. }
  90847. /**
  90848. * This defines an action responsible that does nothing once triggered.
  90849. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90850. */
  90851. export class DoNothingAction extends Action {
  90852. /**
  90853. * Instantiate the action
  90854. * @param triggerOptions defines the trigger options
  90855. * @param condition defines the trigger related conditions
  90856. */
  90857. constructor(triggerOptions?: any, condition?: Condition);
  90858. /**
  90859. * Execute the action and do nothing.
  90860. */
  90861. execute(): void;
  90862. /**
  90863. * Serializes the actions and its related information.
  90864. * @param parent defines the object to serialize in
  90865. * @returns the serialized object
  90866. */
  90867. serialize(parent: any): any;
  90868. }
  90869. /**
  90870. * This defines an action responsible to trigger several actions once triggered.
  90871. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90872. */
  90873. export class CombineAction extends Action {
  90874. /**
  90875. * The list of aggregated animations to run.
  90876. */
  90877. children: Action[];
  90878. /**
  90879. * Instantiate the action
  90880. * @param triggerOptions defines the trigger options
  90881. * @param children defines the list of aggregated animations to run
  90882. * @param condition defines the trigger related conditions
  90883. */
  90884. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  90885. /** @hidden */
  90886. _prepare(): void;
  90887. /**
  90888. * Execute the action and executes all the aggregated actions.
  90889. */
  90890. execute(evt: ActionEvent): void;
  90891. /**
  90892. * Serializes the actions and its related information.
  90893. * @param parent defines the object to serialize in
  90894. * @returns the serialized object
  90895. */
  90896. serialize(parent: any): any;
  90897. }
  90898. /**
  90899. * This defines an action responsible to run code (external event) once triggered.
  90900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90901. */
  90902. export class ExecuteCodeAction extends Action {
  90903. /**
  90904. * The callback function to run.
  90905. */
  90906. func: (evt: ActionEvent) => void;
  90907. /**
  90908. * Instantiate the action
  90909. * @param triggerOptions defines the trigger options
  90910. * @param func defines the callback function to run
  90911. * @param condition defines the trigger related conditions
  90912. */
  90913. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  90914. /**
  90915. * Execute the action and run the attached code.
  90916. */
  90917. execute(evt: ActionEvent): void;
  90918. }
  90919. /**
  90920. * This defines an action responsible to set the parent property of the target once triggered.
  90921. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90922. */
  90923. export class SetParentAction extends Action {
  90924. private _parent;
  90925. private _target;
  90926. /**
  90927. * Instantiate the action
  90928. * @param triggerOptions defines the trigger options
  90929. * @param target defines the target containing the parent property
  90930. * @param parent defines from where the animation should start (animation frame)
  90931. * @param condition defines the trigger related conditions
  90932. */
  90933. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  90934. /** @hidden */
  90935. _prepare(): void;
  90936. /**
  90937. * Execute the action and set the parent property.
  90938. */
  90939. execute(): void;
  90940. /**
  90941. * Serializes the actions and its related information.
  90942. * @param parent defines the object to serialize in
  90943. * @returns the serialized object
  90944. */
  90945. serialize(parent: any): any;
  90946. }
  90947. }
  90948. declare module BABYLON {
  90949. /**
  90950. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  90951. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  90952. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90953. */
  90954. export class ActionManager extends AbstractActionManager {
  90955. /**
  90956. * Nothing
  90957. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90958. */
  90959. static readonly NothingTrigger: number;
  90960. /**
  90961. * On pick
  90962. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90963. */
  90964. static readonly OnPickTrigger: number;
  90965. /**
  90966. * On left pick
  90967. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90968. */
  90969. static readonly OnLeftPickTrigger: number;
  90970. /**
  90971. * On right pick
  90972. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90973. */
  90974. static readonly OnRightPickTrigger: number;
  90975. /**
  90976. * On center pick
  90977. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90978. */
  90979. static readonly OnCenterPickTrigger: number;
  90980. /**
  90981. * On pick down
  90982. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90983. */
  90984. static readonly OnPickDownTrigger: number;
  90985. /**
  90986. * On double pick
  90987. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90988. */
  90989. static readonly OnDoublePickTrigger: number;
  90990. /**
  90991. * On pick up
  90992. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90993. */
  90994. static readonly OnPickUpTrigger: number;
  90995. /**
  90996. * On pick out.
  90997. * This trigger will only be raised if you also declared a OnPickDown
  90998. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90999. */
  91000. static readonly OnPickOutTrigger: number;
  91001. /**
  91002. * On long press
  91003. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91004. */
  91005. static readonly OnLongPressTrigger: number;
  91006. /**
  91007. * On pointer over
  91008. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91009. */
  91010. static readonly OnPointerOverTrigger: number;
  91011. /**
  91012. * On pointer out
  91013. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91014. */
  91015. static readonly OnPointerOutTrigger: number;
  91016. /**
  91017. * On every frame
  91018. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91019. */
  91020. static readonly OnEveryFrameTrigger: number;
  91021. /**
  91022. * On intersection enter
  91023. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91024. */
  91025. static readonly OnIntersectionEnterTrigger: number;
  91026. /**
  91027. * On intersection exit
  91028. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91029. */
  91030. static readonly OnIntersectionExitTrigger: number;
  91031. /**
  91032. * On key down
  91033. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91034. */
  91035. static readonly OnKeyDownTrigger: number;
  91036. /**
  91037. * On key up
  91038. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91039. */
  91040. static readonly OnKeyUpTrigger: number;
  91041. private _scene;
  91042. /**
  91043. * Creates a new action manager
  91044. * @param scene defines the hosting scene
  91045. */
  91046. constructor(scene: Scene);
  91047. /**
  91048. * Releases all associated resources
  91049. */
  91050. dispose(): void;
  91051. /**
  91052. * Gets hosting scene
  91053. * @returns the hosting scene
  91054. */
  91055. getScene(): Scene;
  91056. /**
  91057. * Does this action manager handles actions of any of the given triggers
  91058. * @param triggers defines the triggers to be tested
  91059. * @return a boolean indicating whether one (or more) of the triggers is handled
  91060. */
  91061. hasSpecificTriggers(triggers: number[]): boolean;
  91062. /**
  91063. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  91064. * speed.
  91065. * @param triggerA defines the trigger to be tested
  91066. * @param triggerB defines the trigger to be tested
  91067. * @return a boolean indicating whether one (or more) of the triggers is handled
  91068. */
  91069. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  91070. /**
  91071. * Does this action manager handles actions of a given trigger
  91072. * @param trigger defines the trigger to be tested
  91073. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  91074. * @return whether the trigger is handled
  91075. */
  91076. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  91077. /**
  91078. * Does this action manager has pointer triggers
  91079. */
  91080. get hasPointerTriggers(): boolean;
  91081. /**
  91082. * Does this action manager has pick triggers
  91083. */
  91084. get hasPickTriggers(): boolean;
  91085. /**
  91086. * Registers an action to this action manager
  91087. * @param action defines the action to be registered
  91088. * @return the action amended (prepared) after registration
  91089. */
  91090. registerAction(action: IAction): Nullable<IAction>;
  91091. /**
  91092. * Unregisters an action to this action manager
  91093. * @param action defines the action to be unregistered
  91094. * @return a boolean indicating whether the action has been unregistered
  91095. */
  91096. unregisterAction(action: IAction): Boolean;
  91097. /**
  91098. * Process a specific trigger
  91099. * @param trigger defines the trigger to process
  91100. * @param evt defines the event details to be processed
  91101. */
  91102. processTrigger(trigger: number, evt?: IActionEvent): void;
  91103. /** @hidden */
  91104. _getEffectiveTarget(target: any, propertyPath: string): any;
  91105. /** @hidden */
  91106. _getProperty(propertyPath: string): string;
  91107. /**
  91108. * Serialize this manager to a JSON object
  91109. * @param name defines the property name to store this manager
  91110. * @returns a JSON representation of this manager
  91111. */
  91112. serialize(name: string): any;
  91113. /**
  91114. * Creates a new ActionManager from a JSON data
  91115. * @param parsedActions defines the JSON data to read from
  91116. * @param object defines the hosting mesh
  91117. * @param scene defines the hosting scene
  91118. */
  91119. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  91120. /**
  91121. * Get a trigger name by index
  91122. * @param trigger defines the trigger index
  91123. * @returns a trigger name
  91124. */
  91125. static GetTriggerName(trigger: number): string;
  91126. }
  91127. }
  91128. declare module BABYLON {
  91129. /**
  91130. * Class used to represent a sprite
  91131. * @see http://doc.babylonjs.com/babylon101/sprites
  91132. */
  91133. export class Sprite {
  91134. /** defines the name */
  91135. name: string;
  91136. /** Gets or sets the current world position */
  91137. position: Vector3;
  91138. /** Gets or sets the main color */
  91139. color: Color4;
  91140. /** Gets or sets the width */
  91141. width: number;
  91142. /** Gets or sets the height */
  91143. height: number;
  91144. /** Gets or sets rotation angle */
  91145. angle: number;
  91146. /** Gets or sets the cell index in the sprite sheet */
  91147. cellIndex: number;
  91148. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  91149. cellRef: string;
  91150. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  91151. invertU: number;
  91152. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  91153. invertV: number;
  91154. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  91155. disposeWhenFinishedAnimating: boolean;
  91156. /** Gets the list of attached animations */
  91157. animations: Animation[];
  91158. /** Gets or sets a boolean indicating if the sprite can be picked */
  91159. isPickable: boolean;
  91160. /**
  91161. * Gets or sets the associated action manager
  91162. */
  91163. actionManager: Nullable<ActionManager>;
  91164. private _animationStarted;
  91165. private _loopAnimation;
  91166. private _fromIndex;
  91167. private _toIndex;
  91168. private _delay;
  91169. private _direction;
  91170. private _manager;
  91171. private _time;
  91172. private _onAnimationEnd;
  91173. /**
  91174. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  91175. */
  91176. isVisible: boolean;
  91177. /**
  91178. * Gets or sets the sprite size
  91179. */
  91180. get size(): number;
  91181. set size(value: number);
  91182. /**
  91183. * Creates a new Sprite
  91184. * @param name defines the name
  91185. * @param manager defines the manager
  91186. */
  91187. constructor(
  91188. /** defines the name */
  91189. name: string, manager: ISpriteManager);
  91190. /**
  91191. * Starts an animation
  91192. * @param from defines the initial key
  91193. * @param to defines the end key
  91194. * @param loop defines if the animation must loop
  91195. * @param delay defines the start delay (in ms)
  91196. * @param onAnimationEnd defines a callback to call when animation ends
  91197. */
  91198. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  91199. /** Stops current animation (if any) */
  91200. stopAnimation(): void;
  91201. /** @hidden */
  91202. _animate(deltaTime: number): void;
  91203. /** Release associated resources */
  91204. dispose(): void;
  91205. }
  91206. }
  91207. declare module BABYLON {
  91208. /**
  91209. * Information about the result of picking within a scene
  91210. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  91211. */
  91212. export class PickingInfo {
  91213. /** @hidden */
  91214. _pickingUnavailable: boolean;
  91215. /**
  91216. * If the pick collided with an object
  91217. */
  91218. hit: boolean;
  91219. /**
  91220. * Distance away where the pick collided
  91221. */
  91222. distance: number;
  91223. /**
  91224. * The location of pick collision
  91225. */
  91226. pickedPoint: Nullable<Vector3>;
  91227. /**
  91228. * The mesh corresponding the the pick collision
  91229. */
  91230. pickedMesh: Nullable<AbstractMesh>;
  91231. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  91232. bu: number;
  91233. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  91234. bv: number;
  91235. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  91236. faceId: number;
  91237. /** Id of the the submesh that was picked */
  91238. subMeshId: number;
  91239. /** If a sprite was picked, this will be the sprite the pick collided with */
  91240. pickedSprite: Nullable<Sprite>;
  91241. /**
  91242. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  91243. */
  91244. originMesh: Nullable<AbstractMesh>;
  91245. /**
  91246. * The ray that was used to perform the picking.
  91247. */
  91248. ray: Nullable<Ray>;
  91249. /**
  91250. * Gets the normal correspodning to the face the pick collided with
  91251. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  91252. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  91253. * @returns The normal correspodning to the face the pick collided with
  91254. */
  91255. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  91256. /**
  91257. * Gets the texture coordinates of where the pick occured
  91258. * @returns the vector containing the coordnates of the texture
  91259. */
  91260. getTextureCoordinates(): Nullable<Vector2>;
  91261. }
  91262. }
  91263. declare module BABYLON {
  91264. /**
  91265. * Gather the list of pointer event types as constants.
  91266. */
  91267. export class PointerEventTypes {
  91268. /**
  91269. * 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.
  91270. */
  91271. static readonly POINTERDOWN: number;
  91272. /**
  91273. * The pointerup event is fired when a pointer is no longer active.
  91274. */
  91275. static readonly POINTERUP: number;
  91276. /**
  91277. * The pointermove event is fired when a pointer changes coordinates.
  91278. */
  91279. static readonly POINTERMOVE: number;
  91280. /**
  91281. * The pointerwheel event is fired when a mouse wheel has been rotated.
  91282. */
  91283. static readonly POINTERWHEEL: number;
  91284. /**
  91285. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  91286. */
  91287. static readonly POINTERPICK: number;
  91288. /**
  91289. * The pointertap event is fired when a the object has been touched and released without drag.
  91290. */
  91291. static readonly POINTERTAP: number;
  91292. /**
  91293. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  91294. */
  91295. static readonly POINTERDOUBLETAP: number;
  91296. }
  91297. /**
  91298. * Base class of pointer info types.
  91299. */
  91300. export class PointerInfoBase {
  91301. /**
  91302. * Defines the type of event (PointerEventTypes)
  91303. */
  91304. type: number;
  91305. /**
  91306. * Defines the related dom event
  91307. */
  91308. event: PointerEvent | MouseWheelEvent;
  91309. /**
  91310. * Instantiates the base class of pointers info.
  91311. * @param type Defines the type of event (PointerEventTypes)
  91312. * @param event Defines the related dom event
  91313. */
  91314. constructor(
  91315. /**
  91316. * Defines the type of event (PointerEventTypes)
  91317. */
  91318. type: number,
  91319. /**
  91320. * Defines the related dom event
  91321. */
  91322. event: PointerEvent | MouseWheelEvent);
  91323. }
  91324. /**
  91325. * This class is used to store pointer related info for the onPrePointerObservable event.
  91326. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  91327. */
  91328. export class PointerInfoPre extends PointerInfoBase {
  91329. /**
  91330. * Ray from a pointer if availible (eg. 6dof controller)
  91331. */
  91332. ray: Nullable<Ray>;
  91333. /**
  91334. * Defines the local position of the pointer on the canvas.
  91335. */
  91336. localPosition: Vector2;
  91337. /**
  91338. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  91339. */
  91340. skipOnPointerObservable: boolean;
  91341. /**
  91342. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  91343. * @param type Defines the type of event (PointerEventTypes)
  91344. * @param event Defines the related dom event
  91345. * @param localX Defines the local x coordinates of the pointer when the event occured
  91346. * @param localY Defines the local y coordinates of the pointer when the event occured
  91347. */
  91348. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  91349. }
  91350. /**
  91351. * This type contains all the data related to a pointer event in Babylon.js.
  91352. * 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.
  91353. */
  91354. export class PointerInfo extends PointerInfoBase {
  91355. /**
  91356. * Defines the picking info associated to the info (if any)\
  91357. */
  91358. pickInfo: Nullable<PickingInfo>;
  91359. /**
  91360. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  91361. * @param type Defines the type of event (PointerEventTypes)
  91362. * @param event Defines the related dom event
  91363. * @param pickInfo Defines the picking info associated to the info (if any)\
  91364. */
  91365. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  91366. /**
  91367. * Defines the picking info associated to the info (if any)\
  91368. */
  91369. pickInfo: Nullable<PickingInfo>);
  91370. }
  91371. /**
  91372. * Data relating to a touch event on the screen.
  91373. */
  91374. export interface PointerTouch {
  91375. /**
  91376. * X coordinate of touch.
  91377. */
  91378. x: number;
  91379. /**
  91380. * Y coordinate of touch.
  91381. */
  91382. y: number;
  91383. /**
  91384. * Id of touch. Unique for each finger.
  91385. */
  91386. pointerId: number;
  91387. /**
  91388. * Event type passed from DOM.
  91389. */
  91390. type: any;
  91391. }
  91392. }
  91393. declare module BABYLON {
  91394. /**
  91395. * Manage the mouse inputs to control the movement of a free camera.
  91396. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91397. */
  91398. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  91399. /**
  91400. * Define if touch is enabled in the mouse input
  91401. */
  91402. touchEnabled: boolean;
  91403. /**
  91404. * Defines the camera the input is attached to.
  91405. */
  91406. camera: FreeCamera;
  91407. /**
  91408. * Defines the buttons associated with the input to handle camera move.
  91409. */
  91410. buttons: number[];
  91411. /**
  91412. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  91413. */
  91414. angularSensibility: number;
  91415. private _pointerInput;
  91416. private _onMouseMove;
  91417. private _observer;
  91418. private previousPosition;
  91419. /**
  91420. * Observable for when a pointer move event occurs containing the move offset
  91421. */
  91422. onPointerMovedObservable: Observable<{
  91423. offsetX: number;
  91424. offsetY: number;
  91425. }>;
  91426. /**
  91427. * @hidden
  91428. * If the camera should be rotated automatically based on pointer movement
  91429. */
  91430. _allowCameraRotation: boolean;
  91431. /**
  91432. * Manage the mouse inputs to control the movement of a free camera.
  91433. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91434. * @param touchEnabled Defines if touch is enabled or not
  91435. */
  91436. constructor(
  91437. /**
  91438. * Define if touch is enabled in the mouse input
  91439. */
  91440. touchEnabled?: boolean);
  91441. /**
  91442. * Attach the input controls to a specific dom element to get the input from.
  91443. * @param element Defines the element the controls should be listened from
  91444. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91445. */
  91446. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91447. /**
  91448. * Called on JS contextmenu event.
  91449. * Override this method to provide functionality.
  91450. */
  91451. protected onContextMenu(evt: PointerEvent): void;
  91452. /**
  91453. * Detach the current controls from the specified dom element.
  91454. * @param element Defines the element to stop listening the inputs from
  91455. */
  91456. detachControl(element: Nullable<HTMLElement>): void;
  91457. /**
  91458. * Gets the class name of the current intput.
  91459. * @returns the class name
  91460. */
  91461. getClassName(): string;
  91462. /**
  91463. * Get the friendly name associated with the input class.
  91464. * @returns the input friendly name
  91465. */
  91466. getSimpleName(): string;
  91467. }
  91468. }
  91469. declare module BABYLON {
  91470. /**
  91471. * Manage the touch inputs to control the movement of a free camera.
  91472. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91473. */
  91474. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  91475. /**
  91476. * Defines the camera the input is attached to.
  91477. */
  91478. camera: FreeCamera;
  91479. /**
  91480. * Defines the touch sensibility for rotation.
  91481. * The higher the faster.
  91482. */
  91483. touchAngularSensibility: number;
  91484. /**
  91485. * Defines the touch sensibility for move.
  91486. * The higher the faster.
  91487. */
  91488. touchMoveSensibility: number;
  91489. private _offsetX;
  91490. private _offsetY;
  91491. private _pointerPressed;
  91492. private _pointerInput;
  91493. private _observer;
  91494. private _onLostFocus;
  91495. /**
  91496. * Attach the input controls to a specific dom element to get the input from.
  91497. * @param element Defines the element the controls should be listened from
  91498. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91499. */
  91500. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91501. /**
  91502. * Detach the current controls from the specified dom element.
  91503. * @param element Defines the element to stop listening the inputs from
  91504. */
  91505. detachControl(element: Nullable<HTMLElement>): void;
  91506. /**
  91507. * Update the current camera state depending on the inputs that have been used this frame.
  91508. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  91509. */
  91510. checkInputs(): void;
  91511. /**
  91512. * Gets the class name of the current intput.
  91513. * @returns the class name
  91514. */
  91515. getClassName(): string;
  91516. /**
  91517. * Get the friendly name associated with the input class.
  91518. * @returns the input friendly name
  91519. */
  91520. getSimpleName(): string;
  91521. }
  91522. }
  91523. declare module BABYLON {
  91524. /**
  91525. * Default Inputs manager for the FreeCamera.
  91526. * It groups all the default supported inputs for ease of use.
  91527. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91528. */
  91529. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  91530. /**
  91531. * @hidden
  91532. */
  91533. _mouseInput: Nullable<FreeCameraMouseInput>;
  91534. /**
  91535. * Instantiates a new FreeCameraInputsManager.
  91536. * @param camera Defines the camera the inputs belong to
  91537. */
  91538. constructor(camera: FreeCamera);
  91539. /**
  91540. * Add keyboard input support to the input manager.
  91541. * @returns the current input manager
  91542. */
  91543. addKeyboard(): FreeCameraInputsManager;
  91544. /**
  91545. * Add mouse input support to the input manager.
  91546. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  91547. * @returns the current input manager
  91548. */
  91549. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  91550. /**
  91551. * Removes the mouse input support from the manager
  91552. * @returns the current input manager
  91553. */
  91554. removeMouse(): FreeCameraInputsManager;
  91555. /**
  91556. * Add touch input support to the input manager.
  91557. * @returns the current input manager
  91558. */
  91559. addTouch(): FreeCameraInputsManager;
  91560. /**
  91561. * Remove all attached input methods from a camera
  91562. */
  91563. clear(): void;
  91564. }
  91565. }
  91566. declare module BABYLON {
  91567. /**
  91568. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  91569. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  91570. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  91571. */
  91572. export class FreeCamera extends TargetCamera {
  91573. /**
  91574. * Define the collision ellipsoid of the camera.
  91575. * This is helpful to simulate a camera body like the player body around the camera
  91576. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  91577. */
  91578. ellipsoid: Vector3;
  91579. /**
  91580. * Define an offset for the position of the ellipsoid around the camera.
  91581. * This can be helpful to determine the center of the body near the gravity center of the body
  91582. * instead of its head.
  91583. */
  91584. ellipsoidOffset: Vector3;
  91585. /**
  91586. * Enable or disable collisions of the camera with the rest of the scene objects.
  91587. */
  91588. checkCollisions: boolean;
  91589. /**
  91590. * Enable or disable gravity on the camera.
  91591. */
  91592. applyGravity: boolean;
  91593. /**
  91594. * Define the input manager associated to the camera.
  91595. */
  91596. inputs: FreeCameraInputsManager;
  91597. /**
  91598. * Gets the input sensibility for a mouse input. (default is 2000.0)
  91599. * Higher values reduce sensitivity.
  91600. */
  91601. get angularSensibility(): number;
  91602. /**
  91603. * Sets the input sensibility for a mouse input. (default is 2000.0)
  91604. * Higher values reduce sensitivity.
  91605. */
  91606. set angularSensibility(value: number);
  91607. /**
  91608. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  91609. */
  91610. get keysUp(): number[];
  91611. set keysUp(value: number[]);
  91612. /**
  91613. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  91614. */
  91615. get keysDown(): number[];
  91616. set keysDown(value: number[]);
  91617. /**
  91618. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  91619. */
  91620. get keysLeft(): number[];
  91621. set keysLeft(value: number[]);
  91622. /**
  91623. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  91624. */
  91625. get keysRight(): number[];
  91626. set keysRight(value: number[]);
  91627. /**
  91628. * Event raised when the camera collide with a mesh in the scene.
  91629. */
  91630. onCollide: (collidedMesh: AbstractMesh) => void;
  91631. private _collider;
  91632. private _needMoveForGravity;
  91633. private _oldPosition;
  91634. private _diffPosition;
  91635. private _newPosition;
  91636. /** @hidden */
  91637. _localDirection: Vector3;
  91638. /** @hidden */
  91639. _transformedDirection: Vector3;
  91640. /**
  91641. * Instantiates a Free Camera.
  91642. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  91643. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  91644. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  91645. * @param name Define the name of the camera in the scene
  91646. * @param position Define the start position of the camera in the scene
  91647. * @param scene Define the scene the camera belongs to
  91648. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  91649. */
  91650. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  91651. /**
  91652. * Attached controls to the current camera.
  91653. * @param element Defines the element the controls should be listened from
  91654. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91655. */
  91656. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91657. /**
  91658. * Detach the current controls from the camera.
  91659. * The camera will stop reacting to inputs.
  91660. * @param element Defines the element to stop listening the inputs from
  91661. */
  91662. detachControl(element: HTMLElement): void;
  91663. private _collisionMask;
  91664. /**
  91665. * Define a collision mask to limit the list of object the camera can collide with
  91666. */
  91667. get collisionMask(): number;
  91668. set collisionMask(mask: number);
  91669. /** @hidden */
  91670. _collideWithWorld(displacement: Vector3): void;
  91671. private _onCollisionPositionChange;
  91672. /** @hidden */
  91673. _checkInputs(): void;
  91674. /** @hidden */
  91675. _decideIfNeedsToMove(): boolean;
  91676. /** @hidden */
  91677. _updatePosition(): void;
  91678. /**
  91679. * Destroy the camera and release the current resources hold by it.
  91680. */
  91681. dispose(): void;
  91682. /**
  91683. * Gets the current object class name.
  91684. * @return the class name
  91685. */
  91686. getClassName(): string;
  91687. }
  91688. }
  91689. declare module BABYLON {
  91690. /**
  91691. * Represents a gamepad control stick position
  91692. */
  91693. export class StickValues {
  91694. /**
  91695. * The x component of the control stick
  91696. */
  91697. x: number;
  91698. /**
  91699. * The y component of the control stick
  91700. */
  91701. y: number;
  91702. /**
  91703. * Initializes the gamepad x and y control stick values
  91704. * @param x The x component of the gamepad control stick value
  91705. * @param y The y component of the gamepad control stick value
  91706. */
  91707. constructor(
  91708. /**
  91709. * The x component of the control stick
  91710. */
  91711. x: number,
  91712. /**
  91713. * The y component of the control stick
  91714. */
  91715. y: number);
  91716. }
  91717. /**
  91718. * An interface which manages callbacks for gamepad button changes
  91719. */
  91720. export interface GamepadButtonChanges {
  91721. /**
  91722. * Called when a gamepad has been changed
  91723. */
  91724. changed: boolean;
  91725. /**
  91726. * Called when a gamepad press event has been triggered
  91727. */
  91728. pressChanged: boolean;
  91729. /**
  91730. * Called when a touch event has been triggered
  91731. */
  91732. touchChanged: boolean;
  91733. /**
  91734. * Called when a value has changed
  91735. */
  91736. valueChanged: boolean;
  91737. }
  91738. /**
  91739. * Represents a gamepad
  91740. */
  91741. export class Gamepad {
  91742. /**
  91743. * The id of the gamepad
  91744. */
  91745. id: string;
  91746. /**
  91747. * The index of the gamepad
  91748. */
  91749. index: number;
  91750. /**
  91751. * The browser gamepad
  91752. */
  91753. browserGamepad: any;
  91754. /**
  91755. * Specifies what type of gamepad this represents
  91756. */
  91757. type: number;
  91758. private _leftStick;
  91759. private _rightStick;
  91760. /** @hidden */
  91761. _isConnected: boolean;
  91762. private _leftStickAxisX;
  91763. private _leftStickAxisY;
  91764. private _rightStickAxisX;
  91765. private _rightStickAxisY;
  91766. /**
  91767. * Triggered when the left control stick has been changed
  91768. */
  91769. private _onleftstickchanged;
  91770. /**
  91771. * Triggered when the right control stick has been changed
  91772. */
  91773. private _onrightstickchanged;
  91774. /**
  91775. * Represents a gamepad controller
  91776. */
  91777. static GAMEPAD: number;
  91778. /**
  91779. * Represents a generic controller
  91780. */
  91781. static GENERIC: number;
  91782. /**
  91783. * Represents an XBox controller
  91784. */
  91785. static XBOX: number;
  91786. /**
  91787. * Represents a pose-enabled controller
  91788. */
  91789. static POSE_ENABLED: number;
  91790. /**
  91791. * Represents an Dual Shock controller
  91792. */
  91793. static DUALSHOCK: number;
  91794. /**
  91795. * Specifies whether the left control stick should be Y-inverted
  91796. */
  91797. protected _invertLeftStickY: boolean;
  91798. /**
  91799. * Specifies if the gamepad has been connected
  91800. */
  91801. get isConnected(): boolean;
  91802. /**
  91803. * Initializes the gamepad
  91804. * @param id The id of the gamepad
  91805. * @param index The index of the gamepad
  91806. * @param browserGamepad The browser gamepad
  91807. * @param leftStickX The x component of the left joystick
  91808. * @param leftStickY The y component of the left joystick
  91809. * @param rightStickX The x component of the right joystick
  91810. * @param rightStickY The y component of the right joystick
  91811. */
  91812. constructor(
  91813. /**
  91814. * The id of the gamepad
  91815. */
  91816. id: string,
  91817. /**
  91818. * The index of the gamepad
  91819. */
  91820. index: number,
  91821. /**
  91822. * The browser gamepad
  91823. */
  91824. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  91825. /**
  91826. * Callback triggered when the left joystick has changed
  91827. * @param callback
  91828. */
  91829. onleftstickchanged(callback: (values: StickValues) => void): void;
  91830. /**
  91831. * Callback triggered when the right joystick has changed
  91832. * @param callback
  91833. */
  91834. onrightstickchanged(callback: (values: StickValues) => void): void;
  91835. /**
  91836. * Gets the left joystick
  91837. */
  91838. get leftStick(): StickValues;
  91839. /**
  91840. * Sets the left joystick values
  91841. */
  91842. set leftStick(newValues: StickValues);
  91843. /**
  91844. * Gets the right joystick
  91845. */
  91846. get rightStick(): StickValues;
  91847. /**
  91848. * Sets the right joystick value
  91849. */
  91850. set rightStick(newValues: StickValues);
  91851. /**
  91852. * Updates the gamepad joystick positions
  91853. */
  91854. update(): void;
  91855. /**
  91856. * Disposes the gamepad
  91857. */
  91858. dispose(): void;
  91859. }
  91860. /**
  91861. * Represents a generic gamepad
  91862. */
  91863. export class GenericPad extends Gamepad {
  91864. private _buttons;
  91865. private _onbuttondown;
  91866. private _onbuttonup;
  91867. /**
  91868. * Observable triggered when a button has been pressed
  91869. */
  91870. onButtonDownObservable: Observable<number>;
  91871. /**
  91872. * Observable triggered when a button has been released
  91873. */
  91874. onButtonUpObservable: Observable<number>;
  91875. /**
  91876. * Callback triggered when a button has been pressed
  91877. * @param callback Called when a button has been pressed
  91878. */
  91879. onbuttondown(callback: (buttonPressed: number) => void): void;
  91880. /**
  91881. * Callback triggered when a button has been released
  91882. * @param callback Called when a button has been released
  91883. */
  91884. onbuttonup(callback: (buttonReleased: number) => void): void;
  91885. /**
  91886. * Initializes the generic gamepad
  91887. * @param id The id of the generic gamepad
  91888. * @param index The index of the generic gamepad
  91889. * @param browserGamepad The browser gamepad
  91890. */
  91891. constructor(id: string, index: number, browserGamepad: any);
  91892. private _setButtonValue;
  91893. /**
  91894. * Updates the generic gamepad
  91895. */
  91896. update(): void;
  91897. /**
  91898. * Disposes the generic gamepad
  91899. */
  91900. dispose(): void;
  91901. }
  91902. }
  91903. declare module BABYLON {
  91904. /**
  91905. * Defines the types of pose enabled controllers that are supported
  91906. */
  91907. export enum PoseEnabledControllerType {
  91908. /**
  91909. * HTC Vive
  91910. */
  91911. VIVE = 0,
  91912. /**
  91913. * Oculus Rift
  91914. */
  91915. OCULUS = 1,
  91916. /**
  91917. * Windows mixed reality
  91918. */
  91919. WINDOWS = 2,
  91920. /**
  91921. * Samsung gear VR
  91922. */
  91923. GEAR_VR = 3,
  91924. /**
  91925. * Google Daydream
  91926. */
  91927. DAYDREAM = 4,
  91928. /**
  91929. * Generic
  91930. */
  91931. GENERIC = 5
  91932. }
  91933. /**
  91934. * Defines the MutableGamepadButton interface for the state of a gamepad button
  91935. */
  91936. export interface MutableGamepadButton {
  91937. /**
  91938. * Value of the button/trigger
  91939. */
  91940. value: number;
  91941. /**
  91942. * If the button/trigger is currently touched
  91943. */
  91944. touched: boolean;
  91945. /**
  91946. * If the button/trigger is currently pressed
  91947. */
  91948. pressed: boolean;
  91949. }
  91950. /**
  91951. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  91952. * @hidden
  91953. */
  91954. export interface ExtendedGamepadButton extends GamepadButton {
  91955. /**
  91956. * If the button/trigger is currently pressed
  91957. */
  91958. readonly pressed: boolean;
  91959. /**
  91960. * If the button/trigger is currently touched
  91961. */
  91962. readonly touched: boolean;
  91963. /**
  91964. * Value of the button/trigger
  91965. */
  91966. readonly value: number;
  91967. }
  91968. /** @hidden */
  91969. export interface _GamePadFactory {
  91970. /**
  91971. * Returns whether or not the current gamepad can be created for this type of controller.
  91972. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  91973. * @returns true if it can be created, otherwise false
  91974. */
  91975. canCreate(gamepadInfo: any): boolean;
  91976. /**
  91977. * Creates a new instance of the Gamepad.
  91978. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  91979. * @returns the new gamepad instance
  91980. */
  91981. create(gamepadInfo: any): Gamepad;
  91982. }
  91983. /**
  91984. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  91985. */
  91986. export class PoseEnabledControllerHelper {
  91987. /** @hidden */
  91988. static _ControllerFactories: _GamePadFactory[];
  91989. /** @hidden */
  91990. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  91991. /**
  91992. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  91993. * @param vrGamepad the gamepad to initialized
  91994. * @returns a vr controller of the type the gamepad identified as
  91995. */
  91996. static InitiateController(vrGamepad: any): Gamepad;
  91997. }
  91998. /**
  91999. * Defines the PoseEnabledController object that contains state of a vr capable controller
  92000. */
  92001. export class PoseEnabledController extends Gamepad implements PoseControlled {
  92002. /**
  92003. * If the controller is used in a webXR session
  92004. */
  92005. isXR: boolean;
  92006. private _deviceRoomPosition;
  92007. private _deviceRoomRotationQuaternion;
  92008. /**
  92009. * The device position in babylon space
  92010. */
  92011. devicePosition: Vector3;
  92012. /**
  92013. * The device rotation in babylon space
  92014. */
  92015. deviceRotationQuaternion: Quaternion;
  92016. /**
  92017. * The scale factor of the device in babylon space
  92018. */
  92019. deviceScaleFactor: number;
  92020. /**
  92021. * (Likely devicePosition should be used instead) The device position in its room space
  92022. */
  92023. position: Vector3;
  92024. /**
  92025. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  92026. */
  92027. rotationQuaternion: Quaternion;
  92028. /**
  92029. * The type of controller (Eg. Windows mixed reality)
  92030. */
  92031. controllerType: PoseEnabledControllerType;
  92032. protected _calculatedPosition: Vector3;
  92033. private _calculatedRotation;
  92034. /**
  92035. * The raw pose from the device
  92036. */
  92037. rawPose: DevicePose;
  92038. private _trackPosition;
  92039. private _maxRotationDistFromHeadset;
  92040. private _draggedRoomRotation;
  92041. /**
  92042. * @hidden
  92043. */
  92044. _disableTrackPosition(fixedPosition: Vector3): void;
  92045. /**
  92046. * Internal, the mesh attached to the controller
  92047. * @hidden
  92048. */
  92049. _mesh: Nullable<AbstractMesh>;
  92050. private _poseControlledCamera;
  92051. private _leftHandSystemQuaternion;
  92052. /**
  92053. * Internal, matrix used to convert room space to babylon space
  92054. * @hidden
  92055. */
  92056. _deviceToWorld: Matrix;
  92057. /**
  92058. * Node to be used when casting a ray from the controller
  92059. * @hidden
  92060. */
  92061. _pointingPoseNode: Nullable<TransformNode>;
  92062. /**
  92063. * Name of the child mesh that can be used to cast a ray from the controller
  92064. */
  92065. static readonly POINTING_POSE: string;
  92066. /**
  92067. * Creates a new PoseEnabledController from a gamepad
  92068. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  92069. */
  92070. constructor(browserGamepad: any);
  92071. private _workingMatrix;
  92072. /**
  92073. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  92074. */
  92075. update(): void;
  92076. /**
  92077. * Updates only the pose device and mesh without doing any button event checking
  92078. */
  92079. protected _updatePoseAndMesh(): void;
  92080. /**
  92081. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  92082. * @param poseData raw pose fromthe device
  92083. */
  92084. updateFromDevice(poseData: DevicePose): void;
  92085. /**
  92086. * @hidden
  92087. */
  92088. _meshAttachedObservable: Observable<AbstractMesh>;
  92089. /**
  92090. * Attaches a mesh to the controller
  92091. * @param mesh the mesh to be attached
  92092. */
  92093. attachToMesh(mesh: AbstractMesh): void;
  92094. /**
  92095. * Attaches the controllers mesh to a camera
  92096. * @param camera the camera the mesh should be attached to
  92097. */
  92098. attachToPoseControlledCamera(camera: TargetCamera): void;
  92099. /**
  92100. * Disposes of the controller
  92101. */
  92102. dispose(): void;
  92103. /**
  92104. * The mesh that is attached to the controller
  92105. */
  92106. get mesh(): Nullable<AbstractMesh>;
  92107. /**
  92108. * Gets the ray of the controller in the direction the controller is pointing
  92109. * @param length the length the resulting ray should be
  92110. * @returns a ray in the direction the controller is pointing
  92111. */
  92112. getForwardRay(length?: number): Ray;
  92113. }
  92114. }
  92115. declare module BABYLON {
  92116. /**
  92117. * Defines the WebVRController object that represents controllers tracked in 3D space
  92118. */
  92119. export abstract class WebVRController extends PoseEnabledController {
  92120. /**
  92121. * Internal, the default controller model for the controller
  92122. */
  92123. protected _defaultModel: Nullable<AbstractMesh>;
  92124. /**
  92125. * Fired when the trigger state has changed
  92126. */
  92127. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  92128. /**
  92129. * Fired when the main button state has changed
  92130. */
  92131. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  92132. /**
  92133. * Fired when the secondary button state has changed
  92134. */
  92135. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  92136. /**
  92137. * Fired when the pad state has changed
  92138. */
  92139. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  92140. /**
  92141. * Fired when controllers stick values have changed
  92142. */
  92143. onPadValuesChangedObservable: Observable<StickValues>;
  92144. /**
  92145. * Array of button availible on the controller
  92146. */
  92147. protected _buttons: Array<MutableGamepadButton>;
  92148. private _onButtonStateChange;
  92149. /**
  92150. * Fired when a controller button's state has changed
  92151. * @param callback the callback containing the button that was modified
  92152. */
  92153. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  92154. /**
  92155. * X and Y axis corresponding to the controllers joystick
  92156. */
  92157. pad: StickValues;
  92158. /**
  92159. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  92160. */
  92161. hand: string;
  92162. /**
  92163. * The default controller model for the controller
  92164. */
  92165. get defaultModel(): Nullable<AbstractMesh>;
  92166. /**
  92167. * Creates a new WebVRController from a gamepad
  92168. * @param vrGamepad the gamepad that the WebVRController should be created from
  92169. */
  92170. constructor(vrGamepad: any);
  92171. /**
  92172. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  92173. */
  92174. update(): void;
  92175. /**
  92176. * Function to be called when a button is modified
  92177. */
  92178. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  92179. /**
  92180. * Loads a mesh and attaches it to the controller
  92181. * @param scene the scene the mesh should be added to
  92182. * @param meshLoaded callback for when the mesh has been loaded
  92183. */
  92184. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  92185. private _setButtonValue;
  92186. private _changes;
  92187. private _checkChanges;
  92188. /**
  92189. * Disposes of th webVRCOntroller
  92190. */
  92191. dispose(): void;
  92192. }
  92193. }
  92194. declare module BABYLON {
  92195. /**
  92196. * The HemisphericLight simulates the ambient environment light,
  92197. * so the passed direction is the light reflection direction, not the incoming direction.
  92198. */
  92199. export class HemisphericLight extends Light {
  92200. /**
  92201. * The groundColor is the light in the opposite direction to the one specified during creation.
  92202. * 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.
  92203. */
  92204. groundColor: Color3;
  92205. /**
  92206. * The light reflection direction, not the incoming direction.
  92207. */
  92208. direction: Vector3;
  92209. /**
  92210. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  92211. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  92212. * The HemisphericLight can't cast shadows.
  92213. * Documentation : https://doc.babylonjs.com/babylon101/lights
  92214. * @param name The friendly name of the light
  92215. * @param direction The direction of the light reflection
  92216. * @param scene The scene the light belongs to
  92217. */
  92218. constructor(name: string, direction: Vector3, scene: Scene);
  92219. protected _buildUniformLayout(): void;
  92220. /**
  92221. * Returns the string "HemisphericLight".
  92222. * @return The class name
  92223. */
  92224. getClassName(): string;
  92225. /**
  92226. * Sets the HemisphericLight direction towards the passed target (Vector3).
  92227. * Returns the updated direction.
  92228. * @param target The target the direction should point to
  92229. * @return The computed direction
  92230. */
  92231. setDirectionToTarget(target: Vector3): Vector3;
  92232. /**
  92233. * Returns the shadow generator associated to the light.
  92234. * @returns Always null for hemispheric lights because it does not support shadows.
  92235. */
  92236. getShadowGenerator(): Nullable<IShadowGenerator>;
  92237. /**
  92238. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  92239. * @param effect The effect to update
  92240. * @param lightIndex The index of the light in the effect to update
  92241. * @returns The hemispheric light
  92242. */
  92243. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  92244. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  92245. /**
  92246. * Computes the world matrix of the node
  92247. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  92248. * @param useWasUpdatedFlag defines a reserved property
  92249. * @returns the world matrix
  92250. */
  92251. computeWorldMatrix(): Matrix;
  92252. /**
  92253. * Returns the integer 3.
  92254. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  92255. */
  92256. getTypeID(): number;
  92257. /**
  92258. * Prepares the list of defines specific to the light type.
  92259. * @param defines the list of defines
  92260. * @param lightIndex defines the index of the light for the effect
  92261. */
  92262. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  92263. }
  92264. }
  92265. declare module BABYLON {
  92266. /** @hidden */
  92267. export var vrMultiviewToSingleviewPixelShader: {
  92268. name: string;
  92269. shader: string;
  92270. };
  92271. }
  92272. declare module BABYLON {
  92273. /**
  92274. * Renders to multiple views with a single draw call
  92275. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  92276. */
  92277. export class MultiviewRenderTarget extends RenderTargetTexture {
  92278. /**
  92279. * Creates a multiview render target
  92280. * @param scene scene used with the render target
  92281. * @param size the size of the render target (used for each view)
  92282. */
  92283. constructor(scene: Scene, size?: number | {
  92284. width: number;
  92285. height: number;
  92286. } | {
  92287. ratio: number;
  92288. });
  92289. /**
  92290. * @hidden
  92291. * @param faceIndex the face index, if its a cube texture
  92292. */
  92293. _bindFrameBuffer(faceIndex?: number): void;
  92294. /**
  92295. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  92296. * @returns the view count
  92297. */
  92298. getViewCount(): number;
  92299. }
  92300. }
  92301. declare module BABYLON {
  92302. /**
  92303. * Represents a camera frustum
  92304. */
  92305. export class Frustum {
  92306. /**
  92307. * Gets the planes representing the frustum
  92308. * @param transform matrix to be applied to the returned planes
  92309. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  92310. */
  92311. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  92312. /**
  92313. * Gets the near frustum plane transformed by the transform matrix
  92314. * @param transform transformation matrix to be applied to the resulting frustum plane
  92315. * @param frustumPlane the resuling frustum plane
  92316. */
  92317. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92318. /**
  92319. * Gets the far frustum plane transformed by the transform matrix
  92320. * @param transform transformation matrix to be applied to the resulting frustum plane
  92321. * @param frustumPlane the resuling frustum plane
  92322. */
  92323. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92324. /**
  92325. * Gets the left frustum plane transformed by the transform matrix
  92326. * @param transform transformation matrix to be applied to the resulting frustum plane
  92327. * @param frustumPlane the resuling frustum plane
  92328. */
  92329. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92330. /**
  92331. * Gets the right frustum plane transformed by the transform matrix
  92332. * @param transform transformation matrix to be applied to the resulting frustum plane
  92333. * @param frustumPlane the resuling frustum plane
  92334. */
  92335. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92336. /**
  92337. * Gets the top frustum plane transformed by the transform matrix
  92338. * @param transform transformation matrix to be applied to the resulting frustum plane
  92339. * @param frustumPlane the resuling frustum plane
  92340. */
  92341. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92342. /**
  92343. * Gets the bottom frustum plane transformed by the transform matrix
  92344. * @param transform transformation matrix to be applied to the resulting frustum plane
  92345. * @param frustumPlane the resuling frustum plane
  92346. */
  92347. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92348. /**
  92349. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  92350. * @param transform transformation matrix to be applied to the resulting frustum planes
  92351. * @param frustumPlanes the resuling frustum planes
  92352. */
  92353. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  92354. }
  92355. }
  92356. declare module BABYLON {
  92357. interface Engine {
  92358. /**
  92359. * Creates a new multiview render target
  92360. * @param width defines the width of the texture
  92361. * @param height defines the height of the texture
  92362. * @returns the created multiview texture
  92363. */
  92364. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  92365. /**
  92366. * Binds a multiview framebuffer to be drawn to
  92367. * @param multiviewTexture texture to bind
  92368. */
  92369. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  92370. }
  92371. interface Camera {
  92372. /**
  92373. * @hidden
  92374. * 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)
  92375. */
  92376. _useMultiviewToSingleView: boolean;
  92377. /**
  92378. * @hidden
  92379. * 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)
  92380. */
  92381. _multiviewTexture: Nullable<RenderTargetTexture>;
  92382. /**
  92383. * @hidden
  92384. * ensures the multiview texture of the camera exists and has the specified width/height
  92385. * @param width height to set on the multiview texture
  92386. * @param height width to set on the multiview texture
  92387. */
  92388. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  92389. }
  92390. interface Scene {
  92391. /** @hidden */
  92392. _transformMatrixR: Matrix;
  92393. /** @hidden */
  92394. _multiviewSceneUbo: Nullable<UniformBuffer>;
  92395. /** @hidden */
  92396. _createMultiviewUbo(): void;
  92397. /** @hidden */
  92398. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  92399. /** @hidden */
  92400. _renderMultiviewToSingleView(camera: Camera): void;
  92401. }
  92402. }
  92403. declare module BABYLON {
  92404. /**
  92405. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  92406. * This will not be used for webXR as it supports displaying texture arrays directly
  92407. */
  92408. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  92409. /**
  92410. * Initializes a VRMultiviewToSingleview
  92411. * @param name name of the post process
  92412. * @param camera camera to be applied to
  92413. * @param scaleFactor scaling factor to the size of the output texture
  92414. */
  92415. constructor(name: string, camera: Camera, scaleFactor: number);
  92416. }
  92417. }
  92418. declare module BABYLON {
  92419. /**
  92420. * Interface used to define additional presentation attributes
  92421. */
  92422. export interface IVRPresentationAttributes {
  92423. /**
  92424. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  92425. */
  92426. highRefreshRate: boolean;
  92427. /**
  92428. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  92429. */
  92430. foveationLevel: number;
  92431. }
  92432. interface Engine {
  92433. /** @hidden */
  92434. _vrDisplay: any;
  92435. /** @hidden */
  92436. _vrSupported: boolean;
  92437. /** @hidden */
  92438. _oldSize: Size;
  92439. /** @hidden */
  92440. _oldHardwareScaleFactor: number;
  92441. /** @hidden */
  92442. _vrExclusivePointerMode: boolean;
  92443. /** @hidden */
  92444. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  92445. /** @hidden */
  92446. _onVRDisplayPointerRestricted: () => void;
  92447. /** @hidden */
  92448. _onVRDisplayPointerUnrestricted: () => void;
  92449. /** @hidden */
  92450. _onVrDisplayConnect: Nullable<(display: any) => void>;
  92451. /** @hidden */
  92452. _onVrDisplayDisconnect: Nullable<() => void>;
  92453. /** @hidden */
  92454. _onVrDisplayPresentChange: Nullable<() => void>;
  92455. /**
  92456. * Observable signaled when VR display mode changes
  92457. */
  92458. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  92459. /**
  92460. * Observable signaled when VR request present is complete
  92461. */
  92462. onVRRequestPresentComplete: Observable<boolean>;
  92463. /**
  92464. * Observable signaled when VR request present starts
  92465. */
  92466. onVRRequestPresentStart: Observable<Engine>;
  92467. /**
  92468. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  92469. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  92470. */
  92471. isInVRExclusivePointerMode: boolean;
  92472. /**
  92473. * Gets a boolean indicating if a webVR device was detected
  92474. * @returns true if a webVR device was detected
  92475. */
  92476. isVRDevicePresent(): boolean;
  92477. /**
  92478. * Gets the current webVR device
  92479. * @returns the current webVR device (or null)
  92480. */
  92481. getVRDevice(): any;
  92482. /**
  92483. * Initializes a webVR display and starts listening to display change events
  92484. * The onVRDisplayChangedObservable will be notified upon these changes
  92485. * @returns A promise containing a VRDisplay and if vr is supported
  92486. */
  92487. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  92488. /** @hidden */
  92489. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  92490. /**
  92491. * Gets or sets the presentation attributes used to configure VR rendering
  92492. */
  92493. vrPresentationAttributes?: IVRPresentationAttributes;
  92494. /**
  92495. * Call this function to switch to webVR mode
  92496. * Will do nothing if webVR is not supported or if there is no webVR device
  92497. * @param options the webvr options provided to the camera. mainly used for multiview
  92498. * @see http://doc.babylonjs.com/how_to/webvr_camera
  92499. */
  92500. enableVR(options: WebVROptions): void;
  92501. /** @hidden */
  92502. _onVRFullScreenTriggered(): void;
  92503. }
  92504. }
  92505. declare module BABYLON {
  92506. /**
  92507. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  92508. * IMPORTANT!! The data is right-hand data.
  92509. * @export
  92510. * @interface DevicePose
  92511. */
  92512. export interface DevicePose {
  92513. /**
  92514. * The position of the device, values in array are [x,y,z].
  92515. */
  92516. readonly position: Nullable<Float32Array>;
  92517. /**
  92518. * The linearVelocity of the device, values in array are [x,y,z].
  92519. */
  92520. readonly linearVelocity: Nullable<Float32Array>;
  92521. /**
  92522. * The linearAcceleration of the device, values in array are [x,y,z].
  92523. */
  92524. readonly linearAcceleration: Nullable<Float32Array>;
  92525. /**
  92526. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  92527. */
  92528. readonly orientation: Nullable<Float32Array>;
  92529. /**
  92530. * The angularVelocity of the device, values in array are [x,y,z].
  92531. */
  92532. readonly angularVelocity: Nullable<Float32Array>;
  92533. /**
  92534. * The angularAcceleration of the device, values in array are [x,y,z].
  92535. */
  92536. readonly angularAcceleration: Nullable<Float32Array>;
  92537. }
  92538. /**
  92539. * Interface representing a pose controlled object in Babylon.
  92540. * A pose controlled object has both regular pose values as well as pose values
  92541. * from an external device such as a VR head mounted display
  92542. */
  92543. export interface PoseControlled {
  92544. /**
  92545. * The position of the object in babylon space.
  92546. */
  92547. position: Vector3;
  92548. /**
  92549. * The rotation quaternion of the object in babylon space.
  92550. */
  92551. rotationQuaternion: Quaternion;
  92552. /**
  92553. * The position of the device in babylon space.
  92554. */
  92555. devicePosition?: Vector3;
  92556. /**
  92557. * The rotation quaternion of the device in babylon space.
  92558. */
  92559. deviceRotationQuaternion: Quaternion;
  92560. /**
  92561. * The raw pose coming from the device.
  92562. */
  92563. rawPose: Nullable<DevicePose>;
  92564. /**
  92565. * The scale of the device to be used when translating from device space to babylon space.
  92566. */
  92567. deviceScaleFactor: number;
  92568. /**
  92569. * Updates the poseControlled values based on the input device pose.
  92570. * @param poseData the pose data to update the object with
  92571. */
  92572. updateFromDevice(poseData: DevicePose): void;
  92573. }
  92574. /**
  92575. * Set of options to customize the webVRCamera
  92576. */
  92577. export interface WebVROptions {
  92578. /**
  92579. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  92580. */
  92581. trackPosition?: boolean;
  92582. /**
  92583. * Sets the scale of the vrDevice in babylon space. (default: 1)
  92584. */
  92585. positionScale?: number;
  92586. /**
  92587. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  92588. */
  92589. displayName?: string;
  92590. /**
  92591. * Should the native controller meshes be initialized. (default: true)
  92592. */
  92593. controllerMeshes?: boolean;
  92594. /**
  92595. * Creating a default HemiLight only on controllers. (default: true)
  92596. */
  92597. defaultLightingOnControllers?: boolean;
  92598. /**
  92599. * If you don't want to use the default VR button of the helper. (default: false)
  92600. */
  92601. useCustomVRButton?: boolean;
  92602. /**
  92603. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  92604. */
  92605. customVRButton?: HTMLButtonElement;
  92606. /**
  92607. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  92608. */
  92609. rayLength?: number;
  92610. /**
  92611. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  92612. */
  92613. defaultHeight?: number;
  92614. /**
  92615. * If multiview should be used if availible (default: false)
  92616. */
  92617. useMultiview?: boolean;
  92618. }
  92619. /**
  92620. * This represents a WebVR camera.
  92621. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  92622. * @example http://doc.babylonjs.com/how_to/webvr_camera
  92623. */
  92624. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  92625. private webVROptions;
  92626. /**
  92627. * @hidden
  92628. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  92629. */
  92630. _vrDevice: any;
  92631. /**
  92632. * The rawPose of the vrDevice.
  92633. */
  92634. rawPose: Nullable<DevicePose>;
  92635. private _onVREnabled;
  92636. private _specsVersion;
  92637. private _attached;
  92638. private _frameData;
  92639. protected _descendants: Array<Node>;
  92640. private _deviceRoomPosition;
  92641. /** @hidden */
  92642. _deviceRoomRotationQuaternion: Quaternion;
  92643. private _standingMatrix;
  92644. /**
  92645. * Represents device position in babylon space.
  92646. */
  92647. devicePosition: Vector3;
  92648. /**
  92649. * Represents device rotation in babylon space.
  92650. */
  92651. deviceRotationQuaternion: Quaternion;
  92652. /**
  92653. * The scale of the device to be used when translating from device space to babylon space.
  92654. */
  92655. deviceScaleFactor: number;
  92656. private _deviceToWorld;
  92657. private _worldToDevice;
  92658. /**
  92659. * References to the webVR controllers for the vrDevice.
  92660. */
  92661. controllers: Array<WebVRController>;
  92662. /**
  92663. * Emits an event when a controller is attached.
  92664. */
  92665. onControllersAttachedObservable: Observable<WebVRController[]>;
  92666. /**
  92667. * Emits an event when a controller's mesh has been loaded;
  92668. */
  92669. onControllerMeshLoadedObservable: Observable<WebVRController>;
  92670. /**
  92671. * Emits an event when the HMD's pose has been updated.
  92672. */
  92673. onPoseUpdatedFromDeviceObservable: Observable<any>;
  92674. private _poseSet;
  92675. /**
  92676. * If the rig cameras be used as parent instead of this camera.
  92677. */
  92678. rigParenting: boolean;
  92679. private _lightOnControllers;
  92680. private _defaultHeight?;
  92681. /**
  92682. * Instantiates a WebVRFreeCamera.
  92683. * @param name The name of the WebVRFreeCamera
  92684. * @param position The starting anchor position for the camera
  92685. * @param scene The scene the camera belongs to
  92686. * @param webVROptions a set of customizable options for the webVRCamera
  92687. */
  92688. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  92689. /**
  92690. * Gets the device distance from the ground in meters.
  92691. * @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.
  92692. */
  92693. deviceDistanceToRoomGround(): number;
  92694. /**
  92695. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  92696. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  92697. */
  92698. useStandingMatrix(callback?: (bool: boolean) => void): void;
  92699. /**
  92700. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  92701. * @returns A promise with a boolean set to if the standing matrix is supported.
  92702. */
  92703. useStandingMatrixAsync(): Promise<boolean>;
  92704. /**
  92705. * Disposes the camera
  92706. */
  92707. dispose(): void;
  92708. /**
  92709. * Gets a vrController by name.
  92710. * @param name The name of the controller to retreive
  92711. * @returns the controller matching the name specified or null if not found
  92712. */
  92713. getControllerByName(name: string): Nullable<WebVRController>;
  92714. private _leftController;
  92715. /**
  92716. * The controller corresponding to the users left hand.
  92717. */
  92718. get leftController(): Nullable<WebVRController>;
  92719. private _rightController;
  92720. /**
  92721. * The controller corresponding to the users right hand.
  92722. */
  92723. get rightController(): Nullable<WebVRController>;
  92724. /**
  92725. * Casts a ray forward from the vrCamera's gaze.
  92726. * @param length Length of the ray (default: 100)
  92727. * @returns the ray corresponding to the gaze
  92728. */
  92729. getForwardRay(length?: number): Ray;
  92730. /**
  92731. * @hidden
  92732. * Updates the camera based on device's frame data
  92733. */
  92734. _checkInputs(): void;
  92735. /**
  92736. * Updates the poseControlled values based on the input device pose.
  92737. * @param poseData Pose coming from the device
  92738. */
  92739. updateFromDevice(poseData: DevicePose): void;
  92740. private _htmlElementAttached;
  92741. private _detachIfAttached;
  92742. /**
  92743. * WebVR's attach control will start broadcasting frames to the device.
  92744. * Note that in certain browsers (chrome for example) this function must be called
  92745. * within a user-interaction callback. Example:
  92746. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  92747. *
  92748. * @param element html element to attach the vrDevice to
  92749. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  92750. */
  92751. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92752. /**
  92753. * Detaches the camera from the html element and disables VR
  92754. *
  92755. * @param element html element to detach from
  92756. */
  92757. detachControl(element: HTMLElement): void;
  92758. /**
  92759. * @returns the name of this class
  92760. */
  92761. getClassName(): string;
  92762. /**
  92763. * Calls resetPose on the vrDisplay
  92764. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  92765. */
  92766. resetToCurrentRotation(): void;
  92767. /**
  92768. * @hidden
  92769. * Updates the rig cameras (left and right eye)
  92770. */
  92771. _updateRigCameras(): void;
  92772. private _workingVector;
  92773. private _oneVector;
  92774. private _workingMatrix;
  92775. private updateCacheCalled;
  92776. private _correctPositionIfNotTrackPosition;
  92777. /**
  92778. * @hidden
  92779. * Updates the cached values of the camera
  92780. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  92781. */
  92782. _updateCache(ignoreParentClass?: boolean): void;
  92783. /**
  92784. * @hidden
  92785. * Get current device position in babylon world
  92786. */
  92787. _computeDevicePosition(): void;
  92788. /**
  92789. * Updates the current device position and rotation in the babylon world
  92790. */
  92791. update(): void;
  92792. /**
  92793. * @hidden
  92794. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  92795. * @returns an identity matrix
  92796. */
  92797. _getViewMatrix(): Matrix;
  92798. private _tmpMatrix;
  92799. /**
  92800. * This function is called by the two RIG cameras.
  92801. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  92802. * @hidden
  92803. */
  92804. _getWebVRViewMatrix(): Matrix;
  92805. /** @hidden */
  92806. _getWebVRProjectionMatrix(): Matrix;
  92807. private _onGamepadConnectedObserver;
  92808. private _onGamepadDisconnectedObserver;
  92809. private _updateCacheWhenTrackingDisabledObserver;
  92810. /**
  92811. * Initializes the controllers and their meshes
  92812. */
  92813. initControllers(): void;
  92814. }
  92815. }
  92816. declare module BABYLON {
  92817. /**
  92818. * Size options for a post process
  92819. */
  92820. export type PostProcessOptions = {
  92821. width: number;
  92822. height: number;
  92823. };
  92824. /**
  92825. * PostProcess can be used to apply a shader to a texture after it has been rendered
  92826. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  92827. */
  92828. export class PostProcess {
  92829. /** Name of the PostProcess. */
  92830. name: string;
  92831. /**
  92832. * Gets or sets the unique id of the post process
  92833. */
  92834. uniqueId: number;
  92835. /**
  92836. * Width of the texture to apply the post process on
  92837. */
  92838. width: number;
  92839. /**
  92840. * Height of the texture to apply the post process on
  92841. */
  92842. height: number;
  92843. /**
  92844. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  92845. * @hidden
  92846. */
  92847. _outputTexture: Nullable<InternalTexture>;
  92848. /**
  92849. * Sampling mode used by the shader
  92850. * See https://doc.babylonjs.com/classes/3.1/texture
  92851. */
  92852. renderTargetSamplingMode: number;
  92853. /**
  92854. * Clear color to use when screen clearing
  92855. */
  92856. clearColor: Color4;
  92857. /**
  92858. * If the buffer needs to be cleared before applying the post process. (default: true)
  92859. * Should be set to false if shader will overwrite all previous pixels.
  92860. */
  92861. autoClear: boolean;
  92862. /**
  92863. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  92864. */
  92865. alphaMode: number;
  92866. /**
  92867. * Sets the setAlphaBlendConstants of the babylon engine
  92868. */
  92869. alphaConstants: Color4;
  92870. /**
  92871. * Animations to be used for the post processing
  92872. */
  92873. animations: Animation[];
  92874. /**
  92875. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  92876. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  92877. */
  92878. enablePixelPerfectMode: boolean;
  92879. /**
  92880. * Force the postprocess to be applied without taking in account viewport
  92881. */
  92882. forceFullscreenViewport: boolean;
  92883. /**
  92884. * List of inspectable custom properties (used by the Inspector)
  92885. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  92886. */
  92887. inspectableCustomProperties: IInspectable[];
  92888. /**
  92889. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  92890. *
  92891. * | Value | Type | Description |
  92892. * | ----- | ----------------------------------- | ----------- |
  92893. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  92894. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  92895. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  92896. *
  92897. */
  92898. scaleMode: number;
  92899. /**
  92900. * Force textures to be a power of two (default: false)
  92901. */
  92902. alwaysForcePOT: boolean;
  92903. private _samples;
  92904. /**
  92905. * Number of sample textures (default: 1)
  92906. */
  92907. get samples(): number;
  92908. set samples(n: number);
  92909. /**
  92910. * Modify the scale of the post process to be the same as the viewport (default: false)
  92911. */
  92912. adaptScaleToCurrentViewport: boolean;
  92913. private _camera;
  92914. private _scene;
  92915. private _engine;
  92916. private _options;
  92917. private _reusable;
  92918. private _textureType;
  92919. private _textureFormat;
  92920. /**
  92921. * Smart array of input and output textures for the post process.
  92922. * @hidden
  92923. */
  92924. _textures: SmartArray<InternalTexture>;
  92925. /**
  92926. * The index in _textures that corresponds to the output texture.
  92927. * @hidden
  92928. */
  92929. _currentRenderTextureInd: number;
  92930. private _effect;
  92931. private _samplers;
  92932. private _fragmentUrl;
  92933. private _vertexUrl;
  92934. private _parameters;
  92935. private _scaleRatio;
  92936. protected _indexParameters: any;
  92937. private _shareOutputWithPostProcess;
  92938. private _texelSize;
  92939. private _forcedOutputTexture;
  92940. /**
  92941. * Returns the fragment url or shader name used in the post process.
  92942. * @returns the fragment url or name in the shader store.
  92943. */
  92944. getEffectName(): string;
  92945. /**
  92946. * An event triggered when the postprocess is activated.
  92947. */
  92948. onActivateObservable: Observable<Camera>;
  92949. private _onActivateObserver;
  92950. /**
  92951. * A function that is added to the onActivateObservable
  92952. */
  92953. set onActivate(callback: Nullable<(camera: Camera) => void>);
  92954. /**
  92955. * An event triggered when the postprocess changes its size.
  92956. */
  92957. onSizeChangedObservable: Observable<PostProcess>;
  92958. private _onSizeChangedObserver;
  92959. /**
  92960. * A function that is added to the onSizeChangedObservable
  92961. */
  92962. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  92963. /**
  92964. * An event triggered when the postprocess applies its effect.
  92965. */
  92966. onApplyObservable: Observable<Effect>;
  92967. private _onApplyObserver;
  92968. /**
  92969. * A function that is added to the onApplyObservable
  92970. */
  92971. set onApply(callback: (effect: Effect) => void);
  92972. /**
  92973. * An event triggered before rendering the postprocess
  92974. */
  92975. onBeforeRenderObservable: Observable<Effect>;
  92976. private _onBeforeRenderObserver;
  92977. /**
  92978. * A function that is added to the onBeforeRenderObservable
  92979. */
  92980. set onBeforeRender(callback: (effect: Effect) => void);
  92981. /**
  92982. * An event triggered after rendering the postprocess
  92983. */
  92984. onAfterRenderObservable: Observable<Effect>;
  92985. private _onAfterRenderObserver;
  92986. /**
  92987. * A function that is added to the onAfterRenderObservable
  92988. */
  92989. set onAfterRender(callback: (efect: Effect) => void);
  92990. /**
  92991. * 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
  92992. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  92993. */
  92994. get inputTexture(): InternalTexture;
  92995. set inputTexture(value: InternalTexture);
  92996. /**
  92997. * Gets the camera which post process is applied to.
  92998. * @returns The camera the post process is applied to.
  92999. */
  93000. getCamera(): Camera;
  93001. /**
  93002. * Gets the texel size of the postprocess.
  93003. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  93004. */
  93005. get texelSize(): Vector2;
  93006. /**
  93007. * Creates a new instance PostProcess
  93008. * @param name The name of the PostProcess.
  93009. * @param fragmentUrl The url of the fragment shader to be used.
  93010. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  93011. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  93012. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  93013. * @param camera The camera to apply the render pass to.
  93014. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  93015. * @param engine The engine which the post process will be applied. (default: current engine)
  93016. * @param reusable If the post process can be reused on the same frame. (default: false)
  93017. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  93018. * @param textureType Type of textures used when performing the post process. (default: 0)
  93019. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  93020. * @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
  93021. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  93022. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  93023. */
  93024. constructor(
  93025. /** Name of the PostProcess. */
  93026. 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);
  93027. /**
  93028. * Gets a string idenfifying the name of the class
  93029. * @returns "PostProcess" string
  93030. */
  93031. getClassName(): string;
  93032. /**
  93033. * Gets the engine which this post process belongs to.
  93034. * @returns The engine the post process was enabled with.
  93035. */
  93036. getEngine(): Engine;
  93037. /**
  93038. * The effect that is created when initializing the post process.
  93039. * @returns The created effect corresponding the the postprocess.
  93040. */
  93041. getEffect(): Effect;
  93042. /**
  93043. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  93044. * @param postProcess The post process to share the output with.
  93045. * @returns This post process.
  93046. */
  93047. shareOutputWith(postProcess: PostProcess): PostProcess;
  93048. /**
  93049. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  93050. * This should be called if the post process that shares output with this post process is disabled/disposed.
  93051. */
  93052. useOwnOutput(): void;
  93053. /**
  93054. * Updates the effect with the current post process compile time values and recompiles the shader.
  93055. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  93056. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  93057. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  93058. * @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
  93059. * @param onCompiled Called when the shader has been compiled.
  93060. * @param onError Called if there is an error when compiling a shader.
  93061. */
  93062. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  93063. /**
  93064. * The post process is reusable if it can be used multiple times within one frame.
  93065. * @returns If the post process is reusable
  93066. */
  93067. isReusable(): boolean;
  93068. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  93069. markTextureDirty(): void;
  93070. /**
  93071. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  93072. * 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.
  93073. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  93074. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  93075. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  93076. * @returns The target texture that was bound to be written to.
  93077. */
  93078. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  93079. /**
  93080. * If the post process is supported.
  93081. */
  93082. get isSupported(): boolean;
  93083. /**
  93084. * The aspect ratio of the output texture.
  93085. */
  93086. get aspectRatio(): number;
  93087. /**
  93088. * Get a value indicating if the post-process is ready to be used
  93089. * @returns true if the post-process is ready (shader is compiled)
  93090. */
  93091. isReady(): boolean;
  93092. /**
  93093. * Binds all textures and uniforms to the shader, this will be run on every pass.
  93094. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  93095. */
  93096. apply(): Nullable<Effect>;
  93097. private _disposeTextures;
  93098. /**
  93099. * Disposes the post process.
  93100. * @param camera The camera to dispose the post process on.
  93101. */
  93102. dispose(camera?: Camera): void;
  93103. }
  93104. }
  93105. declare module BABYLON {
  93106. /** @hidden */
  93107. export var kernelBlurVaryingDeclaration: {
  93108. name: string;
  93109. shader: string;
  93110. };
  93111. }
  93112. declare module BABYLON {
  93113. /** @hidden */
  93114. export var kernelBlurFragment: {
  93115. name: string;
  93116. shader: string;
  93117. };
  93118. }
  93119. declare module BABYLON {
  93120. /** @hidden */
  93121. export var kernelBlurFragment2: {
  93122. name: string;
  93123. shader: string;
  93124. };
  93125. }
  93126. declare module BABYLON {
  93127. /** @hidden */
  93128. export var kernelBlurPixelShader: {
  93129. name: string;
  93130. shader: string;
  93131. };
  93132. }
  93133. declare module BABYLON {
  93134. /** @hidden */
  93135. export var kernelBlurVertex: {
  93136. name: string;
  93137. shader: string;
  93138. };
  93139. }
  93140. declare module BABYLON {
  93141. /** @hidden */
  93142. export var kernelBlurVertexShader: {
  93143. name: string;
  93144. shader: string;
  93145. };
  93146. }
  93147. declare module BABYLON {
  93148. /**
  93149. * The Blur Post Process which blurs an image based on a kernel and direction.
  93150. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  93151. */
  93152. export class BlurPostProcess extends PostProcess {
  93153. /** The direction in which to blur the image. */
  93154. direction: Vector2;
  93155. private blockCompilation;
  93156. protected _kernel: number;
  93157. protected _idealKernel: number;
  93158. protected _packedFloat: boolean;
  93159. private _staticDefines;
  93160. /**
  93161. * Sets the length in pixels of the blur sample region
  93162. */
  93163. set kernel(v: number);
  93164. /**
  93165. * Gets the length in pixels of the blur sample region
  93166. */
  93167. get kernel(): number;
  93168. /**
  93169. * Sets wether or not the blur needs to unpack/repack floats
  93170. */
  93171. set packedFloat(v: boolean);
  93172. /**
  93173. * Gets wether or not the blur is unpacking/repacking floats
  93174. */
  93175. get packedFloat(): boolean;
  93176. /**
  93177. * Creates a new instance BlurPostProcess
  93178. * @param name The name of the effect.
  93179. * @param direction The direction in which to blur the image.
  93180. * @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.
  93181. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  93182. * @param camera The camera to apply the render pass to.
  93183. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  93184. * @param engine The engine which the post process will be applied. (default: current engine)
  93185. * @param reusable If the post process can be reused on the same frame. (default: false)
  93186. * @param textureType Type of textures used when performing the post process. (default: 0)
  93187. * @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)
  93188. */
  93189. constructor(name: string,
  93190. /** The direction in which to blur the image. */
  93191. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  93192. /**
  93193. * Updates the effect with the current post process compile time values and recompiles the shader.
  93194. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  93195. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  93196. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  93197. * @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
  93198. * @param onCompiled Called when the shader has been compiled.
  93199. * @param onError Called if there is an error when compiling a shader.
  93200. */
  93201. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  93202. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  93203. /**
  93204. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  93205. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  93206. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  93207. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  93208. * The gaps between physical kernels are compensated for in the weighting of the samples
  93209. * @param idealKernel Ideal blur kernel.
  93210. * @return Nearest best kernel.
  93211. */
  93212. protected _nearestBestKernel(idealKernel: number): number;
  93213. /**
  93214. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  93215. * @param x The point on the Gaussian distribution to sample.
  93216. * @return the value of the Gaussian function at x.
  93217. */
  93218. protected _gaussianWeight(x: number): number;
  93219. /**
  93220. * Generates a string that can be used as a floating point number in GLSL.
  93221. * @param x Value to print.
  93222. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  93223. * @return GLSL float string.
  93224. */
  93225. protected _glslFloat(x: number, decimalFigures?: number): string;
  93226. }
  93227. }
  93228. declare module BABYLON {
  93229. /**
  93230. * Mirror texture can be used to simulate the view from a mirror in a scene.
  93231. * It will dynamically be rendered every frame to adapt to the camera point of view.
  93232. * You can then easily use it as a reflectionTexture on a flat surface.
  93233. * In case the surface is not a plane, please consider relying on reflection probes.
  93234. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  93235. */
  93236. export class MirrorTexture extends RenderTargetTexture {
  93237. private scene;
  93238. /**
  93239. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  93240. * 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.
  93241. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  93242. */
  93243. mirrorPlane: Plane;
  93244. /**
  93245. * Define the blur ratio used to blur the reflection if needed.
  93246. */
  93247. set blurRatio(value: number);
  93248. get blurRatio(): number;
  93249. /**
  93250. * Define the adaptive blur kernel used to blur the reflection if needed.
  93251. * This will autocompute the closest best match for the `blurKernel`
  93252. */
  93253. set adaptiveBlurKernel(value: number);
  93254. /**
  93255. * Define the blur kernel used to blur the reflection if needed.
  93256. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  93257. */
  93258. set blurKernel(value: number);
  93259. /**
  93260. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  93261. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  93262. */
  93263. set blurKernelX(value: number);
  93264. get blurKernelX(): number;
  93265. /**
  93266. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  93267. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  93268. */
  93269. set blurKernelY(value: number);
  93270. get blurKernelY(): number;
  93271. private _autoComputeBlurKernel;
  93272. protected _onRatioRescale(): void;
  93273. private _updateGammaSpace;
  93274. private _imageProcessingConfigChangeObserver;
  93275. private _transformMatrix;
  93276. private _mirrorMatrix;
  93277. private _savedViewMatrix;
  93278. private _blurX;
  93279. private _blurY;
  93280. private _adaptiveBlurKernel;
  93281. private _blurKernelX;
  93282. private _blurKernelY;
  93283. private _blurRatio;
  93284. /**
  93285. * Instantiates a Mirror Texture.
  93286. * Mirror texture can be used to simulate the view from a mirror in a scene.
  93287. * It will dynamically be rendered every frame to adapt to the camera point of view.
  93288. * You can then easily use it as a reflectionTexture on a flat surface.
  93289. * In case the surface is not a plane, please consider relying on reflection probes.
  93290. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  93291. * @param name
  93292. * @param size
  93293. * @param scene
  93294. * @param generateMipMaps
  93295. * @param type
  93296. * @param samplingMode
  93297. * @param generateDepthBuffer
  93298. */
  93299. constructor(name: string, size: number | {
  93300. width: number;
  93301. height: number;
  93302. } | {
  93303. ratio: number;
  93304. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  93305. private _preparePostProcesses;
  93306. /**
  93307. * Clone the mirror texture.
  93308. * @returns the cloned texture
  93309. */
  93310. clone(): MirrorTexture;
  93311. /**
  93312. * Serialize the texture to a JSON representation you could use in Parse later on
  93313. * @returns the serialized JSON representation
  93314. */
  93315. serialize(): any;
  93316. /**
  93317. * Dispose the texture and release its associated resources.
  93318. */
  93319. dispose(): void;
  93320. }
  93321. }
  93322. declare module BABYLON {
  93323. /**
  93324. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  93325. * @see http://doc.babylonjs.com/babylon101/materials#texture
  93326. */
  93327. export class Texture extends BaseTexture {
  93328. /**
  93329. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  93330. */
  93331. static SerializeBuffers: boolean;
  93332. /** @hidden */
  93333. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  93334. /** @hidden */
  93335. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  93336. /** @hidden */
  93337. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  93338. /** nearest is mag = nearest and min = nearest and mip = linear */
  93339. static readonly NEAREST_SAMPLINGMODE: number;
  93340. /** nearest is mag = nearest and min = nearest and mip = linear */
  93341. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  93342. /** Bilinear is mag = linear and min = linear and mip = nearest */
  93343. static readonly BILINEAR_SAMPLINGMODE: number;
  93344. /** Bilinear is mag = linear and min = linear and mip = nearest */
  93345. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  93346. /** Trilinear is mag = linear and min = linear and mip = linear */
  93347. static readonly TRILINEAR_SAMPLINGMODE: number;
  93348. /** Trilinear is mag = linear and min = linear and mip = linear */
  93349. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  93350. /** mag = nearest and min = nearest and mip = nearest */
  93351. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  93352. /** mag = nearest and min = linear and mip = nearest */
  93353. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  93354. /** mag = nearest and min = linear and mip = linear */
  93355. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  93356. /** mag = nearest and min = linear and mip = none */
  93357. static readonly NEAREST_LINEAR: number;
  93358. /** mag = nearest and min = nearest and mip = none */
  93359. static readonly NEAREST_NEAREST: number;
  93360. /** mag = linear and min = nearest and mip = nearest */
  93361. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  93362. /** mag = linear and min = nearest and mip = linear */
  93363. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  93364. /** mag = linear and min = linear and mip = none */
  93365. static readonly LINEAR_LINEAR: number;
  93366. /** mag = linear and min = nearest and mip = none */
  93367. static readonly LINEAR_NEAREST: number;
  93368. /** Explicit coordinates mode */
  93369. static readonly EXPLICIT_MODE: number;
  93370. /** Spherical coordinates mode */
  93371. static readonly SPHERICAL_MODE: number;
  93372. /** Planar coordinates mode */
  93373. static readonly PLANAR_MODE: number;
  93374. /** Cubic coordinates mode */
  93375. static readonly CUBIC_MODE: number;
  93376. /** Projection coordinates mode */
  93377. static readonly PROJECTION_MODE: number;
  93378. /** Inverse Cubic coordinates mode */
  93379. static readonly SKYBOX_MODE: number;
  93380. /** Inverse Cubic coordinates mode */
  93381. static readonly INVCUBIC_MODE: number;
  93382. /** Equirectangular coordinates mode */
  93383. static readonly EQUIRECTANGULAR_MODE: number;
  93384. /** Equirectangular Fixed coordinates mode */
  93385. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  93386. /** Equirectangular Fixed Mirrored coordinates mode */
  93387. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  93388. /** Texture is not repeating outside of 0..1 UVs */
  93389. static readonly CLAMP_ADDRESSMODE: number;
  93390. /** Texture is repeating outside of 0..1 UVs */
  93391. static readonly WRAP_ADDRESSMODE: number;
  93392. /** Texture is repeating and mirrored */
  93393. static readonly MIRROR_ADDRESSMODE: number;
  93394. /**
  93395. * 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
  93396. */
  93397. static UseSerializedUrlIfAny: boolean;
  93398. /**
  93399. * Define the url of the texture.
  93400. */
  93401. url: Nullable<string>;
  93402. /**
  93403. * Define an offset on the texture to offset the u coordinates of the UVs
  93404. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  93405. */
  93406. uOffset: number;
  93407. /**
  93408. * Define an offset on the texture to offset the v coordinates of the UVs
  93409. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  93410. */
  93411. vOffset: number;
  93412. /**
  93413. * Define an offset on the texture to scale the u coordinates of the UVs
  93414. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  93415. */
  93416. uScale: number;
  93417. /**
  93418. * Define an offset on the texture to scale the v coordinates of the UVs
  93419. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  93420. */
  93421. vScale: number;
  93422. /**
  93423. * Define an offset on the texture to rotate around the u coordinates of the UVs
  93424. * @see http://doc.babylonjs.com/how_to/more_materials
  93425. */
  93426. uAng: number;
  93427. /**
  93428. * Define an offset on the texture to rotate around the v coordinates of the UVs
  93429. * @see http://doc.babylonjs.com/how_to/more_materials
  93430. */
  93431. vAng: number;
  93432. /**
  93433. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  93434. * @see http://doc.babylonjs.com/how_to/more_materials
  93435. */
  93436. wAng: number;
  93437. /**
  93438. * Defines the center of rotation (U)
  93439. */
  93440. uRotationCenter: number;
  93441. /**
  93442. * Defines the center of rotation (V)
  93443. */
  93444. vRotationCenter: number;
  93445. /**
  93446. * Defines the center of rotation (W)
  93447. */
  93448. wRotationCenter: number;
  93449. /**
  93450. * Are mip maps generated for this texture or not.
  93451. */
  93452. get noMipmap(): boolean;
  93453. /**
  93454. * List of inspectable custom properties (used by the Inspector)
  93455. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  93456. */
  93457. inspectableCustomProperties: Nullable<IInspectable[]>;
  93458. private _noMipmap;
  93459. /** @hidden */
  93460. _invertY: boolean;
  93461. private _rowGenerationMatrix;
  93462. private _cachedTextureMatrix;
  93463. private _projectionModeMatrix;
  93464. private _t0;
  93465. private _t1;
  93466. private _t2;
  93467. private _cachedUOffset;
  93468. private _cachedVOffset;
  93469. private _cachedUScale;
  93470. private _cachedVScale;
  93471. private _cachedUAng;
  93472. private _cachedVAng;
  93473. private _cachedWAng;
  93474. private _cachedProjectionMatrixId;
  93475. private _cachedCoordinatesMode;
  93476. /** @hidden */
  93477. protected _initialSamplingMode: number;
  93478. /** @hidden */
  93479. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  93480. private _deleteBuffer;
  93481. protected _format: Nullable<number>;
  93482. private _delayedOnLoad;
  93483. private _delayedOnError;
  93484. private _mimeType?;
  93485. /**
  93486. * Observable triggered once the texture has been loaded.
  93487. */
  93488. onLoadObservable: Observable<Texture>;
  93489. protected _isBlocking: boolean;
  93490. /**
  93491. * Is the texture preventing material to render while loading.
  93492. * If false, a default texture will be used instead of the loading one during the preparation step.
  93493. */
  93494. set isBlocking(value: boolean);
  93495. get isBlocking(): boolean;
  93496. /**
  93497. * Get the current sampling mode associated with the texture.
  93498. */
  93499. get samplingMode(): number;
  93500. /**
  93501. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  93502. */
  93503. get invertY(): boolean;
  93504. /**
  93505. * Instantiates a new texture.
  93506. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  93507. * @see http://doc.babylonjs.com/babylon101/materials#texture
  93508. * @param url defines the url of the picture to load as a texture
  93509. * @param scene defines the scene or engine the texture will belong to
  93510. * @param noMipmap defines if the texture will require mip maps or not
  93511. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  93512. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  93513. * @param onLoad defines a callback triggered when the texture has been loaded
  93514. * @param onError defines a callback triggered when an error occurred during the loading session
  93515. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  93516. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  93517. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  93518. * @param mimeType defines an optional mime type information
  93519. */
  93520. 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);
  93521. /**
  93522. * Update the url (and optional buffer) of this texture if url was null during construction.
  93523. * @param url the url of the texture
  93524. * @param buffer the buffer of the texture (defaults to null)
  93525. * @param onLoad callback called when the texture is loaded (defaults to null)
  93526. */
  93527. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  93528. /**
  93529. * Finish the loading sequence of a texture flagged as delayed load.
  93530. * @hidden
  93531. */
  93532. delayLoad(): void;
  93533. private _prepareRowForTextureGeneration;
  93534. /**
  93535. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  93536. * @returns the transform matrix of the texture.
  93537. */
  93538. getTextureMatrix(uBase?: number): Matrix;
  93539. /**
  93540. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  93541. * @returns The reflection texture transform
  93542. */
  93543. getReflectionTextureMatrix(): Matrix;
  93544. /**
  93545. * Clones the texture.
  93546. * @returns the cloned texture
  93547. */
  93548. clone(): Texture;
  93549. /**
  93550. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  93551. * @returns The JSON representation of the texture
  93552. */
  93553. serialize(): any;
  93554. /**
  93555. * Get the current class name of the texture useful for serialization or dynamic coding.
  93556. * @returns "Texture"
  93557. */
  93558. getClassName(): string;
  93559. /**
  93560. * Dispose the texture and release its associated resources.
  93561. */
  93562. dispose(): void;
  93563. /**
  93564. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  93565. * @param parsedTexture Define the JSON representation of the texture
  93566. * @param scene Define the scene the parsed texture should be instantiated in
  93567. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  93568. * @returns The parsed texture if successful
  93569. */
  93570. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  93571. /**
  93572. * Creates a texture from its base 64 representation.
  93573. * @param data Define the base64 payload without the data: prefix
  93574. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  93575. * @param scene Define the scene the texture should belong to
  93576. * @param noMipmap Forces the texture to not create mip map information if true
  93577. * @param invertY define if the texture needs to be inverted on the y axis during loading
  93578. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  93579. * @param onLoad define a callback triggered when the texture has been loaded
  93580. * @param onError define a callback triggered when an error occurred during the loading session
  93581. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  93582. * @returns the created texture
  93583. */
  93584. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  93585. /**
  93586. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  93587. * @param data Define the base64 payload without the data: prefix
  93588. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  93589. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  93590. * @param scene Define the scene the texture should belong to
  93591. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  93592. * @param noMipmap Forces the texture to not create mip map information if true
  93593. * @param invertY define if the texture needs to be inverted on the y axis during loading
  93594. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  93595. * @param onLoad define a callback triggered when the texture has been loaded
  93596. * @param onError define a callback triggered when an error occurred during the loading session
  93597. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  93598. * @returns the created texture
  93599. */
  93600. 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;
  93601. }
  93602. }
  93603. declare module BABYLON {
  93604. /**
  93605. * PostProcessManager is used to manage one or more post processes or post process pipelines
  93606. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  93607. */
  93608. export class PostProcessManager {
  93609. private _scene;
  93610. private _indexBuffer;
  93611. private _vertexBuffers;
  93612. /**
  93613. * Creates a new instance PostProcess
  93614. * @param scene The scene that the post process is associated with.
  93615. */
  93616. constructor(scene: Scene);
  93617. private _prepareBuffers;
  93618. private _buildIndexBuffer;
  93619. /**
  93620. * Rebuilds the vertex buffers of the manager.
  93621. * @hidden
  93622. */
  93623. _rebuild(): void;
  93624. /**
  93625. * Prepares a frame to be run through a post process.
  93626. * @param sourceTexture The input texture to the post procesess. (default: null)
  93627. * @param postProcesses An array of post processes to be run. (default: null)
  93628. * @returns True if the post processes were able to be run.
  93629. * @hidden
  93630. */
  93631. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  93632. /**
  93633. * Manually render a set of post processes to a texture.
  93634. * @param postProcesses An array of post processes to be run.
  93635. * @param targetTexture The target texture to render to.
  93636. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  93637. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  93638. * @param lodLevel defines which lod of the texture to render to
  93639. */
  93640. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  93641. /**
  93642. * Finalize the result of the output of the postprocesses.
  93643. * @param doNotPresent If true the result will not be displayed to the screen.
  93644. * @param targetTexture The target texture to render to.
  93645. * @param faceIndex The index of the face to bind the target texture to.
  93646. * @param postProcesses The array of post processes to render.
  93647. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  93648. * @hidden
  93649. */
  93650. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  93651. /**
  93652. * Disposes of the post process manager.
  93653. */
  93654. dispose(): void;
  93655. }
  93656. }
  93657. declare module BABYLON {
  93658. /**
  93659. * This Helps creating a texture that will be created from a camera in your scene.
  93660. * It is basically a dynamic texture that could be used to create special effects for instance.
  93661. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  93662. */
  93663. export class RenderTargetTexture extends Texture {
  93664. isCube: boolean;
  93665. /**
  93666. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  93667. */
  93668. static readonly REFRESHRATE_RENDER_ONCE: number;
  93669. /**
  93670. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  93671. */
  93672. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  93673. /**
  93674. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  93675. * the central point of your effect and can save a lot of performances.
  93676. */
  93677. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  93678. /**
  93679. * Use this predicate to dynamically define the list of mesh you want to render.
  93680. * If set, the renderList property will be overwritten.
  93681. */
  93682. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  93683. private _renderList;
  93684. /**
  93685. * Use this list to define the list of mesh you want to render.
  93686. */
  93687. get renderList(): Nullable<Array<AbstractMesh>>;
  93688. set renderList(value: Nullable<Array<AbstractMesh>>);
  93689. /**
  93690. * Use this function to overload the renderList array at rendering time.
  93691. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  93692. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  93693. * the cube (if the RTT is a cube, else layerOrFace=0).
  93694. * The renderList passed to the function is the current render list (the one that will be used if the function returns null)
  93695. */
  93696. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>) => Nullable<Array<AbstractMesh>>;
  93697. private _hookArray;
  93698. /**
  93699. * Define if particles should be rendered in your texture.
  93700. */
  93701. renderParticles: boolean;
  93702. /**
  93703. * Define if sprites should be rendered in your texture.
  93704. */
  93705. renderSprites: boolean;
  93706. /**
  93707. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  93708. */
  93709. coordinatesMode: number;
  93710. /**
  93711. * Define the camera used to render the texture.
  93712. */
  93713. activeCamera: Nullable<Camera>;
  93714. /**
  93715. * Override the render function of the texture with your own one.
  93716. */
  93717. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  93718. /**
  93719. * Define if camera post processes should be use while rendering the texture.
  93720. */
  93721. useCameraPostProcesses: boolean;
  93722. /**
  93723. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  93724. */
  93725. ignoreCameraViewport: boolean;
  93726. private _postProcessManager;
  93727. private _postProcesses;
  93728. private _resizeObserver;
  93729. /**
  93730. * An event triggered when the texture is unbind.
  93731. */
  93732. onBeforeBindObservable: Observable<RenderTargetTexture>;
  93733. /**
  93734. * An event triggered when the texture is unbind.
  93735. */
  93736. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  93737. private _onAfterUnbindObserver;
  93738. /**
  93739. * Set a after unbind callback in the texture.
  93740. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  93741. */
  93742. set onAfterUnbind(callback: () => void);
  93743. /**
  93744. * An event triggered before rendering the texture
  93745. */
  93746. onBeforeRenderObservable: Observable<number>;
  93747. private _onBeforeRenderObserver;
  93748. /**
  93749. * Set a before render callback in the texture.
  93750. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  93751. */
  93752. set onBeforeRender(callback: (faceIndex: number) => void);
  93753. /**
  93754. * An event triggered after rendering the texture
  93755. */
  93756. onAfterRenderObservable: Observable<number>;
  93757. private _onAfterRenderObserver;
  93758. /**
  93759. * Set a after render callback in the texture.
  93760. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  93761. */
  93762. set onAfterRender(callback: (faceIndex: number) => void);
  93763. /**
  93764. * An event triggered after the texture clear
  93765. */
  93766. onClearObservable: Observable<Engine>;
  93767. private _onClearObserver;
  93768. /**
  93769. * Set a clear callback in the texture.
  93770. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  93771. */
  93772. set onClear(callback: (Engine: Engine) => void);
  93773. /**
  93774. * An event triggered when the texture is resized.
  93775. */
  93776. onResizeObservable: Observable<RenderTargetTexture>;
  93777. /**
  93778. * Define the clear color of the Render Target if it should be different from the scene.
  93779. */
  93780. clearColor: Color4;
  93781. protected _size: number | {
  93782. width: number;
  93783. height: number;
  93784. layers?: number;
  93785. };
  93786. protected _initialSizeParameter: number | {
  93787. width: number;
  93788. height: number;
  93789. } | {
  93790. ratio: number;
  93791. };
  93792. protected _sizeRatio: Nullable<number>;
  93793. /** @hidden */
  93794. _generateMipMaps: boolean;
  93795. protected _renderingManager: RenderingManager;
  93796. /** @hidden */
  93797. _waitingRenderList: string[];
  93798. protected _doNotChangeAspectRatio: boolean;
  93799. protected _currentRefreshId: number;
  93800. protected _refreshRate: number;
  93801. protected _textureMatrix: Matrix;
  93802. protected _samples: number;
  93803. protected _renderTargetOptions: RenderTargetCreationOptions;
  93804. /**
  93805. * Gets render target creation options that were used.
  93806. */
  93807. get renderTargetOptions(): RenderTargetCreationOptions;
  93808. protected _engine: Engine;
  93809. protected _onRatioRescale(): void;
  93810. /**
  93811. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  93812. * It must define where the camera used to render the texture is set
  93813. */
  93814. boundingBoxPosition: Vector3;
  93815. private _boundingBoxSize;
  93816. /**
  93817. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  93818. * When defined, the cubemap will switch to local mode
  93819. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  93820. * @example https://www.babylonjs-playground.com/#RNASML
  93821. */
  93822. set boundingBoxSize(value: Vector3);
  93823. get boundingBoxSize(): Vector3;
  93824. /**
  93825. * In case the RTT has been created with a depth texture, get the associated
  93826. * depth texture.
  93827. * Otherwise, return null.
  93828. */
  93829. get depthStencilTexture(): Nullable<InternalTexture>;
  93830. /**
  93831. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  93832. * or used a shadow, depth texture...
  93833. * @param name The friendly name of the texture
  93834. * @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)
  93835. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  93836. * @param generateMipMaps True if mip maps need to be generated after render.
  93837. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  93838. * @param type The type of the buffer in the RTT (int, half float, float...)
  93839. * @param isCube True if a cube texture needs to be created
  93840. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  93841. * @param generateDepthBuffer True to generate a depth buffer
  93842. * @param generateStencilBuffer True to generate a stencil buffer
  93843. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  93844. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  93845. * @param delayAllocation if the texture allocation should be delayed (default: false)
  93846. */
  93847. constructor(name: string, size: number | {
  93848. width: number;
  93849. height: number;
  93850. layers?: number;
  93851. } | {
  93852. ratio: number;
  93853. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  93854. /**
  93855. * Creates a depth stencil texture.
  93856. * This is only available in WebGL 2 or with the depth texture extension available.
  93857. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  93858. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  93859. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  93860. */
  93861. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  93862. private _processSizeParameter;
  93863. /**
  93864. * Define the number of samples to use in case of MSAA.
  93865. * It defaults to one meaning no MSAA has been enabled.
  93866. */
  93867. get samples(): number;
  93868. set samples(value: number);
  93869. /**
  93870. * Resets the refresh counter of the texture and start bak from scratch.
  93871. * Could be useful to regenerate the texture if it is setup to render only once.
  93872. */
  93873. resetRefreshCounter(): void;
  93874. /**
  93875. * Define the refresh rate of the texture or the rendering frequency.
  93876. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  93877. */
  93878. get refreshRate(): number;
  93879. set refreshRate(value: number);
  93880. /**
  93881. * Adds a post process to the render target rendering passes.
  93882. * @param postProcess define the post process to add
  93883. */
  93884. addPostProcess(postProcess: PostProcess): void;
  93885. /**
  93886. * Clear all the post processes attached to the render target
  93887. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  93888. */
  93889. clearPostProcesses(dispose?: boolean): void;
  93890. /**
  93891. * Remove one of the post process from the list of attached post processes to the texture
  93892. * @param postProcess define the post process to remove from the list
  93893. */
  93894. removePostProcess(postProcess: PostProcess): void;
  93895. /** @hidden */
  93896. _shouldRender(): boolean;
  93897. /**
  93898. * Gets the actual render size of the texture.
  93899. * @returns the width of the render size
  93900. */
  93901. getRenderSize(): number;
  93902. /**
  93903. * Gets the actual render width of the texture.
  93904. * @returns the width of the render size
  93905. */
  93906. getRenderWidth(): number;
  93907. /**
  93908. * Gets the actual render height of the texture.
  93909. * @returns the height of the render size
  93910. */
  93911. getRenderHeight(): number;
  93912. /**
  93913. * Gets the actual number of layers of the texture.
  93914. * @returns the number of layers
  93915. */
  93916. getRenderLayers(): number;
  93917. /**
  93918. * Get if the texture can be rescaled or not.
  93919. */
  93920. get canRescale(): boolean;
  93921. /**
  93922. * Resize the texture using a ratio.
  93923. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  93924. */
  93925. scale(ratio: number): void;
  93926. /**
  93927. * Get the texture reflection matrix used to rotate/transform the reflection.
  93928. * @returns the reflection matrix
  93929. */
  93930. getReflectionTextureMatrix(): Matrix;
  93931. /**
  93932. * Resize the texture to a new desired size.
  93933. * Be carrefull as it will recreate all the data in the new texture.
  93934. * @param size Define the new size. It can be:
  93935. * - a number for squared texture,
  93936. * - an object containing { width: number, height: number }
  93937. * - or an object containing a ratio { ratio: number }
  93938. */
  93939. resize(size: number | {
  93940. width: number;
  93941. height: number;
  93942. } | {
  93943. ratio: number;
  93944. }): void;
  93945. private _defaultRenderListPrepared;
  93946. /**
  93947. * Renders all the objects from the render list into the texture.
  93948. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  93949. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  93950. */
  93951. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  93952. private _bestReflectionRenderTargetDimension;
  93953. private _prepareRenderingManager;
  93954. /**
  93955. * @hidden
  93956. * @param faceIndex face index to bind to if this is a cubetexture
  93957. * @param layer defines the index of the texture to bind in the array
  93958. */
  93959. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  93960. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  93961. private renderToTarget;
  93962. /**
  93963. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  93964. * This allowed control for front to back rendering or reversly depending of the special needs.
  93965. *
  93966. * @param renderingGroupId The rendering group id corresponding to its index
  93967. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  93968. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  93969. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  93970. */
  93971. 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;
  93972. /**
  93973. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  93974. *
  93975. * @param renderingGroupId The rendering group id corresponding to its index
  93976. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  93977. */
  93978. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  93979. /**
  93980. * Clones the texture.
  93981. * @returns the cloned texture
  93982. */
  93983. clone(): RenderTargetTexture;
  93984. /**
  93985. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  93986. * @returns The JSON representation of the texture
  93987. */
  93988. serialize(): any;
  93989. /**
  93990. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  93991. */
  93992. disposeFramebufferObjects(): void;
  93993. /**
  93994. * Dispose the texture and release its associated resources.
  93995. */
  93996. dispose(): void;
  93997. /** @hidden */
  93998. _rebuild(): void;
  93999. /**
  94000. * Clear the info related to rendering groups preventing retention point in material dispose.
  94001. */
  94002. freeRenderingGroups(): void;
  94003. /**
  94004. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  94005. * @returns the view count
  94006. */
  94007. getViewCount(): number;
  94008. }
  94009. }
  94010. declare module BABYLON {
  94011. /**
  94012. * Options for compiling materials.
  94013. */
  94014. export interface IMaterialCompilationOptions {
  94015. /**
  94016. * Defines whether clip planes are enabled.
  94017. */
  94018. clipPlane: boolean;
  94019. /**
  94020. * Defines whether instances are enabled.
  94021. */
  94022. useInstances: boolean;
  94023. }
  94024. /**
  94025. * Base class for the main features of a material in Babylon.js
  94026. */
  94027. export class Material implements IAnimatable {
  94028. /**
  94029. * Returns the triangle fill mode
  94030. */
  94031. static readonly TriangleFillMode: number;
  94032. /**
  94033. * Returns the wireframe mode
  94034. */
  94035. static readonly WireFrameFillMode: number;
  94036. /**
  94037. * Returns the point fill mode
  94038. */
  94039. static readonly PointFillMode: number;
  94040. /**
  94041. * Returns the point list draw mode
  94042. */
  94043. static readonly PointListDrawMode: number;
  94044. /**
  94045. * Returns the line list draw mode
  94046. */
  94047. static readonly LineListDrawMode: number;
  94048. /**
  94049. * Returns the line loop draw mode
  94050. */
  94051. static readonly LineLoopDrawMode: number;
  94052. /**
  94053. * Returns the line strip draw mode
  94054. */
  94055. static readonly LineStripDrawMode: number;
  94056. /**
  94057. * Returns the triangle strip draw mode
  94058. */
  94059. static readonly TriangleStripDrawMode: number;
  94060. /**
  94061. * Returns the triangle fan draw mode
  94062. */
  94063. static readonly TriangleFanDrawMode: number;
  94064. /**
  94065. * Stores the clock-wise side orientation
  94066. */
  94067. static readonly ClockWiseSideOrientation: number;
  94068. /**
  94069. * Stores the counter clock-wise side orientation
  94070. */
  94071. static readonly CounterClockWiseSideOrientation: number;
  94072. /**
  94073. * The dirty texture flag value
  94074. */
  94075. static readonly TextureDirtyFlag: number;
  94076. /**
  94077. * The dirty light flag value
  94078. */
  94079. static readonly LightDirtyFlag: number;
  94080. /**
  94081. * The dirty fresnel flag value
  94082. */
  94083. static readonly FresnelDirtyFlag: number;
  94084. /**
  94085. * The dirty attribute flag value
  94086. */
  94087. static readonly AttributesDirtyFlag: number;
  94088. /**
  94089. * The dirty misc flag value
  94090. */
  94091. static readonly MiscDirtyFlag: number;
  94092. /**
  94093. * The all dirty flag value
  94094. */
  94095. static readonly AllDirtyFlag: number;
  94096. /**
  94097. * The ID of the material
  94098. */
  94099. id: string;
  94100. /**
  94101. * Gets or sets the unique id of the material
  94102. */
  94103. uniqueId: number;
  94104. /**
  94105. * The name of the material
  94106. */
  94107. name: string;
  94108. /**
  94109. * Gets or sets user defined metadata
  94110. */
  94111. metadata: any;
  94112. /**
  94113. * For internal use only. Please do not use.
  94114. */
  94115. reservedDataStore: any;
  94116. /**
  94117. * Specifies if the ready state should be checked on each call
  94118. */
  94119. checkReadyOnEveryCall: boolean;
  94120. /**
  94121. * Specifies if the ready state should be checked once
  94122. */
  94123. checkReadyOnlyOnce: boolean;
  94124. /**
  94125. * The state of the material
  94126. */
  94127. state: string;
  94128. /**
  94129. * The alpha value of the material
  94130. */
  94131. protected _alpha: number;
  94132. /**
  94133. * List of inspectable custom properties (used by the Inspector)
  94134. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  94135. */
  94136. inspectableCustomProperties: IInspectable[];
  94137. /**
  94138. * Sets the alpha value of the material
  94139. */
  94140. set alpha(value: number);
  94141. /**
  94142. * Gets the alpha value of the material
  94143. */
  94144. get alpha(): number;
  94145. /**
  94146. * Specifies if back face culling is enabled
  94147. */
  94148. protected _backFaceCulling: boolean;
  94149. /**
  94150. * Sets the back-face culling state
  94151. */
  94152. set backFaceCulling(value: boolean);
  94153. /**
  94154. * Gets the back-face culling state
  94155. */
  94156. get backFaceCulling(): boolean;
  94157. /**
  94158. * Stores the value for side orientation
  94159. */
  94160. sideOrientation: number;
  94161. /**
  94162. * Callback triggered when the material is compiled
  94163. */
  94164. onCompiled: Nullable<(effect: Effect) => void>;
  94165. /**
  94166. * Callback triggered when an error occurs
  94167. */
  94168. onError: Nullable<(effect: Effect, errors: string) => void>;
  94169. /**
  94170. * Callback triggered to get the render target textures
  94171. */
  94172. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  94173. /**
  94174. * Gets a boolean indicating that current material needs to register RTT
  94175. */
  94176. get hasRenderTargetTextures(): boolean;
  94177. /**
  94178. * Specifies if the material should be serialized
  94179. */
  94180. doNotSerialize: boolean;
  94181. /**
  94182. * @hidden
  94183. */
  94184. _storeEffectOnSubMeshes: boolean;
  94185. /**
  94186. * Stores the animations for the material
  94187. */
  94188. animations: Nullable<Array<Animation>>;
  94189. /**
  94190. * An event triggered when the material is disposed
  94191. */
  94192. onDisposeObservable: Observable<Material>;
  94193. /**
  94194. * An observer which watches for dispose events
  94195. */
  94196. private _onDisposeObserver;
  94197. private _onUnBindObservable;
  94198. /**
  94199. * Called during a dispose event
  94200. */
  94201. set onDispose(callback: () => void);
  94202. private _onBindObservable;
  94203. /**
  94204. * An event triggered when the material is bound
  94205. */
  94206. get onBindObservable(): Observable<AbstractMesh>;
  94207. /**
  94208. * An observer which watches for bind events
  94209. */
  94210. private _onBindObserver;
  94211. /**
  94212. * Called during a bind event
  94213. */
  94214. set onBind(callback: (Mesh: AbstractMesh) => void);
  94215. /**
  94216. * An event triggered when the material is unbound
  94217. */
  94218. get onUnBindObservable(): Observable<Material>;
  94219. /**
  94220. * Stores the value of the alpha mode
  94221. */
  94222. private _alphaMode;
  94223. /**
  94224. * Sets the value of the alpha mode.
  94225. *
  94226. * | Value | Type | Description |
  94227. * | --- | --- | --- |
  94228. * | 0 | ALPHA_DISABLE | |
  94229. * | 1 | ALPHA_ADD | |
  94230. * | 2 | ALPHA_COMBINE | |
  94231. * | 3 | ALPHA_SUBTRACT | |
  94232. * | 4 | ALPHA_MULTIPLY | |
  94233. * | 5 | ALPHA_MAXIMIZED | |
  94234. * | 6 | ALPHA_ONEONE | |
  94235. * | 7 | ALPHA_PREMULTIPLIED | |
  94236. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  94237. * | 9 | ALPHA_INTERPOLATE | |
  94238. * | 10 | ALPHA_SCREENMODE | |
  94239. *
  94240. */
  94241. set alphaMode(value: number);
  94242. /**
  94243. * Gets the value of the alpha mode
  94244. */
  94245. get alphaMode(): number;
  94246. /**
  94247. * Stores the state of the need depth pre-pass value
  94248. */
  94249. private _needDepthPrePass;
  94250. /**
  94251. * Sets the need depth pre-pass value
  94252. */
  94253. set needDepthPrePass(value: boolean);
  94254. /**
  94255. * Gets the depth pre-pass value
  94256. */
  94257. get needDepthPrePass(): boolean;
  94258. /**
  94259. * Specifies if depth writing should be disabled
  94260. */
  94261. disableDepthWrite: boolean;
  94262. /**
  94263. * Specifies if depth writing should be forced
  94264. */
  94265. forceDepthWrite: boolean;
  94266. /**
  94267. * Specifies the depth function that should be used. 0 means the default engine function
  94268. */
  94269. depthFunction: number;
  94270. /**
  94271. * Specifies if there should be a separate pass for culling
  94272. */
  94273. separateCullingPass: boolean;
  94274. /**
  94275. * Stores the state specifing if fog should be enabled
  94276. */
  94277. private _fogEnabled;
  94278. /**
  94279. * Sets the state for enabling fog
  94280. */
  94281. set fogEnabled(value: boolean);
  94282. /**
  94283. * Gets the value of the fog enabled state
  94284. */
  94285. get fogEnabled(): boolean;
  94286. /**
  94287. * Stores the size of points
  94288. */
  94289. pointSize: number;
  94290. /**
  94291. * Stores the z offset value
  94292. */
  94293. zOffset: number;
  94294. /**
  94295. * Gets a value specifying if wireframe mode is enabled
  94296. */
  94297. get wireframe(): boolean;
  94298. /**
  94299. * Sets the state of wireframe mode
  94300. */
  94301. set wireframe(value: boolean);
  94302. /**
  94303. * Gets the value specifying if point clouds are enabled
  94304. */
  94305. get pointsCloud(): boolean;
  94306. /**
  94307. * Sets the state of point cloud mode
  94308. */
  94309. set pointsCloud(value: boolean);
  94310. /**
  94311. * Gets the material fill mode
  94312. */
  94313. get fillMode(): number;
  94314. /**
  94315. * Sets the material fill mode
  94316. */
  94317. set fillMode(value: number);
  94318. /**
  94319. * @hidden
  94320. * Stores the effects for the material
  94321. */
  94322. _effect: Nullable<Effect>;
  94323. /**
  94324. * Specifies if uniform buffers should be used
  94325. */
  94326. private _useUBO;
  94327. /**
  94328. * Stores a reference to the scene
  94329. */
  94330. private _scene;
  94331. /**
  94332. * Stores the fill mode state
  94333. */
  94334. private _fillMode;
  94335. /**
  94336. * Specifies if the depth write state should be cached
  94337. */
  94338. private _cachedDepthWriteState;
  94339. /**
  94340. * Specifies if the depth function state should be cached
  94341. */
  94342. private _cachedDepthFunctionState;
  94343. /**
  94344. * Stores the uniform buffer
  94345. */
  94346. protected _uniformBuffer: UniformBuffer;
  94347. /** @hidden */
  94348. _indexInSceneMaterialArray: number;
  94349. /** @hidden */
  94350. meshMap: Nullable<{
  94351. [id: string]: AbstractMesh | undefined;
  94352. }>;
  94353. /**
  94354. * Creates a material instance
  94355. * @param name defines the name of the material
  94356. * @param scene defines the scene to reference
  94357. * @param doNotAdd specifies if the material should be added to the scene
  94358. */
  94359. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  94360. /**
  94361. * Returns a string representation of the current material
  94362. * @param fullDetails defines a boolean indicating which levels of logging is desired
  94363. * @returns a string with material information
  94364. */
  94365. toString(fullDetails?: boolean): string;
  94366. /**
  94367. * Gets the class name of the material
  94368. * @returns a string with the class name of the material
  94369. */
  94370. getClassName(): string;
  94371. /**
  94372. * Specifies if updates for the material been locked
  94373. */
  94374. get isFrozen(): boolean;
  94375. /**
  94376. * Locks updates for the material
  94377. */
  94378. freeze(): void;
  94379. /**
  94380. * Unlocks updates for the material
  94381. */
  94382. unfreeze(): void;
  94383. /**
  94384. * Specifies if the material is ready to be used
  94385. * @param mesh defines the mesh to check
  94386. * @param useInstances specifies if instances should be used
  94387. * @returns a boolean indicating if the material is ready to be used
  94388. */
  94389. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  94390. /**
  94391. * Specifies that the submesh is ready to be used
  94392. * @param mesh defines the mesh to check
  94393. * @param subMesh defines which submesh to check
  94394. * @param useInstances specifies that instances should be used
  94395. * @returns a boolean indicating that the submesh is ready or not
  94396. */
  94397. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  94398. /**
  94399. * Returns the material effect
  94400. * @returns the effect associated with the material
  94401. */
  94402. getEffect(): Nullable<Effect>;
  94403. /**
  94404. * Returns the current scene
  94405. * @returns a Scene
  94406. */
  94407. getScene(): Scene;
  94408. /**
  94409. * Specifies if the material will require alpha blending
  94410. * @returns a boolean specifying if alpha blending is needed
  94411. */
  94412. needAlphaBlending(): boolean;
  94413. /**
  94414. * Specifies if the mesh will require alpha blending
  94415. * @param mesh defines the mesh to check
  94416. * @returns a boolean specifying if alpha blending is needed for the mesh
  94417. */
  94418. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  94419. /**
  94420. * Specifies if this material should be rendered in alpha test mode
  94421. * @returns a boolean specifying if an alpha test is needed.
  94422. */
  94423. needAlphaTesting(): boolean;
  94424. /**
  94425. * Gets the texture used for the alpha test
  94426. * @returns the texture to use for alpha testing
  94427. */
  94428. getAlphaTestTexture(): Nullable<BaseTexture>;
  94429. /**
  94430. * Marks the material to indicate that it needs to be re-calculated
  94431. */
  94432. markDirty(): void;
  94433. /** @hidden */
  94434. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  94435. /**
  94436. * Binds the material to the mesh
  94437. * @param world defines the world transformation matrix
  94438. * @param mesh defines the mesh to bind the material to
  94439. */
  94440. bind(world: Matrix, mesh?: Mesh): void;
  94441. /**
  94442. * Binds the submesh to the material
  94443. * @param world defines the world transformation matrix
  94444. * @param mesh defines the mesh containing the submesh
  94445. * @param subMesh defines the submesh to bind the material to
  94446. */
  94447. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  94448. /**
  94449. * Binds the world matrix to the material
  94450. * @param world defines the world transformation matrix
  94451. */
  94452. bindOnlyWorldMatrix(world: Matrix): void;
  94453. /**
  94454. * Binds the scene's uniform buffer to the effect.
  94455. * @param effect defines the effect to bind to the scene uniform buffer
  94456. * @param sceneUbo defines the uniform buffer storing scene data
  94457. */
  94458. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  94459. /**
  94460. * Binds the view matrix to the effect
  94461. * @param effect defines the effect to bind the view matrix to
  94462. */
  94463. bindView(effect: Effect): void;
  94464. /**
  94465. * Binds the view projection matrix to the effect
  94466. * @param effect defines the effect to bind the view projection matrix to
  94467. */
  94468. bindViewProjection(effect: Effect): void;
  94469. /**
  94470. * Specifies if material alpha testing should be turned on for the mesh
  94471. * @param mesh defines the mesh to check
  94472. */
  94473. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  94474. /**
  94475. * Processes to execute after binding the material to a mesh
  94476. * @param mesh defines the rendered mesh
  94477. */
  94478. protected _afterBind(mesh?: Mesh): void;
  94479. /**
  94480. * Unbinds the material from the mesh
  94481. */
  94482. unbind(): void;
  94483. /**
  94484. * Gets the active textures from the material
  94485. * @returns an array of textures
  94486. */
  94487. getActiveTextures(): BaseTexture[];
  94488. /**
  94489. * Specifies if the material uses a texture
  94490. * @param texture defines the texture to check against the material
  94491. * @returns a boolean specifying if the material uses the texture
  94492. */
  94493. hasTexture(texture: BaseTexture): boolean;
  94494. /**
  94495. * Makes a duplicate of the material, and gives it a new name
  94496. * @param name defines the new name for the duplicated material
  94497. * @returns the cloned material
  94498. */
  94499. clone(name: string): Nullable<Material>;
  94500. /**
  94501. * Gets the meshes bound to the material
  94502. * @returns an array of meshes bound to the material
  94503. */
  94504. getBindedMeshes(): AbstractMesh[];
  94505. /**
  94506. * Force shader compilation
  94507. * @param mesh defines the mesh associated with this material
  94508. * @param onCompiled defines a function to execute once the material is compiled
  94509. * @param options defines the options to configure the compilation
  94510. * @param onError defines a function to execute if the material fails compiling
  94511. */
  94512. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  94513. /**
  94514. * Force shader compilation
  94515. * @param mesh defines the mesh that will use this material
  94516. * @param options defines additional options for compiling the shaders
  94517. * @returns a promise that resolves when the compilation completes
  94518. */
  94519. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  94520. private static readonly _AllDirtyCallBack;
  94521. private static readonly _ImageProcessingDirtyCallBack;
  94522. private static readonly _TextureDirtyCallBack;
  94523. private static readonly _FresnelDirtyCallBack;
  94524. private static readonly _MiscDirtyCallBack;
  94525. private static readonly _LightsDirtyCallBack;
  94526. private static readonly _AttributeDirtyCallBack;
  94527. private static _FresnelAndMiscDirtyCallBack;
  94528. private static _TextureAndMiscDirtyCallBack;
  94529. private static readonly _DirtyCallbackArray;
  94530. private static readonly _RunDirtyCallBacks;
  94531. /**
  94532. * Marks a define in the material to indicate that it needs to be re-computed
  94533. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  94534. */
  94535. markAsDirty(flag: number): void;
  94536. /**
  94537. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  94538. * @param func defines a function which checks material defines against the submeshes
  94539. */
  94540. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  94541. /**
  94542. * Indicates that we need to re-calculated for all submeshes
  94543. */
  94544. protected _markAllSubMeshesAsAllDirty(): void;
  94545. /**
  94546. * Indicates that image processing needs to be re-calculated for all submeshes
  94547. */
  94548. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  94549. /**
  94550. * Indicates that textures need to be re-calculated for all submeshes
  94551. */
  94552. protected _markAllSubMeshesAsTexturesDirty(): void;
  94553. /**
  94554. * Indicates that fresnel needs to be re-calculated for all submeshes
  94555. */
  94556. protected _markAllSubMeshesAsFresnelDirty(): void;
  94557. /**
  94558. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  94559. */
  94560. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  94561. /**
  94562. * Indicates that lights need to be re-calculated for all submeshes
  94563. */
  94564. protected _markAllSubMeshesAsLightsDirty(): void;
  94565. /**
  94566. * Indicates that attributes need to be re-calculated for all submeshes
  94567. */
  94568. protected _markAllSubMeshesAsAttributesDirty(): void;
  94569. /**
  94570. * Indicates that misc needs to be re-calculated for all submeshes
  94571. */
  94572. protected _markAllSubMeshesAsMiscDirty(): void;
  94573. /**
  94574. * Indicates that textures and misc need to be re-calculated for all submeshes
  94575. */
  94576. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  94577. /**
  94578. * Disposes the material
  94579. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  94580. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  94581. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  94582. */
  94583. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  94584. /** @hidden */
  94585. private releaseVertexArrayObject;
  94586. /**
  94587. * Serializes this material
  94588. * @returns the serialized material object
  94589. */
  94590. serialize(): any;
  94591. /**
  94592. * Creates a material from parsed material data
  94593. * @param parsedMaterial defines parsed material data
  94594. * @param scene defines the hosting scene
  94595. * @param rootUrl defines the root URL to use to load textures
  94596. * @returns a new material
  94597. */
  94598. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  94599. }
  94600. }
  94601. declare module BABYLON {
  94602. /**
  94603. * A multi-material is used to apply different materials to different parts of the same object without the need of
  94604. * separate meshes. This can be use to improve performances.
  94605. * @see http://doc.babylonjs.com/how_to/multi_materials
  94606. */
  94607. export class MultiMaterial extends Material {
  94608. private _subMaterials;
  94609. /**
  94610. * Gets or Sets the list of Materials used within the multi material.
  94611. * They need to be ordered according to the submeshes order in the associated mesh
  94612. */
  94613. get subMaterials(): Nullable<Material>[];
  94614. set subMaterials(value: Nullable<Material>[]);
  94615. /**
  94616. * Function used to align with Node.getChildren()
  94617. * @returns the list of Materials used within the multi material
  94618. */
  94619. getChildren(): Nullable<Material>[];
  94620. /**
  94621. * Instantiates a new Multi Material
  94622. * A multi-material is used to apply different materials to different parts of the same object without the need of
  94623. * separate meshes. This can be use to improve performances.
  94624. * @see http://doc.babylonjs.com/how_to/multi_materials
  94625. * @param name Define the name in the scene
  94626. * @param scene Define the scene the material belongs to
  94627. */
  94628. constructor(name: string, scene: Scene);
  94629. private _hookArray;
  94630. /**
  94631. * Get one of the submaterial by its index in the submaterials array
  94632. * @param index The index to look the sub material at
  94633. * @returns The Material if the index has been defined
  94634. */
  94635. getSubMaterial(index: number): Nullable<Material>;
  94636. /**
  94637. * Get the list of active textures for the whole sub materials list.
  94638. * @returns All the textures that will be used during the rendering
  94639. */
  94640. getActiveTextures(): BaseTexture[];
  94641. /**
  94642. * Gets the current class name of the material e.g. "MultiMaterial"
  94643. * Mainly use in serialization.
  94644. * @returns the class name
  94645. */
  94646. getClassName(): string;
  94647. /**
  94648. * Checks if the material is ready to render the requested sub mesh
  94649. * @param mesh Define the mesh the submesh belongs to
  94650. * @param subMesh Define the sub mesh to look readyness for
  94651. * @param useInstances Define whether or not the material is used with instances
  94652. * @returns true if ready, otherwise false
  94653. */
  94654. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  94655. /**
  94656. * Clones the current material and its related sub materials
  94657. * @param name Define the name of the newly cloned material
  94658. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  94659. * @returns the cloned material
  94660. */
  94661. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  94662. /**
  94663. * Serializes the materials into a JSON representation.
  94664. * @returns the JSON representation
  94665. */
  94666. serialize(): any;
  94667. /**
  94668. * Dispose the material and release its associated resources
  94669. * @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)
  94670. * @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)
  94671. * @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)
  94672. */
  94673. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  94674. /**
  94675. * Creates a MultiMaterial from parsed MultiMaterial data.
  94676. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  94677. * @param scene defines the hosting scene
  94678. * @returns a new MultiMaterial
  94679. */
  94680. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  94681. }
  94682. }
  94683. declare module BABYLON {
  94684. /**
  94685. * Base class for submeshes
  94686. */
  94687. export class BaseSubMesh {
  94688. /** @hidden */
  94689. _materialDefines: Nullable<MaterialDefines>;
  94690. /** @hidden */
  94691. _materialEffect: Nullable<Effect>;
  94692. /**
  94693. * Gets material defines used by the effect associated to the sub mesh
  94694. */
  94695. get materialDefines(): Nullable<MaterialDefines>;
  94696. /**
  94697. * Sets material defines used by the effect associated to the sub mesh
  94698. */
  94699. set materialDefines(defines: Nullable<MaterialDefines>);
  94700. /**
  94701. * Gets associated effect
  94702. */
  94703. get effect(): Nullable<Effect>;
  94704. /**
  94705. * Sets associated effect (effect used to render this submesh)
  94706. * @param effect defines the effect to associate with
  94707. * @param defines defines the set of defines used to compile this effect
  94708. */
  94709. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  94710. }
  94711. /**
  94712. * Defines a subdivision inside a mesh
  94713. */
  94714. export class SubMesh extends BaseSubMesh implements ICullable {
  94715. /** the material index to use */
  94716. materialIndex: number;
  94717. /** vertex index start */
  94718. verticesStart: number;
  94719. /** vertices count */
  94720. verticesCount: number;
  94721. /** index start */
  94722. indexStart: number;
  94723. /** indices count */
  94724. indexCount: number;
  94725. /** @hidden */
  94726. _linesIndexCount: number;
  94727. private _mesh;
  94728. private _renderingMesh;
  94729. private _boundingInfo;
  94730. private _linesIndexBuffer;
  94731. /** @hidden */
  94732. _lastColliderWorldVertices: Nullable<Vector3[]>;
  94733. /** @hidden */
  94734. _trianglePlanes: Plane[];
  94735. /** @hidden */
  94736. _lastColliderTransformMatrix: Nullable<Matrix>;
  94737. /** @hidden */
  94738. _renderId: number;
  94739. /** @hidden */
  94740. _alphaIndex: number;
  94741. /** @hidden */
  94742. _distanceToCamera: number;
  94743. /** @hidden */
  94744. _id: number;
  94745. private _currentMaterial;
  94746. /**
  94747. * Add a new submesh to a mesh
  94748. * @param materialIndex defines the material index to use
  94749. * @param verticesStart defines vertex index start
  94750. * @param verticesCount defines vertices count
  94751. * @param indexStart defines index start
  94752. * @param indexCount defines indices count
  94753. * @param mesh defines the parent mesh
  94754. * @param renderingMesh defines an optional rendering mesh
  94755. * @param createBoundingBox defines if bounding box should be created for this submesh
  94756. * @returns the new submesh
  94757. */
  94758. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  94759. /**
  94760. * Creates a new submesh
  94761. * @param materialIndex defines the material index to use
  94762. * @param verticesStart defines vertex index start
  94763. * @param verticesCount defines vertices count
  94764. * @param indexStart defines index start
  94765. * @param indexCount defines indices count
  94766. * @param mesh defines the parent mesh
  94767. * @param renderingMesh defines an optional rendering mesh
  94768. * @param createBoundingBox defines if bounding box should be created for this submesh
  94769. */
  94770. constructor(
  94771. /** the material index to use */
  94772. materialIndex: number,
  94773. /** vertex index start */
  94774. verticesStart: number,
  94775. /** vertices count */
  94776. verticesCount: number,
  94777. /** index start */
  94778. indexStart: number,
  94779. /** indices count */
  94780. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  94781. /**
  94782. * Returns true if this submesh covers the entire parent mesh
  94783. * @ignorenaming
  94784. */
  94785. get IsGlobal(): boolean;
  94786. /**
  94787. * Returns the submesh BoudingInfo object
  94788. * @returns current bounding info (or mesh's one if the submesh is global)
  94789. */
  94790. getBoundingInfo(): BoundingInfo;
  94791. /**
  94792. * Sets the submesh BoundingInfo
  94793. * @param boundingInfo defines the new bounding info to use
  94794. * @returns the SubMesh
  94795. */
  94796. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  94797. /**
  94798. * Returns the mesh of the current submesh
  94799. * @return the parent mesh
  94800. */
  94801. getMesh(): AbstractMesh;
  94802. /**
  94803. * Returns the rendering mesh of the submesh
  94804. * @returns the rendering mesh (could be different from parent mesh)
  94805. */
  94806. getRenderingMesh(): Mesh;
  94807. /**
  94808. * Returns the submesh material
  94809. * @returns null or the current material
  94810. */
  94811. getMaterial(): Nullable<Material>;
  94812. /**
  94813. * Sets a new updated BoundingInfo object to the submesh
  94814. * @param data defines an optional position array to use to determine the bounding info
  94815. * @returns the SubMesh
  94816. */
  94817. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  94818. /** @hidden */
  94819. _checkCollision(collider: Collider): boolean;
  94820. /**
  94821. * Updates the submesh BoundingInfo
  94822. * @param world defines the world matrix to use to update the bounding info
  94823. * @returns the submesh
  94824. */
  94825. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  94826. /**
  94827. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  94828. * @param frustumPlanes defines the frustum planes
  94829. * @returns true if the submesh is intersecting with the frustum
  94830. */
  94831. isInFrustum(frustumPlanes: Plane[]): boolean;
  94832. /**
  94833. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  94834. * @param frustumPlanes defines the frustum planes
  94835. * @returns true if the submesh is inside the frustum
  94836. */
  94837. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  94838. /**
  94839. * Renders the submesh
  94840. * @param enableAlphaMode defines if alpha needs to be used
  94841. * @returns the submesh
  94842. */
  94843. render(enableAlphaMode: boolean): SubMesh;
  94844. /**
  94845. * @hidden
  94846. */
  94847. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  94848. /**
  94849. * Checks if the submesh intersects with a ray
  94850. * @param ray defines the ray to test
  94851. * @returns true is the passed ray intersects the submesh bounding box
  94852. */
  94853. canIntersects(ray: Ray): boolean;
  94854. /**
  94855. * Intersects current submesh with a ray
  94856. * @param ray defines the ray to test
  94857. * @param positions defines mesh's positions array
  94858. * @param indices defines mesh's indices array
  94859. * @param fastCheck defines if only bounding info should be used
  94860. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  94861. * @returns intersection info or null if no intersection
  94862. */
  94863. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  94864. /** @hidden */
  94865. private _intersectLines;
  94866. /** @hidden */
  94867. private _intersectUnIndexedLines;
  94868. /** @hidden */
  94869. private _intersectTriangles;
  94870. /** @hidden */
  94871. private _intersectUnIndexedTriangles;
  94872. /** @hidden */
  94873. _rebuild(): void;
  94874. /**
  94875. * Creates a new submesh from the passed mesh
  94876. * @param newMesh defines the new hosting mesh
  94877. * @param newRenderingMesh defines an optional rendering mesh
  94878. * @returns the new submesh
  94879. */
  94880. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  94881. /**
  94882. * Release associated resources
  94883. */
  94884. dispose(): void;
  94885. /**
  94886. * Gets the class name
  94887. * @returns the string "SubMesh".
  94888. */
  94889. getClassName(): string;
  94890. /**
  94891. * Creates a new submesh from indices data
  94892. * @param materialIndex the index of the main mesh material
  94893. * @param startIndex the index where to start the copy in the mesh indices array
  94894. * @param indexCount the number of indices to copy then from the startIndex
  94895. * @param mesh the main mesh to create the submesh from
  94896. * @param renderingMesh the optional rendering mesh
  94897. * @returns a new submesh
  94898. */
  94899. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  94900. }
  94901. }
  94902. declare module BABYLON {
  94903. /**
  94904. * Class used to represent data loading progression
  94905. */
  94906. export class SceneLoaderFlags {
  94907. private static _ForceFullSceneLoadingForIncremental;
  94908. private static _ShowLoadingScreen;
  94909. private static _CleanBoneMatrixWeights;
  94910. private static _loggingLevel;
  94911. /**
  94912. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  94913. */
  94914. static get ForceFullSceneLoadingForIncremental(): boolean;
  94915. static set ForceFullSceneLoadingForIncremental(value: boolean);
  94916. /**
  94917. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  94918. */
  94919. static get ShowLoadingScreen(): boolean;
  94920. static set ShowLoadingScreen(value: boolean);
  94921. /**
  94922. * Defines the current logging level (while loading the scene)
  94923. * @ignorenaming
  94924. */
  94925. static get loggingLevel(): number;
  94926. static set loggingLevel(value: number);
  94927. /**
  94928. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  94929. */
  94930. static get CleanBoneMatrixWeights(): boolean;
  94931. static set CleanBoneMatrixWeights(value: boolean);
  94932. }
  94933. }
  94934. declare module BABYLON {
  94935. /**
  94936. * Class used to store geometry data (vertex buffers + index buffer)
  94937. */
  94938. export class Geometry implements IGetSetVerticesData {
  94939. /**
  94940. * Gets or sets the ID of the geometry
  94941. */
  94942. id: string;
  94943. /**
  94944. * Gets or sets the unique ID of the geometry
  94945. */
  94946. uniqueId: number;
  94947. /**
  94948. * Gets the delay loading state of the geometry (none by default which means not delayed)
  94949. */
  94950. delayLoadState: number;
  94951. /**
  94952. * Gets the file containing the data to load when running in delay load state
  94953. */
  94954. delayLoadingFile: Nullable<string>;
  94955. /**
  94956. * Callback called when the geometry is updated
  94957. */
  94958. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  94959. private _scene;
  94960. private _engine;
  94961. private _meshes;
  94962. private _totalVertices;
  94963. /** @hidden */
  94964. _indices: IndicesArray;
  94965. /** @hidden */
  94966. _vertexBuffers: {
  94967. [key: string]: VertexBuffer;
  94968. };
  94969. private _isDisposed;
  94970. private _extend;
  94971. private _boundingBias;
  94972. /** @hidden */
  94973. _delayInfo: Array<string>;
  94974. private _indexBuffer;
  94975. private _indexBufferIsUpdatable;
  94976. /** @hidden */
  94977. _boundingInfo: Nullable<BoundingInfo>;
  94978. /** @hidden */
  94979. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  94980. /** @hidden */
  94981. _softwareSkinningFrameId: number;
  94982. private _vertexArrayObjects;
  94983. private _updatable;
  94984. /** @hidden */
  94985. _positions: Nullable<Vector3[]>;
  94986. /**
  94987. * 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
  94988. */
  94989. get boundingBias(): Vector2;
  94990. /**
  94991. * 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
  94992. */
  94993. set boundingBias(value: Vector2);
  94994. /**
  94995. * Static function used to attach a new empty geometry to a mesh
  94996. * @param mesh defines the mesh to attach the geometry to
  94997. * @returns the new Geometry
  94998. */
  94999. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  95000. /**
  95001. * Creates a new geometry
  95002. * @param id defines the unique ID
  95003. * @param scene defines the hosting scene
  95004. * @param vertexData defines the VertexData used to get geometry data
  95005. * @param updatable defines if geometry must be updatable (false by default)
  95006. * @param mesh defines the mesh that will be associated with the geometry
  95007. */
  95008. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  95009. /**
  95010. * Gets the current extend of the geometry
  95011. */
  95012. get extend(): {
  95013. minimum: Vector3;
  95014. maximum: Vector3;
  95015. };
  95016. /**
  95017. * Gets the hosting scene
  95018. * @returns the hosting Scene
  95019. */
  95020. getScene(): Scene;
  95021. /**
  95022. * Gets the hosting engine
  95023. * @returns the hosting Engine
  95024. */
  95025. getEngine(): Engine;
  95026. /**
  95027. * Defines if the geometry is ready to use
  95028. * @returns true if the geometry is ready to be used
  95029. */
  95030. isReady(): boolean;
  95031. /**
  95032. * Gets a value indicating that the geometry should not be serialized
  95033. */
  95034. get doNotSerialize(): boolean;
  95035. /** @hidden */
  95036. _rebuild(): void;
  95037. /**
  95038. * Affects all geometry data in one call
  95039. * @param vertexData defines the geometry data
  95040. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  95041. */
  95042. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  95043. /**
  95044. * Set specific vertex data
  95045. * @param kind defines the data kind (Position, normal, etc...)
  95046. * @param data defines the vertex data to use
  95047. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  95048. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  95049. */
  95050. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  95051. /**
  95052. * Removes a specific vertex data
  95053. * @param kind defines the data kind (Position, normal, etc...)
  95054. */
  95055. removeVerticesData(kind: string): void;
  95056. /**
  95057. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  95058. * @param buffer defines the vertex buffer to use
  95059. * @param totalVertices defines the total number of vertices for position kind (could be null)
  95060. */
  95061. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  95062. /**
  95063. * Update a specific vertex buffer
  95064. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  95065. * It will do nothing if the buffer is not updatable
  95066. * @param kind defines the data kind (Position, normal, etc...)
  95067. * @param data defines the data to use
  95068. * @param offset defines the offset in the target buffer where to store the data
  95069. * @param useBytes set to true if the offset is in bytes
  95070. */
  95071. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  95072. /**
  95073. * Update a specific vertex buffer
  95074. * This function will create a new buffer if the current one is not updatable
  95075. * @param kind defines the data kind (Position, normal, etc...)
  95076. * @param data defines the data to use
  95077. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  95078. */
  95079. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  95080. private _updateBoundingInfo;
  95081. /** @hidden */
  95082. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  95083. /**
  95084. * Gets total number of vertices
  95085. * @returns the total number of vertices
  95086. */
  95087. getTotalVertices(): number;
  95088. /**
  95089. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  95090. * @param kind defines the data kind (Position, normal, etc...)
  95091. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  95092. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95093. * @returns a float array containing vertex data
  95094. */
  95095. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  95096. /**
  95097. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  95098. * @param kind defines the data kind (Position, normal, etc...)
  95099. * @returns true if the vertex buffer with the specified kind is updatable
  95100. */
  95101. isVertexBufferUpdatable(kind: string): boolean;
  95102. /**
  95103. * Gets a specific vertex buffer
  95104. * @param kind defines the data kind (Position, normal, etc...)
  95105. * @returns a VertexBuffer
  95106. */
  95107. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  95108. /**
  95109. * Returns all vertex buffers
  95110. * @return an object holding all vertex buffers indexed by kind
  95111. */
  95112. getVertexBuffers(): Nullable<{
  95113. [key: string]: VertexBuffer;
  95114. }>;
  95115. /**
  95116. * Gets a boolean indicating if specific vertex buffer is present
  95117. * @param kind defines the data kind (Position, normal, etc...)
  95118. * @returns true if data is present
  95119. */
  95120. isVerticesDataPresent(kind: string): boolean;
  95121. /**
  95122. * Gets a list of all attached data kinds (Position, normal, etc...)
  95123. * @returns a list of string containing all kinds
  95124. */
  95125. getVerticesDataKinds(): string[];
  95126. /**
  95127. * Update index buffer
  95128. * @param indices defines the indices to store in the index buffer
  95129. * @param offset defines the offset in the target buffer where to store the data
  95130. * @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)
  95131. */
  95132. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  95133. /**
  95134. * Creates a new index buffer
  95135. * @param indices defines the indices to store in the index buffer
  95136. * @param totalVertices defines the total number of vertices (could be null)
  95137. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  95138. */
  95139. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  95140. /**
  95141. * Return the total number of indices
  95142. * @returns the total number of indices
  95143. */
  95144. getTotalIndices(): number;
  95145. /**
  95146. * Gets the index buffer array
  95147. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  95148. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95149. * @returns the index buffer array
  95150. */
  95151. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  95152. /**
  95153. * Gets the index buffer
  95154. * @return the index buffer
  95155. */
  95156. getIndexBuffer(): Nullable<DataBuffer>;
  95157. /** @hidden */
  95158. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  95159. /**
  95160. * Release the associated resources for a specific mesh
  95161. * @param mesh defines the source mesh
  95162. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  95163. */
  95164. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  95165. /**
  95166. * Apply current geometry to a given mesh
  95167. * @param mesh defines the mesh to apply geometry to
  95168. */
  95169. applyToMesh(mesh: Mesh): void;
  95170. private _updateExtend;
  95171. private _applyToMesh;
  95172. private notifyUpdate;
  95173. /**
  95174. * Load the geometry if it was flagged as delay loaded
  95175. * @param scene defines the hosting scene
  95176. * @param onLoaded defines a callback called when the geometry is loaded
  95177. */
  95178. load(scene: Scene, onLoaded?: () => void): void;
  95179. private _queueLoad;
  95180. /**
  95181. * Invert the geometry to move from a right handed system to a left handed one.
  95182. */
  95183. toLeftHanded(): void;
  95184. /** @hidden */
  95185. _resetPointsArrayCache(): void;
  95186. /** @hidden */
  95187. _generatePointsArray(): boolean;
  95188. /**
  95189. * Gets a value indicating if the geometry is disposed
  95190. * @returns true if the geometry was disposed
  95191. */
  95192. isDisposed(): boolean;
  95193. private _disposeVertexArrayObjects;
  95194. /**
  95195. * Free all associated resources
  95196. */
  95197. dispose(): void;
  95198. /**
  95199. * Clone the current geometry into a new geometry
  95200. * @param id defines the unique ID of the new geometry
  95201. * @returns a new geometry object
  95202. */
  95203. copy(id: string): Geometry;
  95204. /**
  95205. * Serialize the current geometry info (and not the vertices data) into a JSON object
  95206. * @return a JSON representation of the current geometry data (without the vertices data)
  95207. */
  95208. serialize(): any;
  95209. private toNumberArray;
  95210. /**
  95211. * Serialize all vertices data into a JSON oject
  95212. * @returns a JSON representation of the current geometry data
  95213. */
  95214. serializeVerticeData(): any;
  95215. /**
  95216. * Extracts a clone of a mesh geometry
  95217. * @param mesh defines the source mesh
  95218. * @param id defines the unique ID of the new geometry object
  95219. * @returns the new geometry object
  95220. */
  95221. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  95222. /**
  95223. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  95224. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  95225. * Be aware Math.random() could cause collisions, but:
  95226. * "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"
  95227. * @returns a string containing a new GUID
  95228. */
  95229. static RandomId(): string;
  95230. /** @hidden */
  95231. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  95232. private static _CleanMatricesWeights;
  95233. /**
  95234. * Create a new geometry from persisted data (Using .babylon file format)
  95235. * @param parsedVertexData defines the persisted data
  95236. * @param scene defines the hosting scene
  95237. * @param rootUrl defines the root url to use to load assets (like delayed data)
  95238. * @returns the new geometry object
  95239. */
  95240. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  95241. }
  95242. }
  95243. declare module BABYLON {
  95244. /**
  95245. * Define an interface for all classes that will get and set the data on vertices
  95246. */
  95247. export interface IGetSetVerticesData {
  95248. /**
  95249. * Gets a boolean indicating if specific vertex data is present
  95250. * @param kind defines the vertex data kind to use
  95251. * @returns true is data kind is present
  95252. */
  95253. isVerticesDataPresent(kind: string): boolean;
  95254. /**
  95255. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  95256. * @param kind defines the data kind (Position, normal, etc...)
  95257. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  95258. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95259. * @returns a float array containing vertex data
  95260. */
  95261. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  95262. /**
  95263. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  95264. * @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.
  95265. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95266. * @returns the indices array or an empty array if the mesh has no geometry
  95267. */
  95268. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  95269. /**
  95270. * Set specific vertex data
  95271. * @param kind defines the data kind (Position, normal, etc...)
  95272. * @param data defines the vertex data to use
  95273. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  95274. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  95275. */
  95276. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  95277. /**
  95278. * Update a specific associated vertex buffer
  95279. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  95280. * - VertexBuffer.PositionKind
  95281. * - VertexBuffer.UVKind
  95282. * - VertexBuffer.UV2Kind
  95283. * - VertexBuffer.UV3Kind
  95284. * - VertexBuffer.UV4Kind
  95285. * - VertexBuffer.UV5Kind
  95286. * - VertexBuffer.UV6Kind
  95287. * - VertexBuffer.ColorKind
  95288. * - VertexBuffer.MatricesIndicesKind
  95289. * - VertexBuffer.MatricesIndicesExtraKind
  95290. * - VertexBuffer.MatricesWeightsKind
  95291. * - VertexBuffer.MatricesWeightsExtraKind
  95292. * @param data defines the data source
  95293. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  95294. * @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)
  95295. */
  95296. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  95297. /**
  95298. * Creates a new index buffer
  95299. * @param indices defines the indices to store in the index buffer
  95300. * @param totalVertices defines the total number of vertices (could be null)
  95301. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  95302. */
  95303. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  95304. }
  95305. /**
  95306. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  95307. */
  95308. export class VertexData {
  95309. /**
  95310. * Mesh side orientation : usually the external or front surface
  95311. */
  95312. static readonly FRONTSIDE: number;
  95313. /**
  95314. * Mesh side orientation : usually the internal or back surface
  95315. */
  95316. static readonly BACKSIDE: number;
  95317. /**
  95318. * Mesh side orientation : both internal and external or front and back surfaces
  95319. */
  95320. static readonly DOUBLESIDE: number;
  95321. /**
  95322. * Mesh side orientation : by default, `FRONTSIDE`
  95323. */
  95324. static readonly DEFAULTSIDE: number;
  95325. /**
  95326. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  95327. */
  95328. positions: Nullable<FloatArray>;
  95329. /**
  95330. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  95331. */
  95332. normals: Nullable<FloatArray>;
  95333. /**
  95334. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  95335. */
  95336. tangents: Nullable<FloatArray>;
  95337. /**
  95338. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95339. */
  95340. uvs: Nullable<FloatArray>;
  95341. /**
  95342. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95343. */
  95344. uvs2: Nullable<FloatArray>;
  95345. /**
  95346. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95347. */
  95348. uvs3: Nullable<FloatArray>;
  95349. /**
  95350. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95351. */
  95352. uvs4: Nullable<FloatArray>;
  95353. /**
  95354. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95355. */
  95356. uvs5: Nullable<FloatArray>;
  95357. /**
  95358. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95359. */
  95360. uvs6: Nullable<FloatArray>;
  95361. /**
  95362. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  95363. */
  95364. colors: Nullable<FloatArray>;
  95365. /**
  95366. * 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).
  95367. */
  95368. matricesIndices: Nullable<FloatArray>;
  95369. /**
  95370. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  95371. */
  95372. matricesWeights: Nullable<FloatArray>;
  95373. /**
  95374. * An array extending the number of possible indices
  95375. */
  95376. matricesIndicesExtra: Nullable<FloatArray>;
  95377. /**
  95378. * An array extending the number of possible weights when the number of indices is extended
  95379. */
  95380. matricesWeightsExtra: Nullable<FloatArray>;
  95381. /**
  95382. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  95383. */
  95384. indices: Nullable<IndicesArray>;
  95385. /**
  95386. * Uses the passed data array to set the set the values for the specified kind of data
  95387. * @param data a linear array of floating numbers
  95388. * @param kind the type of data that is being set, eg positions, colors etc
  95389. */
  95390. set(data: FloatArray, kind: string): void;
  95391. /**
  95392. * Associates the vertexData to the passed Mesh.
  95393. * Sets it as updatable or not (default `false`)
  95394. * @param mesh the mesh the vertexData is applied to
  95395. * @param updatable when used and having the value true allows new data to update the vertexData
  95396. * @returns the VertexData
  95397. */
  95398. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  95399. /**
  95400. * Associates the vertexData to the passed Geometry.
  95401. * Sets it as updatable or not (default `false`)
  95402. * @param geometry the geometry the vertexData is applied to
  95403. * @param updatable when used and having the value true allows new data to update the vertexData
  95404. * @returns VertexData
  95405. */
  95406. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  95407. /**
  95408. * Updates the associated mesh
  95409. * @param mesh the mesh to be updated
  95410. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  95411. * @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
  95412. * @returns VertexData
  95413. */
  95414. updateMesh(mesh: Mesh): VertexData;
  95415. /**
  95416. * Updates the associated geometry
  95417. * @param geometry the geometry to be updated
  95418. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  95419. * @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
  95420. * @returns VertexData.
  95421. */
  95422. updateGeometry(geometry: Geometry): VertexData;
  95423. private _applyTo;
  95424. private _update;
  95425. /**
  95426. * Transforms each position and each normal of the vertexData according to the passed Matrix
  95427. * @param matrix the transforming matrix
  95428. * @returns the VertexData
  95429. */
  95430. transform(matrix: Matrix): VertexData;
  95431. /**
  95432. * Merges the passed VertexData into the current one
  95433. * @param other the VertexData to be merged into the current one
  95434. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  95435. * @returns the modified VertexData
  95436. */
  95437. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  95438. private _mergeElement;
  95439. private _validate;
  95440. /**
  95441. * Serializes the VertexData
  95442. * @returns a serialized object
  95443. */
  95444. serialize(): any;
  95445. /**
  95446. * Extracts the vertexData from a mesh
  95447. * @param mesh the mesh from which to extract the VertexData
  95448. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  95449. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  95450. * @returns the object VertexData associated to the passed mesh
  95451. */
  95452. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  95453. /**
  95454. * Extracts the vertexData from the geometry
  95455. * @param geometry the geometry from which to extract the VertexData
  95456. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  95457. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  95458. * @returns the object VertexData associated to the passed mesh
  95459. */
  95460. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  95461. private static _ExtractFrom;
  95462. /**
  95463. * Creates the VertexData for a Ribbon
  95464. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  95465. * * pathArray array of paths, each of which an array of successive Vector3
  95466. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  95467. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  95468. * * 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
  95469. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95470. * * 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)
  95471. * * 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)
  95472. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  95473. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  95474. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  95475. * @returns the VertexData of the ribbon
  95476. */
  95477. static CreateRibbon(options: {
  95478. pathArray: Vector3[][];
  95479. closeArray?: boolean;
  95480. closePath?: boolean;
  95481. offset?: number;
  95482. sideOrientation?: number;
  95483. frontUVs?: Vector4;
  95484. backUVs?: Vector4;
  95485. invertUV?: boolean;
  95486. uvs?: Vector2[];
  95487. colors?: Color4[];
  95488. }): VertexData;
  95489. /**
  95490. * Creates the VertexData for a box
  95491. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95492. * * size sets the width, height and depth of the box to the value of size, optional default 1
  95493. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  95494. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  95495. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  95496. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  95497. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  95498. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95499. * * 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)
  95500. * * 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)
  95501. * @returns the VertexData of the box
  95502. */
  95503. static CreateBox(options: {
  95504. size?: number;
  95505. width?: number;
  95506. height?: number;
  95507. depth?: number;
  95508. faceUV?: Vector4[];
  95509. faceColors?: Color4[];
  95510. sideOrientation?: number;
  95511. frontUVs?: Vector4;
  95512. backUVs?: Vector4;
  95513. }): VertexData;
  95514. /**
  95515. * Creates the VertexData for a tiled box
  95516. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95517. * * faceTiles sets the pattern, tile size and number of tiles for a face
  95518. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  95519. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  95520. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95521. * @returns the VertexData of the box
  95522. */
  95523. static CreateTiledBox(options: {
  95524. pattern?: number;
  95525. width?: number;
  95526. height?: number;
  95527. depth?: number;
  95528. tileSize?: number;
  95529. tileWidth?: number;
  95530. tileHeight?: number;
  95531. alignHorizontal?: number;
  95532. alignVertical?: number;
  95533. faceUV?: Vector4[];
  95534. faceColors?: Color4[];
  95535. sideOrientation?: number;
  95536. }): VertexData;
  95537. /**
  95538. * Creates the VertexData for a tiled plane
  95539. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95540. * * pattern a limited pattern arrangement depending on the number
  95541. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  95542. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  95543. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  95544. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95545. * * 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)
  95546. * * 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)
  95547. * @returns the VertexData of the tiled plane
  95548. */
  95549. static CreateTiledPlane(options: {
  95550. pattern?: number;
  95551. tileSize?: number;
  95552. tileWidth?: number;
  95553. tileHeight?: number;
  95554. size?: number;
  95555. width?: number;
  95556. height?: number;
  95557. alignHorizontal?: number;
  95558. alignVertical?: number;
  95559. sideOrientation?: number;
  95560. frontUVs?: Vector4;
  95561. backUVs?: Vector4;
  95562. }): VertexData;
  95563. /**
  95564. * Creates the VertexData for an ellipsoid, defaults to a sphere
  95565. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95566. * * segments sets the number of horizontal strips optional, default 32
  95567. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  95568. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  95569. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  95570. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  95571. * * 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
  95572. * * 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
  95573. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95574. * * 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)
  95575. * * 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)
  95576. * @returns the VertexData of the ellipsoid
  95577. */
  95578. static CreateSphere(options: {
  95579. segments?: number;
  95580. diameter?: number;
  95581. diameterX?: number;
  95582. diameterY?: number;
  95583. diameterZ?: number;
  95584. arc?: number;
  95585. slice?: number;
  95586. sideOrientation?: number;
  95587. frontUVs?: Vector4;
  95588. backUVs?: Vector4;
  95589. }): VertexData;
  95590. /**
  95591. * Creates the VertexData for a cylinder, cone or prism
  95592. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95593. * * height sets the height (y direction) of the cylinder, optional, default 2
  95594. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  95595. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  95596. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  95597. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  95598. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  95599. * * 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
  95600. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  95601. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  95602. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  95603. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  95604. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95605. * * 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)
  95606. * * 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)
  95607. * @returns the VertexData of the cylinder, cone or prism
  95608. */
  95609. static CreateCylinder(options: {
  95610. height?: number;
  95611. diameterTop?: number;
  95612. diameterBottom?: number;
  95613. diameter?: number;
  95614. tessellation?: number;
  95615. subdivisions?: number;
  95616. arc?: number;
  95617. faceColors?: Color4[];
  95618. faceUV?: Vector4[];
  95619. hasRings?: boolean;
  95620. enclose?: boolean;
  95621. sideOrientation?: number;
  95622. frontUVs?: Vector4;
  95623. backUVs?: Vector4;
  95624. }): VertexData;
  95625. /**
  95626. * Creates the VertexData for a torus
  95627. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95628. * * diameter the diameter of the torus, optional default 1
  95629. * * thickness the diameter of the tube forming the torus, optional default 0.5
  95630. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  95631. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95632. * * 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)
  95633. * * 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)
  95634. * @returns the VertexData of the torus
  95635. */
  95636. static CreateTorus(options: {
  95637. diameter?: number;
  95638. thickness?: number;
  95639. tessellation?: number;
  95640. sideOrientation?: number;
  95641. frontUVs?: Vector4;
  95642. backUVs?: Vector4;
  95643. }): VertexData;
  95644. /**
  95645. * Creates the VertexData of the LineSystem
  95646. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  95647. * - lines an array of lines, each line being an array of successive Vector3
  95648. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  95649. * @returns the VertexData of the LineSystem
  95650. */
  95651. static CreateLineSystem(options: {
  95652. lines: Vector3[][];
  95653. colors?: Nullable<Color4[][]>;
  95654. }): VertexData;
  95655. /**
  95656. * Create the VertexData for a DashedLines
  95657. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  95658. * - points an array successive Vector3
  95659. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  95660. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  95661. * - dashNb the intended total number of dashes, optional, default 200
  95662. * @returns the VertexData for the DashedLines
  95663. */
  95664. static CreateDashedLines(options: {
  95665. points: Vector3[];
  95666. dashSize?: number;
  95667. gapSize?: number;
  95668. dashNb?: number;
  95669. }): VertexData;
  95670. /**
  95671. * Creates the VertexData for a Ground
  95672. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  95673. * - width the width (x direction) of the ground, optional, default 1
  95674. * - height the height (z direction) of the ground, optional, default 1
  95675. * - subdivisions the number of subdivisions per side, optional, default 1
  95676. * @returns the VertexData of the Ground
  95677. */
  95678. static CreateGround(options: {
  95679. width?: number;
  95680. height?: number;
  95681. subdivisions?: number;
  95682. subdivisionsX?: number;
  95683. subdivisionsY?: number;
  95684. }): VertexData;
  95685. /**
  95686. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  95687. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  95688. * * xmin the ground minimum X coordinate, optional, default -1
  95689. * * zmin the ground minimum Z coordinate, optional, default -1
  95690. * * xmax the ground maximum X coordinate, optional, default 1
  95691. * * zmax the ground maximum Z coordinate, optional, default 1
  95692. * * 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}
  95693. * * 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}
  95694. * @returns the VertexData of the TiledGround
  95695. */
  95696. static CreateTiledGround(options: {
  95697. xmin: number;
  95698. zmin: number;
  95699. xmax: number;
  95700. zmax: number;
  95701. subdivisions?: {
  95702. w: number;
  95703. h: number;
  95704. };
  95705. precision?: {
  95706. w: number;
  95707. h: number;
  95708. };
  95709. }): VertexData;
  95710. /**
  95711. * Creates the VertexData of the Ground designed from a heightmap
  95712. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  95713. * * width the width (x direction) of the ground
  95714. * * height the height (z direction) of the ground
  95715. * * subdivisions the number of subdivisions per side
  95716. * * minHeight the minimum altitude on the ground, optional, default 0
  95717. * * maxHeight the maximum altitude on the ground, optional default 1
  95718. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  95719. * * buffer the array holding the image color data
  95720. * * bufferWidth the width of image
  95721. * * bufferHeight the height of image
  95722. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  95723. * @returns the VertexData of the Ground designed from a heightmap
  95724. */
  95725. static CreateGroundFromHeightMap(options: {
  95726. width: number;
  95727. height: number;
  95728. subdivisions: number;
  95729. minHeight: number;
  95730. maxHeight: number;
  95731. colorFilter: Color3;
  95732. buffer: Uint8Array;
  95733. bufferWidth: number;
  95734. bufferHeight: number;
  95735. alphaFilter: number;
  95736. }): VertexData;
  95737. /**
  95738. * Creates the VertexData for a Plane
  95739. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  95740. * * size sets the width and height of the plane to the value of size, optional default 1
  95741. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  95742. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  95743. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95744. * * 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)
  95745. * * 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)
  95746. * @returns the VertexData of the box
  95747. */
  95748. static CreatePlane(options: {
  95749. size?: number;
  95750. width?: number;
  95751. height?: number;
  95752. sideOrientation?: number;
  95753. frontUVs?: Vector4;
  95754. backUVs?: Vector4;
  95755. }): VertexData;
  95756. /**
  95757. * Creates the VertexData of the Disc or regular Polygon
  95758. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  95759. * * radius the radius of the disc, optional default 0.5
  95760. * * tessellation the number of polygon sides, optional, default 64
  95761. * * 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
  95762. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95763. * * 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)
  95764. * * 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)
  95765. * @returns the VertexData of the box
  95766. */
  95767. static CreateDisc(options: {
  95768. radius?: number;
  95769. tessellation?: number;
  95770. arc?: number;
  95771. sideOrientation?: number;
  95772. frontUVs?: Vector4;
  95773. backUVs?: Vector4;
  95774. }): VertexData;
  95775. /**
  95776. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  95777. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  95778. * @param polygon a mesh built from polygonTriangulation.build()
  95779. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95780. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  95781. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  95782. * @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)
  95783. * @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)
  95784. * @returns the VertexData of the Polygon
  95785. */
  95786. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  95787. /**
  95788. * Creates the VertexData of the IcoSphere
  95789. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  95790. * * radius the radius of the IcoSphere, optional default 1
  95791. * * radiusX allows stretching in the x direction, optional, default radius
  95792. * * radiusY allows stretching in the y direction, optional, default radius
  95793. * * radiusZ allows stretching in the z direction, optional, default radius
  95794. * * flat when true creates a flat shaded mesh, optional, default true
  95795. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  95796. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95797. * * 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)
  95798. * * 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)
  95799. * @returns the VertexData of the IcoSphere
  95800. */
  95801. static CreateIcoSphere(options: {
  95802. radius?: number;
  95803. radiusX?: number;
  95804. radiusY?: number;
  95805. radiusZ?: number;
  95806. flat?: boolean;
  95807. subdivisions?: number;
  95808. sideOrientation?: number;
  95809. frontUVs?: Vector4;
  95810. backUVs?: Vector4;
  95811. }): VertexData;
  95812. /**
  95813. * Creates the VertexData for a Polyhedron
  95814. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  95815. * * type provided types are:
  95816. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  95817. * * 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)
  95818. * * size the size of the IcoSphere, optional default 1
  95819. * * sizeX allows stretching in the x direction, optional, default size
  95820. * * sizeY allows stretching in the y direction, optional, default size
  95821. * * sizeZ allows stretching in the z direction, optional, default size
  95822. * * 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
  95823. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  95824. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  95825. * * flat when true creates a flat shaded mesh, optional, default true
  95826. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  95827. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95828. * * 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)
  95829. * * 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)
  95830. * @returns the VertexData of the Polyhedron
  95831. */
  95832. static CreatePolyhedron(options: {
  95833. type?: number;
  95834. size?: number;
  95835. sizeX?: number;
  95836. sizeY?: number;
  95837. sizeZ?: number;
  95838. custom?: any;
  95839. faceUV?: Vector4[];
  95840. faceColors?: Color4[];
  95841. flat?: boolean;
  95842. sideOrientation?: number;
  95843. frontUVs?: Vector4;
  95844. backUVs?: Vector4;
  95845. }): VertexData;
  95846. /**
  95847. * Creates the VertexData for a TorusKnot
  95848. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  95849. * * radius the radius of the torus knot, optional, default 2
  95850. * * tube the thickness of the tube, optional, default 0.5
  95851. * * radialSegments the number of sides on each tube segments, optional, default 32
  95852. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  95853. * * p the number of windings around the z axis, optional, default 2
  95854. * * q the number of windings around the x axis, optional, default 3
  95855. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95856. * * 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)
  95857. * * 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)
  95858. * @returns the VertexData of the Torus Knot
  95859. */
  95860. static CreateTorusKnot(options: {
  95861. radius?: number;
  95862. tube?: number;
  95863. radialSegments?: number;
  95864. tubularSegments?: number;
  95865. p?: number;
  95866. q?: number;
  95867. sideOrientation?: number;
  95868. frontUVs?: Vector4;
  95869. backUVs?: Vector4;
  95870. }): VertexData;
  95871. /**
  95872. * Compute normals for given positions and indices
  95873. * @param positions an array of vertex positions, [...., x, y, z, ......]
  95874. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  95875. * @param normals an array of vertex normals, [...., x, y, z, ......]
  95876. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  95877. * * facetNormals : optional array of facet normals (vector3)
  95878. * * facetPositions : optional array of facet positions (vector3)
  95879. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  95880. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  95881. * * bInfo : optional bounding info, required for facetPartitioning computation
  95882. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  95883. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  95884. * * useRightHandedSystem: optional boolean to for right handed system computation
  95885. * * depthSort : optional boolean to enable the facet depth sort computation
  95886. * * distanceTo : optional Vector3 to compute the facet depth from this location
  95887. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  95888. */
  95889. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  95890. facetNormals?: any;
  95891. facetPositions?: any;
  95892. facetPartitioning?: any;
  95893. ratio?: number;
  95894. bInfo?: any;
  95895. bbSize?: Vector3;
  95896. subDiv?: any;
  95897. useRightHandedSystem?: boolean;
  95898. depthSort?: boolean;
  95899. distanceTo?: Vector3;
  95900. depthSortedFacets?: any;
  95901. }): void;
  95902. /** @hidden */
  95903. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  95904. /**
  95905. * Applies VertexData created from the imported parameters to the geometry
  95906. * @param parsedVertexData the parsed data from an imported file
  95907. * @param geometry the geometry to apply the VertexData to
  95908. */
  95909. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  95910. }
  95911. }
  95912. declare module BABYLON {
  95913. /**
  95914. * Defines a target to use with MorphTargetManager
  95915. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  95916. */
  95917. export class MorphTarget implements IAnimatable {
  95918. /** defines the name of the target */
  95919. name: string;
  95920. /**
  95921. * Gets or sets the list of animations
  95922. */
  95923. animations: Animation[];
  95924. private _scene;
  95925. private _positions;
  95926. private _normals;
  95927. private _tangents;
  95928. private _uvs;
  95929. private _influence;
  95930. private _uniqueId;
  95931. /**
  95932. * Observable raised when the influence changes
  95933. */
  95934. onInfluenceChanged: Observable<boolean>;
  95935. /** @hidden */
  95936. _onDataLayoutChanged: Observable<void>;
  95937. /**
  95938. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  95939. */
  95940. get influence(): number;
  95941. set influence(influence: number);
  95942. /**
  95943. * Gets or sets the id of the morph Target
  95944. */
  95945. id: string;
  95946. private _animationPropertiesOverride;
  95947. /**
  95948. * Gets or sets the animation properties override
  95949. */
  95950. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  95951. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  95952. /**
  95953. * Creates a new MorphTarget
  95954. * @param name defines the name of the target
  95955. * @param influence defines the influence to use
  95956. * @param scene defines the scene the morphtarget belongs to
  95957. */
  95958. constructor(
  95959. /** defines the name of the target */
  95960. name: string, influence?: number, scene?: Nullable<Scene>);
  95961. /**
  95962. * Gets the unique ID of this manager
  95963. */
  95964. get uniqueId(): number;
  95965. /**
  95966. * Gets a boolean defining if the target contains position data
  95967. */
  95968. get hasPositions(): boolean;
  95969. /**
  95970. * Gets a boolean defining if the target contains normal data
  95971. */
  95972. get hasNormals(): boolean;
  95973. /**
  95974. * Gets a boolean defining if the target contains tangent data
  95975. */
  95976. get hasTangents(): boolean;
  95977. /**
  95978. * Gets a boolean defining if the target contains texture coordinates data
  95979. */
  95980. get hasUVs(): boolean;
  95981. /**
  95982. * Affects position data to this target
  95983. * @param data defines the position data to use
  95984. */
  95985. setPositions(data: Nullable<FloatArray>): void;
  95986. /**
  95987. * Gets the position data stored in this target
  95988. * @returns a FloatArray containing the position data (or null if not present)
  95989. */
  95990. getPositions(): Nullable<FloatArray>;
  95991. /**
  95992. * Affects normal data to this target
  95993. * @param data defines the normal data to use
  95994. */
  95995. setNormals(data: Nullable<FloatArray>): void;
  95996. /**
  95997. * Gets the normal data stored in this target
  95998. * @returns a FloatArray containing the normal data (or null if not present)
  95999. */
  96000. getNormals(): Nullable<FloatArray>;
  96001. /**
  96002. * Affects tangent data to this target
  96003. * @param data defines the tangent data to use
  96004. */
  96005. setTangents(data: Nullable<FloatArray>): void;
  96006. /**
  96007. * Gets the tangent data stored in this target
  96008. * @returns a FloatArray containing the tangent data (or null if not present)
  96009. */
  96010. getTangents(): Nullable<FloatArray>;
  96011. /**
  96012. * Affects texture coordinates data to this target
  96013. * @param data defines the texture coordinates data to use
  96014. */
  96015. setUVs(data: Nullable<FloatArray>): void;
  96016. /**
  96017. * Gets the texture coordinates data stored in this target
  96018. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  96019. */
  96020. getUVs(): Nullable<FloatArray>;
  96021. /**
  96022. * Clone the current target
  96023. * @returns a new MorphTarget
  96024. */
  96025. clone(): MorphTarget;
  96026. /**
  96027. * Serializes the current target into a Serialization object
  96028. * @returns the serialized object
  96029. */
  96030. serialize(): any;
  96031. /**
  96032. * Returns the string "MorphTarget"
  96033. * @returns "MorphTarget"
  96034. */
  96035. getClassName(): string;
  96036. /**
  96037. * Creates a new target from serialized data
  96038. * @param serializationObject defines the serialized data to use
  96039. * @returns a new MorphTarget
  96040. */
  96041. static Parse(serializationObject: any): MorphTarget;
  96042. /**
  96043. * Creates a MorphTarget from mesh data
  96044. * @param mesh defines the source mesh
  96045. * @param name defines the name to use for the new target
  96046. * @param influence defines the influence to attach to the target
  96047. * @returns a new MorphTarget
  96048. */
  96049. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  96050. }
  96051. }
  96052. declare module BABYLON {
  96053. /**
  96054. * This class is used to deform meshes using morphing between different targets
  96055. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  96056. */
  96057. export class MorphTargetManager {
  96058. private _targets;
  96059. private _targetInfluenceChangedObservers;
  96060. private _targetDataLayoutChangedObservers;
  96061. private _activeTargets;
  96062. private _scene;
  96063. private _influences;
  96064. private _supportsNormals;
  96065. private _supportsTangents;
  96066. private _supportsUVs;
  96067. private _vertexCount;
  96068. private _uniqueId;
  96069. private _tempInfluences;
  96070. /**
  96071. * Gets or sets a boolean indicating if normals must be morphed
  96072. */
  96073. enableNormalMorphing: boolean;
  96074. /**
  96075. * Gets or sets a boolean indicating if tangents must be morphed
  96076. */
  96077. enableTangentMorphing: boolean;
  96078. /**
  96079. * Gets or sets a boolean indicating if UV must be morphed
  96080. */
  96081. enableUVMorphing: boolean;
  96082. /**
  96083. * Creates a new MorphTargetManager
  96084. * @param scene defines the current scene
  96085. */
  96086. constructor(scene?: Nullable<Scene>);
  96087. /**
  96088. * Gets the unique ID of this manager
  96089. */
  96090. get uniqueId(): number;
  96091. /**
  96092. * Gets the number of vertices handled by this manager
  96093. */
  96094. get vertexCount(): number;
  96095. /**
  96096. * Gets a boolean indicating if this manager supports morphing of normals
  96097. */
  96098. get supportsNormals(): boolean;
  96099. /**
  96100. * Gets a boolean indicating if this manager supports morphing of tangents
  96101. */
  96102. get supportsTangents(): boolean;
  96103. /**
  96104. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  96105. */
  96106. get supportsUVs(): boolean;
  96107. /**
  96108. * Gets the number of targets stored in this manager
  96109. */
  96110. get numTargets(): number;
  96111. /**
  96112. * Gets the number of influencers (ie. the number of targets with influences > 0)
  96113. */
  96114. get numInfluencers(): number;
  96115. /**
  96116. * Gets the list of influences (one per target)
  96117. */
  96118. get influences(): Float32Array;
  96119. /**
  96120. * Gets the active target at specified index. An active target is a target with an influence > 0
  96121. * @param index defines the index to check
  96122. * @returns the requested target
  96123. */
  96124. getActiveTarget(index: number): MorphTarget;
  96125. /**
  96126. * Gets the target at specified index
  96127. * @param index defines the index to check
  96128. * @returns the requested target
  96129. */
  96130. getTarget(index: number): MorphTarget;
  96131. /**
  96132. * Add a new target to this manager
  96133. * @param target defines the target to add
  96134. */
  96135. addTarget(target: MorphTarget): void;
  96136. /**
  96137. * Removes a target from the manager
  96138. * @param target defines the target to remove
  96139. */
  96140. removeTarget(target: MorphTarget): void;
  96141. /**
  96142. * Clone the current manager
  96143. * @returns a new MorphTargetManager
  96144. */
  96145. clone(): MorphTargetManager;
  96146. /**
  96147. * Serializes the current manager into a Serialization object
  96148. * @returns the serialized object
  96149. */
  96150. serialize(): any;
  96151. private _syncActiveTargets;
  96152. /**
  96153. * Syncrhonize the targets with all the meshes using this morph target manager
  96154. */
  96155. synchronize(): void;
  96156. /**
  96157. * Creates a new MorphTargetManager from serialized data
  96158. * @param serializationObject defines the serialized data
  96159. * @param scene defines the hosting scene
  96160. * @returns the new MorphTargetManager
  96161. */
  96162. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  96163. }
  96164. }
  96165. declare module BABYLON {
  96166. /**
  96167. * Class used to represent a specific level of detail of a mesh
  96168. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  96169. */
  96170. export class MeshLODLevel {
  96171. /** Defines the distance where this level should start being displayed */
  96172. distance: number;
  96173. /** Defines the mesh to use to render this level */
  96174. mesh: Nullable<Mesh>;
  96175. /**
  96176. * Creates a new LOD level
  96177. * @param distance defines the distance where this level should star being displayed
  96178. * @param mesh defines the mesh to use to render this level
  96179. */
  96180. constructor(
  96181. /** Defines the distance where this level should start being displayed */
  96182. distance: number,
  96183. /** Defines the mesh to use to render this level */
  96184. mesh: Nullable<Mesh>);
  96185. }
  96186. }
  96187. declare module BABYLON {
  96188. /**
  96189. * Mesh representing the gorund
  96190. */
  96191. export class GroundMesh extends Mesh {
  96192. /** If octree should be generated */
  96193. generateOctree: boolean;
  96194. private _heightQuads;
  96195. /** @hidden */
  96196. _subdivisionsX: number;
  96197. /** @hidden */
  96198. _subdivisionsY: number;
  96199. /** @hidden */
  96200. _width: number;
  96201. /** @hidden */
  96202. _height: number;
  96203. /** @hidden */
  96204. _minX: number;
  96205. /** @hidden */
  96206. _maxX: number;
  96207. /** @hidden */
  96208. _minZ: number;
  96209. /** @hidden */
  96210. _maxZ: number;
  96211. constructor(name: string, scene: Scene);
  96212. /**
  96213. * "GroundMesh"
  96214. * @returns "GroundMesh"
  96215. */
  96216. getClassName(): string;
  96217. /**
  96218. * The minimum of x and y subdivisions
  96219. */
  96220. get subdivisions(): number;
  96221. /**
  96222. * X subdivisions
  96223. */
  96224. get subdivisionsX(): number;
  96225. /**
  96226. * Y subdivisions
  96227. */
  96228. get subdivisionsY(): number;
  96229. /**
  96230. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  96231. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  96232. * @param chunksCount the number of subdivisions for x and y
  96233. * @param octreeBlocksSize (Default: 32)
  96234. */
  96235. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  96236. /**
  96237. * Returns a height (y) value in the Worl system :
  96238. * the ground altitude at the coordinates (x, z) expressed in the World system.
  96239. * @param x x coordinate
  96240. * @param z z coordinate
  96241. * @returns the ground y position if (x, z) are outside the ground surface.
  96242. */
  96243. getHeightAtCoordinates(x: number, z: number): number;
  96244. /**
  96245. * Returns a normalized vector (Vector3) orthogonal to the ground
  96246. * at the ground coordinates (x, z) expressed in the World system.
  96247. * @param x x coordinate
  96248. * @param z z coordinate
  96249. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  96250. */
  96251. getNormalAtCoordinates(x: number, z: number): Vector3;
  96252. /**
  96253. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  96254. * at the ground coordinates (x, z) expressed in the World system.
  96255. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  96256. * @param x x coordinate
  96257. * @param z z coordinate
  96258. * @param ref vector to store the result
  96259. * @returns the GroundMesh.
  96260. */
  96261. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  96262. /**
  96263. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  96264. * if the ground has been updated.
  96265. * This can be used in the render loop.
  96266. * @returns the GroundMesh.
  96267. */
  96268. updateCoordinateHeights(): GroundMesh;
  96269. private _getFacetAt;
  96270. private _initHeightQuads;
  96271. private _computeHeightQuads;
  96272. /**
  96273. * Serializes this ground mesh
  96274. * @param serializationObject object to write serialization to
  96275. */
  96276. serialize(serializationObject: any): void;
  96277. /**
  96278. * Parses a serialized ground mesh
  96279. * @param parsedMesh the serialized mesh
  96280. * @param scene the scene to create the ground mesh in
  96281. * @returns the created ground mesh
  96282. */
  96283. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  96284. }
  96285. }
  96286. declare module BABYLON {
  96287. /**
  96288. * Interface for Physics-Joint data
  96289. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96290. */
  96291. export interface PhysicsJointData {
  96292. /**
  96293. * The main pivot of the joint
  96294. */
  96295. mainPivot?: Vector3;
  96296. /**
  96297. * The connected pivot of the joint
  96298. */
  96299. connectedPivot?: Vector3;
  96300. /**
  96301. * The main axis of the joint
  96302. */
  96303. mainAxis?: Vector3;
  96304. /**
  96305. * The connected axis of the joint
  96306. */
  96307. connectedAxis?: Vector3;
  96308. /**
  96309. * The collision of the joint
  96310. */
  96311. collision?: boolean;
  96312. /**
  96313. * Native Oimo/Cannon/Energy data
  96314. */
  96315. nativeParams?: any;
  96316. }
  96317. /**
  96318. * This is a holder class for the physics joint created by the physics plugin
  96319. * It holds a set of functions to control the underlying joint
  96320. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96321. */
  96322. export class PhysicsJoint {
  96323. /**
  96324. * The type of the physics joint
  96325. */
  96326. type: number;
  96327. /**
  96328. * The data for the physics joint
  96329. */
  96330. jointData: PhysicsJointData;
  96331. private _physicsJoint;
  96332. protected _physicsPlugin: IPhysicsEnginePlugin;
  96333. /**
  96334. * Initializes the physics joint
  96335. * @param type The type of the physics joint
  96336. * @param jointData The data for the physics joint
  96337. */
  96338. constructor(
  96339. /**
  96340. * The type of the physics joint
  96341. */
  96342. type: number,
  96343. /**
  96344. * The data for the physics joint
  96345. */
  96346. jointData: PhysicsJointData);
  96347. /**
  96348. * Gets the physics joint
  96349. */
  96350. get physicsJoint(): any;
  96351. /**
  96352. * Sets the physics joint
  96353. */
  96354. set physicsJoint(newJoint: any);
  96355. /**
  96356. * Sets the physics plugin
  96357. */
  96358. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  96359. /**
  96360. * Execute a function that is physics-plugin specific.
  96361. * @param {Function} func the function that will be executed.
  96362. * It accepts two parameters: the physics world and the physics joint
  96363. */
  96364. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  96365. /**
  96366. * Distance-Joint type
  96367. */
  96368. static DistanceJoint: number;
  96369. /**
  96370. * Hinge-Joint type
  96371. */
  96372. static HingeJoint: number;
  96373. /**
  96374. * Ball-and-Socket joint type
  96375. */
  96376. static BallAndSocketJoint: number;
  96377. /**
  96378. * Wheel-Joint type
  96379. */
  96380. static WheelJoint: number;
  96381. /**
  96382. * Slider-Joint type
  96383. */
  96384. static SliderJoint: number;
  96385. /**
  96386. * Prismatic-Joint type
  96387. */
  96388. static PrismaticJoint: number;
  96389. /**
  96390. * Universal-Joint type
  96391. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  96392. */
  96393. static UniversalJoint: number;
  96394. /**
  96395. * Hinge-Joint 2 type
  96396. */
  96397. static Hinge2Joint: number;
  96398. /**
  96399. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  96400. */
  96401. static PointToPointJoint: number;
  96402. /**
  96403. * Spring-Joint type
  96404. */
  96405. static SpringJoint: number;
  96406. /**
  96407. * Lock-Joint type
  96408. */
  96409. static LockJoint: number;
  96410. }
  96411. /**
  96412. * A class representing a physics distance joint
  96413. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96414. */
  96415. export class DistanceJoint extends PhysicsJoint {
  96416. /**
  96417. *
  96418. * @param jointData The data for the Distance-Joint
  96419. */
  96420. constructor(jointData: DistanceJointData);
  96421. /**
  96422. * Update the predefined distance.
  96423. * @param maxDistance The maximum preferred distance
  96424. * @param minDistance The minimum preferred distance
  96425. */
  96426. updateDistance(maxDistance: number, minDistance?: number): void;
  96427. }
  96428. /**
  96429. * Represents a Motor-Enabled Joint
  96430. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96431. */
  96432. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  96433. /**
  96434. * Initializes the Motor-Enabled Joint
  96435. * @param type The type of the joint
  96436. * @param jointData The physica joint data for the joint
  96437. */
  96438. constructor(type: number, jointData: PhysicsJointData);
  96439. /**
  96440. * Set the motor values.
  96441. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96442. * @param force the force to apply
  96443. * @param maxForce max force for this motor.
  96444. */
  96445. setMotor(force?: number, maxForce?: number): void;
  96446. /**
  96447. * Set the motor's limits.
  96448. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96449. * @param upperLimit The upper limit of the motor
  96450. * @param lowerLimit The lower limit of the motor
  96451. */
  96452. setLimit(upperLimit: number, lowerLimit?: number): void;
  96453. }
  96454. /**
  96455. * This class represents a single physics Hinge-Joint
  96456. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96457. */
  96458. export class HingeJoint extends MotorEnabledJoint {
  96459. /**
  96460. * Initializes the Hinge-Joint
  96461. * @param jointData The joint data for the Hinge-Joint
  96462. */
  96463. constructor(jointData: PhysicsJointData);
  96464. /**
  96465. * Set the motor values.
  96466. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96467. * @param {number} force the force to apply
  96468. * @param {number} maxForce max force for this motor.
  96469. */
  96470. setMotor(force?: number, maxForce?: number): void;
  96471. /**
  96472. * Set the motor's limits.
  96473. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96474. * @param upperLimit The upper limit of the motor
  96475. * @param lowerLimit The lower limit of the motor
  96476. */
  96477. setLimit(upperLimit: number, lowerLimit?: number): void;
  96478. }
  96479. /**
  96480. * This class represents a dual hinge physics joint (same as wheel joint)
  96481. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96482. */
  96483. export class Hinge2Joint extends MotorEnabledJoint {
  96484. /**
  96485. * Initializes the Hinge2-Joint
  96486. * @param jointData The joint data for the Hinge2-Joint
  96487. */
  96488. constructor(jointData: PhysicsJointData);
  96489. /**
  96490. * Set the motor values.
  96491. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96492. * @param {number} targetSpeed the speed the motor is to reach
  96493. * @param {number} maxForce max force for this motor.
  96494. * @param {motorIndex} the motor's index, 0 or 1.
  96495. */
  96496. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  96497. /**
  96498. * Set the motor limits.
  96499. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96500. * @param {number} upperLimit the upper limit
  96501. * @param {number} lowerLimit lower limit
  96502. * @param {motorIndex} the motor's index, 0 or 1.
  96503. */
  96504. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  96505. }
  96506. /**
  96507. * Interface for a motor enabled joint
  96508. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96509. */
  96510. export interface IMotorEnabledJoint {
  96511. /**
  96512. * Physics joint
  96513. */
  96514. physicsJoint: any;
  96515. /**
  96516. * Sets the motor of the motor-enabled joint
  96517. * @param force The force of the motor
  96518. * @param maxForce The maximum force of the motor
  96519. * @param motorIndex The index of the motor
  96520. */
  96521. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  96522. /**
  96523. * Sets the limit of the motor
  96524. * @param upperLimit The upper limit of the motor
  96525. * @param lowerLimit The lower limit of the motor
  96526. * @param motorIndex The index of the motor
  96527. */
  96528. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  96529. }
  96530. /**
  96531. * Joint data for a Distance-Joint
  96532. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96533. */
  96534. export interface DistanceJointData extends PhysicsJointData {
  96535. /**
  96536. * Max distance the 2 joint objects can be apart
  96537. */
  96538. maxDistance: number;
  96539. }
  96540. /**
  96541. * Joint data from a spring joint
  96542. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96543. */
  96544. export interface SpringJointData extends PhysicsJointData {
  96545. /**
  96546. * Length of the spring
  96547. */
  96548. length: number;
  96549. /**
  96550. * Stiffness of the spring
  96551. */
  96552. stiffness: number;
  96553. /**
  96554. * Damping of the spring
  96555. */
  96556. damping: number;
  96557. /** this callback will be called when applying the force to the impostors. */
  96558. forceApplicationCallback: () => void;
  96559. }
  96560. }
  96561. declare module BABYLON {
  96562. /**
  96563. * Holds the data for the raycast result
  96564. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96565. */
  96566. export class PhysicsRaycastResult {
  96567. private _hasHit;
  96568. private _hitDistance;
  96569. private _hitNormalWorld;
  96570. private _hitPointWorld;
  96571. private _rayFromWorld;
  96572. private _rayToWorld;
  96573. /**
  96574. * Gets if there was a hit
  96575. */
  96576. get hasHit(): boolean;
  96577. /**
  96578. * Gets the distance from the hit
  96579. */
  96580. get hitDistance(): number;
  96581. /**
  96582. * Gets the hit normal/direction in the world
  96583. */
  96584. get hitNormalWorld(): Vector3;
  96585. /**
  96586. * Gets the hit point in the world
  96587. */
  96588. get hitPointWorld(): Vector3;
  96589. /**
  96590. * Gets the ray "start point" of the ray in the world
  96591. */
  96592. get rayFromWorld(): Vector3;
  96593. /**
  96594. * Gets the ray "end point" of the ray in the world
  96595. */
  96596. get rayToWorld(): Vector3;
  96597. /**
  96598. * Sets the hit data (normal & point in world space)
  96599. * @param hitNormalWorld defines the normal in world space
  96600. * @param hitPointWorld defines the point in world space
  96601. */
  96602. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  96603. /**
  96604. * Sets the distance from the start point to the hit point
  96605. * @param distance
  96606. */
  96607. setHitDistance(distance: number): void;
  96608. /**
  96609. * Calculates the distance manually
  96610. */
  96611. calculateHitDistance(): void;
  96612. /**
  96613. * Resets all the values to default
  96614. * @param from The from point on world space
  96615. * @param to The to point on world space
  96616. */
  96617. reset(from?: Vector3, to?: Vector3): void;
  96618. }
  96619. /**
  96620. * Interface for the size containing width and height
  96621. */
  96622. interface IXYZ {
  96623. /**
  96624. * X
  96625. */
  96626. x: number;
  96627. /**
  96628. * Y
  96629. */
  96630. y: number;
  96631. /**
  96632. * Z
  96633. */
  96634. z: number;
  96635. }
  96636. }
  96637. declare module BABYLON {
  96638. /**
  96639. * Interface used to describe a physics joint
  96640. */
  96641. export interface PhysicsImpostorJoint {
  96642. /** Defines the main impostor to which the joint is linked */
  96643. mainImpostor: PhysicsImpostor;
  96644. /** Defines the impostor that is connected to the main impostor using this joint */
  96645. connectedImpostor: PhysicsImpostor;
  96646. /** Defines the joint itself */
  96647. joint: PhysicsJoint;
  96648. }
  96649. /** @hidden */
  96650. export interface IPhysicsEnginePlugin {
  96651. world: any;
  96652. name: string;
  96653. setGravity(gravity: Vector3): void;
  96654. setTimeStep(timeStep: number): void;
  96655. getTimeStep(): number;
  96656. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  96657. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  96658. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  96659. generatePhysicsBody(impostor: PhysicsImpostor): void;
  96660. removePhysicsBody(impostor: PhysicsImpostor): void;
  96661. generateJoint(joint: PhysicsImpostorJoint): void;
  96662. removeJoint(joint: PhysicsImpostorJoint): void;
  96663. isSupported(): boolean;
  96664. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  96665. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  96666. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  96667. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  96668. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  96669. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  96670. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  96671. getBodyMass(impostor: PhysicsImpostor): number;
  96672. getBodyFriction(impostor: PhysicsImpostor): number;
  96673. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  96674. getBodyRestitution(impostor: PhysicsImpostor): number;
  96675. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  96676. getBodyPressure?(impostor: PhysicsImpostor): number;
  96677. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  96678. getBodyStiffness?(impostor: PhysicsImpostor): number;
  96679. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  96680. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  96681. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  96682. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  96683. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  96684. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  96685. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  96686. sleepBody(impostor: PhysicsImpostor): void;
  96687. wakeUpBody(impostor: PhysicsImpostor): void;
  96688. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  96689. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  96690. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  96691. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  96692. getRadius(impostor: PhysicsImpostor): number;
  96693. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  96694. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  96695. dispose(): void;
  96696. }
  96697. /**
  96698. * Interface used to define a physics engine
  96699. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  96700. */
  96701. export interface IPhysicsEngine {
  96702. /**
  96703. * Gets the gravity vector used by the simulation
  96704. */
  96705. gravity: Vector3;
  96706. /**
  96707. * Sets the gravity vector used by the simulation
  96708. * @param gravity defines the gravity vector to use
  96709. */
  96710. setGravity(gravity: Vector3): void;
  96711. /**
  96712. * Set the time step of the physics engine.
  96713. * Default is 1/60.
  96714. * To slow it down, enter 1/600 for example.
  96715. * To speed it up, 1/30
  96716. * @param newTimeStep the new timestep to apply to this world.
  96717. */
  96718. setTimeStep(newTimeStep: number): void;
  96719. /**
  96720. * Get the time step of the physics engine.
  96721. * @returns the current time step
  96722. */
  96723. getTimeStep(): number;
  96724. /**
  96725. * Set the sub time step of the physics engine.
  96726. * Default is 0 meaning there is no sub steps
  96727. * To increase physics resolution precision, set a small value (like 1 ms)
  96728. * @param subTimeStep defines the new sub timestep used for physics resolution.
  96729. */
  96730. setSubTimeStep(subTimeStep: number): void;
  96731. /**
  96732. * Get the sub time step of the physics engine.
  96733. * @returns the current sub time step
  96734. */
  96735. getSubTimeStep(): number;
  96736. /**
  96737. * Release all resources
  96738. */
  96739. dispose(): void;
  96740. /**
  96741. * Gets the name of the current physics plugin
  96742. * @returns the name of the plugin
  96743. */
  96744. getPhysicsPluginName(): string;
  96745. /**
  96746. * Adding a new impostor for the impostor tracking.
  96747. * This will be done by the impostor itself.
  96748. * @param impostor the impostor to add
  96749. */
  96750. addImpostor(impostor: PhysicsImpostor): void;
  96751. /**
  96752. * Remove an impostor from the engine.
  96753. * This impostor and its mesh will not longer be updated by the physics engine.
  96754. * @param impostor the impostor to remove
  96755. */
  96756. removeImpostor(impostor: PhysicsImpostor): void;
  96757. /**
  96758. * Add a joint to the physics engine
  96759. * @param mainImpostor defines the main impostor to which the joint is added.
  96760. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  96761. * @param joint defines the joint that will connect both impostors.
  96762. */
  96763. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  96764. /**
  96765. * Removes a joint from the simulation
  96766. * @param mainImpostor defines the impostor used with the joint
  96767. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  96768. * @param joint defines the joint to remove
  96769. */
  96770. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  96771. /**
  96772. * Gets the current plugin used to run the simulation
  96773. * @returns current plugin
  96774. */
  96775. getPhysicsPlugin(): IPhysicsEnginePlugin;
  96776. /**
  96777. * Gets the list of physic impostors
  96778. * @returns an array of PhysicsImpostor
  96779. */
  96780. getImpostors(): Array<PhysicsImpostor>;
  96781. /**
  96782. * Gets the impostor for a physics enabled object
  96783. * @param object defines the object impersonated by the impostor
  96784. * @returns the PhysicsImpostor or null if not found
  96785. */
  96786. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  96787. /**
  96788. * Gets the impostor for a physics body object
  96789. * @param body defines physics body used by the impostor
  96790. * @returns the PhysicsImpostor or null if not found
  96791. */
  96792. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  96793. /**
  96794. * Does a raycast in the physics world
  96795. * @param from when should the ray start?
  96796. * @param to when should the ray end?
  96797. * @returns PhysicsRaycastResult
  96798. */
  96799. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  96800. /**
  96801. * Called by the scene. No need to call it.
  96802. * @param delta defines the timespam between frames
  96803. */
  96804. _step(delta: number): void;
  96805. }
  96806. }
  96807. declare module BABYLON {
  96808. /**
  96809. * The interface for the physics imposter parameters
  96810. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96811. */
  96812. export interface PhysicsImpostorParameters {
  96813. /**
  96814. * The mass of the physics imposter
  96815. */
  96816. mass: number;
  96817. /**
  96818. * The friction of the physics imposter
  96819. */
  96820. friction?: number;
  96821. /**
  96822. * The coefficient of restitution of the physics imposter
  96823. */
  96824. restitution?: number;
  96825. /**
  96826. * The native options of the physics imposter
  96827. */
  96828. nativeOptions?: any;
  96829. /**
  96830. * Specifies if the parent should be ignored
  96831. */
  96832. ignoreParent?: boolean;
  96833. /**
  96834. * Specifies if bi-directional transformations should be disabled
  96835. */
  96836. disableBidirectionalTransformation?: boolean;
  96837. /**
  96838. * The pressure inside the physics imposter, soft object only
  96839. */
  96840. pressure?: number;
  96841. /**
  96842. * The stiffness the physics imposter, soft object only
  96843. */
  96844. stiffness?: number;
  96845. /**
  96846. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  96847. */
  96848. velocityIterations?: number;
  96849. /**
  96850. * The number of iterations used in maintaining consistent vertex positions, soft object only
  96851. */
  96852. positionIterations?: number;
  96853. /**
  96854. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  96855. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  96856. * Add to fix multiple points
  96857. */
  96858. fixedPoints?: number;
  96859. /**
  96860. * The collision margin around a soft object
  96861. */
  96862. margin?: number;
  96863. /**
  96864. * The collision margin around a soft object
  96865. */
  96866. damping?: number;
  96867. /**
  96868. * The path for a rope based on an extrusion
  96869. */
  96870. path?: any;
  96871. /**
  96872. * The shape of an extrusion used for a rope based on an extrusion
  96873. */
  96874. shape?: any;
  96875. }
  96876. /**
  96877. * Interface for a physics-enabled object
  96878. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96879. */
  96880. export interface IPhysicsEnabledObject {
  96881. /**
  96882. * The position of the physics-enabled object
  96883. */
  96884. position: Vector3;
  96885. /**
  96886. * The rotation of the physics-enabled object
  96887. */
  96888. rotationQuaternion: Nullable<Quaternion>;
  96889. /**
  96890. * The scale of the physics-enabled object
  96891. */
  96892. scaling: Vector3;
  96893. /**
  96894. * The rotation of the physics-enabled object
  96895. */
  96896. rotation?: Vector3;
  96897. /**
  96898. * The parent of the physics-enabled object
  96899. */
  96900. parent?: any;
  96901. /**
  96902. * The bounding info of the physics-enabled object
  96903. * @returns The bounding info of the physics-enabled object
  96904. */
  96905. getBoundingInfo(): BoundingInfo;
  96906. /**
  96907. * Computes the world matrix
  96908. * @param force Specifies if the world matrix should be computed by force
  96909. * @returns A world matrix
  96910. */
  96911. computeWorldMatrix(force: boolean): Matrix;
  96912. /**
  96913. * Gets the world matrix
  96914. * @returns A world matrix
  96915. */
  96916. getWorldMatrix?(): Matrix;
  96917. /**
  96918. * Gets the child meshes
  96919. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  96920. * @returns An array of abstract meshes
  96921. */
  96922. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  96923. /**
  96924. * Gets the vertex data
  96925. * @param kind The type of vertex data
  96926. * @returns A nullable array of numbers, or a float32 array
  96927. */
  96928. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  96929. /**
  96930. * Gets the indices from the mesh
  96931. * @returns A nullable array of index arrays
  96932. */
  96933. getIndices?(): Nullable<IndicesArray>;
  96934. /**
  96935. * Gets the scene from the mesh
  96936. * @returns the indices array or null
  96937. */
  96938. getScene?(): Scene;
  96939. /**
  96940. * Gets the absolute position from the mesh
  96941. * @returns the absolute position
  96942. */
  96943. getAbsolutePosition(): Vector3;
  96944. /**
  96945. * Gets the absolute pivot point from the mesh
  96946. * @returns the absolute pivot point
  96947. */
  96948. getAbsolutePivotPoint(): Vector3;
  96949. /**
  96950. * Rotates the mesh
  96951. * @param axis The axis of rotation
  96952. * @param amount The amount of rotation
  96953. * @param space The space of the rotation
  96954. * @returns The rotation transform node
  96955. */
  96956. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  96957. /**
  96958. * Translates the mesh
  96959. * @param axis The axis of translation
  96960. * @param distance The distance of translation
  96961. * @param space The space of the translation
  96962. * @returns The transform node
  96963. */
  96964. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  96965. /**
  96966. * Sets the absolute position of the mesh
  96967. * @param absolutePosition The absolute position of the mesh
  96968. * @returns The transform node
  96969. */
  96970. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  96971. /**
  96972. * Gets the class name of the mesh
  96973. * @returns The class name
  96974. */
  96975. getClassName(): string;
  96976. }
  96977. /**
  96978. * Represents a physics imposter
  96979. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96980. */
  96981. export class PhysicsImpostor {
  96982. /**
  96983. * The physics-enabled object used as the physics imposter
  96984. */
  96985. object: IPhysicsEnabledObject;
  96986. /**
  96987. * The type of the physics imposter
  96988. */
  96989. type: number;
  96990. private _options;
  96991. private _scene?;
  96992. /**
  96993. * The default object size of the imposter
  96994. */
  96995. static DEFAULT_OBJECT_SIZE: Vector3;
  96996. /**
  96997. * The identity quaternion of the imposter
  96998. */
  96999. static IDENTITY_QUATERNION: Quaternion;
  97000. /** @hidden */
  97001. _pluginData: any;
  97002. private _physicsEngine;
  97003. private _physicsBody;
  97004. private _bodyUpdateRequired;
  97005. private _onBeforePhysicsStepCallbacks;
  97006. private _onAfterPhysicsStepCallbacks;
  97007. /** @hidden */
  97008. _onPhysicsCollideCallbacks: Array<{
  97009. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  97010. otherImpostors: Array<PhysicsImpostor>;
  97011. }>;
  97012. private _deltaPosition;
  97013. private _deltaRotation;
  97014. private _deltaRotationConjugated;
  97015. /** @hidden */
  97016. _isFromLine: boolean;
  97017. private _parent;
  97018. private _isDisposed;
  97019. private static _tmpVecs;
  97020. private static _tmpQuat;
  97021. /**
  97022. * Specifies if the physics imposter is disposed
  97023. */
  97024. get isDisposed(): boolean;
  97025. /**
  97026. * Gets the mass of the physics imposter
  97027. */
  97028. get mass(): number;
  97029. set mass(value: number);
  97030. /**
  97031. * Gets the coefficient of friction
  97032. */
  97033. get friction(): number;
  97034. /**
  97035. * Sets the coefficient of friction
  97036. */
  97037. set friction(value: number);
  97038. /**
  97039. * Gets the coefficient of restitution
  97040. */
  97041. get restitution(): number;
  97042. /**
  97043. * Sets the coefficient of restitution
  97044. */
  97045. set restitution(value: number);
  97046. /**
  97047. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  97048. */
  97049. get pressure(): number;
  97050. /**
  97051. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  97052. */
  97053. set pressure(value: number);
  97054. /**
  97055. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  97056. */
  97057. get stiffness(): number;
  97058. /**
  97059. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  97060. */
  97061. set stiffness(value: number);
  97062. /**
  97063. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  97064. */
  97065. get velocityIterations(): number;
  97066. /**
  97067. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  97068. */
  97069. set velocityIterations(value: number);
  97070. /**
  97071. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  97072. */
  97073. get positionIterations(): number;
  97074. /**
  97075. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  97076. */
  97077. set positionIterations(value: number);
  97078. /**
  97079. * The unique id of the physics imposter
  97080. * set by the physics engine when adding this impostor to the array
  97081. */
  97082. uniqueId: number;
  97083. /**
  97084. * @hidden
  97085. */
  97086. soft: boolean;
  97087. /**
  97088. * @hidden
  97089. */
  97090. segments: number;
  97091. private _joints;
  97092. /**
  97093. * Initializes the physics imposter
  97094. * @param object The physics-enabled object used as the physics imposter
  97095. * @param type The type of the physics imposter
  97096. * @param _options The options for the physics imposter
  97097. * @param _scene The Babylon scene
  97098. */
  97099. constructor(
  97100. /**
  97101. * The physics-enabled object used as the physics imposter
  97102. */
  97103. object: IPhysicsEnabledObject,
  97104. /**
  97105. * The type of the physics imposter
  97106. */
  97107. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  97108. /**
  97109. * This function will completly initialize this impostor.
  97110. * It will create a new body - but only if this mesh has no parent.
  97111. * If it has, this impostor will not be used other than to define the impostor
  97112. * of the child mesh.
  97113. * @hidden
  97114. */
  97115. _init(): void;
  97116. private _getPhysicsParent;
  97117. /**
  97118. * Should a new body be generated.
  97119. * @returns boolean specifying if body initialization is required
  97120. */
  97121. isBodyInitRequired(): boolean;
  97122. /**
  97123. * Sets the updated scaling
  97124. * @param updated Specifies if the scaling is updated
  97125. */
  97126. setScalingUpdated(): void;
  97127. /**
  97128. * Force a regeneration of this or the parent's impostor's body.
  97129. * Use under cautious - This will remove all joints already implemented.
  97130. */
  97131. forceUpdate(): void;
  97132. /**
  97133. * Gets the body that holds this impostor. Either its own, or its parent.
  97134. */
  97135. get physicsBody(): any;
  97136. /**
  97137. * Get the parent of the physics imposter
  97138. * @returns Physics imposter or null
  97139. */
  97140. get parent(): Nullable<PhysicsImpostor>;
  97141. /**
  97142. * Sets the parent of the physics imposter
  97143. */
  97144. set parent(value: Nullable<PhysicsImpostor>);
  97145. /**
  97146. * Set the physics body. Used mainly by the physics engine/plugin
  97147. */
  97148. set physicsBody(physicsBody: any);
  97149. /**
  97150. * Resets the update flags
  97151. */
  97152. resetUpdateFlags(): void;
  97153. /**
  97154. * Gets the object extend size
  97155. * @returns the object extend size
  97156. */
  97157. getObjectExtendSize(): Vector3;
  97158. /**
  97159. * Gets the object center
  97160. * @returns The object center
  97161. */
  97162. getObjectCenter(): Vector3;
  97163. /**
  97164. * Get a specific parameter from the options parameters
  97165. * @param paramName The object parameter name
  97166. * @returns The object parameter
  97167. */
  97168. getParam(paramName: string): any;
  97169. /**
  97170. * Sets a specific parameter in the options given to the physics plugin
  97171. * @param paramName The parameter name
  97172. * @param value The value of the parameter
  97173. */
  97174. setParam(paramName: string, value: number): void;
  97175. /**
  97176. * Specifically change the body's mass option. Won't recreate the physics body object
  97177. * @param mass The mass of the physics imposter
  97178. */
  97179. setMass(mass: number): void;
  97180. /**
  97181. * Gets the linear velocity
  97182. * @returns linear velocity or null
  97183. */
  97184. getLinearVelocity(): Nullable<Vector3>;
  97185. /**
  97186. * Sets the linear velocity
  97187. * @param velocity linear velocity or null
  97188. */
  97189. setLinearVelocity(velocity: Nullable<Vector3>): void;
  97190. /**
  97191. * Gets the angular velocity
  97192. * @returns angular velocity or null
  97193. */
  97194. getAngularVelocity(): Nullable<Vector3>;
  97195. /**
  97196. * Sets the angular velocity
  97197. * @param velocity The velocity or null
  97198. */
  97199. setAngularVelocity(velocity: Nullable<Vector3>): void;
  97200. /**
  97201. * Execute a function with the physics plugin native code
  97202. * Provide a function the will have two variables - the world object and the physics body object
  97203. * @param func The function to execute with the physics plugin native code
  97204. */
  97205. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  97206. /**
  97207. * Register a function that will be executed before the physics world is stepping forward
  97208. * @param func The function to execute before the physics world is stepped forward
  97209. */
  97210. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97211. /**
  97212. * Unregister a function that will be executed before the physics world is stepping forward
  97213. * @param func The function to execute before the physics world is stepped forward
  97214. */
  97215. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97216. /**
  97217. * Register a function that will be executed after the physics step
  97218. * @param func The function to execute after physics step
  97219. */
  97220. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97221. /**
  97222. * Unregisters a function that will be executed after the physics step
  97223. * @param func The function to execute after physics step
  97224. */
  97225. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97226. /**
  97227. * register a function that will be executed when this impostor collides against a different body
  97228. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  97229. * @param func Callback that is executed on collision
  97230. */
  97231. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  97232. /**
  97233. * Unregisters the physics imposter on contact
  97234. * @param collideAgainst The physics object to collide against
  97235. * @param func Callback to execute on collision
  97236. */
  97237. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  97238. private _tmpQuat;
  97239. private _tmpQuat2;
  97240. /**
  97241. * Get the parent rotation
  97242. * @returns The parent rotation
  97243. */
  97244. getParentsRotation(): Quaternion;
  97245. /**
  97246. * this function is executed by the physics engine.
  97247. */
  97248. beforeStep: () => void;
  97249. /**
  97250. * this function is executed by the physics engine
  97251. */
  97252. afterStep: () => void;
  97253. /**
  97254. * Legacy collision detection event support
  97255. */
  97256. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  97257. /**
  97258. * event and body object due to cannon's event-based architecture.
  97259. */
  97260. onCollide: (e: {
  97261. body: any;
  97262. }) => void;
  97263. /**
  97264. * Apply a force
  97265. * @param force The force to apply
  97266. * @param contactPoint The contact point for the force
  97267. * @returns The physics imposter
  97268. */
  97269. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  97270. /**
  97271. * Apply an impulse
  97272. * @param force The impulse force
  97273. * @param contactPoint The contact point for the impulse force
  97274. * @returns The physics imposter
  97275. */
  97276. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  97277. /**
  97278. * A help function to create a joint
  97279. * @param otherImpostor A physics imposter used to create a joint
  97280. * @param jointType The type of joint
  97281. * @param jointData The data for the joint
  97282. * @returns The physics imposter
  97283. */
  97284. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  97285. /**
  97286. * Add a joint to this impostor with a different impostor
  97287. * @param otherImpostor A physics imposter used to add a joint
  97288. * @param joint The joint to add
  97289. * @returns The physics imposter
  97290. */
  97291. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  97292. /**
  97293. * Add an anchor to a cloth impostor
  97294. * @param otherImpostor rigid impostor to anchor to
  97295. * @param width ratio across width from 0 to 1
  97296. * @param height ratio up height from 0 to 1
  97297. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  97298. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  97299. * @returns impostor the soft imposter
  97300. */
  97301. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  97302. /**
  97303. * Add a hook to a rope impostor
  97304. * @param otherImpostor rigid impostor to anchor to
  97305. * @param length ratio across rope from 0 to 1
  97306. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  97307. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  97308. * @returns impostor the rope imposter
  97309. */
  97310. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  97311. /**
  97312. * Will keep this body still, in a sleep mode.
  97313. * @returns the physics imposter
  97314. */
  97315. sleep(): PhysicsImpostor;
  97316. /**
  97317. * Wake the body up.
  97318. * @returns The physics imposter
  97319. */
  97320. wakeUp(): PhysicsImpostor;
  97321. /**
  97322. * Clones the physics imposter
  97323. * @param newObject The physics imposter clones to this physics-enabled object
  97324. * @returns A nullable physics imposter
  97325. */
  97326. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  97327. /**
  97328. * Disposes the physics imposter
  97329. */
  97330. dispose(): void;
  97331. /**
  97332. * Sets the delta position
  97333. * @param position The delta position amount
  97334. */
  97335. setDeltaPosition(position: Vector3): void;
  97336. /**
  97337. * Sets the delta rotation
  97338. * @param rotation The delta rotation amount
  97339. */
  97340. setDeltaRotation(rotation: Quaternion): void;
  97341. /**
  97342. * Gets the box size of the physics imposter and stores the result in the input parameter
  97343. * @param result Stores the box size
  97344. * @returns The physics imposter
  97345. */
  97346. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  97347. /**
  97348. * Gets the radius of the physics imposter
  97349. * @returns Radius of the physics imposter
  97350. */
  97351. getRadius(): number;
  97352. /**
  97353. * Sync a bone with this impostor
  97354. * @param bone The bone to sync to the impostor.
  97355. * @param boneMesh The mesh that the bone is influencing.
  97356. * @param jointPivot The pivot of the joint / bone in local space.
  97357. * @param distToJoint Optional distance from the impostor to the joint.
  97358. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  97359. */
  97360. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  97361. /**
  97362. * Sync impostor to a bone
  97363. * @param bone The bone that the impostor will be synced to.
  97364. * @param boneMesh The mesh that the bone is influencing.
  97365. * @param jointPivot The pivot of the joint / bone in local space.
  97366. * @param distToJoint Optional distance from the impostor to the joint.
  97367. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  97368. * @param boneAxis Optional vector3 axis the bone is aligned with
  97369. */
  97370. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  97371. /**
  97372. * No-Imposter type
  97373. */
  97374. static NoImpostor: number;
  97375. /**
  97376. * Sphere-Imposter type
  97377. */
  97378. static SphereImpostor: number;
  97379. /**
  97380. * Box-Imposter type
  97381. */
  97382. static BoxImpostor: number;
  97383. /**
  97384. * Plane-Imposter type
  97385. */
  97386. static PlaneImpostor: number;
  97387. /**
  97388. * Mesh-imposter type
  97389. */
  97390. static MeshImpostor: number;
  97391. /**
  97392. * Capsule-Impostor type (Ammo.js plugin only)
  97393. */
  97394. static CapsuleImpostor: number;
  97395. /**
  97396. * Cylinder-Imposter type
  97397. */
  97398. static CylinderImpostor: number;
  97399. /**
  97400. * Particle-Imposter type
  97401. */
  97402. static ParticleImpostor: number;
  97403. /**
  97404. * Heightmap-Imposter type
  97405. */
  97406. static HeightmapImpostor: number;
  97407. /**
  97408. * ConvexHull-Impostor type (Ammo.js plugin only)
  97409. */
  97410. static ConvexHullImpostor: number;
  97411. /**
  97412. * Custom-Imposter type (Ammo.js plugin only)
  97413. */
  97414. static CustomImpostor: number;
  97415. /**
  97416. * Rope-Imposter type
  97417. */
  97418. static RopeImpostor: number;
  97419. /**
  97420. * Cloth-Imposter type
  97421. */
  97422. static ClothImpostor: number;
  97423. /**
  97424. * Softbody-Imposter type
  97425. */
  97426. static SoftbodyImpostor: number;
  97427. }
  97428. }
  97429. declare module BABYLON {
  97430. /**
  97431. * @hidden
  97432. **/
  97433. export class _CreationDataStorage {
  97434. closePath?: boolean;
  97435. closeArray?: boolean;
  97436. idx: number[];
  97437. dashSize: number;
  97438. gapSize: number;
  97439. path3D: Path3D;
  97440. pathArray: Vector3[][];
  97441. arc: number;
  97442. radius: number;
  97443. cap: number;
  97444. tessellation: number;
  97445. }
  97446. /**
  97447. * @hidden
  97448. **/
  97449. class _InstanceDataStorage {
  97450. visibleInstances: any;
  97451. batchCache: _InstancesBatch;
  97452. instancesBufferSize: number;
  97453. instancesBuffer: Nullable<Buffer>;
  97454. instancesData: Float32Array;
  97455. overridenInstanceCount: number;
  97456. isFrozen: boolean;
  97457. previousBatch: Nullable<_InstancesBatch>;
  97458. hardwareInstancedRendering: boolean;
  97459. sideOrientation: number;
  97460. manualUpdate: boolean;
  97461. }
  97462. /**
  97463. * @hidden
  97464. **/
  97465. export class _InstancesBatch {
  97466. mustReturn: boolean;
  97467. visibleInstances: Nullable<InstancedMesh[]>[];
  97468. renderSelf: boolean[];
  97469. hardwareInstancedRendering: boolean[];
  97470. }
  97471. /**
  97472. * Class used to represent renderable models
  97473. */
  97474. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  97475. /**
  97476. * Mesh side orientation : usually the external or front surface
  97477. */
  97478. static readonly FRONTSIDE: number;
  97479. /**
  97480. * Mesh side orientation : usually the internal or back surface
  97481. */
  97482. static readonly BACKSIDE: number;
  97483. /**
  97484. * Mesh side orientation : both internal and external or front and back surfaces
  97485. */
  97486. static readonly DOUBLESIDE: number;
  97487. /**
  97488. * Mesh side orientation : by default, `FRONTSIDE`
  97489. */
  97490. static readonly DEFAULTSIDE: number;
  97491. /**
  97492. * Mesh cap setting : no cap
  97493. */
  97494. static readonly NO_CAP: number;
  97495. /**
  97496. * Mesh cap setting : one cap at the beginning of the mesh
  97497. */
  97498. static readonly CAP_START: number;
  97499. /**
  97500. * Mesh cap setting : one cap at the end of the mesh
  97501. */
  97502. static readonly CAP_END: number;
  97503. /**
  97504. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  97505. */
  97506. static readonly CAP_ALL: number;
  97507. /**
  97508. * Mesh pattern setting : no flip or rotate
  97509. */
  97510. static readonly NO_FLIP: number;
  97511. /**
  97512. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  97513. */
  97514. static readonly FLIP_TILE: number;
  97515. /**
  97516. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  97517. */
  97518. static readonly ROTATE_TILE: number;
  97519. /**
  97520. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  97521. */
  97522. static readonly FLIP_ROW: number;
  97523. /**
  97524. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  97525. */
  97526. static readonly ROTATE_ROW: number;
  97527. /**
  97528. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  97529. */
  97530. static readonly FLIP_N_ROTATE_TILE: number;
  97531. /**
  97532. * Mesh pattern setting : rotate pattern and rotate
  97533. */
  97534. static readonly FLIP_N_ROTATE_ROW: number;
  97535. /**
  97536. * Mesh tile positioning : part tiles same on left/right or top/bottom
  97537. */
  97538. static readonly CENTER: number;
  97539. /**
  97540. * Mesh tile positioning : part tiles on left
  97541. */
  97542. static readonly LEFT: number;
  97543. /**
  97544. * Mesh tile positioning : part tiles on right
  97545. */
  97546. static readonly RIGHT: number;
  97547. /**
  97548. * Mesh tile positioning : part tiles on top
  97549. */
  97550. static readonly TOP: number;
  97551. /**
  97552. * Mesh tile positioning : part tiles on bottom
  97553. */
  97554. static readonly BOTTOM: number;
  97555. /**
  97556. * Gets the default side orientation.
  97557. * @param orientation the orientation to value to attempt to get
  97558. * @returns the default orientation
  97559. * @hidden
  97560. */
  97561. static _GetDefaultSideOrientation(orientation?: number): number;
  97562. private _internalMeshDataInfo;
  97563. /**
  97564. * An event triggered before rendering the mesh
  97565. */
  97566. get onBeforeRenderObservable(): Observable<Mesh>;
  97567. /**
  97568. * An event triggered before binding the mesh
  97569. */
  97570. get onBeforeBindObservable(): Observable<Mesh>;
  97571. /**
  97572. * An event triggered after rendering the mesh
  97573. */
  97574. get onAfterRenderObservable(): Observable<Mesh>;
  97575. /**
  97576. * An event triggered before drawing the mesh
  97577. */
  97578. get onBeforeDrawObservable(): Observable<Mesh>;
  97579. private _onBeforeDrawObserver;
  97580. /**
  97581. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  97582. */
  97583. set onBeforeDraw(callback: () => void);
  97584. get hasInstances(): boolean;
  97585. /**
  97586. * Gets the delay loading state of the mesh (when delay loading is turned on)
  97587. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  97588. */
  97589. delayLoadState: number;
  97590. /**
  97591. * Gets the list of instances created from this mesh
  97592. * it is not supposed to be modified manually.
  97593. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  97594. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  97595. */
  97596. instances: InstancedMesh[];
  97597. /**
  97598. * Gets the file containing delay loading data for this mesh
  97599. */
  97600. delayLoadingFile: string;
  97601. /** @hidden */
  97602. _binaryInfo: any;
  97603. /**
  97604. * User defined function used to change how LOD level selection is done
  97605. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  97606. */
  97607. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  97608. /**
  97609. * Gets or sets the morph target manager
  97610. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  97611. */
  97612. get morphTargetManager(): Nullable<MorphTargetManager>;
  97613. set morphTargetManager(value: Nullable<MorphTargetManager>);
  97614. /** @hidden */
  97615. _creationDataStorage: Nullable<_CreationDataStorage>;
  97616. /** @hidden */
  97617. _geometry: Nullable<Geometry>;
  97618. /** @hidden */
  97619. _delayInfo: Array<string>;
  97620. /** @hidden */
  97621. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  97622. /** @hidden */
  97623. _instanceDataStorage: _InstanceDataStorage;
  97624. private _effectiveMaterial;
  97625. /** @hidden */
  97626. _shouldGenerateFlatShading: boolean;
  97627. /** @hidden */
  97628. _originalBuilderSideOrientation: number;
  97629. /**
  97630. * Use this property to change the original side orientation defined at construction time
  97631. */
  97632. overrideMaterialSideOrientation: Nullable<number>;
  97633. /**
  97634. * Gets the source mesh (the one used to clone this one from)
  97635. */
  97636. get source(): Nullable<Mesh>;
  97637. /**
  97638. * Gets or sets a boolean indicating that this mesh does not use index buffer
  97639. */
  97640. get isUnIndexed(): boolean;
  97641. set isUnIndexed(value: boolean);
  97642. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  97643. get worldMatrixInstancedBuffer(): Float32Array;
  97644. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  97645. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  97646. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  97647. /**
  97648. * @constructor
  97649. * @param name The value used by scene.getMeshByName() to do a lookup.
  97650. * @param scene The scene to add this mesh to.
  97651. * @param parent The parent of this mesh, if it has one
  97652. * @param source An optional Mesh from which geometry is shared, cloned.
  97653. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  97654. * When false, achieved by calling a clone(), also passing False.
  97655. * This will make creation of children, recursive.
  97656. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  97657. */
  97658. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  97659. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  97660. doNotInstantiate: boolean;
  97661. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  97662. /**
  97663. * Gets the class name
  97664. * @returns the string "Mesh".
  97665. */
  97666. getClassName(): string;
  97667. /** @hidden */
  97668. get _isMesh(): boolean;
  97669. /**
  97670. * Returns a description of this mesh
  97671. * @param fullDetails define if full details about this mesh must be used
  97672. * @returns a descriptive string representing this mesh
  97673. */
  97674. toString(fullDetails?: boolean): string;
  97675. /** @hidden */
  97676. _unBindEffect(): void;
  97677. /**
  97678. * Gets a boolean indicating if this mesh has LOD
  97679. */
  97680. get hasLODLevels(): boolean;
  97681. /**
  97682. * Gets the list of MeshLODLevel associated with the current mesh
  97683. * @returns an array of MeshLODLevel
  97684. */
  97685. getLODLevels(): MeshLODLevel[];
  97686. private _sortLODLevels;
  97687. /**
  97688. * Add a mesh as LOD level triggered at the given distance.
  97689. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97690. * @param distance The distance from the center of the object to show this level
  97691. * @param mesh The mesh to be added as LOD level (can be null)
  97692. * @return This mesh (for chaining)
  97693. */
  97694. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  97695. /**
  97696. * Returns the LOD level mesh at the passed distance or null if not found.
  97697. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97698. * @param distance The distance from the center of the object to show this level
  97699. * @returns a Mesh or `null`
  97700. */
  97701. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  97702. /**
  97703. * Remove a mesh from the LOD array
  97704. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97705. * @param mesh defines the mesh to be removed
  97706. * @return This mesh (for chaining)
  97707. */
  97708. removeLODLevel(mesh: Mesh): Mesh;
  97709. /**
  97710. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  97711. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97712. * @param camera defines the camera to use to compute distance
  97713. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  97714. * @return This mesh (for chaining)
  97715. */
  97716. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  97717. /**
  97718. * Gets the mesh internal Geometry object
  97719. */
  97720. get geometry(): Nullable<Geometry>;
  97721. /**
  97722. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  97723. * @returns the total number of vertices
  97724. */
  97725. getTotalVertices(): number;
  97726. /**
  97727. * Returns the content of an associated vertex buffer
  97728. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  97729. * - VertexBuffer.PositionKind
  97730. * - VertexBuffer.UVKind
  97731. * - VertexBuffer.UV2Kind
  97732. * - VertexBuffer.UV3Kind
  97733. * - VertexBuffer.UV4Kind
  97734. * - VertexBuffer.UV5Kind
  97735. * - VertexBuffer.UV6Kind
  97736. * - VertexBuffer.ColorKind
  97737. * - VertexBuffer.MatricesIndicesKind
  97738. * - VertexBuffer.MatricesIndicesExtraKind
  97739. * - VertexBuffer.MatricesWeightsKind
  97740. * - VertexBuffer.MatricesWeightsExtraKind
  97741. * @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
  97742. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  97743. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  97744. */
  97745. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  97746. /**
  97747. * Returns the mesh VertexBuffer object from the requested `kind`
  97748. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  97749. * - VertexBuffer.PositionKind
  97750. * - VertexBuffer.NormalKind
  97751. * - VertexBuffer.UVKind
  97752. * - VertexBuffer.UV2Kind
  97753. * - VertexBuffer.UV3Kind
  97754. * - VertexBuffer.UV4Kind
  97755. * - VertexBuffer.UV5Kind
  97756. * - VertexBuffer.UV6Kind
  97757. * - VertexBuffer.ColorKind
  97758. * - VertexBuffer.MatricesIndicesKind
  97759. * - VertexBuffer.MatricesIndicesExtraKind
  97760. * - VertexBuffer.MatricesWeightsKind
  97761. * - VertexBuffer.MatricesWeightsExtraKind
  97762. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  97763. */
  97764. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  97765. /**
  97766. * Tests if a specific vertex buffer is associated with this mesh
  97767. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  97768. * - VertexBuffer.PositionKind
  97769. * - VertexBuffer.NormalKind
  97770. * - VertexBuffer.UVKind
  97771. * - VertexBuffer.UV2Kind
  97772. * - VertexBuffer.UV3Kind
  97773. * - VertexBuffer.UV4Kind
  97774. * - VertexBuffer.UV5Kind
  97775. * - VertexBuffer.UV6Kind
  97776. * - VertexBuffer.ColorKind
  97777. * - VertexBuffer.MatricesIndicesKind
  97778. * - VertexBuffer.MatricesIndicesExtraKind
  97779. * - VertexBuffer.MatricesWeightsKind
  97780. * - VertexBuffer.MatricesWeightsExtraKind
  97781. * @returns a boolean
  97782. */
  97783. isVerticesDataPresent(kind: string): boolean;
  97784. /**
  97785. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  97786. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  97787. * - VertexBuffer.PositionKind
  97788. * - VertexBuffer.UVKind
  97789. * - VertexBuffer.UV2Kind
  97790. * - VertexBuffer.UV3Kind
  97791. * - VertexBuffer.UV4Kind
  97792. * - VertexBuffer.UV5Kind
  97793. * - VertexBuffer.UV6Kind
  97794. * - VertexBuffer.ColorKind
  97795. * - VertexBuffer.MatricesIndicesKind
  97796. * - VertexBuffer.MatricesIndicesExtraKind
  97797. * - VertexBuffer.MatricesWeightsKind
  97798. * - VertexBuffer.MatricesWeightsExtraKind
  97799. * @returns a boolean
  97800. */
  97801. isVertexBufferUpdatable(kind: string): boolean;
  97802. /**
  97803. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  97804. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  97805. * - VertexBuffer.PositionKind
  97806. * - VertexBuffer.NormalKind
  97807. * - VertexBuffer.UVKind
  97808. * - VertexBuffer.UV2Kind
  97809. * - VertexBuffer.UV3Kind
  97810. * - VertexBuffer.UV4Kind
  97811. * - VertexBuffer.UV5Kind
  97812. * - VertexBuffer.UV6Kind
  97813. * - VertexBuffer.ColorKind
  97814. * - VertexBuffer.MatricesIndicesKind
  97815. * - VertexBuffer.MatricesIndicesExtraKind
  97816. * - VertexBuffer.MatricesWeightsKind
  97817. * - VertexBuffer.MatricesWeightsExtraKind
  97818. * @returns an array of strings
  97819. */
  97820. getVerticesDataKinds(): string[];
  97821. /**
  97822. * Returns a positive integer : the total number of indices in this mesh geometry.
  97823. * @returns the numner of indices or zero if the mesh has no geometry.
  97824. */
  97825. getTotalIndices(): number;
  97826. /**
  97827. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  97828. * @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.
  97829. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  97830. * @returns the indices array or an empty array if the mesh has no geometry
  97831. */
  97832. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  97833. get isBlocked(): boolean;
  97834. /**
  97835. * Determine if the current mesh is ready to be rendered
  97836. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  97837. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  97838. * @returns true if all associated assets are ready (material, textures, shaders)
  97839. */
  97840. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  97841. /**
  97842. * 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.
  97843. */
  97844. get areNormalsFrozen(): boolean;
  97845. /**
  97846. * 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.
  97847. * @returns the current mesh
  97848. */
  97849. freezeNormals(): Mesh;
  97850. /**
  97851. * 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
  97852. * @returns the current mesh
  97853. */
  97854. unfreezeNormals(): Mesh;
  97855. /**
  97856. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  97857. */
  97858. set overridenInstanceCount(count: number);
  97859. /** @hidden */
  97860. _preActivate(): Mesh;
  97861. /** @hidden */
  97862. _preActivateForIntermediateRendering(renderId: number): Mesh;
  97863. /** @hidden */
  97864. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  97865. /**
  97866. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  97867. * This means the mesh underlying bounding box and sphere are recomputed.
  97868. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  97869. * @returns the current mesh
  97870. */
  97871. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  97872. /** @hidden */
  97873. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  97874. /**
  97875. * This function will subdivide the mesh into multiple submeshes
  97876. * @param count defines the expected number of submeshes
  97877. */
  97878. subdivide(count: number): void;
  97879. /**
  97880. * Copy a FloatArray into a specific associated vertex buffer
  97881. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  97882. * - VertexBuffer.PositionKind
  97883. * - VertexBuffer.UVKind
  97884. * - VertexBuffer.UV2Kind
  97885. * - VertexBuffer.UV3Kind
  97886. * - VertexBuffer.UV4Kind
  97887. * - VertexBuffer.UV5Kind
  97888. * - VertexBuffer.UV6Kind
  97889. * - VertexBuffer.ColorKind
  97890. * - VertexBuffer.MatricesIndicesKind
  97891. * - VertexBuffer.MatricesIndicesExtraKind
  97892. * - VertexBuffer.MatricesWeightsKind
  97893. * - VertexBuffer.MatricesWeightsExtraKind
  97894. * @param data defines the data source
  97895. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  97896. * @param stride defines the data stride size (can be null)
  97897. * @returns the current mesh
  97898. */
  97899. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  97900. /**
  97901. * Delete a vertex buffer associated with this mesh
  97902. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  97903. * - VertexBuffer.PositionKind
  97904. * - VertexBuffer.UVKind
  97905. * - VertexBuffer.UV2Kind
  97906. * - VertexBuffer.UV3Kind
  97907. * - VertexBuffer.UV4Kind
  97908. * - VertexBuffer.UV5Kind
  97909. * - VertexBuffer.UV6Kind
  97910. * - VertexBuffer.ColorKind
  97911. * - VertexBuffer.MatricesIndicesKind
  97912. * - VertexBuffer.MatricesIndicesExtraKind
  97913. * - VertexBuffer.MatricesWeightsKind
  97914. * - VertexBuffer.MatricesWeightsExtraKind
  97915. */
  97916. removeVerticesData(kind: string): void;
  97917. /**
  97918. * Flags an associated vertex buffer as updatable
  97919. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  97920. * - VertexBuffer.PositionKind
  97921. * - VertexBuffer.UVKind
  97922. * - VertexBuffer.UV2Kind
  97923. * - VertexBuffer.UV3Kind
  97924. * - VertexBuffer.UV4Kind
  97925. * - VertexBuffer.UV5Kind
  97926. * - VertexBuffer.UV6Kind
  97927. * - VertexBuffer.ColorKind
  97928. * - VertexBuffer.MatricesIndicesKind
  97929. * - VertexBuffer.MatricesIndicesExtraKind
  97930. * - VertexBuffer.MatricesWeightsKind
  97931. * - VertexBuffer.MatricesWeightsExtraKind
  97932. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  97933. */
  97934. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  97935. /**
  97936. * Sets the mesh global Vertex Buffer
  97937. * @param buffer defines the buffer to use
  97938. * @returns the current mesh
  97939. */
  97940. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  97941. /**
  97942. * Update a specific associated vertex buffer
  97943. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  97944. * - VertexBuffer.PositionKind
  97945. * - VertexBuffer.UVKind
  97946. * - VertexBuffer.UV2Kind
  97947. * - VertexBuffer.UV3Kind
  97948. * - VertexBuffer.UV4Kind
  97949. * - VertexBuffer.UV5Kind
  97950. * - VertexBuffer.UV6Kind
  97951. * - VertexBuffer.ColorKind
  97952. * - VertexBuffer.MatricesIndicesKind
  97953. * - VertexBuffer.MatricesIndicesExtraKind
  97954. * - VertexBuffer.MatricesWeightsKind
  97955. * - VertexBuffer.MatricesWeightsExtraKind
  97956. * @param data defines the data source
  97957. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  97958. * @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)
  97959. * @returns the current mesh
  97960. */
  97961. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  97962. /**
  97963. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  97964. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  97965. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  97966. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  97967. * @returns the current mesh
  97968. */
  97969. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  97970. /**
  97971. * Creates a un-shared specific occurence of the geometry for the mesh.
  97972. * @returns the current mesh
  97973. */
  97974. makeGeometryUnique(): Mesh;
  97975. /**
  97976. * Set the index buffer of this mesh
  97977. * @param indices defines the source data
  97978. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  97979. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  97980. * @returns the current mesh
  97981. */
  97982. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  97983. /**
  97984. * Update the current index buffer
  97985. * @param indices defines the source data
  97986. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  97987. * @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)
  97988. * @returns the current mesh
  97989. */
  97990. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  97991. /**
  97992. * Invert the geometry to move from a right handed system to a left handed one.
  97993. * @returns the current mesh
  97994. */
  97995. toLeftHanded(): Mesh;
  97996. /** @hidden */
  97997. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  97998. /** @hidden */
  97999. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  98000. /**
  98001. * Registers for this mesh a javascript function called just before the rendering process
  98002. * @param func defines the function to call before rendering this mesh
  98003. * @returns the current mesh
  98004. */
  98005. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  98006. /**
  98007. * Disposes a previously registered javascript function called before the rendering
  98008. * @param func defines the function to remove
  98009. * @returns the current mesh
  98010. */
  98011. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  98012. /**
  98013. * Registers for this mesh a javascript function called just after the rendering is complete
  98014. * @param func defines the function to call after rendering this mesh
  98015. * @returns the current mesh
  98016. */
  98017. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  98018. /**
  98019. * Disposes a previously registered javascript function called after the rendering.
  98020. * @param func defines the function to remove
  98021. * @returns the current mesh
  98022. */
  98023. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  98024. /** @hidden */
  98025. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  98026. /** @hidden */
  98027. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  98028. /** @hidden */
  98029. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  98030. /** @hidden */
  98031. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  98032. /** @hidden */
  98033. _rebuild(): void;
  98034. /** @hidden */
  98035. _freeze(): void;
  98036. /** @hidden */
  98037. _unFreeze(): void;
  98038. /**
  98039. * 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
  98040. * @param subMesh defines the subMesh to render
  98041. * @param enableAlphaMode defines if alpha mode can be changed
  98042. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  98043. * @returns the current mesh
  98044. */
  98045. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  98046. private _onBeforeDraw;
  98047. /**
  98048. * Renormalize the mesh and patch it up if there are no weights
  98049. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  98050. * However in the case of zero weights then we set just a single influence to 1.
  98051. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  98052. */
  98053. cleanMatrixWeights(): void;
  98054. private normalizeSkinFourWeights;
  98055. private normalizeSkinWeightsAndExtra;
  98056. /**
  98057. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  98058. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  98059. * the user know there was an issue with importing the mesh
  98060. * @returns a validation object with skinned, valid and report string
  98061. */
  98062. validateSkinning(): {
  98063. skinned: boolean;
  98064. valid: boolean;
  98065. report: string;
  98066. };
  98067. /** @hidden */
  98068. _checkDelayState(): Mesh;
  98069. private _queueLoad;
  98070. /**
  98071. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  98072. * A mesh is in the frustum if its bounding box intersects the frustum
  98073. * @param frustumPlanes defines the frustum to test
  98074. * @returns true if the mesh is in the frustum planes
  98075. */
  98076. isInFrustum(frustumPlanes: Plane[]): boolean;
  98077. /**
  98078. * Sets the mesh material by the material or multiMaterial `id` property
  98079. * @param id is a string identifying the material or the multiMaterial
  98080. * @returns the current mesh
  98081. */
  98082. setMaterialByID(id: string): Mesh;
  98083. /**
  98084. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  98085. * @returns an array of IAnimatable
  98086. */
  98087. getAnimatables(): IAnimatable[];
  98088. /**
  98089. * Modifies the mesh geometry according to the passed transformation matrix.
  98090. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  98091. * The mesh normals are modified using the same transformation.
  98092. * Note that, under the hood, this method sets a new VertexBuffer each call.
  98093. * @param transform defines the transform matrix to use
  98094. * @see http://doc.babylonjs.com/resources/baking_transformations
  98095. * @returns the current mesh
  98096. */
  98097. bakeTransformIntoVertices(transform: Matrix): Mesh;
  98098. /**
  98099. * Modifies the mesh geometry according to its own current World Matrix.
  98100. * The mesh World Matrix is then reset.
  98101. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  98102. * Note that, under the hood, this method sets a new VertexBuffer each call.
  98103. * @see http://doc.babylonjs.com/resources/baking_transformations
  98104. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  98105. * @returns the current mesh
  98106. */
  98107. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  98108. /** @hidden */
  98109. get _positions(): Nullable<Vector3[]>;
  98110. /** @hidden */
  98111. _resetPointsArrayCache(): Mesh;
  98112. /** @hidden */
  98113. _generatePointsArray(): boolean;
  98114. /**
  98115. * Returns a new Mesh object generated from the current mesh properties.
  98116. * This method must not get confused with createInstance()
  98117. * @param name is a string, the name given to the new mesh
  98118. * @param newParent can be any Node object (default `null`)
  98119. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  98120. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  98121. * @returns a new mesh
  98122. */
  98123. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  98124. /**
  98125. * Releases resources associated with this mesh.
  98126. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  98127. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  98128. */
  98129. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  98130. /** @hidden */
  98131. _disposeInstanceSpecificData(): void;
  98132. /**
  98133. * Modifies the mesh geometry according to a displacement map.
  98134. * 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.
  98135. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  98136. * @param url is a string, the URL from the image file is to be downloaded.
  98137. * @param minHeight is the lower limit of the displacement.
  98138. * @param maxHeight is the upper limit of the displacement.
  98139. * @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.
  98140. * @param uvOffset is an optional vector2 used to offset UV.
  98141. * @param uvScale is an optional vector2 used to scale UV.
  98142. * @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.
  98143. * @returns the Mesh.
  98144. */
  98145. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  98146. /**
  98147. * Modifies the mesh geometry according to a displacementMap buffer.
  98148. * 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.
  98149. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  98150. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  98151. * @param heightMapWidth is the width of the buffer image.
  98152. * @param heightMapHeight is the height of the buffer image.
  98153. * @param minHeight is the lower limit of the displacement.
  98154. * @param maxHeight is the upper limit of the displacement.
  98155. * @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.
  98156. * @param uvOffset is an optional vector2 used to offset UV.
  98157. * @param uvScale is an optional vector2 used to scale UV.
  98158. * @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.
  98159. * @returns the Mesh.
  98160. */
  98161. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  98162. /**
  98163. * Modify the mesh to get a flat shading rendering.
  98164. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  98165. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  98166. * @returns current mesh
  98167. */
  98168. convertToFlatShadedMesh(): Mesh;
  98169. /**
  98170. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  98171. * In other words, more vertices, no more indices and a single bigger VBO.
  98172. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  98173. * @returns current mesh
  98174. */
  98175. convertToUnIndexedMesh(): Mesh;
  98176. /**
  98177. * Inverses facet orientations.
  98178. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  98179. * @param flipNormals will also inverts the normals
  98180. * @returns current mesh
  98181. */
  98182. flipFaces(flipNormals?: boolean): Mesh;
  98183. /**
  98184. * Increase the number of facets and hence vertices in a mesh
  98185. * Vertex normals are interpolated from existing vertex normals
  98186. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  98187. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  98188. */
  98189. increaseVertices(numberPerEdge: number): void;
  98190. /**
  98191. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  98192. * This will undo any application of covertToFlatShadedMesh
  98193. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  98194. */
  98195. forceSharedVertices(): void;
  98196. /** @hidden */
  98197. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  98198. /** @hidden */
  98199. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  98200. /**
  98201. * Creates a new InstancedMesh object from the mesh model.
  98202. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  98203. * @param name defines the name of the new instance
  98204. * @returns a new InstancedMesh
  98205. */
  98206. createInstance(name: string): InstancedMesh;
  98207. /**
  98208. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  98209. * After this call, all the mesh instances have the same submeshes than the current mesh.
  98210. * @returns the current mesh
  98211. */
  98212. synchronizeInstances(): Mesh;
  98213. /**
  98214. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  98215. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  98216. * This should be used together with the simplification to avoid disappearing triangles.
  98217. * @param successCallback an optional success callback to be called after the optimization finished.
  98218. * @returns the current mesh
  98219. */
  98220. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  98221. /**
  98222. * Serialize current mesh
  98223. * @param serializationObject defines the object which will receive the serialization data
  98224. */
  98225. serialize(serializationObject: any): void;
  98226. /** @hidden */
  98227. _syncGeometryWithMorphTargetManager(): void;
  98228. /** @hidden */
  98229. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  98230. /**
  98231. * Returns a new Mesh object parsed from the source provided.
  98232. * @param parsedMesh is the source
  98233. * @param scene defines the hosting scene
  98234. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  98235. * @returns a new Mesh
  98236. */
  98237. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  98238. /**
  98239. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  98240. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  98241. * @param name defines the name of the mesh to create
  98242. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  98243. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  98244. * @param closePath creates a seam between the first and the last points of each path of the path array
  98245. * @param offset is taken in account only if the `pathArray` is containing a single path
  98246. * @param scene defines the hosting scene
  98247. * @param updatable defines if the mesh must be flagged as updatable
  98248. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98249. * @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)
  98250. * @returns a new Mesh
  98251. */
  98252. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  98253. /**
  98254. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  98255. * @param name defines the name of the mesh to create
  98256. * @param radius sets the radius size (float) of the polygon (default 0.5)
  98257. * @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
  98258. * @param scene defines the hosting scene
  98259. * @param updatable defines if the mesh must be flagged as updatable
  98260. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98261. * @returns a new Mesh
  98262. */
  98263. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  98264. /**
  98265. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  98266. * @param name defines the name of the mesh to create
  98267. * @param size sets the size (float) of each box side (default 1)
  98268. * @param scene defines the hosting scene
  98269. * @param updatable defines if the mesh must be flagged as updatable
  98270. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98271. * @returns a new Mesh
  98272. */
  98273. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  98274. /**
  98275. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  98276. * @param name defines the name of the mesh to create
  98277. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  98278. * @param diameter sets the diameter size (float) of the sphere (default 1)
  98279. * @param scene defines the hosting scene
  98280. * @param updatable defines if the mesh must be flagged as updatable
  98281. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98282. * @returns a new Mesh
  98283. */
  98284. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98285. /**
  98286. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  98287. * @param name defines the name of the mesh to create
  98288. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  98289. * @param diameter sets the diameter size (float) of the sphere (default 1)
  98290. * @param scene defines the hosting scene
  98291. * @returns a new Mesh
  98292. */
  98293. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  98294. /**
  98295. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  98296. * @param name defines the name of the mesh to create
  98297. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  98298. * @param diameterTop set the top cap diameter (floats, default 1)
  98299. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  98300. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  98301. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  98302. * @param scene defines the hosting scene
  98303. * @param updatable defines if the mesh must be flagged as updatable
  98304. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98305. * @returns a new Mesh
  98306. */
  98307. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  98308. /**
  98309. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  98310. * @param name defines the name of the mesh to create
  98311. * @param diameter sets the diameter size (float) of the torus (default 1)
  98312. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  98313. * @param tessellation sets the number of torus sides (postive integer, default 16)
  98314. * @param scene defines the hosting scene
  98315. * @param updatable defines if the mesh must be flagged as updatable
  98316. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98317. * @returns a new Mesh
  98318. */
  98319. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98320. /**
  98321. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  98322. * @param name defines the name of the mesh to create
  98323. * @param radius sets the global radius size (float) of the torus knot (default 2)
  98324. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  98325. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  98326. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  98327. * @param p the number of windings on X axis (positive integers, default 2)
  98328. * @param q the number of windings on Y axis (positive integers, default 3)
  98329. * @param scene defines the hosting scene
  98330. * @param updatable defines if the mesh must be flagged as updatable
  98331. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98332. * @returns a new Mesh
  98333. */
  98334. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98335. /**
  98336. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  98337. * @param name defines the name of the mesh to create
  98338. * @param points is an array successive Vector3
  98339. * @param scene defines the hosting scene
  98340. * @param updatable defines if the mesh must be flagged as updatable
  98341. * @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).
  98342. * @returns a new Mesh
  98343. */
  98344. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  98345. /**
  98346. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  98347. * @param name defines the name of the mesh to create
  98348. * @param points is an array successive Vector3
  98349. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  98350. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  98351. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  98352. * @param scene defines the hosting scene
  98353. * @param updatable defines if the mesh must be flagged as updatable
  98354. * @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)
  98355. * @returns a new Mesh
  98356. */
  98357. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  98358. /**
  98359. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  98360. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  98361. * 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.
  98362. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98363. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98364. * Remember you can only change the shape positions, not their number when updating a polygon.
  98365. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  98366. * @param name defines the name of the mesh to create
  98367. * @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
  98368. * @param scene defines the hosting scene
  98369. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  98370. * @param updatable defines if the mesh must be flagged as updatable
  98371. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98372. * @param earcutInjection can be used to inject your own earcut reference
  98373. * @returns a new Mesh
  98374. */
  98375. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  98376. /**
  98377. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  98378. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  98379. * @param name defines the name of the mesh to create
  98380. * @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
  98381. * @param depth defines the height of extrusion
  98382. * @param scene defines the hosting scene
  98383. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  98384. * @param updatable defines if the mesh must be flagged as updatable
  98385. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98386. * @param earcutInjection can be used to inject your own earcut reference
  98387. * @returns a new Mesh
  98388. */
  98389. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  98390. /**
  98391. * Creates an extruded shape mesh.
  98392. * 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
  98393. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  98394. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  98395. * @param name defines the name of the mesh to create
  98396. * @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
  98397. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  98398. * @param scale is the value to scale the shape
  98399. * @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
  98400. * @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
  98401. * @param scene defines the hosting scene
  98402. * @param updatable defines if the mesh must be flagged as updatable
  98403. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98404. * @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)
  98405. * @returns a new Mesh
  98406. */
  98407. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  98408. /**
  98409. * Creates an custom extruded shape mesh.
  98410. * The custom extrusion is a parametric shape.
  98411. * It has no predefined shape. Its final shape will depend on the input parameters.
  98412. * Please consider using the same method from the MeshBuilder class instead
  98413. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  98414. * @param name defines the name of the mesh to create
  98415. * @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
  98416. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  98417. * @param scaleFunction is a custom Javascript function called on each path point
  98418. * @param rotationFunction is a custom Javascript function called on each path point
  98419. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  98420. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  98421. * @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
  98422. * @param scene defines the hosting scene
  98423. * @param updatable defines if the mesh must be flagged as updatable
  98424. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98425. * @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)
  98426. * @returns a new Mesh
  98427. */
  98428. 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;
  98429. /**
  98430. * Creates lathe mesh.
  98431. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  98432. * Please consider using the same method from the MeshBuilder class instead
  98433. * @param name defines the name of the mesh to create
  98434. * @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
  98435. * @param radius is the radius value of the lathe
  98436. * @param tessellation is the side number of the lathe.
  98437. * @param scene defines the hosting scene
  98438. * @param updatable defines if the mesh must be flagged as updatable
  98439. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98440. * @returns a new Mesh
  98441. */
  98442. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98443. /**
  98444. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  98445. * @param name defines the name of the mesh to create
  98446. * @param size sets the size (float) of both sides of the plane at once (default 1)
  98447. * @param scene defines the hosting scene
  98448. * @param updatable defines if the mesh must be flagged as updatable
  98449. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98450. * @returns a new Mesh
  98451. */
  98452. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98453. /**
  98454. * Creates a ground mesh.
  98455. * Please consider using the same method from the MeshBuilder class instead
  98456. * @param name defines the name of the mesh to create
  98457. * @param width set the width of the ground
  98458. * @param height set the height of the ground
  98459. * @param subdivisions sets the number of subdivisions per side
  98460. * @param scene defines the hosting scene
  98461. * @param updatable defines if the mesh must be flagged as updatable
  98462. * @returns a new Mesh
  98463. */
  98464. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  98465. /**
  98466. * Creates a tiled ground mesh.
  98467. * Please consider using the same method from the MeshBuilder class instead
  98468. * @param name defines the name of the mesh to create
  98469. * @param xmin set the ground minimum X coordinate
  98470. * @param zmin set the ground minimum Y coordinate
  98471. * @param xmax set the ground maximum X coordinate
  98472. * @param zmax set the ground maximum Z coordinate
  98473. * @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
  98474. * @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
  98475. * @param scene defines the hosting scene
  98476. * @param updatable defines if the mesh must be flagged as updatable
  98477. * @returns a new Mesh
  98478. */
  98479. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  98480. w: number;
  98481. h: number;
  98482. }, precision: {
  98483. w: number;
  98484. h: number;
  98485. }, scene: Scene, updatable?: boolean): Mesh;
  98486. /**
  98487. * Creates a ground mesh from a height map.
  98488. * Please consider using the same method from the MeshBuilder class instead
  98489. * @see http://doc.babylonjs.com/babylon101/height_map
  98490. * @param name defines the name of the mesh to create
  98491. * @param url sets the URL of the height map image resource
  98492. * @param width set the ground width size
  98493. * @param height set the ground height size
  98494. * @param subdivisions sets the number of subdivision per side
  98495. * @param minHeight is the minimum altitude on the ground
  98496. * @param maxHeight is the maximum altitude on the ground
  98497. * @param scene defines the hosting scene
  98498. * @param updatable defines if the mesh must be flagged as updatable
  98499. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  98500. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  98501. * @returns a new Mesh
  98502. */
  98503. 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;
  98504. /**
  98505. * Creates a tube mesh.
  98506. * The tube is a parametric shape.
  98507. * It has no predefined shape. Its final shape will depend on the input parameters.
  98508. * Please consider using the same method from the MeshBuilder class instead
  98509. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  98510. * @param name defines the name of the mesh to create
  98511. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  98512. * @param radius sets the tube radius size
  98513. * @param tessellation is the number of sides on the tubular surface
  98514. * @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
  98515. * @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
  98516. * @param scene defines the hosting scene
  98517. * @param updatable defines if the mesh must be flagged as updatable
  98518. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98519. * @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)
  98520. * @returns a new Mesh
  98521. */
  98522. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  98523. (i: number, distance: number): number;
  98524. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  98525. /**
  98526. * Creates a polyhedron mesh.
  98527. * Please consider using the same method from the MeshBuilder class instead.
  98528. * * 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
  98529. * * The parameter `size` (positive float, default 1) sets the polygon size
  98530. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  98531. * * 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`
  98532. * * 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
  98533. * * 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)`)
  98534. * * 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
  98535. * * 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
  98536. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98537. * * If you create a double-sided mesh, you can choose what parts of 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
  98538. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98539. * @param name defines the name of the mesh to create
  98540. * @param options defines the options used to create the mesh
  98541. * @param scene defines the hosting scene
  98542. * @returns a new Mesh
  98543. */
  98544. static CreatePolyhedron(name: string, options: {
  98545. type?: number;
  98546. size?: number;
  98547. sizeX?: number;
  98548. sizeY?: number;
  98549. sizeZ?: number;
  98550. custom?: any;
  98551. faceUV?: Vector4[];
  98552. faceColors?: Color4[];
  98553. updatable?: boolean;
  98554. sideOrientation?: number;
  98555. }, scene: Scene): Mesh;
  98556. /**
  98557. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  98558. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  98559. * * 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`)
  98560. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  98561. * * 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
  98562. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98563. * * If you create a double-sided mesh, you can choose what parts of 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
  98564. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98565. * @param name defines the name of the mesh
  98566. * @param options defines the options used to create the mesh
  98567. * @param scene defines the hosting scene
  98568. * @returns a new Mesh
  98569. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  98570. */
  98571. static CreateIcoSphere(name: string, options: {
  98572. radius?: number;
  98573. flat?: boolean;
  98574. subdivisions?: number;
  98575. sideOrientation?: number;
  98576. updatable?: boolean;
  98577. }, scene: Scene): Mesh;
  98578. /**
  98579. * Creates a decal mesh.
  98580. * Please consider using the same method from the MeshBuilder class instead.
  98581. * A decal is a mesh usually applied as a model onto the surface of another mesh
  98582. * @param name defines the name of the mesh
  98583. * @param sourceMesh defines the mesh receiving the decal
  98584. * @param position sets the position of the decal in world coordinates
  98585. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  98586. * @param size sets the decal scaling
  98587. * @param angle sets the angle to rotate the decal
  98588. * @returns a new Mesh
  98589. */
  98590. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  98591. /**
  98592. * Prepare internal position array for software CPU skinning
  98593. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  98594. */
  98595. setPositionsForCPUSkinning(): Float32Array;
  98596. /**
  98597. * Prepare internal normal array for software CPU skinning
  98598. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  98599. */
  98600. setNormalsForCPUSkinning(): Float32Array;
  98601. /**
  98602. * Updates the vertex buffer by applying transformation from the bones
  98603. * @param skeleton defines the skeleton to apply to current mesh
  98604. * @returns the current mesh
  98605. */
  98606. applySkeleton(skeleton: Skeleton): Mesh;
  98607. /**
  98608. * 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
  98609. * @param meshes defines the list of meshes to scan
  98610. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  98611. */
  98612. static MinMax(meshes: AbstractMesh[]): {
  98613. min: Vector3;
  98614. max: Vector3;
  98615. };
  98616. /**
  98617. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  98618. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  98619. * @returns a vector3
  98620. */
  98621. static Center(meshesOrMinMaxVector: {
  98622. min: Vector3;
  98623. max: Vector3;
  98624. } | AbstractMesh[]): Vector3;
  98625. /**
  98626. * Merge the array of meshes into a single mesh for performance reasons.
  98627. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  98628. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  98629. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  98630. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  98631. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  98632. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  98633. * @returns a new mesh
  98634. */
  98635. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  98636. /** @hidden */
  98637. addInstance(instance: InstancedMesh): void;
  98638. /** @hidden */
  98639. removeInstance(instance: InstancedMesh): void;
  98640. }
  98641. }
  98642. declare module BABYLON {
  98643. /**
  98644. * This is the base class of all the camera used in the application.
  98645. * @see http://doc.babylonjs.com/features/cameras
  98646. */
  98647. export class Camera extends Node {
  98648. /** @hidden */
  98649. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  98650. /**
  98651. * This is the default projection mode used by the cameras.
  98652. * It helps recreating a feeling of perspective and better appreciate depth.
  98653. * This is the best way to simulate real life cameras.
  98654. */
  98655. static readonly PERSPECTIVE_CAMERA: number;
  98656. /**
  98657. * This helps creating camera with an orthographic mode.
  98658. * 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.
  98659. */
  98660. static readonly ORTHOGRAPHIC_CAMERA: number;
  98661. /**
  98662. * This is the default FOV mode for perspective cameras.
  98663. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  98664. */
  98665. static readonly FOVMODE_VERTICAL_FIXED: number;
  98666. /**
  98667. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  98668. */
  98669. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  98670. /**
  98671. * This specifies ther is no need for a camera rig.
  98672. * Basically only one eye is rendered corresponding to the camera.
  98673. */
  98674. static readonly RIG_MODE_NONE: number;
  98675. /**
  98676. * Simulates a camera Rig with one blue eye and one red eye.
  98677. * This can be use with 3d blue and red glasses.
  98678. */
  98679. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  98680. /**
  98681. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  98682. */
  98683. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  98684. /**
  98685. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  98686. */
  98687. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  98688. /**
  98689. * Defines that both eyes of the camera will be rendered over under each other.
  98690. */
  98691. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  98692. /**
  98693. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  98694. */
  98695. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  98696. /**
  98697. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  98698. */
  98699. static readonly RIG_MODE_VR: number;
  98700. /**
  98701. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  98702. */
  98703. static readonly RIG_MODE_WEBVR: number;
  98704. /**
  98705. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  98706. */
  98707. static readonly RIG_MODE_CUSTOM: number;
  98708. /**
  98709. * Defines if by default attaching controls should prevent the default javascript event to continue.
  98710. */
  98711. static ForceAttachControlToAlwaysPreventDefault: boolean;
  98712. /**
  98713. * Define the input manager associated with the camera.
  98714. */
  98715. inputs: CameraInputsManager<Camera>;
  98716. /** @hidden */
  98717. _position: Vector3;
  98718. /**
  98719. * Define the current local position of the camera in the scene
  98720. */
  98721. get position(): Vector3;
  98722. set position(newPosition: Vector3);
  98723. /**
  98724. * The vector the camera should consider as up.
  98725. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  98726. */
  98727. upVector: Vector3;
  98728. /**
  98729. * Define the current limit on the left side for an orthographic camera
  98730. * In scene unit
  98731. */
  98732. orthoLeft: Nullable<number>;
  98733. /**
  98734. * Define the current limit on the right side for an orthographic camera
  98735. * In scene unit
  98736. */
  98737. orthoRight: Nullable<number>;
  98738. /**
  98739. * Define the current limit on the bottom side for an orthographic camera
  98740. * In scene unit
  98741. */
  98742. orthoBottom: Nullable<number>;
  98743. /**
  98744. * Define the current limit on the top side for an orthographic camera
  98745. * In scene unit
  98746. */
  98747. orthoTop: Nullable<number>;
  98748. /**
  98749. * Field Of View is set in Radians. (default is 0.8)
  98750. */
  98751. fov: number;
  98752. /**
  98753. * Define the minimum distance the camera can see from.
  98754. * This is important to note that the depth buffer are not infinite and the closer it starts
  98755. * the more your scene might encounter depth fighting issue.
  98756. */
  98757. minZ: number;
  98758. /**
  98759. * Define the maximum distance the camera can see to.
  98760. * This is important to note that the depth buffer are not infinite and the further it end
  98761. * the more your scene might encounter depth fighting issue.
  98762. */
  98763. maxZ: number;
  98764. /**
  98765. * Define the default inertia of the camera.
  98766. * This helps giving a smooth feeling to the camera movement.
  98767. */
  98768. inertia: number;
  98769. /**
  98770. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  98771. */
  98772. mode: number;
  98773. /**
  98774. * Define whether the camera is intermediate.
  98775. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  98776. */
  98777. isIntermediate: boolean;
  98778. /**
  98779. * Define the viewport of the camera.
  98780. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  98781. */
  98782. viewport: Viewport;
  98783. /**
  98784. * Restricts the camera to viewing objects with the same layerMask.
  98785. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  98786. */
  98787. layerMask: number;
  98788. /**
  98789. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  98790. */
  98791. fovMode: number;
  98792. /**
  98793. * Rig mode of the camera.
  98794. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  98795. * This is normally controlled byt the camera themselves as internal use.
  98796. */
  98797. cameraRigMode: number;
  98798. /**
  98799. * Defines the distance between both "eyes" in case of a RIG
  98800. */
  98801. interaxialDistance: number;
  98802. /**
  98803. * Defines if stereoscopic rendering is done side by side or over under.
  98804. */
  98805. isStereoscopicSideBySide: boolean;
  98806. /**
  98807. * 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
  98808. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  98809. * else in the scene. (Eg. security camera)
  98810. *
  98811. * 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)
  98812. */
  98813. customRenderTargets: RenderTargetTexture[];
  98814. /**
  98815. * When set, the camera will render to this render target instead of the default canvas
  98816. *
  98817. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  98818. */
  98819. outputRenderTarget: Nullable<RenderTargetTexture>;
  98820. /**
  98821. * Observable triggered when the camera view matrix has changed.
  98822. */
  98823. onViewMatrixChangedObservable: Observable<Camera>;
  98824. /**
  98825. * Observable triggered when the camera Projection matrix has changed.
  98826. */
  98827. onProjectionMatrixChangedObservable: Observable<Camera>;
  98828. /**
  98829. * Observable triggered when the inputs have been processed.
  98830. */
  98831. onAfterCheckInputsObservable: Observable<Camera>;
  98832. /**
  98833. * Observable triggered when reset has been called and applied to the camera.
  98834. */
  98835. onRestoreStateObservable: Observable<Camera>;
  98836. /**
  98837. * Is this camera a part of a rig system?
  98838. */
  98839. isRigCamera: boolean;
  98840. /**
  98841. * If isRigCamera set to true this will be set with the parent camera.
  98842. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  98843. */
  98844. rigParent?: Camera;
  98845. /** @hidden */
  98846. _cameraRigParams: any;
  98847. /** @hidden */
  98848. _rigCameras: Camera[];
  98849. /** @hidden */
  98850. _rigPostProcess: Nullable<PostProcess>;
  98851. protected _webvrViewMatrix: Matrix;
  98852. /** @hidden */
  98853. _skipRendering: boolean;
  98854. /** @hidden */
  98855. _projectionMatrix: Matrix;
  98856. /** @hidden */
  98857. _postProcesses: Nullable<PostProcess>[];
  98858. /** @hidden */
  98859. _activeMeshes: SmartArray<AbstractMesh>;
  98860. protected _globalPosition: Vector3;
  98861. /** @hidden */
  98862. _computedViewMatrix: Matrix;
  98863. private _doNotComputeProjectionMatrix;
  98864. private _transformMatrix;
  98865. private _frustumPlanes;
  98866. private _refreshFrustumPlanes;
  98867. private _storedFov;
  98868. private _stateStored;
  98869. /**
  98870. * Instantiates a new camera object.
  98871. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  98872. * @see http://doc.babylonjs.com/features/cameras
  98873. * @param name Defines the name of the camera in the scene
  98874. * @param position Defines the position of the camera
  98875. * @param scene Defines the scene the camera belongs too
  98876. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  98877. */
  98878. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  98879. /**
  98880. * Store current camera state (fov, position, etc..)
  98881. * @returns the camera
  98882. */
  98883. storeState(): Camera;
  98884. /**
  98885. * Restores the camera state values if it has been stored. You must call storeState() first
  98886. */
  98887. protected _restoreStateValues(): boolean;
  98888. /**
  98889. * Restored camera state. You must call storeState() first.
  98890. * @returns true if restored and false otherwise
  98891. */
  98892. restoreState(): boolean;
  98893. /**
  98894. * Gets the class name of the camera.
  98895. * @returns the class name
  98896. */
  98897. getClassName(): string;
  98898. /** @hidden */
  98899. readonly _isCamera: boolean;
  98900. /**
  98901. * Gets a string representation of the camera useful for debug purpose.
  98902. * @param fullDetails Defines that a more verboe level of logging is required
  98903. * @returns the string representation
  98904. */
  98905. toString(fullDetails?: boolean): string;
  98906. /**
  98907. * Gets the current world space position of the camera.
  98908. */
  98909. get globalPosition(): Vector3;
  98910. /**
  98911. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  98912. * @returns the active meshe list
  98913. */
  98914. getActiveMeshes(): SmartArray<AbstractMesh>;
  98915. /**
  98916. * Check whether a mesh is part of the current active mesh list of the camera
  98917. * @param mesh Defines the mesh to check
  98918. * @returns true if active, false otherwise
  98919. */
  98920. isActiveMesh(mesh: Mesh): boolean;
  98921. /**
  98922. * Is this camera ready to be used/rendered
  98923. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  98924. * @return true if the camera is ready
  98925. */
  98926. isReady(completeCheck?: boolean): boolean;
  98927. /** @hidden */
  98928. _initCache(): void;
  98929. /** @hidden */
  98930. _updateCache(ignoreParentClass?: boolean): void;
  98931. /** @hidden */
  98932. _isSynchronized(): boolean;
  98933. /** @hidden */
  98934. _isSynchronizedViewMatrix(): boolean;
  98935. /** @hidden */
  98936. _isSynchronizedProjectionMatrix(): boolean;
  98937. /**
  98938. * Attach the input controls to a specific dom element to get the input from.
  98939. * @param element Defines the element the controls should be listened from
  98940. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98941. */
  98942. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98943. /**
  98944. * Detach the current controls from the specified dom element.
  98945. * @param element Defines the element to stop listening the inputs from
  98946. */
  98947. detachControl(element: HTMLElement): void;
  98948. /**
  98949. * Update the camera state according to the different inputs gathered during the frame.
  98950. */
  98951. update(): void;
  98952. /** @hidden */
  98953. _checkInputs(): void;
  98954. /** @hidden */
  98955. get rigCameras(): Camera[];
  98956. /**
  98957. * Gets the post process used by the rig cameras
  98958. */
  98959. get rigPostProcess(): Nullable<PostProcess>;
  98960. /**
  98961. * Internal, gets the first post proces.
  98962. * @returns the first post process to be run on this camera.
  98963. */
  98964. _getFirstPostProcess(): Nullable<PostProcess>;
  98965. private _cascadePostProcessesToRigCams;
  98966. /**
  98967. * Attach a post process to the camera.
  98968. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  98969. * @param postProcess The post process to attach to the camera
  98970. * @param insertAt The position of the post process in case several of them are in use in the scene
  98971. * @returns the position the post process has been inserted at
  98972. */
  98973. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  98974. /**
  98975. * Detach a post process to the camera.
  98976. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  98977. * @param postProcess The post process to detach from the camera
  98978. */
  98979. detachPostProcess(postProcess: PostProcess): void;
  98980. /**
  98981. * Gets the current world matrix of the camera
  98982. */
  98983. getWorldMatrix(): Matrix;
  98984. /** @hidden */
  98985. _getViewMatrix(): Matrix;
  98986. /**
  98987. * Gets the current view matrix of the camera.
  98988. * @param force forces the camera to recompute the matrix without looking at the cached state
  98989. * @returns the view matrix
  98990. */
  98991. getViewMatrix(force?: boolean): Matrix;
  98992. /**
  98993. * Freeze the projection matrix.
  98994. * It will prevent the cache check of the camera projection compute and can speed up perf
  98995. * if no parameter of the camera are meant to change
  98996. * @param projection Defines manually a projection if necessary
  98997. */
  98998. freezeProjectionMatrix(projection?: Matrix): void;
  98999. /**
  99000. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  99001. */
  99002. unfreezeProjectionMatrix(): void;
  99003. /**
  99004. * Gets the current projection matrix of the camera.
  99005. * @param force forces the camera to recompute the matrix without looking at the cached state
  99006. * @returns the projection matrix
  99007. */
  99008. getProjectionMatrix(force?: boolean): Matrix;
  99009. /**
  99010. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  99011. * @returns a Matrix
  99012. */
  99013. getTransformationMatrix(): Matrix;
  99014. private _updateFrustumPlanes;
  99015. /**
  99016. * Checks if a cullable object (mesh...) is in the camera frustum
  99017. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  99018. * @param target The object to check
  99019. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  99020. * @returns true if the object is in frustum otherwise false
  99021. */
  99022. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  99023. /**
  99024. * Checks if a cullable object (mesh...) is in the camera frustum
  99025. * Unlike isInFrustum this cheks the full bounding box
  99026. * @param target The object to check
  99027. * @returns true if the object is in frustum otherwise false
  99028. */
  99029. isCompletelyInFrustum(target: ICullable): boolean;
  99030. /**
  99031. * Gets a ray in the forward direction from the camera.
  99032. * @param length Defines the length of the ray to create
  99033. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  99034. * @param origin Defines the start point of the ray which defaults to the camera position
  99035. * @returns the forward ray
  99036. */
  99037. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  99038. /**
  99039. * Releases resources associated with this node.
  99040. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  99041. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  99042. */
  99043. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  99044. /** @hidden */
  99045. _isLeftCamera: boolean;
  99046. /**
  99047. * Gets the left camera of a rig setup in case of Rigged Camera
  99048. */
  99049. get isLeftCamera(): boolean;
  99050. /** @hidden */
  99051. _isRightCamera: boolean;
  99052. /**
  99053. * Gets the right camera of a rig setup in case of Rigged Camera
  99054. */
  99055. get isRightCamera(): boolean;
  99056. /**
  99057. * Gets the left camera of a rig setup in case of Rigged Camera
  99058. */
  99059. get leftCamera(): Nullable<FreeCamera>;
  99060. /**
  99061. * Gets the right camera of a rig setup in case of Rigged Camera
  99062. */
  99063. get rightCamera(): Nullable<FreeCamera>;
  99064. /**
  99065. * Gets the left camera target of a rig setup in case of Rigged Camera
  99066. * @returns the target position
  99067. */
  99068. getLeftTarget(): Nullable<Vector3>;
  99069. /**
  99070. * Gets the right camera target of a rig setup in case of Rigged Camera
  99071. * @returns the target position
  99072. */
  99073. getRightTarget(): Nullable<Vector3>;
  99074. /**
  99075. * @hidden
  99076. */
  99077. setCameraRigMode(mode: number, rigParams: any): void;
  99078. /** @hidden */
  99079. static _setStereoscopicRigMode(camera: Camera): void;
  99080. /** @hidden */
  99081. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  99082. /** @hidden */
  99083. static _setVRRigMode(camera: Camera, rigParams: any): void;
  99084. /** @hidden */
  99085. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  99086. /** @hidden */
  99087. _getVRProjectionMatrix(): Matrix;
  99088. protected _updateCameraRotationMatrix(): void;
  99089. protected _updateWebVRCameraRotationMatrix(): void;
  99090. /**
  99091. * This function MUST be overwritten by the different WebVR cameras available.
  99092. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  99093. * @hidden
  99094. */
  99095. _getWebVRProjectionMatrix(): Matrix;
  99096. /**
  99097. * This function MUST be overwritten by the different WebVR cameras available.
  99098. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  99099. * @hidden
  99100. */
  99101. _getWebVRViewMatrix(): Matrix;
  99102. /** @hidden */
  99103. setCameraRigParameter(name: string, value: any): void;
  99104. /**
  99105. * needs to be overridden by children so sub has required properties to be copied
  99106. * @hidden
  99107. */
  99108. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  99109. /**
  99110. * May need to be overridden by children
  99111. * @hidden
  99112. */
  99113. _updateRigCameras(): void;
  99114. /** @hidden */
  99115. _setupInputs(): void;
  99116. /**
  99117. * Serialiaze the camera setup to a json represention
  99118. * @returns the JSON representation
  99119. */
  99120. serialize(): any;
  99121. /**
  99122. * Clones the current camera.
  99123. * @param name The cloned camera name
  99124. * @returns the cloned camera
  99125. */
  99126. clone(name: string): Camera;
  99127. /**
  99128. * Gets the direction of the camera relative to a given local axis.
  99129. * @param localAxis Defines the reference axis to provide a relative direction.
  99130. * @return the direction
  99131. */
  99132. getDirection(localAxis: Vector3): Vector3;
  99133. /**
  99134. * Returns the current camera absolute rotation
  99135. */
  99136. get absoluteRotation(): Quaternion;
  99137. /**
  99138. * Gets the direction of the camera relative to a given local axis into a passed vector.
  99139. * @param localAxis Defines the reference axis to provide a relative direction.
  99140. * @param result Defines the vector to store the result in
  99141. */
  99142. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  99143. /**
  99144. * Gets a camera constructor for a given camera type
  99145. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  99146. * @param name The name of the camera the result will be able to instantiate
  99147. * @param scene The scene the result will construct the camera in
  99148. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  99149. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  99150. * @returns a factory method to construc the camera
  99151. */
  99152. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  99153. /**
  99154. * Compute the world matrix of the camera.
  99155. * @returns the camera world matrix
  99156. */
  99157. computeWorldMatrix(): Matrix;
  99158. /**
  99159. * Parse a JSON and creates the camera from the parsed information
  99160. * @param parsedCamera The JSON to parse
  99161. * @param scene The scene to instantiate the camera in
  99162. * @returns the newly constructed camera
  99163. */
  99164. static Parse(parsedCamera: any, scene: Scene): Camera;
  99165. }
  99166. }
  99167. declare module BABYLON {
  99168. /**
  99169. * Class containing static functions to help procedurally build meshes
  99170. */
  99171. export class DiscBuilder {
  99172. /**
  99173. * Creates a plane polygonal mesh. By default, this is a disc
  99174. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  99175. * * 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
  99176. * * 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
  99177. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99178. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99179. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99180. * @param name defines the name of the mesh
  99181. * @param options defines the options used to create the mesh
  99182. * @param scene defines the hosting scene
  99183. * @returns the plane polygonal mesh
  99184. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  99185. */
  99186. static CreateDisc(name: string, options: {
  99187. radius?: number;
  99188. tessellation?: number;
  99189. arc?: number;
  99190. updatable?: boolean;
  99191. sideOrientation?: number;
  99192. frontUVs?: Vector4;
  99193. backUVs?: Vector4;
  99194. }, scene?: Nullable<Scene>): Mesh;
  99195. }
  99196. }
  99197. declare module BABYLON {
  99198. /**
  99199. * This represents all the required information to add a fresnel effect on a material:
  99200. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99201. */
  99202. export class FresnelParameters {
  99203. private _isEnabled;
  99204. /**
  99205. * Define if the fresnel effect is enable or not.
  99206. */
  99207. get isEnabled(): boolean;
  99208. set isEnabled(value: boolean);
  99209. /**
  99210. * Define the color used on edges (grazing angle)
  99211. */
  99212. leftColor: Color3;
  99213. /**
  99214. * Define the color used on center
  99215. */
  99216. rightColor: Color3;
  99217. /**
  99218. * Define bias applied to computed fresnel term
  99219. */
  99220. bias: number;
  99221. /**
  99222. * Defined the power exponent applied to fresnel term
  99223. */
  99224. power: number;
  99225. /**
  99226. * Clones the current fresnel and its valuues
  99227. * @returns a clone fresnel configuration
  99228. */
  99229. clone(): FresnelParameters;
  99230. /**
  99231. * Serializes the current fresnel parameters to a JSON representation.
  99232. * @return the JSON serialization
  99233. */
  99234. serialize(): any;
  99235. /**
  99236. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  99237. * @param parsedFresnelParameters Define the JSON representation
  99238. * @returns the parsed parameters
  99239. */
  99240. static Parse(parsedFresnelParameters: any): FresnelParameters;
  99241. }
  99242. }
  99243. declare module BABYLON {
  99244. /**
  99245. * Base class of materials working in push mode in babylon JS
  99246. * @hidden
  99247. */
  99248. export class PushMaterial extends Material {
  99249. protected _activeEffect: Effect;
  99250. protected _normalMatrix: Matrix;
  99251. /**
  99252. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  99253. * This means that the material can keep using a previous shader while a new one is being compiled.
  99254. * This is mostly used when shader parallel compilation is supported (true by default)
  99255. */
  99256. allowShaderHotSwapping: boolean;
  99257. constructor(name: string, scene: Scene);
  99258. getEffect(): Effect;
  99259. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  99260. /**
  99261. * Binds the given world matrix to the active effect
  99262. *
  99263. * @param world the matrix to bind
  99264. */
  99265. bindOnlyWorldMatrix(world: Matrix): void;
  99266. /**
  99267. * Binds the given normal matrix to the active effect
  99268. *
  99269. * @param normalMatrix the matrix to bind
  99270. */
  99271. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  99272. bind(world: Matrix, mesh?: Mesh): void;
  99273. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  99274. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  99275. }
  99276. }
  99277. declare module BABYLON {
  99278. /**
  99279. * This groups all the flags used to control the materials channel.
  99280. */
  99281. export class MaterialFlags {
  99282. private static _DiffuseTextureEnabled;
  99283. /**
  99284. * Are diffuse textures enabled in the application.
  99285. */
  99286. static get DiffuseTextureEnabled(): boolean;
  99287. static set DiffuseTextureEnabled(value: boolean);
  99288. private static _AmbientTextureEnabled;
  99289. /**
  99290. * Are ambient textures enabled in the application.
  99291. */
  99292. static get AmbientTextureEnabled(): boolean;
  99293. static set AmbientTextureEnabled(value: boolean);
  99294. private static _OpacityTextureEnabled;
  99295. /**
  99296. * Are opacity textures enabled in the application.
  99297. */
  99298. static get OpacityTextureEnabled(): boolean;
  99299. static set OpacityTextureEnabled(value: boolean);
  99300. private static _ReflectionTextureEnabled;
  99301. /**
  99302. * Are reflection textures enabled in the application.
  99303. */
  99304. static get ReflectionTextureEnabled(): boolean;
  99305. static set ReflectionTextureEnabled(value: boolean);
  99306. private static _EmissiveTextureEnabled;
  99307. /**
  99308. * Are emissive textures enabled in the application.
  99309. */
  99310. static get EmissiveTextureEnabled(): boolean;
  99311. static set EmissiveTextureEnabled(value: boolean);
  99312. private static _SpecularTextureEnabled;
  99313. /**
  99314. * Are specular textures enabled in the application.
  99315. */
  99316. static get SpecularTextureEnabled(): boolean;
  99317. static set SpecularTextureEnabled(value: boolean);
  99318. private static _BumpTextureEnabled;
  99319. /**
  99320. * Are bump textures enabled in the application.
  99321. */
  99322. static get BumpTextureEnabled(): boolean;
  99323. static set BumpTextureEnabled(value: boolean);
  99324. private static _LightmapTextureEnabled;
  99325. /**
  99326. * Are lightmap textures enabled in the application.
  99327. */
  99328. static get LightmapTextureEnabled(): boolean;
  99329. static set LightmapTextureEnabled(value: boolean);
  99330. private static _RefractionTextureEnabled;
  99331. /**
  99332. * Are refraction textures enabled in the application.
  99333. */
  99334. static get RefractionTextureEnabled(): boolean;
  99335. static set RefractionTextureEnabled(value: boolean);
  99336. private static _ColorGradingTextureEnabled;
  99337. /**
  99338. * Are color grading textures enabled in the application.
  99339. */
  99340. static get ColorGradingTextureEnabled(): boolean;
  99341. static set ColorGradingTextureEnabled(value: boolean);
  99342. private static _FresnelEnabled;
  99343. /**
  99344. * Are fresnels enabled in the application.
  99345. */
  99346. static get FresnelEnabled(): boolean;
  99347. static set FresnelEnabled(value: boolean);
  99348. private static _ClearCoatTextureEnabled;
  99349. /**
  99350. * Are clear coat textures enabled in the application.
  99351. */
  99352. static get ClearCoatTextureEnabled(): boolean;
  99353. static set ClearCoatTextureEnabled(value: boolean);
  99354. private static _ClearCoatBumpTextureEnabled;
  99355. /**
  99356. * Are clear coat bump textures enabled in the application.
  99357. */
  99358. static get ClearCoatBumpTextureEnabled(): boolean;
  99359. static set ClearCoatBumpTextureEnabled(value: boolean);
  99360. private static _ClearCoatTintTextureEnabled;
  99361. /**
  99362. * Are clear coat tint textures enabled in the application.
  99363. */
  99364. static get ClearCoatTintTextureEnabled(): boolean;
  99365. static set ClearCoatTintTextureEnabled(value: boolean);
  99366. private static _SheenTextureEnabled;
  99367. /**
  99368. * Are sheen textures enabled in the application.
  99369. */
  99370. static get SheenTextureEnabled(): boolean;
  99371. static set SheenTextureEnabled(value: boolean);
  99372. private static _AnisotropicTextureEnabled;
  99373. /**
  99374. * Are anisotropic textures enabled in the application.
  99375. */
  99376. static get AnisotropicTextureEnabled(): boolean;
  99377. static set AnisotropicTextureEnabled(value: boolean);
  99378. private static _ThicknessTextureEnabled;
  99379. /**
  99380. * Are thickness textures enabled in the application.
  99381. */
  99382. static get ThicknessTextureEnabled(): boolean;
  99383. static set ThicknessTextureEnabled(value: boolean);
  99384. }
  99385. }
  99386. declare module BABYLON {
  99387. /** @hidden */
  99388. export var defaultFragmentDeclaration: {
  99389. name: string;
  99390. shader: string;
  99391. };
  99392. }
  99393. declare module BABYLON {
  99394. /** @hidden */
  99395. export var defaultUboDeclaration: {
  99396. name: string;
  99397. shader: string;
  99398. };
  99399. }
  99400. declare module BABYLON {
  99401. /** @hidden */
  99402. export var lightFragmentDeclaration: {
  99403. name: string;
  99404. shader: string;
  99405. };
  99406. }
  99407. declare module BABYLON {
  99408. /** @hidden */
  99409. export var lightUboDeclaration: {
  99410. name: string;
  99411. shader: string;
  99412. };
  99413. }
  99414. declare module BABYLON {
  99415. /** @hidden */
  99416. export var lightsFragmentFunctions: {
  99417. name: string;
  99418. shader: string;
  99419. };
  99420. }
  99421. declare module BABYLON {
  99422. /** @hidden */
  99423. export var shadowsFragmentFunctions: {
  99424. name: string;
  99425. shader: string;
  99426. };
  99427. }
  99428. declare module BABYLON {
  99429. /** @hidden */
  99430. export var fresnelFunction: {
  99431. name: string;
  99432. shader: string;
  99433. };
  99434. }
  99435. declare module BABYLON {
  99436. /** @hidden */
  99437. export var reflectionFunction: {
  99438. name: string;
  99439. shader: string;
  99440. };
  99441. }
  99442. declare module BABYLON {
  99443. /** @hidden */
  99444. export var bumpFragmentFunctions: {
  99445. name: string;
  99446. shader: string;
  99447. };
  99448. }
  99449. declare module BABYLON {
  99450. /** @hidden */
  99451. export var logDepthDeclaration: {
  99452. name: string;
  99453. shader: string;
  99454. };
  99455. }
  99456. declare module BABYLON {
  99457. /** @hidden */
  99458. export var bumpFragment: {
  99459. name: string;
  99460. shader: string;
  99461. };
  99462. }
  99463. declare module BABYLON {
  99464. /** @hidden */
  99465. export var depthPrePass: {
  99466. name: string;
  99467. shader: string;
  99468. };
  99469. }
  99470. declare module BABYLON {
  99471. /** @hidden */
  99472. export var lightFragment: {
  99473. name: string;
  99474. shader: string;
  99475. };
  99476. }
  99477. declare module BABYLON {
  99478. /** @hidden */
  99479. export var logDepthFragment: {
  99480. name: string;
  99481. shader: string;
  99482. };
  99483. }
  99484. declare module BABYLON {
  99485. /** @hidden */
  99486. export var defaultPixelShader: {
  99487. name: string;
  99488. shader: string;
  99489. };
  99490. }
  99491. declare module BABYLON {
  99492. /** @hidden */
  99493. export var defaultVertexDeclaration: {
  99494. name: string;
  99495. shader: string;
  99496. };
  99497. }
  99498. declare module BABYLON {
  99499. /** @hidden */
  99500. export var bumpVertexDeclaration: {
  99501. name: string;
  99502. shader: string;
  99503. };
  99504. }
  99505. declare module BABYLON {
  99506. /** @hidden */
  99507. export var bumpVertex: {
  99508. name: string;
  99509. shader: string;
  99510. };
  99511. }
  99512. declare module BABYLON {
  99513. /** @hidden */
  99514. export var fogVertex: {
  99515. name: string;
  99516. shader: string;
  99517. };
  99518. }
  99519. declare module BABYLON {
  99520. /** @hidden */
  99521. export var shadowsVertex: {
  99522. name: string;
  99523. shader: string;
  99524. };
  99525. }
  99526. declare module BABYLON {
  99527. /** @hidden */
  99528. export var pointCloudVertex: {
  99529. name: string;
  99530. shader: string;
  99531. };
  99532. }
  99533. declare module BABYLON {
  99534. /** @hidden */
  99535. export var logDepthVertex: {
  99536. name: string;
  99537. shader: string;
  99538. };
  99539. }
  99540. declare module BABYLON {
  99541. /** @hidden */
  99542. export var defaultVertexShader: {
  99543. name: string;
  99544. shader: string;
  99545. };
  99546. }
  99547. declare module BABYLON {
  99548. /** @hidden */
  99549. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  99550. MAINUV1: boolean;
  99551. MAINUV2: boolean;
  99552. DIFFUSE: boolean;
  99553. DIFFUSEDIRECTUV: number;
  99554. AMBIENT: boolean;
  99555. AMBIENTDIRECTUV: number;
  99556. OPACITY: boolean;
  99557. OPACITYDIRECTUV: number;
  99558. OPACITYRGB: boolean;
  99559. REFLECTION: boolean;
  99560. EMISSIVE: boolean;
  99561. EMISSIVEDIRECTUV: number;
  99562. SPECULAR: boolean;
  99563. SPECULARDIRECTUV: number;
  99564. BUMP: boolean;
  99565. BUMPDIRECTUV: number;
  99566. PARALLAX: boolean;
  99567. PARALLAXOCCLUSION: boolean;
  99568. SPECULAROVERALPHA: boolean;
  99569. CLIPPLANE: boolean;
  99570. CLIPPLANE2: boolean;
  99571. CLIPPLANE3: boolean;
  99572. CLIPPLANE4: boolean;
  99573. CLIPPLANE5: boolean;
  99574. CLIPPLANE6: boolean;
  99575. ALPHATEST: boolean;
  99576. DEPTHPREPASS: boolean;
  99577. ALPHAFROMDIFFUSE: boolean;
  99578. POINTSIZE: boolean;
  99579. FOG: boolean;
  99580. SPECULARTERM: boolean;
  99581. DIFFUSEFRESNEL: boolean;
  99582. OPACITYFRESNEL: boolean;
  99583. REFLECTIONFRESNEL: boolean;
  99584. REFRACTIONFRESNEL: boolean;
  99585. EMISSIVEFRESNEL: boolean;
  99586. FRESNEL: boolean;
  99587. NORMAL: boolean;
  99588. UV1: boolean;
  99589. UV2: boolean;
  99590. VERTEXCOLOR: boolean;
  99591. VERTEXALPHA: boolean;
  99592. NUM_BONE_INFLUENCERS: number;
  99593. BonesPerMesh: number;
  99594. BONETEXTURE: boolean;
  99595. INSTANCES: boolean;
  99596. GLOSSINESS: boolean;
  99597. ROUGHNESS: boolean;
  99598. EMISSIVEASILLUMINATION: boolean;
  99599. LINKEMISSIVEWITHDIFFUSE: boolean;
  99600. REFLECTIONFRESNELFROMSPECULAR: boolean;
  99601. LIGHTMAP: boolean;
  99602. LIGHTMAPDIRECTUV: number;
  99603. OBJECTSPACE_NORMALMAP: boolean;
  99604. USELIGHTMAPASSHADOWMAP: boolean;
  99605. REFLECTIONMAP_3D: boolean;
  99606. REFLECTIONMAP_SPHERICAL: boolean;
  99607. REFLECTIONMAP_PLANAR: boolean;
  99608. REFLECTIONMAP_CUBIC: boolean;
  99609. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  99610. REFLECTIONMAP_PROJECTION: boolean;
  99611. REFLECTIONMAP_SKYBOX: boolean;
  99612. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  99613. REFLECTIONMAP_EXPLICIT: boolean;
  99614. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  99615. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  99616. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  99617. INVERTCUBICMAP: boolean;
  99618. LOGARITHMICDEPTH: boolean;
  99619. REFRACTION: boolean;
  99620. REFRACTIONMAP_3D: boolean;
  99621. REFLECTIONOVERALPHA: boolean;
  99622. TWOSIDEDLIGHTING: boolean;
  99623. SHADOWFLOAT: boolean;
  99624. MORPHTARGETS: boolean;
  99625. MORPHTARGETS_NORMAL: boolean;
  99626. MORPHTARGETS_TANGENT: boolean;
  99627. MORPHTARGETS_UV: boolean;
  99628. NUM_MORPH_INFLUENCERS: number;
  99629. NONUNIFORMSCALING: boolean;
  99630. PREMULTIPLYALPHA: boolean;
  99631. IMAGEPROCESSING: boolean;
  99632. VIGNETTE: boolean;
  99633. VIGNETTEBLENDMODEMULTIPLY: boolean;
  99634. VIGNETTEBLENDMODEOPAQUE: boolean;
  99635. TONEMAPPING: boolean;
  99636. TONEMAPPING_ACES: boolean;
  99637. CONTRAST: boolean;
  99638. COLORCURVES: boolean;
  99639. COLORGRADING: boolean;
  99640. COLORGRADING3D: boolean;
  99641. SAMPLER3DGREENDEPTH: boolean;
  99642. SAMPLER3DBGRMAP: boolean;
  99643. IMAGEPROCESSINGPOSTPROCESS: boolean;
  99644. MULTIVIEW: boolean;
  99645. /**
  99646. * If the reflection texture on this material is in linear color space
  99647. * @hidden
  99648. */
  99649. IS_REFLECTION_LINEAR: boolean;
  99650. /**
  99651. * If the refraction texture on this material is in linear color space
  99652. * @hidden
  99653. */
  99654. IS_REFRACTION_LINEAR: boolean;
  99655. EXPOSURE: boolean;
  99656. constructor();
  99657. setReflectionMode(modeToEnable: string): void;
  99658. }
  99659. /**
  99660. * This is the default material used in Babylon. It is the best trade off between quality
  99661. * and performances.
  99662. * @see http://doc.babylonjs.com/babylon101/materials
  99663. */
  99664. export class StandardMaterial extends PushMaterial {
  99665. private _diffuseTexture;
  99666. /**
  99667. * The basic texture of the material as viewed under a light.
  99668. */
  99669. diffuseTexture: Nullable<BaseTexture>;
  99670. private _ambientTexture;
  99671. /**
  99672. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  99673. */
  99674. ambientTexture: Nullable<BaseTexture>;
  99675. private _opacityTexture;
  99676. /**
  99677. * Define the transparency of the material from a texture.
  99678. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  99679. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  99680. */
  99681. opacityTexture: Nullable<BaseTexture>;
  99682. private _reflectionTexture;
  99683. /**
  99684. * Define the texture used to display the reflection.
  99685. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99686. */
  99687. reflectionTexture: Nullable<BaseTexture>;
  99688. private _emissiveTexture;
  99689. /**
  99690. * Define texture of the material as if self lit.
  99691. * This will be mixed in the final result even in the absence of light.
  99692. */
  99693. emissiveTexture: Nullable<BaseTexture>;
  99694. private _specularTexture;
  99695. /**
  99696. * Define how the color and intensity of the highlight given by the light in the material.
  99697. */
  99698. specularTexture: Nullable<BaseTexture>;
  99699. private _bumpTexture;
  99700. /**
  99701. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  99702. * 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.
  99703. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  99704. */
  99705. bumpTexture: Nullable<BaseTexture>;
  99706. private _lightmapTexture;
  99707. /**
  99708. * Complex lighting can be computationally expensive to compute at runtime.
  99709. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  99710. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  99711. */
  99712. lightmapTexture: Nullable<BaseTexture>;
  99713. private _refractionTexture;
  99714. /**
  99715. * Define the texture used to display the refraction.
  99716. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99717. */
  99718. refractionTexture: Nullable<BaseTexture>;
  99719. /**
  99720. * The color of the material lit by the environmental background lighting.
  99721. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  99722. */
  99723. ambientColor: Color3;
  99724. /**
  99725. * The basic color of the material as viewed under a light.
  99726. */
  99727. diffuseColor: Color3;
  99728. /**
  99729. * Define how the color and intensity of the highlight given by the light in the material.
  99730. */
  99731. specularColor: Color3;
  99732. /**
  99733. * Define the color of the material as if self lit.
  99734. * This will be mixed in the final result even in the absence of light.
  99735. */
  99736. emissiveColor: Color3;
  99737. /**
  99738. * Defines how sharp are the highlights in the material.
  99739. * The bigger the value the sharper giving a more glossy feeling to the result.
  99740. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  99741. */
  99742. specularPower: number;
  99743. private _useAlphaFromDiffuseTexture;
  99744. /**
  99745. * Does the transparency come from the diffuse texture alpha channel.
  99746. */
  99747. useAlphaFromDiffuseTexture: boolean;
  99748. private _useEmissiveAsIllumination;
  99749. /**
  99750. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  99751. */
  99752. useEmissiveAsIllumination: boolean;
  99753. private _linkEmissiveWithDiffuse;
  99754. /**
  99755. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  99756. * the emissive level when the final color is close to one.
  99757. */
  99758. linkEmissiveWithDiffuse: boolean;
  99759. private _useSpecularOverAlpha;
  99760. /**
  99761. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  99762. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  99763. */
  99764. useSpecularOverAlpha: boolean;
  99765. private _useReflectionOverAlpha;
  99766. /**
  99767. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  99768. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  99769. */
  99770. useReflectionOverAlpha: boolean;
  99771. private _disableLighting;
  99772. /**
  99773. * Does lights from the scene impacts this material.
  99774. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  99775. */
  99776. disableLighting: boolean;
  99777. private _useObjectSpaceNormalMap;
  99778. /**
  99779. * Allows using an object space normal map (instead of tangent space).
  99780. */
  99781. useObjectSpaceNormalMap: boolean;
  99782. private _useParallax;
  99783. /**
  99784. * Is parallax enabled or not.
  99785. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  99786. */
  99787. useParallax: boolean;
  99788. private _useParallaxOcclusion;
  99789. /**
  99790. * Is parallax occlusion enabled or not.
  99791. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  99792. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  99793. */
  99794. useParallaxOcclusion: boolean;
  99795. /**
  99796. * 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.
  99797. */
  99798. parallaxScaleBias: number;
  99799. private _roughness;
  99800. /**
  99801. * Helps to define how blurry the reflections should appears in the material.
  99802. */
  99803. roughness: number;
  99804. /**
  99805. * In case of refraction, define the value of the index of refraction.
  99806. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99807. */
  99808. indexOfRefraction: number;
  99809. /**
  99810. * Invert the refraction texture alongside the y axis.
  99811. * It can be useful with procedural textures or probe for instance.
  99812. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99813. */
  99814. invertRefractionY: boolean;
  99815. /**
  99816. * Defines the alpha limits in alpha test mode.
  99817. */
  99818. alphaCutOff: number;
  99819. private _useLightmapAsShadowmap;
  99820. /**
  99821. * In case of light mapping, define whether the map contains light or shadow informations.
  99822. */
  99823. useLightmapAsShadowmap: boolean;
  99824. private _diffuseFresnelParameters;
  99825. /**
  99826. * Define the diffuse fresnel parameters of the material.
  99827. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99828. */
  99829. diffuseFresnelParameters: FresnelParameters;
  99830. private _opacityFresnelParameters;
  99831. /**
  99832. * Define the opacity fresnel parameters of the material.
  99833. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99834. */
  99835. opacityFresnelParameters: FresnelParameters;
  99836. private _reflectionFresnelParameters;
  99837. /**
  99838. * Define the reflection fresnel parameters of the material.
  99839. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99840. */
  99841. reflectionFresnelParameters: FresnelParameters;
  99842. private _refractionFresnelParameters;
  99843. /**
  99844. * Define the refraction fresnel parameters of the material.
  99845. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99846. */
  99847. refractionFresnelParameters: FresnelParameters;
  99848. private _emissiveFresnelParameters;
  99849. /**
  99850. * Define the emissive fresnel parameters of the material.
  99851. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99852. */
  99853. emissiveFresnelParameters: FresnelParameters;
  99854. private _useReflectionFresnelFromSpecular;
  99855. /**
  99856. * If true automatically deducts the fresnels values from the material specularity.
  99857. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99858. */
  99859. useReflectionFresnelFromSpecular: boolean;
  99860. private _useGlossinessFromSpecularMapAlpha;
  99861. /**
  99862. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  99863. */
  99864. useGlossinessFromSpecularMapAlpha: boolean;
  99865. private _maxSimultaneousLights;
  99866. /**
  99867. * Defines the maximum number of lights that can be used in the material
  99868. */
  99869. maxSimultaneousLights: number;
  99870. private _invertNormalMapX;
  99871. /**
  99872. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  99873. */
  99874. invertNormalMapX: boolean;
  99875. private _invertNormalMapY;
  99876. /**
  99877. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  99878. */
  99879. invertNormalMapY: boolean;
  99880. private _twoSidedLighting;
  99881. /**
  99882. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  99883. */
  99884. twoSidedLighting: boolean;
  99885. /**
  99886. * Default configuration related to image processing available in the standard Material.
  99887. */
  99888. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99889. /**
  99890. * Gets the image processing configuration used either in this material.
  99891. */
  99892. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  99893. /**
  99894. * Sets the Default image processing configuration used either in the this material.
  99895. *
  99896. * If sets to null, the scene one is in use.
  99897. */
  99898. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  99899. /**
  99900. * Keep track of the image processing observer to allow dispose and replace.
  99901. */
  99902. private _imageProcessingObserver;
  99903. /**
  99904. * Attaches a new image processing configuration to the Standard Material.
  99905. * @param configuration
  99906. */
  99907. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  99908. /**
  99909. * Gets wether the color curves effect is enabled.
  99910. */
  99911. get cameraColorCurvesEnabled(): boolean;
  99912. /**
  99913. * Sets wether the color curves effect is enabled.
  99914. */
  99915. set cameraColorCurvesEnabled(value: boolean);
  99916. /**
  99917. * Gets wether the color grading effect is enabled.
  99918. */
  99919. get cameraColorGradingEnabled(): boolean;
  99920. /**
  99921. * Gets wether the color grading effect is enabled.
  99922. */
  99923. set cameraColorGradingEnabled(value: boolean);
  99924. /**
  99925. * Gets wether tonemapping is enabled or not.
  99926. */
  99927. get cameraToneMappingEnabled(): boolean;
  99928. /**
  99929. * Sets wether tonemapping is enabled or not
  99930. */
  99931. set cameraToneMappingEnabled(value: boolean);
  99932. /**
  99933. * The camera exposure used on this material.
  99934. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99935. * This corresponds to a photographic exposure.
  99936. */
  99937. get cameraExposure(): number;
  99938. /**
  99939. * The camera exposure used on this material.
  99940. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99941. * This corresponds to a photographic exposure.
  99942. */
  99943. set cameraExposure(value: number);
  99944. /**
  99945. * Gets The camera contrast used on this material.
  99946. */
  99947. get cameraContrast(): number;
  99948. /**
  99949. * Sets The camera contrast used on this material.
  99950. */
  99951. set cameraContrast(value: number);
  99952. /**
  99953. * Gets the Color Grading 2D Lookup Texture.
  99954. */
  99955. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  99956. /**
  99957. * Sets the Color Grading 2D Lookup Texture.
  99958. */
  99959. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  99960. /**
  99961. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99962. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99963. * 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;
  99964. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99965. */
  99966. get cameraColorCurves(): Nullable<ColorCurves>;
  99967. /**
  99968. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99969. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99970. * 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;
  99971. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99972. */
  99973. set cameraColorCurves(value: Nullable<ColorCurves>);
  99974. /**
  99975. * Custom callback helping to override the default shader used in the material.
  99976. */
  99977. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  99978. protected _renderTargets: SmartArray<RenderTargetTexture>;
  99979. protected _worldViewProjectionMatrix: Matrix;
  99980. protected _globalAmbientColor: Color3;
  99981. protected _useLogarithmicDepth: boolean;
  99982. protected _rebuildInParallel: boolean;
  99983. /**
  99984. * Instantiates a new standard material.
  99985. * This is the default material used in Babylon. It is the best trade off between quality
  99986. * and performances.
  99987. * @see http://doc.babylonjs.com/babylon101/materials
  99988. * @param name Define the name of the material in the scene
  99989. * @param scene Define the scene the material belong to
  99990. */
  99991. constructor(name: string, scene: Scene);
  99992. /**
  99993. * Gets a boolean indicating that current material needs to register RTT
  99994. */
  99995. get hasRenderTargetTextures(): boolean;
  99996. /**
  99997. * Gets the current class name of the material e.g. "StandardMaterial"
  99998. * Mainly use in serialization.
  99999. * @returns the class name
  100000. */
  100001. getClassName(): string;
  100002. /**
  100003. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  100004. * You can try switching to logarithmic depth.
  100005. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  100006. */
  100007. get useLogarithmicDepth(): boolean;
  100008. set useLogarithmicDepth(value: boolean);
  100009. /**
  100010. * Specifies if the material will require alpha blending
  100011. * @returns a boolean specifying if alpha blending is needed
  100012. */
  100013. needAlphaBlending(): boolean;
  100014. /**
  100015. * Specifies if this material should be rendered in alpha test mode
  100016. * @returns a boolean specifying if an alpha test is needed.
  100017. */
  100018. needAlphaTesting(): boolean;
  100019. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  100020. /**
  100021. * Get the texture used for alpha test purpose.
  100022. * @returns the diffuse texture in case of the standard material.
  100023. */
  100024. getAlphaTestTexture(): Nullable<BaseTexture>;
  100025. /**
  100026. * Get if the submesh is ready to be used and all its information available.
  100027. * Child classes can use it to update shaders
  100028. * @param mesh defines the mesh to check
  100029. * @param subMesh defines which submesh to check
  100030. * @param useInstances specifies that instances should be used
  100031. * @returns a boolean indicating that the submesh is ready or not
  100032. */
  100033. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  100034. /**
  100035. * Builds the material UBO layouts.
  100036. * Used internally during the effect preparation.
  100037. */
  100038. buildUniformLayout(): void;
  100039. /**
  100040. * Unbinds the material from the mesh
  100041. */
  100042. unbind(): void;
  100043. /**
  100044. * Binds the submesh to this material by preparing the effect and shader to draw
  100045. * @param world defines the world transformation matrix
  100046. * @param mesh defines the mesh containing the submesh
  100047. * @param subMesh defines the submesh to bind the material to
  100048. */
  100049. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  100050. /**
  100051. * Get the list of animatables in the material.
  100052. * @returns the list of animatables object used in the material
  100053. */
  100054. getAnimatables(): IAnimatable[];
  100055. /**
  100056. * Gets the active textures from the material
  100057. * @returns an array of textures
  100058. */
  100059. getActiveTextures(): BaseTexture[];
  100060. /**
  100061. * Specifies if the material uses a texture
  100062. * @param texture defines the texture to check against the material
  100063. * @returns a boolean specifying if the material uses the texture
  100064. */
  100065. hasTexture(texture: BaseTexture): boolean;
  100066. /**
  100067. * Disposes the material
  100068. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  100069. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  100070. */
  100071. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  100072. /**
  100073. * Makes a duplicate of the material, and gives it a new name
  100074. * @param name defines the new name for the duplicated material
  100075. * @returns the cloned material
  100076. */
  100077. clone(name: string): StandardMaterial;
  100078. /**
  100079. * Serializes this material in a JSON representation
  100080. * @returns the serialized material object
  100081. */
  100082. serialize(): any;
  100083. /**
  100084. * Creates a standard material from parsed material data
  100085. * @param source defines the JSON representation of the material
  100086. * @param scene defines the hosting scene
  100087. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100088. * @returns a new standard material
  100089. */
  100090. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  100091. /**
  100092. * Are diffuse textures enabled in the application.
  100093. */
  100094. static get DiffuseTextureEnabled(): boolean;
  100095. static set DiffuseTextureEnabled(value: boolean);
  100096. /**
  100097. * Are ambient textures enabled in the application.
  100098. */
  100099. static get AmbientTextureEnabled(): boolean;
  100100. static set AmbientTextureEnabled(value: boolean);
  100101. /**
  100102. * Are opacity textures enabled in the application.
  100103. */
  100104. static get OpacityTextureEnabled(): boolean;
  100105. static set OpacityTextureEnabled(value: boolean);
  100106. /**
  100107. * Are reflection textures enabled in the application.
  100108. */
  100109. static get ReflectionTextureEnabled(): boolean;
  100110. static set ReflectionTextureEnabled(value: boolean);
  100111. /**
  100112. * Are emissive textures enabled in the application.
  100113. */
  100114. static get EmissiveTextureEnabled(): boolean;
  100115. static set EmissiveTextureEnabled(value: boolean);
  100116. /**
  100117. * Are specular textures enabled in the application.
  100118. */
  100119. static get SpecularTextureEnabled(): boolean;
  100120. static set SpecularTextureEnabled(value: boolean);
  100121. /**
  100122. * Are bump textures enabled in the application.
  100123. */
  100124. static get BumpTextureEnabled(): boolean;
  100125. static set BumpTextureEnabled(value: boolean);
  100126. /**
  100127. * Are lightmap textures enabled in the application.
  100128. */
  100129. static get LightmapTextureEnabled(): boolean;
  100130. static set LightmapTextureEnabled(value: boolean);
  100131. /**
  100132. * Are refraction textures enabled in the application.
  100133. */
  100134. static get RefractionTextureEnabled(): boolean;
  100135. static set RefractionTextureEnabled(value: boolean);
  100136. /**
  100137. * Are color grading textures enabled in the application.
  100138. */
  100139. static get ColorGradingTextureEnabled(): boolean;
  100140. static set ColorGradingTextureEnabled(value: boolean);
  100141. /**
  100142. * Are fresnels enabled in the application.
  100143. */
  100144. static get FresnelEnabled(): boolean;
  100145. static set FresnelEnabled(value: boolean);
  100146. }
  100147. }
  100148. declare module BABYLON {
  100149. /**
  100150. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  100151. *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.
  100152. * The SPS is also a particle system. It provides some methods to manage the particles.
  100153. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  100154. *
  100155. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  100156. */
  100157. export class SolidParticleSystem implements IDisposable {
  100158. /**
  100159. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  100160. * Example : var p = SPS.particles[i];
  100161. */
  100162. particles: SolidParticle[];
  100163. /**
  100164. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  100165. */
  100166. nbParticles: number;
  100167. /**
  100168. * If the particles must ever face the camera (default false). Useful for planar particles.
  100169. */
  100170. billboard: boolean;
  100171. /**
  100172. * Recompute normals when adding a shape
  100173. */
  100174. recomputeNormals: boolean;
  100175. /**
  100176. * This a counter ofr your own usage. It's not set by any SPS functions.
  100177. */
  100178. counter: number;
  100179. /**
  100180. * The SPS name. This name is also given to the underlying mesh.
  100181. */
  100182. name: string;
  100183. /**
  100184. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  100185. */
  100186. mesh: Mesh;
  100187. /**
  100188. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  100189. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  100190. */
  100191. vars: any;
  100192. /**
  100193. * This array is populated when the SPS is set as 'pickable'.
  100194. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  100195. * Each element of this array is an object `{idx: int, faceId: int}`.
  100196. * `idx` is the picked particle index in the `SPS.particles` array
  100197. * `faceId` is the picked face index counted within this particle.
  100198. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  100199. */
  100200. pickedParticles: {
  100201. idx: number;
  100202. faceId: number;
  100203. }[];
  100204. /**
  100205. * This array is populated when `enableDepthSort` is set to true.
  100206. * Each element of this array is an instance of the class DepthSortedParticle.
  100207. */
  100208. depthSortedParticles: DepthSortedParticle[];
  100209. /**
  100210. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  100211. * @hidden
  100212. */
  100213. _bSphereOnly: boolean;
  100214. /**
  100215. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  100216. * @hidden
  100217. */
  100218. _bSphereRadiusFactor: number;
  100219. private _scene;
  100220. private _positions;
  100221. private _indices;
  100222. private _normals;
  100223. private _colors;
  100224. private _uvs;
  100225. private _indices32;
  100226. private _positions32;
  100227. private _normals32;
  100228. private _fixedNormal32;
  100229. private _colors32;
  100230. private _uvs32;
  100231. private _index;
  100232. private _updatable;
  100233. private _pickable;
  100234. private _isVisibilityBoxLocked;
  100235. private _alwaysVisible;
  100236. private _depthSort;
  100237. private _expandable;
  100238. private _shapeCounter;
  100239. private _copy;
  100240. private _color;
  100241. private _computeParticleColor;
  100242. private _computeParticleTexture;
  100243. private _computeParticleRotation;
  100244. private _computeParticleVertex;
  100245. private _computeBoundingBox;
  100246. private _depthSortParticles;
  100247. private _camera;
  100248. private _mustUnrotateFixedNormals;
  100249. private _particlesIntersect;
  100250. private _needs32Bits;
  100251. private _isNotBuilt;
  100252. private _lastParticleId;
  100253. private _idxOfId;
  100254. private _multimaterialEnabled;
  100255. private _useModelMaterial;
  100256. private _indicesByMaterial;
  100257. private _materialIndexes;
  100258. private _depthSortFunction;
  100259. private _materialSortFunction;
  100260. private _materials;
  100261. private _multimaterial;
  100262. private _materialIndexesById;
  100263. private _defaultMaterial;
  100264. private _autoUpdateSubMeshes;
  100265. /**
  100266. * Creates a SPS (Solid Particle System) object.
  100267. * @param name (String) is the SPS name, this will be the underlying mesh name.
  100268. * @param scene (Scene) is the scene in which the SPS is added.
  100269. * @param options defines the options of the sps e.g.
  100270. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  100271. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  100272. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  100273. * * 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.
  100274. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  100275. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  100276. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  100277. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  100278. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  100279. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  100280. */
  100281. constructor(name: string, scene: Scene, options?: {
  100282. updatable?: boolean;
  100283. isPickable?: boolean;
  100284. enableDepthSort?: boolean;
  100285. particleIntersection?: boolean;
  100286. boundingSphereOnly?: boolean;
  100287. bSphereRadiusFactor?: number;
  100288. expandable?: boolean;
  100289. useModelMaterial?: boolean;
  100290. enableMultiMaterial?: boolean;
  100291. });
  100292. /**
  100293. * Builds the SPS underlying mesh. Returns a standard Mesh.
  100294. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  100295. * @returns the created mesh
  100296. */
  100297. buildMesh(): Mesh;
  100298. /**
  100299. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  100300. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  100301. * Thus the particles generated from `digest()` have their property `position` set yet.
  100302. * @param mesh ( Mesh ) is the mesh to be digested
  100303. * @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
  100304. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  100305. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  100306. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  100307. * @returns the current SPS
  100308. */
  100309. digest(mesh: Mesh, options?: {
  100310. facetNb?: number;
  100311. number?: number;
  100312. delta?: number;
  100313. storage?: [];
  100314. }): SolidParticleSystem;
  100315. /**
  100316. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  100317. * @hidden
  100318. */
  100319. private _unrotateFixedNormals;
  100320. /**
  100321. * Resets the temporary working copy particle
  100322. * @hidden
  100323. */
  100324. private _resetCopy;
  100325. /**
  100326. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  100327. * @param p the current index in the positions array to be updated
  100328. * @param ind the current index in the indices array
  100329. * @param shape a Vector3 array, the shape geometry
  100330. * @param positions the positions array to be updated
  100331. * @param meshInd the shape indices array
  100332. * @param indices the indices array to be updated
  100333. * @param meshUV the shape uv array
  100334. * @param uvs the uv array to be updated
  100335. * @param meshCol the shape color array
  100336. * @param colors the color array to be updated
  100337. * @param meshNor the shape normals array
  100338. * @param normals the normals array to be updated
  100339. * @param idx the particle index
  100340. * @param idxInShape the particle index in its shape
  100341. * @param options the addShape() method passed options
  100342. * @model the particle model
  100343. * @hidden
  100344. */
  100345. private _meshBuilder;
  100346. /**
  100347. * Returns a shape Vector3 array from positions float array
  100348. * @param positions float array
  100349. * @returns a vector3 array
  100350. * @hidden
  100351. */
  100352. private _posToShape;
  100353. /**
  100354. * Returns a shapeUV array from a float uvs (array deep copy)
  100355. * @param uvs as a float array
  100356. * @returns a shapeUV array
  100357. * @hidden
  100358. */
  100359. private _uvsToShapeUV;
  100360. /**
  100361. * Adds a new particle object in the particles array
  100362. * @param idx particle index in particles array
  100363. * @param id particle id
  100364. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  100365. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  100366. * @param model particle ModelShape object
  100367. * @param shapeId model shape identifier
  100368. * @param idxInShape index of the particle in the current model
  100369. * @param bInfo model bounding info object
  100370. * @param storage target storage array, if any
  100371. * @hidden
  100372. */
  100373. private _addParticle;
  100374. /**
  100375. * Adds some particles to the SPS from the model shape. Returns the shape id.
  100376. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  100377. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  100378. * @param nb (positive integer) the number of particles to be created from this model
  100379. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  100380. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  100381. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  100382. * @returns the number of shapes in the system
  100383. */
  100384. addShape(mesh: Mesh, nb: number, options?: {
  100385. positionFunction?: any;
  100386. vertexFunction?: any;
  100387. storage?: [];
  100388. }): number;
  100389. /**
  100390. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  100391. * @hidden
  100392. */
  100393. private _rebuildParticle;
  100394. /**
  100395. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  100396. * @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.
  100397. * @returns the SPS.
  100398. */
  100399. rebuildMesh(reset?: boolean): SolidParticleSystem;
  100400. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  100401. * Returns an array with the removed particles.
  100402. * 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.
  100403. * The SPS can't be empty so at least one particle needs to remain in place.
  100404. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  100405. * @param start index of the first particle to remove
  100406. * @param end index of the last particle to remove (included)
  100407. * @returns an array populated with the removed particles
  100408. */
  100409. removeParticles(start: number, end: number): SolidParticle[];
  100410. /**
  100411. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  100412. * @param solidParticleArray an array populated with Solid Particles objects
  100413. * @returns the SPS
  100414. */
  100415. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  100416. /**
  100417. * Creates a new particle and modifies the SPS mesh geometry :
  100418. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  100419. * - calls _addParticle() to populate the particle array
  100420. * factorized code from addShape() and insertParticlesFromArray()
  100421. * @param idx particle index in the particles array
  100422. * @param i particle index in its shape
  100423. * @param modelShape particle ModelShape object
  100424. * @param shape shape vertex array
  100425. * @param meshInd shape indices array
  100426. * @param meshUV shape uv array
  100427. * @param meshCol shape color array
  100428. * @param meshNor shape normals array
  100429. * @param bbInfo shape bounding info
  100430. * @param storage target particle storage
  100431. * @options addShape() passed options
  100432. * @hidden
  100433. */
  100434. private _insertNewParticle;
  100435. /**
  100436. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  100437. * This method calls `updateParticle()` for each particle of the SPS.
  100438. * For an animated SPS, it is usually called within the render loop.
  100439. * 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.
  100440. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  100441. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  100442. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  100443. * @returns the SPS.
  100444. */
  100445. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  100446. /**
  100447. * Disposes the SPS.
  100448. */
  100449. dispose(): void;
  100450. /**
  100451. * Returns a SolidParticle object from its identifier : particle.id
  100452. * @param id (integer) the particle Id
  100453. * @returns the searched particle or null if not found in the SPS.
  100454. */
  100455. getParticleById(id: number): Nullable<SolidParticle>;
  100456. /**
  100457. * Returns a new array populated with the particles having the passed shapeId.
  100458. * @param shapeId (integer) the shape identifier
  100459. * @returns a new solid particle array
  100460. */
  100461. getParticlesByShapeId(shapeId: number): SolidParticle[];
  100462. /**
  100463. * Populates the passed array "ref" with the particles having the passed shapeId.
  100464. * @param shapeId the shape identifier
  100465. * @returns the SPS
  100466. * @param ref
  100467. */
  100468. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  100469. /**
  100470. * Computes the required SubMeshes according the materials assigned to the particles.
  100471. * @returns the solid particle system.
  100472. * Does nothing if called before the SPS mesh is built.
  100473. */
  100474. computeSubMeshes(): SolidParticleSystem;
  100475. /**
  100476. * Sorts the solid particles by material when MultiMaterial is enabled.
  100477. * Updates the indices32 array.
  100478. * Updates the indicesByMaterial array.
  100479. * Updates the mesh indices array.
  100480. * @returns the SPS
  100481. * @hidden
  100482. */
  100483. private _sortParticlesByMaterial;
  100484. /**
  100485. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  100486. * @hidden
  100487. */
  100488. private _setMaterialIndexesById;
  100489. /**
  100490. * Returns an array with unique values of Materials from the passed array
  100491. * @param array the material array to be checked and filtered
  100492. * @hidden
  100493. */
  100494. private _filterUniqueMaterialId;
  100495. /**
  100496. * Sets a new Standard Material as _defaultMaterial if not already set.
  100497. * @hidden
  100498. */
  100499. private _setDefaultMaterial;
  100500. /**
  100501. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  100502. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100503. * @returns the SPS.
  100504. */
  100505. refreshVisibleSize(): SolidParticleSystem;
  100506. /**
  100507. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  100508. * @param size the size (float) of the visibility box
  100509. * note : this doesn't lock the SPS mesh bounding box.
  100510. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100511. */
  100512. setVisibilityBox(size: number): void;
  100513. /**
  100514. * Gets whether the SPS as always visible or not
  100515. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100516. */
  100517. get isAlwaysVisible(): boolean;
  100518. /**
  100519. * Sets the SPS as always visible or not
  100520. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100521. */
  100522. set isAlwaysVisible(val: boolean);
  100523. /**
  100524. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  100525. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100526. */
  100527. set isVisibilityBoxLocked(val: boolean);
  100528. /**
  100529. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  100530. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100531. */
  100532. get isVisibilityBoxLocked(): boolean;
  100533. /**
  100534. * Tells to `setParticles()` to compute the particle rotations or not.
  100535. * Default value : true. The SPS is faster when it's set to false.
  100536. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  100537. */
  100538. set computeParticleRotation(val: boolean);
  100539. /**
  100540. * Tells to `setParticles()` to compute the particle colors or not.
  100541. * Default value : true. The SPS is faster when it's set to false.
  100542. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  100543. */
  100544. set computeParticleColor(val: boolean);
  100545. set computeParticleTexture(val: boolean);
  100546. /**
  100547. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  100548. * Default value : false. The SPS is faster when it's set to false.
  100549. * Note : the particle custom vertex positions aren't stored values.
  100550. */
  100551. set computeParticleVertex(val: boolean);
  100552. /**
  100553. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  100554. */
  100555. set computeBoundingBox(val: boolean);
  100556. /**
  100557. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  100558. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  100559. * Default : `true`
  100560. */
  100561. set depthSortParticles(val: boolean);
  100562. /**
  100563. * Gets if `setParticles()` computes the particle rotations or not.
  100564. * Default value : true. The SPS is faster when it's set to false.
  100565. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  100566. */
  100567. get computeParticleRotation(): boolean;
  100568. /**
  100569. * Gets if `setParticles()` computes the particle colors or not.
  100570. * Default value : true. The SPS is faster when it's set to false.
  100571. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  100572. */
  100573. get computeParticleColor(): boolean;
  100574. /**
  100575. * Gets if `setParticles()` computes the particle textures or not.
  100576. * Default value : true. The SPS is faster when it's set to false.
  100577. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  100578. */
  100579. get computeParticleTexture(): boolean;
  100580. /**
  100581. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  100582. * Default value : false. The SPS is faster when it's set to false.
  100583. * Note : the particle custom vertex positions aren't stored values.
  100584. */
  100585. get computeParticleVertex(): boolean;
  100586. /**
  100587. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  100588. */
  100589. get computeBoundingBox(): boolean;
  100590. /**
  100591. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  100592. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  100593. * Default : `true`
  100594. */
  100595. get depthSortParticles(): boolean;
  100596. /**
  100597. * Gets if the SPS is created as expandable at construction time.
  100598. * Default : `false`
  100599. */
  100600. get expandable(): boolean;
  100601. /**
  100602. * Gets if the SPS supports the Multi Materials
  100603. */
  100604. get multimaterialEnabled(): boolean;
  100605. /**
  100606. * Gets if the SPS uses the model materials for its own multimaterial.
  100607. */
  100608. get useModelMaterial(): boolean;
  100609. /**
  100610. * The SPS used material array.
  100611. */
  100612. get materials(): Material[];
  100613. /**
  100614. * Sets the SPS MultiMaterial from the passed materials.
  100615. * Note : the passed array is internally copied and not used then by reference.
  100616. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  100617. */
  100618. setMultiMaterial(materials: Material[]): void;
  100619. /**
  100620. * The SPS computed multimaterial object
  100621. */
  100622. get multimaterial(): MultiMaterial;
  100623. set multimaterial(mm: MultiMaterial);
  100624. /**
  100625. * If the subMeshes must be updated on the next call to setParticles()
  100626. */
  100627. get autoUpdateSubMeshes(): boolean;
  100628. set autoUpdateSubMeshes(val: boolean);
  100629. /**
  100630. * This function does nothing. It may be overwritten to set all the particle first values.
  100631. * The SPS doesn't call this function, you may have to call it by your own.
  100632. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  100633. */
  100634. initParticles(): void;
  100635. /**
  100636. * This function does nothing. It may be overwritten to recycle a particle.
  100637. * The SPS doesn't call this function, you may have to call it by your own.
  100638. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  100639. * @param particle The particle to recycle
  100640. * @returns the recycled particle
  100641. */
  100642. recycleParticle(particle: SolidParticle): SolidParticle;
  100643. /**
  100644. * Updates a particle : this function should be overwritten by the user.
  100645. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  100646. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  100647. * @example : just set a particle position or velocity and recycle conditions
  100648. * @param particle The particle to update
  100649. * @returns the updated particle
  100650. */
  100651. updateParticle(particle: SolidParticle): SolidParticle;
  100652. /**
  100653. * Updates a vertex of a particle : it can be overwritten by the user.
  100654. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  100655. * @param particle the current particle
  100656. * @param vertex the current index of the current particle
  100657. * @param pt the index of the current vertex in the particle shape
  100658. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  100659. * @example : just set a vertex particle position
  100660. * @returns the updated vertex
  100661. */
  100662. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  100663. /**
  100664. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  100665. * This does nothing and may be overwritten by the user.
  100666. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100667. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100668. * @param update the boolean update value actually passed to setParticles()
  100669. */
  100670. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  100671. /**
  100672. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  100673. * This will be passed three parameters.
  100674. * This does nothing and may be overwritten by the user.
  100675. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100676. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100677. * @param update the boolean update value actually passed to setParticles()
  100678. */
  100679. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  100680. }
  100681. }
  100682. declare module BABYLON {
  100683. /**
  100684. * Represents one particle of a solid particle system.
  100685. */
  100686. export class SolidParticle {
  100687. /**
  100688. * particle global index
  100689. */
  100690. idx: number;
  100691. /**
  100692. * particle identifier
  100693. */
  100694. id: number;
  100695. /**
  100696. * The color of the particle
  100697. */
  100698. color: Nullable<Color4>;
  100699. /**
  100700. * The world space position of the particle.
  100701. */
  100702. position: Vector3;
  100703. /**
  100704. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  100705. */
  100706. rotation: Vector3;
  100707. /**
  100708. * The world space rotation quaternion of the particle.
  100709. */
  100710. rotationQuaternion: Nullable<Quaternion>;
  100711. /**
  100712. * The scaling of the particle.
  100713. */
  100714. scaling: Vector3;
  100715. /**
  100716. * The uvs of the particle.
  100717. */
  100718. uvs: Vector4;
  100719. /**
  100720. * The current speed of the particle.
  100721. */
  100722. velocity: Vector3;
  100723. /**
  100724. * The pivot point in the particle local space.
  100725. */
  100726. pivot: Vector3;
  100727. /**
  100728. * Must the particle be translated from its pivot point in its local space ?
  100729. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  100730. * Default : false
  100731. */
  100732. translateFromPivot: boolean;
  100733. /**
  100734. * Is the particle active or not ?
  100735. */
  100736. alive: boolean;
  100737. /**
  100738. * Is the particle visible or not ?
  100739. */
  100740. isVisible: boolean;
  100741. /**
  100742. * Index of this particle in the global "positions" array (Internal use)
  100743. * @hidden
  100744. */
  100745. _pos: number;
  100746. /**
  100747. * @hidden Index of this particle in the global "indices" array (Internal use)
  100748. */
  100749. _ind: number;
  100750. /**
  100751. * @hidden ModelShape of this particle (Internal use)
  100752. */
  100753. _model: ModelShape;
  100754. /**
  100755. * ModelShape id of this particle
  100756. */
  100757. shapeId: number;
  100758. /**
  100759. * Index of the particle in its shape id
  100760. */
  100761. idxInShape: number;
  100762. /**
  100763. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  100764. */
  100765. _modelBoundingInfo: BoundingInfo;
  100766. /**
  100767. * @hidden Particle BoundingInfo object (Internal use)
  100768. */
  100769. _boundingInfo: BoundingInfo;
  100770. /**
  100771. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  100772. */
  100773. _sps: SolidParticleSystem;
  100774. /**
  100775. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  100776. */
  100777. _stillInvisible: boolean;
  100778. /**
  100779. * @hidden Last computed particle rotation matrix
  100780. */
  100781. _rotationMatrix: number[];
  100782. /**
  100783. * Parent particle Id, if any.
  100784. * Default null.
  100785. */
  100786. parentId: Nullable<number>;
  100787. /**
  100788. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  100789. */
  100790. materialIndex: Nullable<number>;
  100791. /**
  100792. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  100793. * The possible values are :
  100794. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  100795. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  100796. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  100797. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  100798. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  100799. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  100800. * */
  100801. cullingStrategy: number;
  100802. /**
  100803. * @hidden Internal global position in the SPS.
  100804. */
  100805. _globalPosition: Vector3;
  100806. /**
  100807. * Creates a Solid Particle object.
  100808. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  100809. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  100810. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  100811. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  100812. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  100813. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  100814. * @param shapeId (integer) is the model shape identifier in the SPS.
  100815. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  100816. * @param sps defines the sps it is associated to
  100817. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  100818. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  100819. */
  100820. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  100821. /**
  100822. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  100823. * @param target the particle target
  100824. * @returns the current particle
  100825. */
  100826. copyToRef(target: SolidParticle): SolidParticle;
  100827. /**
  100828. * Legacy support, changed scale to scaling
  100829. */
  100830. get scale(): Vector3;
  100831. /**
  100832. * Legacy support, changed scale to scaling
  100833. */
  100834. set scale(scale: Vector3);
  100835. /**
  100836. * Legacy support, changed quaternion to rotationQuaternion
  100837. */
  100838. get quaternion(): Nullable<Quaternion>;
  100839. /**
  100840. * Legacy support, changed quaternion to rotationQuaternion
  100841. */
  100842. set quaternion(q: Nullable<Quaternion>);
  100843. /**
  100844. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  100845. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  100846. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  100847. * @returns true if it intersects
  100848. */
  100849. intersectsMesh(target: Mesh | SolidParticle): boolean;
  100850. /**
  100851. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  100852. * A particle is in the frustum if its bounding box intersects the frustum
  100853. * @param frustumPlanes defines the frustum to test
  100854. * @returns true if the particle is in the frustum planes
  100855. */
  100856. isInFrustum(frustumPlanes: Plane[]): boolean;
  100857. /**
  100858. * get the rotation matrix of the particle
  100859. * @hidden
  100860. */
  100861. getRotationMatrix(m: Matrix): void;
  100862. }
  100863. /**
  100864. * Represents the shape of the model used by one particle of a solid particle system.
  100865. * SPS internal tool, don't use it manually.
  100866. */
  100867. export class ModelShape {
  100868. /**
  100869. * The shape id
  100870. * @hidden
  100871. */
  100872. shapeID: number;
  100873. /**
  100874. * flat array of model positions (internal use)
  100875. * @hidden
  100876. */
  100877. _shape: Vector3[];
  100878. /**
  100879. * flat array of model UVs (internal use)
  100880. * @hidden
  100881. */
  100882. _shapeUV: number[];
  100883. /**
  100884. * color array of the model
  100885. * @hidden
  100886. */
  100887. _shapeColors: number[];
  100888. /**
  100889. * indices array of the model
  100890. * @hidden
  100891. */
  100892. _indices: number[];
  100893. /**
  100894. * normals array of the model
  100895. * @hidden
  100896. */
  100897. _normals: number[];
  100898. /**
  100899. * length of the shape in the model indices array (internal use)
  100900. * @hidden
  100901. */
  100902. _indicesLength: number;
  100903. /**
  100904. * Custom position function (internal use)
  100905. * @hidden
  100906. */
  100907. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  100908. /**
  100909. * Custom vertex function (internal use)
  100910. * @hidden
  100911. */
  100912. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  100913. /**
  100914. * Model material (internal use)
  100915. * @hidden
  100916. */
  100917. _material: Nullable<Material>;
  100918. /**
  100919. * 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.
  100920. * SPS internal tool, don't use it manually.
  100921. * @hidden
  100922. */
  100923. 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>);
  100924. }
  100925. /**
  100926. * Represents a Depth Sorted Particle in the solid particle system.
  100927. * @hidden
  100928. */
  100929. export class DepthSortedParticle {
  100930. /**
  100931. * Index of the particle in the "indices" array
  100932. */
  100933. ind: number;
  100934. /**
  100935. * Length of the particle shape in the "indices" array
  100936. */
  100937. indicesLength: number;
  100938. /**
  100939. * Squared distance from the particle to the camera
  100940. */
  100941. sqDistance: number;
  100942. /**
  100943. * Material index when used with MultiMaterials
  100944. */
  100945. materialIndex: number;
  100946. /**
  100947. * Creates a new sorted particle
  100948. * @param materialIndex
  100949. */
  100950. constructor(ind: number, indLength: number, materialIndex: number);
  100951. }
  100952. }
  100953. declare module BABYLON {
  100954. /**
  100955. * @hidden
  100956. */
  100957. export class _MeshCollisionData {
  100958. _checkCollisions: boolean;
  100959. _collisionMask: number;
  100960. _collisionGroup: number;
  100961. _collider: Nullable<Collider>;
  100962. _oldPositionForCollisions: Vector3;
  100963. _diffPositionForCollisions: Vector3;
  100964. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  100965. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  100966. }
  100967. }
  100968. declare module BABYLON {
  100969. /** @hidden */
  100970. class _FacetDataStorage {
  100971. facetPositions: Vector3[];
  100972. facetNormals: Vector3[];
  100973. facetPartitioning: number[][];
  100974. facetNb: number;
  100975. partitioningSubdivisions: number;
  100976. partitioningBBoxRatio: number;
  100977. facetDataEnabled: boolean;
  100978. facetParameters: any;
  100979. bbSize: Vector3;
  100980. subDiv: {
  100981. max: number;
  100982. X: number;
  100983. Y: number;
  100984. Z: number;
  100985. };
  100986. facetDepthSort: boolean;
  100987. facetDepthSortEnabled: boolean;
  100988. depthSortedIndices: IndicesArray;
  100989. depthSortedFacets: {
  100990. ind: number;
  100991. sqDistance: number;
  100992. }[];
  100993. facetDepthSortFunction: (f1: {
  100994. ind: number;
  100995. sqDistance: number;
  100996. }, f2: {
  100997. ind: number;
  100998. sqDistance: number;
  100999. }) => number;
  101000. facetDepthSortFrom: Vector3;
  101001. facetDepthSortOrigin: Vector3;
  101002. invertedMatrix: Matrix;
  101003. }
  101004. /**
  101005. * @hidden
  101006. **/
  101007. class _InternalAbstractMeshDataInfo {
  101008. _hasVertexAlpha: boolean;
  101009. _useVertexColors: boolean;
  101010. _numBoneInfluencers: number;
  101011. _applyFog: boolean;
  101012. _receiveShadows: boolean;
  101013. _facetData: _FacetDataStorage;
  101014. _visibility: number;
  101015. _skeleton: Nullable<Skeleton>;
  101016. _layerMask: number;
  101017. _computeBonesUsingShaders: boolean;
  101018. _isActive: boolean;
  101019. _onlyForInstances: boolean;
  101020. _isActiveIntermediate: boolean;
  101021. _onlyForInstancesIntermediate: boolean;
  101022. _actAsRegularMesh: boolean;
  101023. }
  101024. /**
  101025. * Class used to store all common mesh properties
  101026. */
  101027. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  101028. /** No occlusion */
  101029. static OCCLUSION_TYPE_NONE: number;
  101030. /** Occlusion set to optimisitic */
  101031. static OCCLUSION_TYPE_OPTIMISTIC: number;
  101032. /** Occlusion set to strict */
  101033. static OCCLUSION_TYPE_STRICT: number;
  101034. /** Use an accurante occlusion algorithm */
  101035. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  101036. /** Use a conservative occlusion algorithm */
  101037. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  101038. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  101039. * Test order :
  101040. * Is the bounding sphere outside the frustum ?
  101041. * If not, are the bounding box vertices outside the frustum ?
  101042. * It not, then the cullable object is in the frustum.
  101043. */
  101044. static readonly CULLINGSTRATEGY_STANDARD: number;
  101045. /** Culling strategy : Bounding Sphere Only.
  101046. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  101047. * It's also less accurate than the standard because some not visible objects can still be selected.
  101048. * Test : is the bounding sphere outside the frustum ?
  101049. * If not, then the cullable object is in the frustum.
  101050. */
  101051. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  101052. /** Culling strategy : Optimistic Inclusion.
  101053. * This in an inclusion test first, then the standard exclusion test.
  101054. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  101055. * 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.
  101056. * Anyway, it's as accurate as the standard strategy.
  101057. * Test :
  101058. * Is the cullable object bounding sphere center in the frustum ?
  101059. * If not, apply the default culling strategy.
  101060. */
  101061. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  101062. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  101063. * This in an inclusion test first, then the bounding sphere only exclusion test.
  101064. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  101065. * 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.
  101066. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  101067. * Test :
  101068. * Is the cullable object bounding sphere center in the frustum ?
  101069. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  101070. */
  101071. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  101072. /**
  101073. * No billboard
  101074. */
  101075. static get BILLBOARDMODE_NONE(): number;
  101076. /** Billboard on X axis */
  101077. static get BILLBOARDMODE_X(): number;
  101078. /** Billboard on Y axis */
  101079. static get BILLBOARDMODE_Y(): number;
  101080. /** Billboard on Z axis */
  101081. static get BILLBOARDMODE_Z(): number;
  101082. /** Billboard on all axes */
  101083. static get BILLBOARDMODE_ALL(): number;
  101084. /** Billboard on using position instead of orientation */
  101085. static get BILLBOARDMODE_USE_POSITION(): number;
  101086. /** @hidden */
  101087. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  101088. /**
  101089. * The culling strategy to use to check whether the mesh must be rendered or not.
  101090. * This value can be changed at any time and will be used on the next render mesh selection.
  101091. * The possible values are :
  101092. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  101093. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  101094. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  101095. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  101096. * Please read each static variable documentation to get details about the culling process.
  101097. * */
  101098. cullingStrategy: number;
  101099. /**
  101100. * Gets the number of facets in the mesh
  101101. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  101102. */
  101103. get facetNb(): number;
  101104. /**
  101105. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  101106. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  101107. */
  101108. get partitioningSubdivisions(): number;
  101109. set partitioningSubdivisions(nb: number);
  101110. /**
  101111. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  101112. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  101113. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  101114. */
  101115. get partitioningBBoxRatio(): number;
  101116. set partitioningBBoxRatio(ratio: number);
  101117. /**
  101118. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  101119. * Works only for updatable meshes.
  101120. * Doesn't work with multi-materials
  101121. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  101122. */
  101123. get mustDepthSortFacets(): boolean;
  101124. set mustDepthSortFacets(sort: boolean);
  101125. /**
  101126. * The location (Vector3) where the facet depth sort must be computed from.
  101127. * By default, the active camera position.
  101128. * Used only when facet depth sort is enabled
  101129. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  101130. */
  101131. get facetDepthSortFrom(): Vector3;
  101132. set facetDepthSortFrom(location: Vector3);
  101133. /**
  101134. * gets a boolean indicating if facetData is enabled
  101135. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  101136. */
  101137. get isFacetDataEnabled(): boolean;
  101138. /** @hidden */
  101139. _updateNonUniformScalingState(value: boolean): boolean;
  101140. /**
  101141. * An event triggered when this mesh collides with another one
  101142. */
  101143. onCollideObservable: Observable<AbstractMesh>;
  101144. /** Set a function to call when this mesh collides with another one */
  101145. set onCollide(callback: () => void);
  101146. /**
  101147. * An event triggered when the collision's position changes
  101148. */
  101149. onCollisionPositionChangeObservable: Observable<Vector3>;
  101150. /** Set a function to call when the collision's position changes */
  101151. set onCollisionPositionChange(callback: () => void);
  101152. /**
  101153. * An event triggered when material is changed
  101154. */
  101155. onMaterialChangedObservable: Observable<AbstractMesh>;
  101156. /**
  101157. * Gets or sets the orientation for POV movement & rotation
  101158. */
  101159. definedFacingForward: boolean;
  101160. /** @hidden */
  101161. _occlusionQuery: Nullable<WebGLQuery>;
  101162. /** @hidden */
  101163. _renderingGroup: Nullable<RenderingGroup>;
  101164. /**
  101165. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  101166. */
  101167. get visibility(): number;
  101168. /**
  101169. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  101170. */
  101171. set visibility(value: number);
  101172. /** Gets or sets the alpha index used to sort transparent meshes
  101173. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  101174. */
  101175. alphaIndex: number;
  101176. /**
  101177. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  101178. */
  101179. isVisible: boolean;
  101180. /**
  101181. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  101182. */
  101183. isPickable: boolean;
  101184. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  101185. showSubMeshesBoundingBox: boolean;
  101186. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  101187. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  101188. */
  101189. isBlocker: boolean;
  101190. /**
  101191. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  101192. */
  101193. enablePointerMoveEvents: boolean;
  101194. /**
  101195. * Specifies the rendering group id for this mesh (0 by default)
  101196. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  101197. */
  101198. renderingGroupId: number;
  101199. private _material;
  101200. /** Gets or sets current material */
  101201. get material(): Nullable<Material>;
  101202. set material(value: Nullable<Material>);
  101203. /**
  101204. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  101205. * @see http://doc.babylonjs.com/babylon101/shadows
  101206. */
  101207. get receiveShadows(): boolean;
  101208. set receiveShadows(value: boolean);
  101209. /** Defines color to use when rendering outline */
  101210. outlineColor: Color3;
  101211. /** Define width to use when rendering outline */
  101212. outlineWidth: number;
  101213. /** Defines color to use when rendering overlay */
  101214. overlayColor: Color3;
  101215. /** Defines alpha to use when rendering overlay */
  101216. overlayAlpha: number;
  101217. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  101218. get hasVertexAlpha(): boolean;
  101219. set hasVertexAlpha(value: boolean);
  101220. /** 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) */
  101221. get useVertexColors(): boolean;
  101222. set useVertexColors(value: boolean);
  101223. /**
  101224. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  101225. */
  101226. get computeBonesUsingShaders(): boolean;
  101227. set computeBonesUsingShaders(value: boolean);
  101228. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  101229. get numBoneInfluencers(): number;
  101230. set numBoneInfluencers(value: number);
  101231. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  101232. get applyFog(): boolean;
  101233. set applyFog(value: boolean);
  101234. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  101235. useOctreeForRenderingSelection: boolean;
  101236. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  101237. useOctreeForPicking: boolean;
  101238. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  101239. useOctreeForCollisions: boolean;
  101240. /**
  101241. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  101242. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  101243. */
  101244. get layerMask(): number;
  101245. set layerMask(value: number);
  101246. /**
  101247. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  101248. */
  101249. alwaysSelectAsActiveMesh: boolean;
  101250. /**
  101251. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  101252. */
  101253. doNotSyncBoundingInfo: boolean;
  101254. /**
  101255. * Gets or sets the current action manager
  101256. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  101257. */
  101258. actionManager: Nullable<AbstractActionManager>;
  101259. private _meshCollisionData;
  101260. /**
  101261. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  101262. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101263. */
  101264. ellipsoid: Vector3;
  101265. /**
  101266. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  101267. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101268. */
  101269. ellipsoidOffset: Vector3;
  101270. /**
  101271. * Gets or sets a collision mask used to mask collisions (default is -1).
  101272. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  101273. */
  101274. get collisionMask(): number;
  101275. set collisionMask(mask: number);
  101276. /**
  101277. * Gets or sets the current collision group mask (-1 by default).
  101278. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  101279. */
  101280. get collisionGroup(): number;
  101281. set collisionGroup(mask: number);
  101282. /**
  101283. * Defines edge width used when edgesRenderer is enabled
  101284. * @see https://www.babylonjs-playground.com/#10OJSG#13
  101285. */
  101286. edgesWidth: number;
  101287. /**
  101288. * Defines edge color used when edgesRenderer is enabled
  101289. * @see https://www.babylonjs-playground.com/#10OJSG#13
  101290. */
  101291. edgesColor: Color4;
  101292. /** @hidden */
  101293. _edgesRenderer: Nullable<IEdgesRenderer>;
  101294. /** @hidden */
  101295. _masterMesh: Nullable<AbstractMesh>;
  101296. /** @hidden */
  101297. _boundingInfo: Nullable<BoundingInfo>;
  101298. /** @hidden */
  101299. _renderId: number;
  101300. /**
  101301. * Gets or sets the list of subMeshes
  101302. * @see http://doc.babylonjs.com/how_to/multi_materials
  101303. */
  101304. subMeshes: SubMesh[];
  101305. /** @hidden */
  101306. _intersectionsInProgress: AbstractMesh[];
  101307. /** @hidden */
  101308. _unIndexed: boolean;
  101309. /** @hidden */
  101310. _lightSources: Light[];
  101311. /** Gets the list of lights affecting that mesh */
  101312. get lightSources(): Light[];
  101313. /** @hidden */
  101314. get _positions(): Nullable<Vector3[]>;
  101315. /** @hidden */
  101316. _waitingData: {
  101317. lods: Nullable<any>;
  101318. actions: Nullable<any>;
  101319. freezeWorldMatrix: Nullable<boolean>;
  101320. };
  101321. /** @hidden */
  101322. _bonesTransformMatrices: Nullable<Float32Array>;
  101323. /** @hidden */
  101324. _transformMatrixTexture: Nullable<RawTexture>;
  101325. /**
  101326. * Gets or sets a skeleton to apply skining transformations
  101327. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  101328. */
  101329. set skeleton(value: Nullable<Skeleton>);
  101330. get skeleton(): Nullable<Skeleton>;
  101331. /**
  101332. * An event triggered when the mesh is rebuilt.
  101333. */
  101334. onRebuildObservable: Observable<AbstractMesh>;
  101335. /**
  101336. * Creates a new AbstractMesh
  101337. * @param name defines the name of the mesh
  101338. * @param scene defines the hosting scene
  101339. */
  101340. constructor(name: string, scene?: Nullable<Scene>);
  101341. /**
  101342. * Returns the string "AbstractMesh"
  101343. * @returns "AbstractMesh"
  101344. */
  101345. getClassName(): string;
  101346. /**
  101347. * Gets a string representation of the current mesh
  101348. * @param fullDetails defines a boolean indicating if full details must be included
  101349. * @returns a string representation of the current mesh
  101350. */
  101351. toString(fullDetails?: boolean): string;
  101352. /**
  101353. * @hidden
  101354. */
  101355. protected _getEffectiveParent(): Nullable<Node>;
  101356. /** @hidden */
  101357. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  101358. /** @hidden */
  101359. _rebuild(): void;
  101360. /** @hidden */
  101361. _resyncLightSources(): void;
  101362. /** @hidden */
  101363. _resyncLightSource(light: Light): void;
  101364. /** @hidden */
  101365. _unBindEffect(): void;
  101366. /** @hidden */
  101367. _removeLightSource(light: Light, dispose: boolean): void;
  101368. private _markSubMeshesAsDirty;
  101369. /** @hidden */
  101370. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  101371. /** @hidden */
  101372. _markSubMeshesAsAttributesDirty(): void;
  101373. /** @hidden */
  101374. _markSubMeshesAsMiscDirty(): void;
  101375. /**
  101376. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  101377. */
  101378. get scaling(): Vector3;
  101379. set scaling(newScaling: Vector3);
  101380. /**
  101381. * Returns true if the mesh is blocked. Implemented by child classes
  101382. */
  101383. get isBlocked(): boolean;
  101384. /**
  101385. * Returns the mesh itself by default. Implemented by child classes
  101386. * @param camera defines the camera to use to pick the right LOD level
  101387. * @returns the currentAbstractMesh
  101388. */
  101389. getLOD(camera: Camera): Nullable<AbstractMesh>;
  101390. /**
  101391. * Returns 0 by default. Implemented by child classes
  101392. * @returns an integer
  101393. */
  101394. getTotalVertices(): number;
  101395. /**
  101396. * Returns a positive integer : the total number of indices in this mesh geometry.
  101397. * @returns the numner of indices or zero if the mesh has no geometry.
  101398. */
  101399. getTotalIndices(): number;
  101400. /**
  101401. * Returns null by default. Implemented by child classes
  101402. * @returns null
  101403. */
  101404. getIndices(): Nullable<IndicesArray>;
  101405. /**
  101406. * Returns the array of the requested vertex data kind. Implemented by child classes
  101407. * @param kind defines the vertex data kind to use
  101408. * @returns null
  101409. */
  101410. getVerticesData(kind: string): Nullable<FloatArray>;
  101411. /**
  101412. * Sets the vertex data of the mesh geometry for the requested `kind`.
  101413. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  101414. * Note that a new underlying VertexBuffer object is created each call.
  101415. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  101416. * @param kind defines vertex data kind:
  101417. * * VertexBuffer.PositionKind
  101418. * * VertexBuffer.UVKind
  101419. * * VertexBuffer.UV2Kind
  101420. * * VertexBuffer.UV3Kind
  101421. * * VertexBuffer.UV4Kind
  101422. * * VertexBuffer.UV5Kind
  101423. * * VertexBuffer.UV6Kind
  101424. * * VertexBuffer.ColorKind
  101425. * * VertexBuffer.MatricesIndicesKind
  101426. * * VertexBuffer.MatricesIndicesExtraKind
  101427. * * VertexBuffer.MatricesWeightsKind
  101428. * * VertexBuffer.MatricesWeightsExtraKind
  101429. * @param data defines the data source
  101430. * @param updatable defines if the data must be flagged as updatable (or static)
  101431. * @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
  101432. * @returns the current mesh
  101433. */
  101434. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  101435. /**
  101436. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  101437. * If the mesh has no geometry, it is simply returned as it is.
  101438. * @param kind defines vertex data kind:
  101439. * * VertexBuffer.PositionKind
  101440. * * VertexBuffer.UVKind
  101441. * * VertexBuffer.UV2Kind
  101442. * * VertexBuffer.UV3Kind
  101443. * * VertexBuffer.UV4Kind
  101444. * * VertexBuffer.UV5Kind
  101445. * * VertexBuffer.UV6Kind
  101446. * * VertexBuffer.ColorKind
  101447. * * VertexBuffer.MatricesIndicesKind
  101448. * * VertexBuffer.MatricesIndicesExtraKind
  101449. * * VertexBuffer.MatricesWeightsKind
  101450. * * VertexBuffer.MatricesWeightsExtraKind
  101451. * @param data defines the data source
  101452. * @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
  101453. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  101454. * @returns the current mesh
  101455. */
  101456. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  101457. /**
  101458. * Sets the mesh indices,
  101459. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  101460. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  101461. * @param totalVertices Defines the total number of vertices
  101462. * @returns the current mesh
  101463. */
  101464. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  101465. /**
  101466. * Gets a boolean indicating if specific vertex data is present
  101467. * @param kind defines the vertex data kind to use
  101468. * @returns true is data kind is present
  101469. */
  101470. isVerticesDataPresent(kind: string): boolean;
  101471. /**
  101472. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  101473. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  101474. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  101475. * @returns a BoundingInfo
  101476. */
  101477. getBoundingInfo(): BoundingInfo;
  101478. /**
  101479. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  101480. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  101481. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  101482. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  101483. * @returns the current mesh
  101484. */
  101485. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  101486. /**
  101487. * Overwrite the current bounding info
  101488. * @param boundingInfo defines the new bounding info
  101489. * @returns the current mesh
  101490. */
  101491. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  101492. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  101493. get useBones(): boolean;
  101494. /** @hidden */
  101495. _preActivate(): void;
  101496. /** @hidden */
  101497. _preActivateForIntermediateRendering(renderId: number): void;
  101498. /** @hidden */
  101499. _activate(renderId: number, intermediateRendering: boolean): boolean;
  101500. /** @hidden */
  101501. _postActivate(): void;
  101502. /** @hidden */
  101503. _freeze(): void;
  101504. /** @hidden */
  101505. _unFreeze(): void;
  101506. /**
  101507. * Gets the current world matrix
  101508. * @returns a Matrix
  101509. */
  101510. getWorldMatrix(): Matrix;
  101511. /** @hidden */
  101512. _getWorldMatrixDeterminant(): number;
  101513. /**
  101514. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  101515. */
  101516. get isAnInstance(): boolean;
  101517. /**
  101518. * Gets a boolean indicating if this mesh has instances
  101519. */
  101520. get hasInstances(): boolean;
  101521. /**
  101522. * Perform relative position change from the point of view of behind the front of the mesh.
  101523. * This is performed taking into account the meshes current rotation, so you do not have to care.
  101524. * Supports definition of mesh facing forward or backward
  101525. * @param amountRight defines the distance on the right axis
  101526. * @param amountUp defines the distance on the up axis
  101527. * @param amountForward defines the distance on the forward axis
  101528. * @returns the current mesh
  101529. */
  101530. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  101531. /**
  101532. * Calculate relative position change from the point of view of behind the front of the mesh.
  101533. * This is performed taking into account the meshes current rotation, so you do not have to care.
  101534. * Supports definition of mesh facing forward or backward
  101535. * @param amountRight defines the distance on the right axis
  101536. * @param amountUp defines the distance on the up axis
  101537. * @param amountForward defines the distance on the forward axis
  101538. * @returns the new displacement vector
  101539. */
  101540. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  101541. /**
  101542. * Perform relative rotation change from the point of view of behind the front of the mesh.
  101543. * Supports definition of mesh facing forward or backward
  101544. * @param flipBack defines the flip
  101545. * @param twirlClockwise defines the twirl
  101546. * @param tiltRight defines the tilt
  101547. * @returns the current mesh
  101548. */
  101549. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  101550. /**
  101551. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  101552. * Supports definition of mesh facing forward or backward.
  101553. * @param flipBack defines the flip
  101554. * @param twirlClockwise defines the twirl
  101555. * @param tiltRight defines the tilt
  101556. * @returns the new rotation vector
  101557. */
  101558. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  101559. /**
  101560. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  101561. * This means the mesh underlying bounding box and sphere are recomputed.
  101562. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  101563. * @returns the current mesh
  101564. */
  101565. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  101566. /** @hidden */
  101567. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  101568. /** @hidden */
  101569. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  101570. /** @hidden */
  101571. _updateBoundingInfo(): AbstractMesh;
  101572. /** @hidden */
  101573. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  101574. /** @hidden */
  101575. protected _afterComputeWorldMatrix(): void;
  101576. /** @hidden */
  101577. get _effectiveMesh(): AbstractMesh;
  101578. /**
  101579. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  101580. * A mesh is in the frustum if its bounding box intersects the frustum
  101581. * @param frustumPlanes defines the frustum to test
  101582. * @returns true if the mesh is in the frustum planes
  101583. */
  101584. isInFrustum(frustumPlanes: Plane[]): boolean;
  101585. /**
  101586. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  101587. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  101588. * @param frustumPlanes defines the frustum to test
  101589. * @returns true if the mesh is completely in the frustum planes
  101590. */
  101591. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  101592. /**
  101593. * True if the mesh intersects another mesh or a SolidParticle object
  101594. * @param mesh defines a target mesh or SolidParticle to test
  101595. * @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)
  101596. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  101597. * @returns true if there is an intersection
  101598. */
  101599. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  101600. /**
  101601. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  101602. * @param point defines the point to test
  101603. * @returns true if there is an intersection
  101604. */
  101605. intersectsPoint(point: Vector3): boolean;
  101606. /**
  101607. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  101608. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101609. */
  101610. get checkCollisions(): boolean;
  101611. set checkCollisions(collisionEnabled: boolean);
  101612. /**
  101613. * Gets Collider object used to compute collisions (not physics)
  101614. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101615. */
  101616. get collider(): Nullable<Collider>;
  101617. /**
  101618. * Move the mesh using collision engine
  101619. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101620. * @param displacement defines the requested displacement vector
  101621. * @returns the current mesh
  101622. */
  101623. moveWithCollisions(displacement: Vector3): AbstractMesh;
  101624. private _onCollisionPositionChange;
  101625. /** @hidden */
  101626. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  101627. /** @hidden */
  101628. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  101629. /** @hidden */
  101630. _checkCollision(collider: Collider): AbstractMesh;
  101631. /** @hidden */
  101632. _generatePointsArray(): boolean;
  101633. /**
  101634. * Checks if the passed Ray intersects with the mesh
  101635. * @param ray defines the ray to use
  101636. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  101637. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101638. * @returns the picking info
  101639. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  101640. */
  101641. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  101642. /**
  101643. * Clones the current mesh
  101644. * @param name defines the mesh name
  101645. * @param newParent defines the new mesh parent
  101646. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  101647. * @returns the new mesh
  101648. */
  101649. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  101650. /**
  101651. * Disposes all the submeshes of the current meshnp
  101652. * @returns the current mesh
  101653. */
  101654. releaseSubMeshes(): AbstractMesh;
  101655. /**
  101656. * Releases resources associated with this abstract mesh.
  101657. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  101658. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  101659. */
  101660. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  101661. /**
  101662. * Adds the passed mesh as a child to the current mesh
  101663. * @param mesh defines the child mesh
  101664. * @returns the current mesh
  101665. */
  101666. addChild(mesh: AbstractMesh): AbstractMesh;
  101667. /**
  101668. * Removes the passed mesh from the current mesh children list
  101669. * @param mesh defines the child mesh
  101670. * @returns the current mesh
  101671. */
  101672. removeChild(mesh: AbstractMesh): AbstractMesh;
  101673. /** @hidden */
  101674. private _initFacetData;
  101675. /**
  101676. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  101677. * This method can be called within the render loop.
  101678. * 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
  101679. * @returns the current mesh
  101680. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101681. */
  101682. updateFacetData(): AbstractMesh;
  101683. /**
  101684. * Returns the facetLocalNormals array.
  101685. * The normals are expressed in the mesh local spac
  101686. * @returns an array of Vector3
  101687. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101688. */
  101689. getFacetLocalNormals(): Vector3[];
  101690. /**
  101691. * Returns the facetLocalPositions array.
  101692. * The facet positions are expressed in the mesh local space
  101693. * @returns an array of Vector3
  101694. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101695. */
  101696. getFacetLocalPositions(): Vector3[];
  101697. /**
  101698. * Returns the facetLocalPartioning array
  101699. * @returns an array of array of numbers
  101700. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101701. */
  101702. getFacetLocalPartitioning(): number[][];
  101703. /**
  101704. * Returns the i-th facet position in the world system.
  101705. * This method allocates a new Vector3 per call
  101706. * @param i defines the facet index
  101707. * @returns a new Vector3
  101708. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101709. */
  101710. getFacetPosition(i: number): Vector3;
  101711. /**
  101712. * Sets the reference Vector3 with the i-th facet position in the world system
  101713. * @param i defines the facet index
  101714. * @param ref defines the target vector
  101715. * @returns the current mesh
  101716. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101717. */
  101718. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  101719. /**
  101720. * Returns the i-th facet normal in the world system.
  101721. * This method allocates a new Vector3 per call
  101722. * @param i defines the facet index
  101723. * @returns a new Vector3
  101724. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101725. */
  101726. getFacetNormal(i: number): Vector3;
  101727. /**
  101728. * Sets the reference Vector3 with the i-th facet normal in the world system
  101729. * @param i defines the facet index
  101730. * @param ref defines the target vector
  101731. * @returns the current mesh
  101732. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101733. */
  101734. getFacetNormalToRef(i: number, ref: Vector3): this;
  101735. /**
  101736. * 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)
  101737. * @param x defines x coordinate
  101738. * @param y defines y coordinate
  101739. * @param z defines z coordinate
  101740. * @returns the array of facet indexes
  101741. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101742. */
  101743. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  101744. /**
  101745. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  101746. * @param projected sets as the (x,y,z) world projection on the facet
  101747. * @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
  101748. * @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
  101749. * @param x defines x coordinate
  101750. * @param y defines y coordinate
  101751. * @param z defines z coordinate
  101752. * @returns the face index if found (or null instead)
  101753. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101754. */
  101755. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  101756. /**
  101757. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  101758. * @param projected sets as the (x,y,z) local projection on the facet
  101759. * @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
  101760. * @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
  101761. * @param x defines x coordinate
  101762. * @param y defines y coordinate
  101763. * @param z defines z coordinate
  101764. * @returns the face index if found (or null instead)
  101765. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101766. */
  101767. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  101768. /**
  101769. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  101770. * @returns the parameters
  101771. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101772. */
  101773. getFacetDataParameters(): any;
  101774. /**
  101775. * Disables the feature FacetData and frees the related memory
  101776. * @returns the current mesh
  101777. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101778. */
  101779. disableFacetData(): AbstractMesh;
  101780. /**
  101781. * Updates the AbstractMesh indices array
  101782. * @param indices defines the data source
  101783. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  101784. * @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)
  101785. * @returns the current mesh
  101786. */
  101787. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  101788. /**
  101789. * Creates new normals data for the mesh
  101790. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  101791. * @returns the current mesh
  101792. */
  101793. createNormals(updatable: boolean): AbstractMesh;
  101794. /**
  101795. * Align the mesh with a normal
  101796. * @param normal defines the normal to use
  101797. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  101798. * @returns the current mesh
  101799. */
  101800. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  101801. /** @hidden */
  101802. _checkOcclusionQuery(): boolean;
  101803. /**
  101804. * Disables the mesh edge rendering mode
  101805. * @returns the currentAbstractMesh
  101806. */
  101807. disableEdgesRendering(): AbstractMesh;
  101808. /**
  101809. * Enables the edge rendering mode on the mesh.
  101810. * This mode makes the mesh edges visible
  101811. * @param epsilon defines the maximal distance between two angles to detect a face
  101812. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  101813. * @returns the currentAbstractMesh
  101814. * @see https://www.babylonjs-playground.com/#19O9TU#0
  101815. */
  101816. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  101817. }
  101818. }
  101819. declare module BABYLON {
  101820. /**
  101821. * Interface used to define ActionEvent
  101822. */
  101823. export interface IActionEvent {
  101824. /** The mesh or sprite that triggered the action */
  101825. source: any;
  101826. /** The X mouse cursor position at the time of the event */
  101827. pointerX: number;
  101828. /** The Y mouse cursor position at the time of the event */
  101829. pointerY: number;
  101830. /** The mesh that is currently pointed at (can be null) */
  101831. meshUnderPointer: Nullable<AbstractMesh>;
  101832. /** the original (browser) event that triggered the ActionEvent */
  101833. sourceEvent?: any;
  101834. /** additional data for the event */
  101835. additionalData?: any;
  101836. }
  101837. /**
  101838. * ActionEvent is the event being sent when an action is triggered.
  101839. */
  101840. export class ActionEvent implements IActionEvent {
  101841. /** The mesh or sprite that triggered the action */
  101842. source: any;
  101843. /** The X mouse cursor position at the time of the event */
  101844. pointerX: number;
  101845. /** The Y mouse cursor position at the time of the event */
  101846. pointerY: number;
  101847. /** The mesh that is currently pointed at (can be null) */
  101848. meshUnderPointer: Nullable<AbstractMesh>;
  101849. /** the original (browser) event that triggered the ActionEvent */
  101850. sourceEvent?: any;
  101851. /** additional data for the event */
  101852. additionalData?: any;
  101853. /**
  101854. * Creates a new ActionEvent
  101855. * @param source The mesh or sprite that triggered the action
  101856. * @param pointerX The X mouse cursor position at the time of the event
  101857. * @param pointerY The Y mouse cursor position at the time of the event
  101858. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  101859. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  101860. * @param additionalData additional data for the event
  101861. */
  101862. constructor(
  101863. /** The mesh or sprite that triggered the action */
  101864. source: any,
  101865. /** The X mouse cursor position at the time of the event */
  101866. pointerX: number,
  101867. /** The Y mouse cursor position at the time of the event */
  101868. pointerY: number,
  101869. /** The mesh that is currently pointed at (can be null) */
  101870. meshUnderPointer: Nullable<AbstractMesh>,
  101871. /** the original (browser) event that triggered the ActionEvent */
  101872. sourceEvent?: any,
  101873. /** additional data for the event */
  101874. additionalData?: any);
  101875. /**
  101876. * Helper function to auto-create an ActionEvent from a source mesh.
  101877. * @param source The source mesh that triggered the event
  101878. * @param evt The original (browser) event
  101879. * @param additionalData additional data for the event
  101880. * @returns the new ActionEvent
  101881. */
  101882. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  101883. /**
  101884. * Helper function to auto-create an ActionEvent from a source sprite
  101885. * @param source The source sprite that triggered the event
  101886. * @param scene Scene associated with the sprite
  101887. * @param evt The original (browser) event
  101888. * @param additionalData additional data for the event
  101889. * @returns the new ActionEvent
  101890. */
  101891. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  101892. /**
  101893. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  101894. * @param scene the scene where the event occurred
  101895. * @param evt The original (browser) event
  101896. * @returns the new ActionEvent
  101897. */
  101898. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  101899. /**
  101900. * Helper function to auto-create an ActionEvent from a primitive
  101901. * @param prim defines the target primitive
  101902. * @param pointerPos defines the pointer position
  101903. * @param evt The original (browser) event
  101904. * @param additionalData additional data for the event
  101905. * @returns the new ActionEvent
  101906. */
  101907. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  101908. }
  101909. }
  101910. declare module BABYLON {
  101911. /**
  101912. * Abstract class used to decouple action Manager from scene and meshes.
  101913. * Do not instantiate.
  101914. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  101915. */
  101916. export abstract class AbstractActionManager implements IDisposable {
  101917. /** Gets the list of active triggers */
  101918. static Triggers: {
  101919. [key: string]: number;
  101920. };
  101921. /** Gets the cursor to use when hovering items */
  101922. hoverCursor: string;
  101923. /** Gets the list of actions */
  101924. actions: IAction[];
  101925. /**
  101926. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  101927. */
  101928. isRecursive: boolean;
  101929. /**
  101930. * Releases all associated resources
  101931. */
  101932. abstract dispose(): void;
  101933. /**
  101934. * Does this action manager has pointer triggers
  101935. */
  101936. abstract get hasPointerTriggers(): boolean;
  101937. /**
  101938. * Does this action manager has pick triggers
  101939. */
  101940. abstract get hasPickTriggers(): boolean;
  101941. /**
  101942. * Process a specific trigger
  101943. * @param trigger defines the trigger to process
  101944. * @param evt defines the event details to be processed
  101945. */
  101946. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  101947. /**
  101948. * Does this action manager handles actions of any of the given triggers
  101949. * @param triggers defines the triggers to be tested
  101950. * @return a boolean indicating whether one (or more) of the triggers is handled
  101951. */
  101952. abstract hasSpecificTriggers(triggers: number[]): boolean;
  101953. /**
  101954. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  101955. * speed.
  101956. * @param triggerA defines the trigger to be tested
  101957. * @param triggerB defines the trigger to be tested
  101958. * @return a boolean indicating whether one (or more) of the triggers is handled
  101959. */
  101960. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  101961. /**
  101962. * Does this action manager handles actions of a given trigger
  101963. * @param trigger defines the trigger to be tested
  101964. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  101965. * @return whether the trigger is handled
  101966. */
  101967. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  101968. /**
  101969. * Serialize this manager to a JSON object
  101970. * @param name defines the property name to store this manager
  101971. * @returns a JSON representation of this manager
  101972. */
  101973. abstract serialize(name: string): any;
  101974. /**
  101975. * Registers an action to this action manager
  101976. * @param action defines the action to be registered
  101977. * @return the action amended (prepared) after registration
  101978. */
  101979. abstract registerAction(action: IAction): Nullable<IAction>;
  101980. /**
  101981. * Unregisters an action to this action manager
  101982. * @param action defines the action to be unregistered
  101983. * @return a boolean indicating whether the action has been unregistered
  101984. */
  101985. abstract unregisterAction(action: IAction): Boolean;
  101986. /**
  101987. * Does exist one action manager with at least one trigger
  101988. **/
  101989. static get HasTriggers(): boolean;
  101990. /**
  101991. * Does exist one action manager with at least one pick trigger
  101992. **/
  101993. static get HasPickTriggers(): boolean;
  101994. /**
  101995. * Does exist one action manager that handles actions of a given trigger
  101996. * @param trigger defines the trigger to be tested
  101997. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  101998. **/
  101999. static HasSpecificTrigger(trigger: number): boolean;
  102000. }
  102001. }
  102002. declare module BABYLON {
  102003. /**
  102004. * Defines how a node can be built from a string name.
  102005. */
  102006. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  102007. /**
  102008. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  102009. */
  102010. export class Node implements IBehaviorAware<Node> {
  102011. /** @hidden */
  102012. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  102013. private static _NodeConstructors;
  102014. /**
  102015. * Add a new node constructor
  102016. * @param type defines the type name of the node to construct
  102017. * @param constructorFunc defines the constructor function
  102018. */
  102019. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  102020. /**
  102021. * Returns a node constructor based on type name
  102022. * @param type defines the type name
  102023. * @param name defines the new node name
  102024. * @param scene defines the hosting scene
  102025. * @param options defines optional options to transmit to constructors
  102026. * @returns the new constructor or null
  102027. */
  102028. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  102029. /**
  102030. * Gets or sets the name of the node
  102031. */
  102032. name: string;
  102033. /**
  102034. * Gets or sets the id of the node
  102035. */
  102036. id: string;
  102037. /**
  102038. * Gets or sets the unique id of the node
  102039. */
  102040. uniqueId: number;
  102041. /**
  102042. * Gets or sets a string used to store user defined state for the node
  102043. */
  102044. state: string;
  102045. /**
  102046. * Gets or sets an object used to store user defined information for the node
  102047. */
  102048. metadata: any;
  102049. /**
  102050. * For internal use only. Please do not use.
  102051. */
  102052. reservedDataStore: any;
  102053. /**
  102054. * List of inspectable custom properties (used by the Inspector)
  102055. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  102056. */
  102057. inspectableCustomProperties: IInspectable[];
  102058. private _doNotSerialize;
  102059. /**
  102060. * Gets or sets a boolean used to define if the node must be serialized
  102061. */
  102062. get doNotSerialize(): boolean;
  102063. set doNotSerialize(value: boolean);
  102064. /** @hidden */
  102065. _isDisposed: boolean;
  102066. /**
  102067. * Gets a list of Animations associated with the node
  102068. */
  102069. animations: Animation[];
  102070. protected _ranges: {
  102071. [name: string]: Nullable<AnimationRange>;
  102072. };
  102073. /**
  102074. * Callback raised when the node is ready to be used
  102075. */
  102076. onReady: Nullable<(node: Node) => void>;
  102077. private _isEnabled;
  102078. private _isParentEnabled;
  102079. private _isReady;
  102080. /** @hidden */
  102081. _currentRenderId: number;
  102082. private _parentUpdateId;
  102083. /** @hidden */
  102084. _childUpdateId: number;
  102085. /** @hidden */
  102086. _waitingParentId: Nullable<string>;
  102087. /** @hidden */
  102088. _scene: Scene;
  102089. /** @hidden */
  102090. _cache: any;
  102091. private _parentNode;
  102092. private _children;
  102093. /** @hidden */
  102094. _worldMatrix: Matrix;
  102095. /** @hidden */
  102096. _worldMatrixDeterminant: number;
  102097. /** @hidden */
  102098. _worldMatrixDeterminantIsDirty: boolean;
  102099. /** @hidden */
  102100. private _sceneRootNodesIndex;
  102101. /**
  102102. * Gets a boolean indicating if the node has been disposed
  102103. * @returns true if the node was disposed
  102104. */
  102105. isDisposed(): boolean;
  102106. /**
  102107. * Gets or sets the parent of the node (without keeping the current position in the scene)
  102108. * @see https://doc.babylonjs.com/how_to/parenting
  102109. */
  102110. set parent(parent: Nullable<Node>);
  102111. get parent(): Nullable<Node>;
  102112. /** @hidden */
  102113. _addToSceneRootNodes(): void;
  102114. /** @hidden */
  102115. _removeFromSceneRootNodes(): void;
  102116. private _animationPropertiesOverride;
  102117. /**
  102118. * Gets or sets the animation properties override
  102119. */
  102120. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  102121. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  102122. /**
  102123. * Gets a string idenfifying the name of the class
  102124. * @returns "Node" string
  102125. */
  102126. getClassName(): string;
  102127. /** @hidden */
  102128. readonly _isNode: boolean;
  102129. /**
  102130. * An event triggered when the mesh is disposed
  102131. */
  102132. onDisposeObservable: Observable<Node>;
  102133. private _onDisposeObserver;
  102134. /**
  102135. * Sets a callback that will be raised when the node will be disposed
  102136. */
  102137. set onDispose(callback: () => void);
  102138. /**
  102139. * Creates a new Node
  102140. * @param name the name and id to be given to this node
  102141. * @param scene the scene this node will be added to
  102142. */
  102143. constructor(name: string, scene?: Nullable<Scene>);
  102144. /**
  102145. * Gets the scene of the node
  102146. * @returns a scene
  102147. */
  102148. getScene(): Scene;
  102149. /**
  102150. * Gets the engine of the node
  102151. * @returns a Engine
  102152. */
  102153. getEngine(): Engine;
  102154. private _behaviors;
  102155. /**
  102156. * Attach a behavior to the node
  102157. * @see http://doc.babylonjs.com/features/behaviour
  102158. * @param behavior defines the behavior to attach
  102159. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  102160. * @returns the current Node
  102161. */
  102162. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  102163. /**
  102164. * Remove an attached behavior
  102165. * @see http://doc.babylonjs.com/features/behaviour
  102166. * @param behavior defines the behavior to attach
  102167. * @returns the current Node
  102168. */
  102169. removeBehavior(behavior: Behavior<Node>): Node;
  102170. /**
  102171. * Gets the list of attached behaviors
  102172. * @see http://doc.babylonjs.com/features/behaviour
  102173. */
  102174. get behaviors(): Behavior<Node>[];
  102175. /**
  102176. * Gets an attached behavior by name
  102177. * @param name defines the name of the behavior to look for
  102178. * @see http://doc.babylonjs.com/features/behaviour
  102179. * @returns null if behavior was not found else the requested behavior
  102180. */
  102181. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  102182. /**
  102183. * Returns the latest update of the World matrix
  102184. * @returns a Matrix
  102185. */
  102186. getWorldMatrix(): Matrix;
  102187. /** @hidden */
  102188. _getWorldMatrixDeterminant(): number;
  102189. /**
  102190. * Returns directly the latest state of the mesh World matrix.
  102191. * A Matrix is returned.
  102192. */
  102193. get worldMatrixFromCache(): Matrix;
  102194. /** @hidden */
  102195. _initCache(): void;
  102196. /** @hidden */
  102197. updateCache(force?: boolean): void;
  102198. /** @hidden */
  102199. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  102200. /** @hidden */
  102201. _updateCache(ignoreParentClass?: boolean): void;
  102202. /** @hidden */
  102203. _isSynchronized(): boolean;
  102204. /** @hidden */
  102205. _markSyncedWithParent(): void;
  102206. /** @hidden */
  102207. isSynchronizedWithParent(): boolean;
  102208. /** @hidden */
  102209. isSynchronized(): boolean;
  102210. /**
  102211. * Is this node ready to be used/rendered
  102212. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  102213. * @return true if the node is ready
  102214. */
  102215. isReady(completeCheck?: boolean): boolean;
  102216. /**
  102217. * Is this node enabled?
  102218. * 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
  102219. * @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
  102220. * @return whether this node (and its parent) is enabled
  102221. */
  102222. isEnabled(checkAncestors?: boolean): boolean;
  102223. /** @hidden */
  102224. protected _syncParentEnabledState(): void;
  102225. /**
  102226. * Set the enabled state of this node
  102227. * @param value defines the new enabled state
  102228. */
  102229. setEnabled(value: boolean): void;
  102230. /**
  102231. * Is this node a descendant of the given node?
  102232. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  102233. * @param ancestor defines the parent node to inspect
  102234. * @returns a boolean indicating if this node is a descendant of the given node
  102235. */
  102236. isDescendantOf(ancestor: Node): boolean;
  102237. /** @hidden */
  102238. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  102239. /**
  102240. * Will return all nodes that have this node as ascendant
  102241. * @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
  102242. * @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
  102243. * @return all children nodes of all types
  102244. */
  102245. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  102246. /**
  102247. * Get all child-meshes of this node
  102248. * @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)
  102249. * @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
  102250. * @returns an array of AbstractMesh
  102251. */
  102252. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  102253. /**
  102254. * Get all direct children of this node
  102255. * @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
  102256. * @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)
  102257. * @returns an array of Node
  102258. */
  102259. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  102260. /** @hidden */
  102261. _setReady(state: boolean): void;
  102262. /**
  102263. * Get an animation by name
  102264. * @param name defines the name of the animation to look for
  102265. * @returns null if not found else the requested animation
  102266. */
  102267. getAnimationByName(name: string): Nullable<Animation>;
  102268. /**
  102269. * Creates an animation range for this node
  102270. * @param name defines the name of the range
  102271. * @param from defines the starting key
  102272. * @param to defines the end key
  102273. */
  102274. createAnimationRange(name: string, from: number, to: number): void;
  102275. /**
  102276. * Delete a specific animation range
  102277. * @param name defines the name of the range to delete
  102278. * @param deleteFrames defines if animation frames from the range must be deleted as well
  102279. */
  102280. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  102281. /**
  102282. * Get an animation range by name
  102283. * @param name defines the name of the animation range to look for
  102284. * @returns null if not found else the requested animation range
  102285. */
  102286. getAnimationRange(name: string): Nullable<AnimationRange>;
  102287. /**
  102288. * Gets the list of all animation ranges defined on this node
  102289. * @returns an array
  102290. */
  102291. getAnimationRanges(): Nullable<AnimationRange>[];
  102292. /**
  102293. * Will start the animation sequence
  102294. * @param name defines the range frames for animation sequence
  102295. * @param loop defines if the animation should loop (false by default)
  102296. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  102297. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  102298. * @returns the object created for this animation. If range does not exist, it will return null
  102299. */
  102300. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  102301. /**
  102302. * Serialize animation ranges into a JSON compatible object
  102303. * @returns serialization object
  102304. */
  102305. serializeAnimationRanges(): any;
  102306. /**
  102307. * Computes the world matrix of the node
  102308. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  102309. * @returns the world matrix
  102310. */
  102311. computeWorldMatrix(force?: boolean): Matrix;
  102312. /**
  102313. * Releases resources associated with this node.
  102314. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  102315. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  102316. */
  102317. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  102318. /**
  102319. * Parse animation range data from a serialization object and store them into a given node
  102320. * @param node defines where to store the animation ranges
  102321. * @param parsedNode defines the serialization object to read data from
  102322. * @param scene defines the hosting scene
  102323. */
  102324. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  102325. /**
  102326. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  102327. * @param includeDescendants Include bounding info from descendants as well (true by default)
  102328. * @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
  102329. * @returns the new bounding vectors
  102330. */
  102331. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  102332. min: Vector3;
  102333. max: Vector3;
  102334. };
  102335. }
  102336. }
  102337. declare module BABYLON {
  102338. /**
  102339. * @hidden
  102340. */
  102341. export class _IAnimationState {
  102342. key: number;
  102343. repeatCount: number;
  102344. workValue?: any;
  102345. loopMode?: number;
  102346. offsetValue?: any;
  102347. highLimitValue?: any;
  102348. }
  102349. /**
  102350. * Class used to store any kind of animation
  102351. */
  102352. export class Animation {
  102353. /**Name of the animation */
  102354. name: string;
  102355. /**Property to animate */
  102356. targetProperty: string;
  102357. /**The frames per second of the animation */
  102358. framePerSecond: number;
  102359. /**The data type of the animation */
  102360. dataType: number;
  102361. /**The loop mode of the animation */
  102362. loopMode?: number | undefined;
  102363. /**Specifies if blending should be enabled */
  102364. enableBlending?: boolean | undefined;
  102365. /**
  102366. * Use matrix interpolation instead of using direct key value when animating matrices
  102367. */
  102368. static AllowMatricesInterpolation: boolean;
  102369. /**
  102370. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  102371. */
  102372. static AllowMatrixDecomposeForInterpolation: boolean;
  102373. /**
  102374. * Stores the key frames of the animation
  102375. */
  102376. private _keys;
  102377. /**
  102378. * Stores the easing function of the animation
  102379. */
  102380. private _easingFunction;
  102381. /**
  102382. * @hidden Internal use only
  102383. */
  102384. _runtimeAnimations: RuntimeAnimation[];
  102385. /**
  102386. * The set of event that will be linked to this animation
  102387. */
  102388. private _events;
  102389. /**
  102390. * Stores an array of target property paths
  102391. */
  102392. targetPropertyPath: string[];
  102393. /**
  102394. * Stores the blending speed of the animation
  102395. */
  102396. blendingSpeed: number;
  102397. /**
  102398. * Stores the animation ranges for the animation
  102399. */
  102400. private _ranges;
  102401. /**
  102402. * @hidden Internal use
  102403. */
  102404. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  102405. /**
  102406. * Sets up an animation
  102407. * @param property The property to animate
  102408. * @param animationType The animation type to apply
  102409. * @param framePerSecond The frames per second of the animation
  102410. * @param easingFunction The easing function used in the animation
  102411. * @returns The created animation
  102412. */
  102413. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  102414. /**
  102415. * Create and start an animation on a node
  102416. * @param name defines the name of the global animation that will be run on all nodes
  102417. * @param node defines the root node where the animation will take place
  102418. * @param targetProperty defines property to animate
  102419. * @param framePerSecond defines the number of frame per second yo use
  102420. * @param totalFrame defines the number of frames in total
  102421. * @param from defines the initial value
  102422. * @param to defines the final value
  102423. * @param loopMode defines which loop mode you want to use (off by default)
  102424. * @param easingFunction defines the easing function to use (linear by default)
  102425. * @param onAnimationEnd defines the callback to call when animation end
  102426. * @returns the animatable created for this animation
  102427. */
  102428. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  102429. /**
  102430. * Create and start an animation on a node and its descendants
  102431. * @param name defines the name of the global animation that will be run on all nodes
  102432. * @param node defines the root node where the animation will take place
  102433. * @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
  102434. * @param targetProperty defines property to animate
  102435. * @param framePerSecond defines the number of frame per second to use
  102436. * @param totalFrame defines the number of frames in total
  102437. * @param from defines the initial value
  102438. * @param to defines the final value
  102439. * @param loopMode defines which loop mode you want to use (off by default)
  102440. * @param easingFunction defines the easing function to use (linear by default)
  102441. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  102442. * @returns the list of animatables created for all nodes
  102443. * @example https://www.babylonjs-playground.com/#MH0VLI
  102444. */
  102445. 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[]>;
  102446. /**
  102447. * Creates a new animation, merges it with the existing animations and starts it
  102448. * @param name Name of the animation
  102449. * @param node Node which contains the scene that begins the animations
  102450. * @param targetProperty Specifies which property to animate
  102451. * @param framePerSecond The frames per second of the animation
  102452. * @param totalFrame The total number of frames
  102453. * @param from The frame at the beginning of the animation
  102454. * @param to The frame at the end of the animation
  102455. * @param loopMode Specifies the loop mode of the animation
  102456. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  102457. * @param onAnimationEnd Callback to run once the animation is complete
  102458. * @returns Nullable animation
  102459. */
  102460. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  102461. /**
  102462. * Transition property of an host to the target Value
  102463. * @param property The property to transition
  102464. * @param targetValue The target Value of the property
  102465. * @param host The object where the property to animate belongs
  102466. * @param scene Scene used to run the animation
  102467. * @param frameRate Framerate (in frame/s) to use
  102468. * @param transition The transition type we want to use
  102469. * @param duration The duration of the animation, in milliseconds
  102470. * @param onAnimationEnd Callback trigger at the end of the animation
  102471. * @returns Nullable animation
  102472. */
  102473. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  102474. /**
  102475. * Return the array of runtime animations currently using this animation
  102476. */
  102477. get runtimeAnimations(): RuntimeAnimation[];
  102478. /**
  102479. * Specifies if any of the runtime animations are currently running
  102480. */
  102481. get hasRunningRuntimeAnimations(): boolean;
  102482. /**
  102483. * Initializes the animation
  102484. * @param name Name of the animation
  102485. * @param targetProperty Property to animate
  102486. * @param framePerSecond The frames per second of the animation
  102487. * @param dataType The data type of the animation
  102488. * @param loopMode The loop mode of the animation
  102489. * @param enableBlending Specifies if blending should be enabled
  102490. */
  102491. constructor(
  102492. /**Name of the animation */
  102493. name: string,
  102494. /**Property to animate */
  102495. targetProperty: string,
  102496. /**The frames per second of the animation */
  102497. framePerSecond: number,
  102498. /**The data type of the animation */
  102499. dataType: number,
  102500. /**The loop mode of the animation */
  102501. loopMode?: number | undefined,
  102502. /**Specifies if blending should be enabled */
  102503. enableBlending?: boolean | undefined);
  102504. /**
  102505. * Converts the animation to a string
  102506. * @param fullDetails support for multiple levels of logging within scene loading
  102507. * @returns String form of the animation
  102508. */
  102509. toString(fullDetails?: boolean): string;
  102510. /**
  102511. * Add an event to this animation
  102512. * @param event Event to add
  102513. */
  102514. addEvent(event: AnimationEvent): void;
  102515. /**
  102516. * Remove all events found at the given frame
  102517. * @param frame The frame to remove events from
  102518. */
  102519. removeEvents(frame: number): void;
  102520. /**
  102521. * Retrieves all the events from the animation
  102522. * @returns Events from the animation
  102523. */
  102524. getEvents(): AnimationEvent[];
  102525. /**
  102526. * Creates an animation range
  102527. * @param name Name of the animation range
  102528. * @param from Starting frame of the animation range
  102529. * @param to Ending frame of the animation
  102530. */
  102531. createRange(name: string, from: number, to: number): void;
  102532. /**
  102533. * Deletes an animation range by name
  102534. * @param name Name of the animation range to delete
  102535. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  102536. */
  102537. deleteRange(name: string, deleteFrames?: boolean): void;
  102538. /**
  102539. * Gets the animation range by name, or null if not defined
  102540. * @param name Name of the animation range
  102541. * @returns Nullable animation range
  102542. */
  102543. getRange(name: string): Nullable<AnimationRange>;
  102544. /**
  102545. * Gets the key frames from the animation
  102546. * @returns The key frames of the animation
  102547. */
  102548. getKeys(): Array<IAnimationKey>;
  102549. /**
  102550. * Gets the highest frame rate of the animation
  102551. * @returns Highest frame rate of the animation
  102552. */
  102553. getHighestFrame(): number;
  102554. /**
  102555. * Gets the easing function of the animation
  102556. * @returns Easing function of the animation
  102557. */
  102558. getEasingFunction(): IEasingFunction;
  102559. /**
  102560. * Sets the easing function of the animation
  102561. * @param easingFunction A custom mathematical formula for animation
  102562. */
  102563. setEasingFunction(easingFunction: EasingFunction): void;
  102564. /**
  102565. * Interpolates a scalar linearly
  102566. * @param startValue Start value of the animation curve
  102567. * @param endValue End value of the animation curve
  102568. * @param gradient Scalar amount to interpolate
  102569. * @returns Interpolated scalar value
  102570. */
  102571. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  102572. /**
  102573. * Interpolates a scalar cubically
  102574. * @param startValue Start value of the animation curve
  102575. * @param outTangent End tangent of the animation
  102576. * @param endValue End value of the animation curve
  102577. * @param inTangent Start tangent of the animation curve
  102578. * @param gradient Scalar amount to interpolate
  102579. * @returns Interpolated scalar value
  102580. */
  102581. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  102582. /**
  102583. * Interpolates a quaternion using a spherical linear interpolation
  102584. * @param startValue Start value of the animation curve
  102585. * @param endValue End value of the animation curve
  102586. * @param gradient Scalar amount to interpolate
  102587. * @returns Interpolated quaternion value
  102588. */
  102589. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  102590. /**
  102591. * Interpolates a quaternion cubically
  102592. * @param startValue Start value of the animation curve
  102593. * @param outTangent End tangent of the animation curve
  102594. * @param endValue End value of the animation curve
  102595. * @param inTangent Start tangent of the animation curve
  102596. * @param gradient Scalar amount to interpolate
  102597. * @returns Interpolated quaternion value
  102598. */
  102599. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  102600. /**
  102601. * Interpolates a Vector3 linearl
  102602. * @param startValue Start value of the animation curve
  102603. * @param endValue End value of the animation curve
  102604. * @param gradient Scalar amount to interpolate
  102605. * @returns Interpolated scalar value
  102606. */
  102607. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  102608. /**
  102609. * Interpolates a Vector3 cubically
  102610. * @param startValue Start value of the animation curve
  102611. * @param outTangent End tangent of the animation
  102612. * @param endValue End value of the animation curve
  102613. * @param inTangent Start tangent of the animation curve
  102614. * @param gradient Scalar amount to interpolate
  102615. * @returns InterpolatedVector3 value
  102616. */
  102617. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  102618. /**
  102619. * Interpolates a Vector2 linearly
  102620. * @param startValue Start value of the animation curve
  102621. * @param endValue End value of the animation curve
  102622. * @param gradient Scalar amount to interpolate
  102623. * @returns Interpolated Vector2 value
  102624. */
  102625. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  102626. /**
  102627. * Interpolates a Vector2 cubically
  102628. * @param startValue Start value of the animation curve
  102629. * @param outTangent End tangent of the animation
  102630. * @param endValue End value of the animation curve
  102631. * @param inTangent Start tangent of the animation curve
  102632. * @param gradient Scalar amount to interpolate
  102633. * @returns Interpolated Vector2 value
  102634. */
  102635. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  102636. /**
  102637. * Interpolates a size linearly
  102638. * @param startValue Start value of the animation curve
  102639. * @param endValue End value of the animation curve
  102640. * @param gradient Scalar amount to interpolate
  102641. * @returns Interpolated Size value
  102642. */
  102643. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  102644. /**
  102645. * Interpolates a Color3 linearly
  102646. * @param startValue Start value of the animation curve
  102647. * @param endValue End value of the animation curve
  102648. * @param gradient Scalar amount to interpolate
  102649. * @returns Interpolated Color3 value
  102650. */
  102651. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  102652. /**
  102653. * Interpolates a Color4 linearly
  102654. * @param startValue Start value of the animation curve
  102655. * @param endValue End value of the animation curve
  102656. * @param gradient Scalar amount to interpolate
  102657. * @returns Interpolated Color3 value
  102658. */
  102659. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  102660. /**
  102661. * @hidden Internal use only
  102662. */
  102663. _getKeyValue(value: any): any;
  102664. /**
  102665. * @hidden Internal use only
  102666. */
  102667. _interpolate(currentFrame: number, state: _IAnimationState): any;
  102668. /**
  102669. * Defines the function to use to interpolate matrices
  102670. * @param startValue defines the start matrix
  102671. * @param endValue defines the end matrix
  102672. * @param gradient defines the gradient between both matrices
  102673. * @param result defines an optional target matrix where to store the interpolation
  102674. * @returns the interpolated matrix
  102675. */
  102676. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  102677. /**
  102678. * Makes a copy of the animation
  102679. * @returns Cloned animation
  102680. */
  102681. clone(): Animation;
  102682. /**
  102683. * Sets the key frames of the animation
  102684. * @param values The animation key frames to set
  102685. */
  102686. setKeys(values: Array<IAnimationKey>): void;
  102687. /**
  102688. * Serializes the animation to an object
  102689. * @returns Serialized object
  102690. */
  102691. serialize(): any;
  102692. /**
  102693. * Float animation type
  102694. */
  102695. static readonly ANIMATIONTYPE_FLOAT: number;
  102696. /**
  102697. * Vector3 animation type
  102698. */
  102699. static readonly ANIMATIONTYPE_VECTOR3: number;
  102700. /**
  102701. * Quaternion animation type
  102702. */
  102703. static readonly ANIMATIONTYPE_QUATERNION: number;
  102704. /**
  102705. * Matrix animation type
  102706. */
  102707. static readonly ANIMATIONTYPE_MATRIX: number;
  102708. /**
  102709. * Color3 animation type
  102710. */
  102711. static readonly ANIMATIONTYPE_COLOR3: number;
  102712. /**
  102713. * Color3 animation type
  102714. */
  102715. static readonly ANIMATIONTYPE_COLOR4: number;
  102716. /**
  102717. * Vector2 animation type
  102718. */
  102719. static readonly ANIMATIONTYPE_VECTOR2: number;
  102720. /**
  102721. * Size animation type
  102722. */
  102723. static readonly ANIMATIONTYPE_SIZE: number;
  102724. /**
  102725. * Relative Loop Mode
  102726. */
  102727. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  102728. /**
  102729. * Cycle Loop Mode
  102730. */
  102731. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  102732. /**
  102733. * Constant Loop Mode
  102734. */
  102735. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  102736. /** @hidden */
  102737. static _UniversalLerp(left: any, right: any, amount: number): any;
  102738. /**
  102739. * Parses an animation object and creates an animation
  102740. * @param parsedAnimation Parsed animation object
  102741. * @returns Animation object
  102742. */
  102743. static Parse(parsedAnimation: any): Animation;
  102744. /**
  102745. * Appends the serialized animations from the source animations
  102746. * @param source Source containing the animations
  102747. * @param destination Target to store the animations
  102748. */
  102749. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  102750. }
  102751. }
  102752. declare module BABYLON {
  102753. /**
  102754. * Interface containing an array of animations
  102755. */
  102756. export interface IAnimatable {
  102757. /**
  102758. * Array of animations
  102759. */
  102760. animations: Nullable<Array<Animation>>;
  102761. }
  102762. }
  102763. declare module BABYLON {
  102764. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  102765. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102766. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102767. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102768. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102769. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102770. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102771. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102772. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102773. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102774. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102775. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102776. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102777. /**
  102778. * Decorator used to define property that can be serialized as reference to a camera
  102779. * @param sourceName defines the name of the property to decorate
  102780. */
  102781. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102782. /**
  102783. * Class used to help serialization objects
  102784. */
  102785. export class SerializationHelper {
  102786. /** @hidden */
  102787. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  102788. /** @hidden */
  102789. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  102790. /** @hidden */
  102791. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  102792. /** @hidden */
  102793. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  102794. /**
  102795. * Appends the serialized animations from the source animations
  102796. * @param source Source containing the animations
  102797. * @param destination Target to store the animations
  102798. */
  102799. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  102800. /**
  102801. * Static function used to serialized a specific entity
  102802. * @param entity defines the entity to serialize
  102803. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  102804. * @returns a JSON compatible object representing the serialization of the entity
  102805. */
  102806. static Serialize<T>(entity: T, serializationObject?: any): any;
  102807. /**
  102808. * Creates a new entity from a serialization data object
  102809. * @param creationFunction defines a function used to instanciated the new entity
  102810. * @param source defines the source serialization data
  102811. * @param scene defines the hosting scene
  102812. * @param rootUrl defines the root url for resources
  102813. * @returns a new entity
  102814. */
  102815. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  102816. /**
  102817. * Clones an object
  102818. * @param creationFunction defines the function used to instanciate the new object
  102819. * @param source defines the source object
  102820. * @returns the cloned object
  102821. */
  102822. static Clone<T>(creationFunction: () => T, source: T): T;
  102823. /**
  102824. * Instanciates a new object based on a source one (some data will be shared between both object)
  102825. * @param creationFunction defines the function used to instanciate the new object
  102826. * @param source defines the source object
  102827. * @returns the new object
  102828. */
  102829. static Instanciate<T>(creationFunction: () => T, source: T): T;
  102830. }
  102831. }
  102832. declare module BABYLON {
  102833. /**
  102834. * Class used to manipulate GUIDs
  102835. */
  102836. export class GUID {
  102837. /**
  102838. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  102839. * Be aware Math.random() could cause collisions, but:
  102840. * "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"
  102841. * @returns a pseudo random id
  102842. */
  102843. static RandomId(): string;
  102844. }
  102845. }
  102846. declare module BABYLON {
  102847. /**
  102848. * Base class of all the textures in babylon.
  102849. * It groups all the common properties the materials, post process, lights... might need
  102850. * in order to make a correct use of the texture.
  102851. */
  102852. export class BaseTexture implements IAnimatable {
  102853. /**
  102854. * Default anisotropic filtering level for the application.
  102855. * It is set to 4 as a good tradeoff between perf and quality.
  102856. */
  102857. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  102858. /**
  102859. * Gets or sets the unique id of the texture
  102860. */
  102861. uniqueId: number;
  102862. /**
  102863. * Define the name of the texture.
  102864. */
  102865. name: string;
  102866. /**
  102867. * Gets or sets an object used to store user defined information.
  102868. */
  102869. metadata: any;
  102870. /**
  102871. * For internal use only. Please do not use.
  102872. */
  102873. reservedDataStore: any;
  102874. private _hasAlpha;
  102875. /**
  102876. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  102877. */
  102878. set hasAlpha(value: boolean);
  102879. get hasAlpha(): boolean;
  102880. /**
  102881. * Defines if the alpha value should be determined via the rgb values.
  102882. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  102883. */
  102884. getAlphaFromRGB: boolean;
  102885. /**
  102886. * Intensity or strength of the texture.
  102887. * It is commonly used by materials to fine tune the intensity of the texture
  102888. */
  102889. level: number;
  102890. /**
  102891. * Define the UV chanel to use starting from 0 and defaulting to 0.
  102892. * This is part of the texture as textures usually maps to one uv set.
  102893. */
  102894. coordinatesIndex: number;
  102895. private _coordinatesMode;
  102896. /**
  102897. * How a texture is mapped.
  102898. *
  102899. * | Value | Type | Description |
  102900. * | ----- | ----------------------------------- | ----------- |
  102901. * | 0 | EXPLICIT_MODE | |
  102902. * | 1 | SPHERICAL_MODE | |
  102903. * | 2 | PLANAR_MODE | |
  102904. * | 3 | CUBIC_MODE | |
  102905. * | 4 | PROJECTION_MODE | |
  102906. * | 5 | SKYBOX_MODE | |
  102907. * | 6 | INVCUBIC_MODE | |
  102908. * | 7 | EQUIRECTANGULAR_MODE | |
  102909. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  102910. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  102911. */
  102912. set coordinatesMode(value: number);
  102913. get coordinatesMode(): number;
  102914. /**
  102915. * | Value | Type | Description |
  102916. * | ----- | ------------------ | ----------- |
  102917. * | 0 | CLAMP_ADDRESSMODE | |
  102918. * | 1 | WRAP_ADDRESSMODE | |
  102919. * | 2 | MIRROR_ADDRESSMODE | |
  102920. */
  102921. wrapU: number;
  102922. /**
  102923. * | Value | Type | Description |
  102924. * | ----- | ------------------ | ----------- |
  102925. * | 0 | CLAMP_ADDRESSMODE | |
  102926. * | 1 | WRAP_ADDRESSMODE | |
  102927. * | 2 | MIRROR_ADDRESSMODE | |
  102928. */
  102929. wrapV: number;
  102930. /**
  102931. * | Value | Type | Description |
  102932. * | ----- | ------------------ | ----------- |
  102933. * | 0 | CLAMP_ADDRESSMODE | |
  102934. * | 1 | WRAP_ADDRESSMODE | |
  102935. * | 2 | MIRROR_ADDRESSMODE | |
  102936. */
  102937. wrapR: number;
  102938. /**
  102939. * With compliant hardware and browser (supporting anisotropic filtering)
  102940. * this defines the level of anisotropic filtering in the texture.
  102941. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  102942. */
  102943. anisotropicFilteringLevel: number;
  102944. /**
  102945. * Define if the texture is a cube texture or if false a 2d texture.
  102946. */
  102947. get isCube(): boolean;
  102948. set isCube(value: boolean);
  102949. /**
  102950. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  102951. */
  102952. get is3D(): boolean;
  102953. set is3D(value: boolean);
  102954. /**
  102955. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  102956. */
  102957. get is2DArray(): boolean;
  102958. set is2DArray(value: boolean);
  102959. /**
  102960. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  102961. * HDR texture are usually stored in linear space.
  102962. * This only impacts the PBR and Background materials
  102963. */
  102964. gammaSpace: boolean;
  102965. /**
  102966. * Gets or sets whether or not the texture contains RGBD data.
  102967. */
  102968. get isRGBD(): boolean;
  102969. set isRGBD(value: boolean);
  102970. /**
  102971. * Is Z inverted in the texture (useful in a cube texture).
  102972. */
  102973. invertZ: boolean;
  102974. /**
  102975. * Are mip maps generated for this texture or not.
  102976. */
  102977. get noMipmap(): boolean;
  102978. /**
  102979. * @hidden
  102980. */
  102981. lodLevelInAlpha: boolean;
  102982. /**
  102983. * With prefiltered texture, defined the offset used during the prefiltering steps.
  102984. */
  102985. get lodGenerationOffset(): number;
  102986. set lodGenerationOffset(value: number);
  102987. /**
  102988. * With prefiltered texture, defined the scale used during the prefiltering steps.
  102989. */
  102990. get lodGenerationScale(): number;
  102991. set lodGenerationScale(value: number);
  102992. /**
  102993. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  102994. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  102995. * average roughness values.
  102996. */
  102997. get linearSpecularLOD(): boolean;
  102998. set linearSpecularLOD(value: boolean);
  102999. /**
  103000. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  103001. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  103002. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  103003. */
  103004. get irradianceTexture(): Nullable<BaseTexture>;
  103005. set irradianceTexture(value: Nullable<BaseTexture>);
  103006. /**
  103007. * Define if the texture is a render target.
  103008. */
  103009. isRenderTarget: boolean;
  103010. /**
  103011. * Define the unique id of the texture in the scene.
  103012. */
  103013. get uid(): string;
  103014. /**
  103015. * Return a string representation of the texture.
  103016. * @returns the texture as a string
  103017. */
  103018. toString(): string;
  103019. /**
  103020. * Get the class name of the texture.
  103021. * @returns "BaseTexture"
  103022. */
  103023. getClassName(): string;
  103024. /**
  103025. * Define the list of animation attached to the texture.
  103026. */
  103027. animations: Animation[];
  103028. /**
  103029. * An event triggered when the texture is disposed.
  103030. */
  103031. onDisposeObservable: Observable<BaseTexture>;
  103032. private _onDisposeObserver;
  103033. /**
  103034. * Callback triggered when the texture has been disposed.
  103035. * Kept for back compatibility, you can use the onDisposeObservable instead.
  103036. */
  103037. set onDispose(callback: () => void);
  103038. /**
  103039. * Define the current state of the loading sequence when in delayed load mode.
  103040. */
  103041. delayLoadState: number;
  103042. private _scene;
  103043. /** @hidden */
  103044. _texture: Nullable<InternalTexture>;
  103045. private _uid;
  103046. /**
  103047. * Define if the texture is preventinga material to render or not.
  103048. * If not and the texture is not ready, the engine will use a default black texture instead.
  103049. */
  103050. get isBlocking(): boolean;
  103051. /**
  103052. * Instantiates a new BaseTexture.
  103053. * Base class of all the textures in babylon.
  103054. * It groups all the common properties the materials, post process, lights... might need
  103055. * in order to make a correct use of the texture.
  103056. * @param scene Define the scene the texture blongs to
  103057. */
  103058. constructor(scene: Nullable<Scene>);
  103059. /**
  103060. * Get the scene the texture belongs to.
  103061. * @returns the scene or null if undefined
  103062. */
  103063. getScene(): Nullable<Scene>;
  103064. /**
  103065. * Get the texture transform matrix used to offset tile the texture for istance.
  103066. * @returns the transformation matrix
  103067. */
  103068. getTextureMatrix(): Matrix;
  103069. /**
  103070. * Get the texture reflection matrix used to rotate/transform the reflection.
  103071. * @returns the reflection matrix
  103072. */
  103073. getReflectionTextureMatrix(): Matrix;
  103074. /**
  103075. * Get the underlying lower level texture from Babylon.
  103076. * @returns the insternal texture
  103077. */
  103078. getInternalTexture(): Nullable<InternalTexture>;
  103079. /**
  103080. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  103081. * @returns true if ready or not blocking
  103082. */
  103083. isReadyOrNotBlocking(): boolean;
  103084. /**
  103085. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  103086. * @returns true if fully ready
  103087. */
  103088. isReady(): boolean;
  103089. private _cachedSize;
  103090. /**
  103091. * Get the size of the texture.
  103092. * @returns the texture size.
  103093. */
  103094. getSize(): ISize;
  103095. /**
  103096. * Get the base size of the texture.
  103097. * It can be different from the size if the texture has been resized for POT for instance
  103098. * @returns the base size
  103099. */
  103100. getBaseSize(): ISize;
  103101. /**
  103102. * Update the sampling mode of the texture.
  103103. * Default is Trilinear mode.
  103104. *
  103105. * | Value | Type | Description |
  103106. * | ----- | ------------------ | ----------- |
  103107. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  103108. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  103109. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  103110. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  103111. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  103112. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  103113. * | 7 | NEAREST_LINEAR | |
  103114. * | 8 | NEAREST_NEAREST | |
  103115. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  103116. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  103117. * | 11 | LINEAR_LINEAR | |
  103118. * | 12 | LINEAR_NEAREST | |
  103119. *
  103120. * > _mag_: magnification filter (close to the viewer)
  103121. * > _min_: minification filter (far from the viewer)
  103122. * > _mip_: filter used between mip map levels
  103123. *@param samplingMode Define the new sampling mode of the texture
  103124. */
  103125. updateSamplingMode(samplingMode: number): void;
  103126. /**
  103127. * Scales the texture if is `canRescale()`
  103128. * @param ratio the resize factor we want to use to rescale
  103129. */
  103130. scale(ratio: number): void;
  103131. /**
  103132. * Get if the texture can rescale.
  103133. */
  103134. get canRescale(): boolean;
  103135. /** @hidden */
  103136. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  103137. /** @hidden */
  103138. _rebuild(): void;
  103139. /**
  103140. * Triggers the load sequence in delayed load mode.
  103141. */
  103142. delayLoad(): void;
  103143. /**
  103144. * Clones the texture.
  103145. * @returns the cloned texture
  103146. */
  103147. clone(): Nullable<BaseTexture>;
  103148. /**
  103149. * Get the texture underlying type (INT, FLOAT...)
  103150. */
  103151. get textureType(): number;
  103152. /**
  103153. * Get the texture underlying format (RGB, RGBA...)
  103154. */
  103155. get textureFormat(): number;
  103156. /**
  103157. * Indicates that textures need to be re-calculated for all materials
  103158. */
  103159. protected _markAllSubMeshesAsTexturesDirty(): void;
  103160. /**
  103161. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  103162. * This will returns an RGBA array buffer containing either in values (0-255) or
  103163. * float values (0-1) depending of the underlying buffer type.
  103164. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  103165. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  103166. * @param buffer defines a user defined buffer to fill with data (can be null)
  103167. * @returns The Array buffer containing the pixels data.
  103168. */
  103169. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  103170. /**
  103171. * Release and destroy the underlying lower level texture aka internalTexture.
  103172. */
  103173. releaseInternalTexture(): void;
  103174. /** @hidden */
  103175. get _lodTextureHigh(): Nullable<BaseTexture>;
  103176. /** @hidden */
  103177. get _lodTextureMid(): Nullable<BaseTexture>;
  103178. /** @hidden */
  103179. get _lodTextureLow(): Nullable<BaseTexture>;
  103180. /**
  103181. * Dispose the texture and release its associated resources.
  103182. */
  103183. dispose(): void;
  103184. /**
  103185. * Serialize the texture into a JSON representation that can be parsed later on.
  103186. * @returns the JSON representation of the texture
  103187. */
  103188. serialize(): any;
  103189. /**
  103190. * Helper function to be called back once a list of texture contains only ready textures.
  103191. * @param textures Define the list of textures to wait for
  103192. * @param callback Define the callback triggered once the entire list will be ready
  103193. */
  103194. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  103195. }
  103196. }
  103197. declare module BABYLON {
  103198. /**
  103199. * Options to be used when creating an effect.
  103200. */
  103201. export interface IEffectCreationOptions {
  103202. /**
  103203. * Atrributes that will be used in the shader.
  103204. */
  103205. attributes: string[];
  103206. /**
  103207. * Uniform varible names that will be set in the shader.
  103208. */
  103209. uniformsNames: string[];
  103210. /**
  103211. * Uniform buffer variable names that will be set in the shader.
  103212. */
  103213. uniformBuffersNames: string[];
  103214. /**
  103215. * Sampler texture variable names that will be set in the shader.
  103216. */
  103217. samplers: string[];
  103218. /**
  103219. * Define statements that will be set in the shader.
  103220. */
  103221. defines: any;
  103222. /**
  103223. * Possible fallbacks for this effect to improve performance when needed.
  103224. */
  103225. fallbacks: Nullable<IEffectFallbacks>;
  103226. /**
  103227. * Callback that will be called when the shader is compiled.
  103228. */
  103229. onCompiled: Nullable<(effect: Effect) => void>;
  103230. /**
  103231. * Callback that will be called if an error occurs during shader compilation.
  103232. */
  103233. onError: Nullable<(effect: Effect, errors: string) => void>;
  103234. /**
  103235. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  103236. */
  103237. indexParameters?: any;
  103238. /**
  103239. * Max number of lights that can be used in the shader.
  103240. */
  103241. maxSimultaneousLights?: number;
  103242. /**
  103243. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  103244. */
  103245. transformFeedbackVaryings?: Nullable<string[]>;
  103246. }
  103247. /**
  103248. * Effect containing vertex and fragment shader that can be executed on an object.
  103249. */
  103250. export class Effect implements IDisposable {
  103251. /**
  103252. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  103253. */
  103254. static ShadersRepository: string;
  103255. /**
  103256. * Name of the effect.
  103257. */
  103258. name: any;
  103259. /**
  103260. * String container all the define statements that should be set on the shader.
  103261. */
  103262. defines: string;
  103263. /**
  103264. * Callback that will be called when the shader is compiled.
  103265. */
  103266. onCompiled: Nullable<(effect: Effect) => void>;
  103267. /**
  103268. * Callback that will be called if an error occurs during shader compilation.
  103269. */
  103270. onError: Nullable<(effect: Effect, errors: string) => void>;
  103271. /**
  103272. * Callback that will be called when effect is bound.
  103273. */
  103274. onBind: Nullable<(effect: Effect) => void>;
  103275. /**
  103276. * Unique ID of the effect.
  103277. */
  103278. uniqueId: number;
  103279. /**
  103280. * Observable that will be called when the shader is compiled.
  103281. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  103282. */
  103283. onCompileObservable: Observable<Effect>;
  103284. /**
  103285. * Observable that will be called if an error occurs during shader compilation.
  103286. */
  103287. onErrorObservable: Observable<Effect>;
  103288. /** @hidden */
  103289. _onBindObservable: Nullable<Observable<Effect>>;
  103290. /**
  103291. * @hidden
  103292. * Specifies if the effect was previously ready
  103293. */
  103294. _wasPreviouslyReady: boolean;
  103295. /**
  103296. * Observable that will be called when effect is bound.
  103297. */
  103298. get onBindObservable(): Observable<Effect>;
  103299. /** @hidden */
  103300. _bonesComputationForcedToCPU: boolean;
  103301. private static _uniqueIdSeed;
  103302. private _engine;
  103303. private _uniformBuffersNames;
  103304. private _uniformsNames;
  103305. private _samplerList;
  103306. private _samplers;
  103307. private _isReady;
  103308. private _compilationError;
  103309. private _allFallbacksProcessed;
  103310. private _attributesNames;
  103311. private _attributes;
  103312. private _attributeLocationByName;
  103313. private _uniforms;
  103314. /**
  103315. * Key for the effect.
  103316. * @hidden
  103317. */
  103318. _key: string;
  103319. private _indexParameters;
  103320. private _fallbacks;
  103321. private _vertexSourceCode;
  103322. private _fragmentSourceCode;
  103323. private _vertexSourceCodeOverride;
  103324. private _fragmentSourceCodeOverride;
  103325. private _transformFeedbackVaryings;
  103326. /**
  103327. * Compiled shader to webGL program.
  103328. * @hidden
  103329. */
  103330. _pipelineContext: Nullable<IPipelineContext>;
  103331. private _valueCache;
  103332. private static _baseCache;
  103333. /**
  103334. * Instantiates an effect.
  103335. * An effect can be used to create/manage/execute vertex and fragment shaders.
  103336. * @param baseName Name of the effect.
  103337. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  103338. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  103339. * @param samplers List of sampler variables that will be passed to the shader.
  103340. * @param engine Engine to be used to render the effect
  103341. * @param defines Define statements to be added to the shader.
  103342. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  103343. * @param onCompiled Callback that will be called when the shader is compiled.
  103344. * @param onError Callback that will be called if an error occurs during shader compilation.
  103345. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  103346. */
  103347. 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);
  103348. private _useFinalCode;
  103349. /**
  103350. * Unique key for this effect
  103351. */
  103352. get key(): string;
  103353. /**
  103354. * If the effect has been compiled and prepared.
  103355. * @returns if the effect is compiled and prepared.
  103356. */
  103357. isReady(): boolean;
  103358. private _isReadyInternal;
  103359. /**
  103360. * The engine the effect was initialized with.
  103361. * @returns the engine.
  103362. */
  103363. getEngine(): Engine;
  103364. /**
  103365. * The pipeline context for this effect
  103366. * @returns the associated pipeline context
  103367. */
  103368. getPipelineContext(): Nullable<IPipelineContext>;
  103369. /**
  103370. * The set of names of attribute variables for the shader.
  103371. * @returns An array of attribute names.
  103372. */
  103373. getAttributesNames(): string[];
  103374. /**
  103375. * Returns the attribute at the given index.
  103376. * @param index The index of the attribute.
  103377. * @returns The location of the attribute.
  103378. */
  103379. getAttributeLocation(index: number): number;
  103380. /**
  103381. * Returns the attribute based on the name of the variable.
  103382. * @param name of the attribute to look up.
  103383. * @returns the attribute location.
  103384. */
  103385. getAttributeLocationByName(name: string): number;
  103386. /**
  103387. * The number of attributes.
  103388. * @returns the numnber of attributes.
  103389. */
  103390. getAttributesCount(): number;
  103391. /**
  103392. * Gets the index of a uniform variable.
  103393. * @param uniformName of the uniform to look up.
  103394. * @returns the index.
  103395. */
  103396. getUniformIndex(uniformName: string): number;
  103397. /**
  103398. * Returns the attribute based on the name of the variable.
  103399. * @param uniformName of the uniform to look up.
  103400. * @returns the location of the uniform.
  103401. */
  103402. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  103403. /**
  103404. * Returns an array of sampler variable names
  103405. * @returns The array of sampler variable neames.
  103406. */
  103407. getSamplers(): string[];
  103408. /**
  103409. * The error from the last compilation.
  103410. * @returns the error string.
  103411. */
  103412. getCompilationError(): string;
  103413. /**
  103414. * Gets a boolean indicating that all fallbacks were used during compilation
  103415. * @returns true if all fallbacks were used
  103416. */
  103417. allFallbacksProcessed(): boolean;
  103418. /**
  103419. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  103420. * @param func The callback to be used.
  103421. */
  103422. executeWhenCompiled(func: (effect: Effect) => void): void;
  103423. private _checkIsReady;
  103424. private _loadShader;
  103425. /**
  103426. * Recompiles the webGL program
  103427. * @param vertexSourceCode The source code for the vertex shader.
  103428. * @param fragmentSourceCode The source code for the fragment shader.
  103429. * @param onCompiled Callback called when completed.
  103430. * @param onError Callback called on error.
  103431. * @hidden
  103432. */
  103433. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  103434. /**
  103435. * Prepares the effect
  103436. * @hidden
  103437. */
  103438. _prepareEffect(): void;
  103439. private _processCompilationErrors;
  103440. /**
  103441. * Checks if the effect is supported. (Must be called after compilation)
  103442. */
  103443. get isSupported(): boolean;
  103444. /**
  103445. * Binds a texture to the engine to be used as output of the shader.
  103446. * @param channel Name of the output variable.
  103447. * @param texture Texture to bind.
  103448. * @hidden
  103449. */
  103450. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  103451. /**
  103452. * Sets a texture on the engine to be used in the shader.
  103453. * @param channel Name of the sampler variable.
  103454. * @param texture Texture to set.
  103455. */
  103456. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  103457. /**
  103458. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  103459. * @param channel Name of the sampler variable.
  103460. * @param texture Texture to set.
  103461. */
  103462. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  103463. /**
  103464. * Sets an array of textures on the engine to be used in the shader.
  103465. * @param channel Name of the variable.
  103466. * @param textures Textures to set.
  103467. */
  103468. setTextureArray(channel: string, textures: BaseTexture[]): void;
  103469. /**
  103470. * 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)
  103471. * @param channel Name of the sampler variable.
  103472. * @param postProcess Post process to get the input texture from.
  103473. */
  103474. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  103475. /**
  103476. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  103477. * 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)
  103478. * @param channel Name of the sampler variable.
  103479. * @param postProcess Post process to get the output texture from.
  103480. */
  103481. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  103482. /** @hidden */
  103483. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  103484. /** @hidden */
  103485. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  103486. /** @hidden */
  103487. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  103488. /** @hidden */
  103489. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  103490. /**
  103491. * Binds a buffer to a uniform.
  103492. * @param buffer Buffer to bind.
  103493. * @param name Name of the uniform variable to bind to.
  103494. */
  103495. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  103496. /**
  103497. * Binds block to a uniform.
  103498. * @param blockName Name of the block to bind.
  103499. * @param index Index to bind.
  103500. */
  103501. bindUniformBlock(blockName: string, index: number): void;
  103502. /**
  103503. * Sets an interger value on a uniform variable.
  103504. * @param uniformName Name of the variable.
  103505. * @param value Value to be set.
  103506. * @returns this effect.
  103507. */
  103508. setInt(uniformName: string, value: number): Effect;
  103509. /**
  103510. * Sets an int array on a uniform variable.
  103511. * @param uniformName Name of the variable.
  103512. * @param array array to be set.
  103513. * @returns this effect.
  103514. */
  103515. setIntArray(uniformName: string, array: Int32Array): Effect;
  103516. /**
  103517. * 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)
  103518. * @param uniformName Name of the variable.
  103519. * @param array array to be set.
  103520. * @returns this effect.
  103521. */
  103522. setIntArray2(uniformName: string, array: Int32Array): Effect;
  103523. /**
  103524. * 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)
  103525. * @param uniformName Name of the variable.
  103526. * @param array array to be set.
  103527. * @returns this effect.
  103528. */
  103529. setIntArray3(uniformName: string, array: Int32Array): Effect;
  103530. /**
  103531. * 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)
  103532. * @param uniformName Name of the variable.
  103533. * @param array array to be set.
  103534. * @returns this effect.
  103535. */
  103536. setIntArray4(uniformName: string, array: Int32Array): Effect;
  103537. /**
  103538. * Sets an float array on a uniform variable.
  103539. * @param uniformName Name of the variable.
  103540. * @param array array to be set.
  103541. * @returns this effect.
  103542. */
  103543. setFloatArray(uniformName: string, array: Float32Array): Effect;
  103544. /**
  103545. * 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)
  103546. * @param uniformName Name of the variable.
  103547. * @param array array to be set.
  103548. * @returns this effect.
  103549. */
  103550. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  103551. /**
  103552. * 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)
  103553. * @param uniformName Name of the variable.
  103554. * @param array array to be set.
  103555. * @returns this effect.
  103556. */
  103557. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  103558. /**
  103559. * 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)
  103560. * @param uniformName Name of the variable.
  103561. * @param array array to be set.
  103562. * @returns this effect.
  103563. */
  103564. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  103565. /**
  103566. * Sets an array on a uniform variable.
  103567. * @param uniformName Name of the variable.
  103568. * @param array array to be set.
  103569. * @returns this effect.
  103570. */
  103571. setArray(uniformName: string, array: number[]): Effect;
  103572. /**
  103573. * 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)
  103574. * @param uniformName Name of the variable.
  103575. * @param array array to be set.
  103576. * @returns this effect.
  103577. */
  103578. setArray2(uniformName: string, array: number[]): Effect;
  103579. /**
  103580. * 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)
  103581. * @param uniformName Name of the variable.
  103582. * @param array array to be set.
  103583. * @returns this effect.
  103584. */
  103585. setArray3(uniformName: string, array: number[]): Effect;
  103586. /**
  103587. * 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)
  103588. * @param uniformName Name of the variable.
  103589. * @param array array to be set.
  103590. * @returns this effect.
  103591. */
  103592. setArray4(uniformName: string, array: number[]): Effect;
  103593. /**
  103594. * Sets matrices on a uniform variable.
  103595. * @param uniformName Name of the variable.
  103596. * @param matrices matrices to be set.
  103597. * @returns this effect.
  103598. */
  103599. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  103600. /**
  103601. * Sets matrix on a uniform variable.
  103602. * @param uniformName Name of the variable.
  103603. * @param matrix matrix to be set.
  103604. * @returns this effect.
  103605. */
  103606. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  103607. /**
  103608. * 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)
  103609. * @param uniformName Name of the variable.
  103610. * @param matrix matrix to be set.
  103611. * @returns this effect.
  103612. */
  103613. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  103614. /**
  103615. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  103616. * @param uniformName Name of the variable.
  103617. * @param matrix matrix to be set.
  103618. * @returns this effect.
  103619. */
  103620. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  103621. /**
  103622. * Sets a float on a uniform variable.
  103623. * @param uniformName Name of the variable.
  103624. * @param value value to be set.
  103625. * @returns this effect.
  103626. */
  103627. setFloat(uniformName: string, value: number): Effect;
  103628. /**
  103629. * Sets a boolean on a uniform variable.
  103630. * @param uniformName Name of the variable.
  103631. * @param bool value to be set.
  103632. * @returns this effect.
  103633. */
  103634. setBool(uniformName: string, bool: boolean): Effect;
  103635. /**
  103636. * Sets a Vector2 on a uniform variable.
  103637. * @param uniformName Name of the variable.
  103638. * @param vector2 vector2 to be set.
  103639. * @returns this effect.
  103640. */
  103641. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  103642. /**
  103643. * Sets a float2 on a uniform variable.
  103644. * @param uniformName Name of the variable.
  103645. * @param x First float in float2.
  103646. * @param y Second float in float2.
  103647. * @returns this effect.
  103648. */
  103649. setFloat2(uniformName: string, x: number, y: number): Effect;
  103650. /**
  103651. * Sets a Vector3 on a uniform variable.
  103652. * @param uniformName Name of the variable.
  103653. * @param vector3 Value to be set.
  103654. * @returns this effect.
  103655. */
  103656. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  103657. /**
  103658. * Sets a float3 on a uniform variable.
  103659. * @param uniformName Name of the variable.
  103660. * @param x First float in float3.
  103661. * @param y Second float in float3.
  103662. * @param z Third float in float3.
  103663. * @returns this effect.
  103664. */
  103665. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  103666. /**
  103667. * Sets a Vector4 on a uniform variable.
  103668. * @param uniformName Name of the variable.
  103669. * @param vector4 Value to be set.
  103670. * @returns this effect.
  103671. */
  103672. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  103673. /**
  103674. * Sets a float4 on a uniform variable.
  103675. * @param uniformName Name of the variable.
  103676. * @param x First float in float4.
  103677. * @param y Second float in float4.
  103678. * @param z Third float in float4.
  103679. * @param w Fourth float in float4.
  103680. * @returns this effect.
  103681. */
  103682. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  103683. /**
  103684. * Sets a Color3 on a uniform variable.
  103685. * @param uniformName Name of the variable.
  103686. * @param color3 Value to be set.
  103687. * @returns this effect.
  103688. */
  103689. setColor3(uniformName: string, color3: IColor3Like): Effect;
  103690. /**
  103691. * Sets a Color4 on a uniform variable.
  103692. * @param uniformName Name of the variable.
  103693. * @param color3 Value to be set.
  103694. * @param alpha Alpha value to be set.
  103695. * @returns this effect.
  103696. */
  103697. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  103698. /**
  103699. * Sets a Color4 on a uniform variable
  103700. * @param uniformName defines the name of the variable
  103701. * @param color4 defines the value to be set
  103702. * @returns this effect.
  103703. */
  103704. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  103705. /** Release all associated resources */
  103706. dispose(): void;
  103707. /**
  103708. * This function will add a new shader to the shader store
  103709. * @param name the name of the shader
  103710. * @param pixelShader optional pixel shader content
  103711. * @param vertexShader optional vertex shader content
  103712. */
  103713. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  103714. /**
  103715. * Store of each shader (The can be looked up using effect.key)
  103716. */
  103717. static ShadersStore: {
  103718. [key: string]: string;
  103719. };
  103720. /**
  103721. * Store of each included file for a shader (The can be looked up using effect.key)
  103722. */
  103723. static IncludesShadersStore: {
  103724. [key: string]: string;
  103725. };
  103726. /**
  103727. * Resets the cache of effects.
  103728. */
  103729. static ResetCache(): void;
  103730. }
  103731. }
  103732. declare module BABYLON {
  103733. /**
  103734. * Interface used to describe the capabilities of the engine relatively to the current browser
  103735. */
  103736. export interface EngineCapabilities {
  103737. /** Maximum textures units per fragment shader */
  103738. maxTexturesImageUnits: number;
  103739. /** Maximum texture units per vertex shader */
  103740. maxVertexTextureImageUnits: number;
  103741. /** Maximum textures units in the entire pipeline */
  103742. maxCombinedTexturesImageUnits: number;
  103743. /** Maximum texture size */
  103744. maxTextureSize: number;
  103745. /** Maximum texture samples */
  103746. maxSamples?: number;
  103747. /** Maximum cube texture size */
  103748. maxCubemapTextureSize: number;
  103749. /** Maximum render texture size */
  103750. maxRenderTextureSize: number;
  103751. /** Maximum number of vertex attributes */
  103752. maxVertexAttribs: number;
  103753. /** Maximum number of varyings */
  103754. maxVaryingVectors: number;
  103755. /** Maximum number of uniforms per vertex shader */
  103756. maxVertexUniformVectors: number;
  103757. /** Maximum number of uniforms per fragment shader */
  103758. maxFragmentUniformVectors: number;
  103759. /** Defines if standard derivates (dx/dy) are supported */
  103760. standardDerivatives: boolean;
  103761. /** Defines if s3tc texture compression is supported */
  103762. s3tc?: WEBGL_compressed_texture_s3tc;
  103763. /** Defines if pvrtc texture compression is supported */
  103764. pvrtc: any;
  103765. /** Defines if etc1 texture compression is supported */
  103766. etc1: any;
  103767. /** Defines if etc2 texture compression is supported */
  103768. etc2: any;
  103769. /** Defines if astc texture compression is supported */
  103770. astc: any;
  103771. /** Defines if float textures are supported */
  103772. textureFloat: boolean;
  103773. /** Defines if vertex array objects are supported */
  103774. vertexArrayObject: boolean;
  103775. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  103776. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  103777. /** Gets the maximum level of anisotropy supported */
  103778. maxAnisotropy: number;
  103779. /** Defines if instancing is supported */
  103780. instancedArrays: boolean;
  103781. /** Defines if 32 bits indices are supported */
  103782. uintIndices: boolean;
  103783. /** Defines if high precision shaders are supported */
  103784. highPrecisionShaderSupported: boolean;
  103785. /** Defines if depth reading in the fragment shader is supported */
  103786. fragmentDepthSupported: boolean;
  103787. /** Defines if float texture linear filtering is supported*/
  103788. textureFloatLinearFiltering: boolean;
  103789. /** Defines if rendering to float textures is supported */
  103790. textureFloatRender: boolean;
  103791. /** Defines if half float textures are supported*/
  103792. textureHalfFloat: boolean;
  103793. /** Defines if half float texture linear filtering is supported*/
  103794. textureHalfFloatLinearFiltering: boolean;
  103795. /** Defines if rendering to half float textures is supported */
  103796. textureHalfFloatRender: boolean;
  103797. /** Defines if textureLOD shader command is supported */
  103798. textureLOD: boolean;
  103799. /** Defines if draw buffers extension is supported */
  103800. drawBuffersExtension: boolean;
  103801. /** Defines if depth textures are supported */
  103802. depthTextureExtension: boolean;
  103803. /** Defines if float color buffer are supported */
  103804. colorBufferFloat: boolean;
  103805. /** Gets disjoint timer query extension (null if not supported) */
  103806. timerQuery?: EXT_disjoint_timer_query;
  103807. /** Defines if timestamp can be used with timer query */
  103808. canUseTimestampForTimerQuery: boolean;
  103809. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  103810. multiview?: any;
  103811. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  103812. oculusMultiview?: any;
  103813. /** Function used to let the system compiles shaders in background */
  103814. parallelShaderCompile?: {
  103815. COMPLETION_STATUS_KHR: number;
  103816. };
  103817. /** Max number of texture samples for MSAA */
  103818. maxMSAASamples: number;
  103819. /** Defines if the blend min max extension is supported */
  103820. blendMinMax: boolean;
  103821. }
  103822. }
  103823. declare module BABYLON {
  103824. /**
  103825. * @hidden
  103826. **/
  103827. export class DepthCullingState {
  103828. private _isDepthTestDirty;
  103829. private _isDepthMaskDirty;
  103830. private _isDepthFuncDirty;
  103831. private _isCullFaceDirty;
  103832. private _isCullDirty;
  103833. private _isZOffsetDirty;
  103834. private _isFrontFaceDirty;
  103835. private _depthTest;
  103836. private _depthMask;
  103837. private _depthFunc;
  103838. private _cull;
  103839. private _cullFace;
  103840. private _zOffset;
  103841. private _frontFace;
  103842. /**
  103843. * Initializes the state.
  103844. */
  103845. constructor();
  103846. get isDirty(): boolean;
  103847. get zOffset(): number;
  103848. set zOffset(value: number);
  103849. get cullFace(): Nullable<number>;
  103850. set cullFace(value: Nullable<number>);
  103851. get cull(): Nullable<boolean>;
  103852. set cull(value: Nullable<boolean>);
  103853. get depthFunc(): Nullable<number>;
  103854. set depthFunc(value: Nullable<number>);
  103855. get depthMask(): boolean;
  103856. set depthMask(value: boolean);
  103857. get depthTest(): boolean;
  103858. set depthTest(value: boolean);
  103859. get frontFace(): Nullable<number>;
  103860. set frontFace(value: Nullable<number>);
  103861. reset(): void;
  103862. apply(gl: WebGLRenderingContext): void;
  103863. }
  103864. }
  103865. declare module BABYLON {
  103866. /**
  103867. * @hidden
  103868. **/
  103869. export class StencilState {
  103870. /** 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 */
  103871. static readonly ALWAYS: number;
  103872. /** Passed to stencilOperation to specify that stencil value must be kept */
  103873. static readonly KEEP: number;
  103874. /** Passed to stencilOperation to specify that stencil value must be replaced */
  103875. static readonly REPLACE: number;
  103876. private _isStencilTestDirty;
  103877. private _isStencilMaskDirty;
  103878. private _isStencilFuncDirty;
  103879. private _isStencilOpDirty;
  103880. private _stencilTest;
  103881. private _stencilMask;
  103882. private _stencilFunc;
  103883. private _stencilFuncRef;
  103884. private _stencilFuncMask;
  103885. private _stencilOpStencilFail;
  103886. private _stencilOpDepthFail;
  103887. private _stencilOpStencilDepthPass;
  103888. get isDirty(): boolean;
  103889. get stencilFunc(): number;
  103890. set stencilFunc(value: number);
  103891. get stencilFuncRef(): number;
  103892. set stencilFuncRef(value: number);
  103893. get stencilFuncMask(): number;
  103894. set stencilFuncMask(value: number);
  103895. get stencilOpStencilFail(): number;
  103896. set stencilOpStencilFail(value: number);
  103897. get stencilOpDepthFail(): number;
  103898. set stencilOpDepthFail(value: number);
  103899. get stencilOpStencilDepthPass(): number;
  103900. set stencilOpStencilDepthPass(value: number);
  103901. get stencilMask(): number;
  103902. set stencilMask(value: number);
  103903. get stencilTest(): boolean;
  103904. set stencilTest(value: boolean);
  103905. constructor();
  103906. reset(): void;
  103907. apply(gl: WebGLRenderingContext): void;
  103908. }
  103909. }
  103910. declare module BABYLON {
  103911. /**
  103912. * @hidden
  103913. **/
  103914. export class AlphaState {
  103915. private _isAlphaBlendDirty;
  103916. private _isBlendFunctionParametersDirty;
  103917. private _isBlendEquationParametersDirty;
  103918. private _isBlendConstantsDirty;
  103919. private _alphaBlend;
  103920. private _blendFunctionParameters;
  103921. private _blendEquationParameters;
  103922. private _blendConstants;
  103923. /**
  103924. * Initializes the state.
  103925. */
  103926. constructor();
  103927. get isDirty(): boolean;
  103928. get alphaBlend(): boolean;
  103929. set alphaBlend(value: boolean);
  103930. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  103931. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  103932. setAlphaEquationParameters(rgb: number, alpha: number): void;
  103933. reset(): void;
  103934. apply(gl: WebGLRenderingContext): void;
  103935. }
  103936. }
  103937. declare module BABYLON {
  103938. /** @hidden */
  103939. export class WebGL2ShaderProcessor implements IShaderProcessor {
  103940. attributeProcessor(attribute: string): string;
  103941. varyingProcessor(varying: string, isFragment: boolean): string;
  103942. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  103943. }
  103944. }
  103945. declare module BABYLON {
  103946. /**
  103947. * Interface for attribute information associated with buffer instanciation
  103948. */
  103949. export interface InstancingAttributeInfo {
  103950. /**
  103951. * Name of the GLSL attribute
  103952. * if attribute index is not specified, this is used to retrieve the index from the effect
  103953. */
  103954. attributeName: string;
  103955. /**
  103956. * Index/offset of the attribute in the vertex shader
  103957. * if not specified, this will be computes from the name.
  103958. */
  103959. index?: number;
  103960. /**
  103961. * size of the attribute, 1, 2, 3 or 4
  103962. */
  103963. attributeSize: number;
  103964. /**
  103965. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  103966. */
  103967. offset: number;
  103968. /**
  103969. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  103970. * default to 1
  103971. */
  103972. divisor?: number;
  103973. /**
  103974. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  103975. * default is FLOAT
  103976. */
  103977. attributeType?: number;
  103978. /**
  103979. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  103980. */
  103981. normalized?: boolean;
  103982. }
  103983. }
  103984. declare module BABYLON {
  103985. interface ThinEngine {
  103986. /**
  103987. * Update a video texture
  103988. * @param texture defines the texture to update
  103989. * @param video defines the video element to use
  103990. * @param invertY defines if data must be stored with Y axis inverted
  103991. */
  103992. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  103993. }
  103994. }
  103995. declare module BABYLON {
  103996. /**
  103997. * Settings for finer control over video usage
  103998. */
  103999. export interface VideoTextureSettings {
  104000. /**
  104001. * Applies `autoplay` to video, if specified
  104002. */
  104003. autoPlay?: boolean;
  104004. /**
  104005. * Applies `loop` to video, if specified
  104006. */
  104007. loop?: boolean;
  104008. /**
  104009. * Automatically updates internal texture from video at every frame in the render loop
  104010. */
  104011. autoUpdateTexture: boolean;
  104012. /**
  104013. * Image src displayed during the video loading or until the user interacts with the video.
  104014. */
  104015. poster?: string;
  104016. }
  104017. /**
  104018. * If you want to display a video in your scene, this is the special texture for that.
  104019. * This special texture works similar to other textures, with the exception of a few parameters.
  104020. * @see https://doc.babylonjs.com/how_to/video_texture
  104021. */
  104022. export class VideoTexture extends Texture {
  104023. /**
  104024. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  104025. */
  104026. readonly autoUpdateTexture: boolean;
  104027. /**
  104028. * The video instance used by the texture internally
  104029. */
  104030. readonly video: HTMLVideoElement;
  104031. private _onUserActionRequestedObservable;
  104032. /**
  104033. * Event triggerd when a dom action is required by the user to play the video.
  104034. * This happens due to recent changes in browser policies preventing video to auto start.
  104035. */
  104036. get onUserActionRequestedObservable(): Observable<Texture>;
  104037. private _generateMipMaps;
  104038. private _engine;
  104039. private _stillImageCaptured;
  104040. private _displayingPosterTexture;
  104041. private _settings;
  104042. private _createInternalTextureOnEvent;
  104043. private _frameId;
  104044. private _currentSrc;
  104045. /**
  104046. * Creates a video texture.
  104047. * If you want to display a video in your scene, this is the special texture for that.
  104048. * This special texture works similar to other textures, with the exception of a few parameters.
  104049. * @see https://doc.babylonjs.com/how_to/video_texture
  104050. * @param name optional name, will detect from video source, if not defined
  104051. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  104052. * @param scene is obviously the current scene.
  104053. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  104054. * @param invertY is false by default but can be used to invert video on Y axis
  104055. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  104056. * @param settings allows finer control over video usage
  104057. */
  104058. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  104059. private _getName;
  104060. private _getVideo;
  104061. private _createInternalTexture;
  104062. private reset;
  104063. /**
  104064. * @hidden Internal method to initiate `update`.
  104065. */
  104066. _rebuild(): void;
  104067. /**
  104068. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  104069. */
  104070. update(): void;
  104071. /**
  104072. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  104073. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  104074. */
  104075. updateTexture(isVisible: boolean): void;
  104076. protected _updateInternalTexture: () => void;
  104077. /**
  104078. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  104079. * @param url New url.
  104080. */
  104081. updateURL(url: string): void;
  104082. /**
  104083. * Clones the texture.
  104084. * @returns the cloned texture
  104085. */
  104086. clone(): VideoTexture;
  104087. /**
  104088. * Dispose the texture and release its associated resources.
  104089. */
  104090. dispose(): void;
  104091. /**
  104092. * Creates a video texture straight from a stream.
  104093. * @param scene Define the scene the texture should be created in
  104094. * @param stream Define the stream the texture should be created from
  104095. * @returns The created video texture as a promise
  104096. */
  104097. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  104098. /**
  104099. * Creates a video texture straight from your WebCam video feed.
  104100. * @param scene Define the scene the texture should be created in
  104101. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  104102. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  104103. * @returns The created video texture as a promise
  104104. */
  104105. static CreateFromWebCamAsync(scene: Scene, constraints: {
  104106. minWidth: number;
  104107. maxWidth: number;
  104108. minHeight: number;
  104109. maxHeight: number;
  104110. deviceId: string;
  104111. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  104112. /**
  104113. * Creates a video texture straight from your WebCam video feed.
  104114. * @param scene Define the scene the texture should be created in
  104115. * @param onReady Define a callback to triggered once the texture will be ready
  104116. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  104117. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  104118. */
  104119. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  104120. minWidth: number;
  104121. maxWidth: number;
  104122. minHeight: number;
  104123. maxHeight: number;
  104124. deviceId: string;
  104125. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  104126. }
  104127. }
  104128. declare module BABYLON {
  104129. /**
  104130. * Defines the interface used by objects working like Scene
  104131. * @hidden
  104132. */
  104133. interface ISceneLike {
  104134. _addPendingData(data: any): void;
  104135. _removePendingData(data: any): void;
  104136. offlineProvider: IOfflineProvider;
  104137. }
  104138. /** Interface defining initialization parameters for Engine class */
  104139. export interface EngineOptions extends WebGLContextAttributes {
  104140. /**
  104141. * Defines if the engine should no exceed a specified device ratio
  104142. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  104143. */
  104144. limitDeviceRatio?: number;
  104145. /**
  104146. * Defines if webvr should be enabled automatically
  104147. * @see http://doc.babylonjs.com/how_to/webvr_camera
  104148. */
  104149. autoEnableWebVR?: boolean;
  104150. /**
  104151. * Defines if webgl2 should be turned off even if supported
  104152. * @see http://doc.babylonjs.com/features/webgl2
  104153. */
  104154. disableWebGL2Support?: boolean;
  104155. /**
  104156. * Defines if webaudio should be initialized as well
  104157. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104158. */
  104159. audioEngine?: boolean;
  104160. /**
  104161. * Defines if animations should run using a deterministic lock step
  104162. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104163. */
  104164. deterministicLockstep?: boolean;
  104165. /** Defines the maximum steps to use with deterministic lock step mode */
  104166. lockstepMaxSteps?: number;
  104167. /** Defines the seconds between each deterministic lock step */
  104168. timeStep?: number;
  104169. /**
  104170. * Defines that engine should ignore context lost events
  104171. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  104172. */
  104173. doNotHandleContextLost?: boolean;
  104174. /**
  104175. * Defines that engine should ignore modifying touch action attribute and style
  104176. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  104177. */
  104178. doNotHandleTouchAction?: boolean;
  104179. /**
  104180. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  104181. */
  104182. useHighPrecisionFloats?: boolean;
  104183. }
  104184. /**
  104185. * The base engine class (root of all engines)
  104186. */
  104187. export class ThinEngine {
  104188. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  104189. static ExceptionList: ({
  104190. key: string;
  104191. capture: string;
  104192. captureConstraint: number;
  104193. targets: string[];
  104194. } | {
  104195. key: string;
  104196. capture: null;
  104197. captureConstraint: null;
  104198. targets: string[];
  104199. })[];
  104200. /** @hidden */
  104201. static _TextureLoaders: IInternalTextureLoader[];
  104202. /**
  104203. * Returns the current npm package of the sdk
  104204. */
  104205. static get NpmPackage(): string;
  104206. /**
  104207. * Returns the current version of the framework
  104208. */
  104209. static get Version(): string;
  104210. /**
  104211. * Returns a string describing the current engine
  104212. */
  104213. get description(): string;
  104214. /**
  104215. * Gets or sets the epsilon value used by collision engine
  104216. */
  104217. static CollisionsEpsilon: number;
  104218. /**
  104219. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  104220. */
  104221. static get ShadersRepository(): string;
  104222. static set ShadersRepository(value: string);
  104223. /**
  104224. * Gets or sets the textures that the engine should not attempt to load as compressed
  104225. */
  104226. protected _excludedCompressedTextures: string[];
  104227. /**
  104228. * Filters the compressed texture formats to only include
  104229. * files that are not included in the skippable list
  104230. *
  104231. * @param url the current extension
  104232. * @param textureFormatInUse the current compressed texture format
  104233. * @returns "format" string
  104234. */
  104235. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  104236. /** @hidden */
  104237. _shaderProcessor: IShaderProcessor;
  104238. /**
  104239. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  104240. */
  104241. forcePOTTextures: boolean;
  104242. /**
  104243. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  104244. */
  104245. isFullscreen: boolean;
  104246. /**
  104247. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  104248. */
  104249. cullBackFaces: boolean;
  104250. /**
  104251. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  104252. */
  104253. renderEvenInBackground: boolean;
  104254. /**
  104255. * Gets or sets a boolean indicating that cache can be kept between frames
  104256. */
  104257. preventCacheWipeBetweenFrames: boolean;
  104258. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  104259. validateShaderPrograms: boolean;
  104260. /**
  104261. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  104262. * This can provide greater z depth for distant objects.
  104263. */
  104264. useReverseDepthBuffer: boolean;
  104265. /**
  104266. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  104267. */
  104268. disableUniformBuffers: boolean;
  104269. /** @hidden */
  104270. _uniformBuffers: UniformBuffer[];
  104271. /**
  104272. * Gets a boolean indicating that the engine supports uniform buffers
  104273. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  104274. */
  104275. get supportsUniformBuffers(): boolean;
  104276. /** @hidden */
  104277. _gl: WebGLRenderingContext;
  104278. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  104279. protected _windowIsBackground: boolean;
  104280. protected _webGLVersion: number;
  104281. protected _creationOptions: EngineOptions;
  104282. protected _highPrecisionShadersAllowed: boolean;
  104283. /** @hidden */
  104284. get _shouldUseHighPrecisionShader(): boolean;
  104285. /**
  104286. * Gets a boolean indicating that only power of 2 textures are supported
  104287. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  104288. */
  104289. get needPOTTextures(): boolean;
  104290. /** @hidden */
  104291. _badOS: boolean;
  104292. /** @hidden */
  104293. _badDesktopOS: boolean;
  104294. private _hardwareScalingLevel;
  104295. /** @hidden */
  104296. _caps: EngineCapabilities;
  104297. private _isStencilEnable;
  104298. private _glVersion;
  104299. private _glRenderer;
  104300. private _glVendor;
  104301. /** @hidden */
  104302. _videoTextureSupported: boolean;
  104303. protected _renderingQueueLaunched: boolean;
  104304. protected _activeRenderLoops: (() => void)[];
  104305. /**
  104306. * Observable signaled when a context lost event is raised
  104307. */
  104308. onContextLostObservable: Observable<ThinEngine>;
  104309. /**
  104310. * Observable signaled when a context restored event is raised
  104311. */
  104312. onContextRestoredObservable: Observable<ThinEngine>;
  104313. private _onContextLost;
  104314. private _onContextRestored;
  104315. protected _contextWasLost: boolean;
  104316. /** @hidden */
  104317. _doNotHandleContextLost: boolean;
  104318. /**
  104319. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  104320. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  104321. */
  104322. get doNotHandleContextLost(): boolean;
  104323. set doNotHandleContextLost(value: boolean);
  104324. /**
  104325. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  104326. */
  104327. disableVertexArrayObjects: boolean;
  104328. /** @hidden */
  104329. protected _colorWrite: boolean;
  104330. /** @hidden */
  104331. protected _colorWriteChanged: boolean;
  104332. /** @hidden */
  104333. protected _depthCullingState: DepthCullingState;
  104334. /** @hidden */
  104335. protected _stencilState: StencilState;
  104336. /** @hidden */
  104337. _alphaState: AlphaState;
  104338. /** @hidden */
  104339. _alphaMode: number;
  104340. /** @hidden */
  104341. _alphaEquation: number;
  104342. /** @hidden */
  104343. _internalTexturesCache: InternalTexture[];
  104344. /** @hidden */
  104345. protected _activeChannel: number;
  104346. private _currentTextureChannel;
  104347. /** @hidden */
  104348. protected _boundTexturesCache: {
  104349. [key: string]: Nullable<InternalTexture>;
  104350. };
  104351. /** @hidden */
  104352. protected _currentEffect: Nullable<Effect>;
  104353. /** @hidden */
  104354. protected _currentProgram: Nullable<WebGLProgram>;
  104355. private _compiledEffects;
  104356. private _vertexAttribArraysEnabled;
  104357. /** @hidden */
  104358. protected _cachedViewport: Nullable<IViewportLike>;
  104359. private _cachedVertexArrayObject;
  104360. /** @hidden */
  104361. protected _cachedVertexBuffers: any;
  104362. /** @hidden */
  104363. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  104364. /** @hidden */
  104365. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  104366. /** @hidden */
  104367. _currentRenderTarget: Nullable<InternalTexture>;
  104368. private _uintIndicesCurrentlySet;
  104369. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  104370. /** @hidden */
  104371. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  104372. private _currentBufferPointers;
  104373. private _currentInstanceLocations;
  104374. private _currentInstanceBuffers;
  104375. private _textureUnits;
  104376. /** @hidden */
  104377. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  104378. /** @hidden */
  104379. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  104380. /** @hidden */
  104381. _boundRenderFunction: any;
  104382. private _vaoRecordInProgress;
  104383. private _mustWipeVertexAttributes;
  104384. private _emptyTexture;
  104385. private _emptyCubeTexture;
  104386. private _emptyTexture3D;
  104387. private _emptyTexture2DArray;
  104388. /** @hidden */
  104389. _frameHandler: number;
  104390. private _nextFreeTextureSlots;
  104391. private _maxSimultaneousTextures;
  104392. private _activeRequests;
  104393. protected _texturesSupported: string[];
  104394. /** @hidden */
  104395. _textureFormatInUse: Nullable<string>;
  104396. protected get _supportsHardwareTextureRescaling(): boolean;
  104397. /**
  104398. * Gets the list of texture formats supported
  104399. */
  104400. get texturesSupported(): Array<string>;
  104401. /**
  104402. * Gets the list of texture formats in use
  104403. */
  104404. get textureFormatInUse(): Nullable<string>;
  104405. /**
  104406. * Gets the current viewport
  104407. */
  104408. get currentViewport(): Nullable<IViewportLike>;
  104409. /**
  104410. * Gets the default empty texture
  104411. */
  104412. get emptyTexture(): InternalTexture;
  104413. /**
  104414. * Gets the default empty 3D texture
  104415. */
  104416. get emptyTexture3D(): InternalTexture;
  104417. /**
  104418. * Gets the default empty 2D array texture
  104419. */
  104420. get emptyTexture2DArray(): InternalTexture;
  104421. /**
  104422. * Gets the default empty cube texture
  104423. */
  104424. get emptyCubeTexture(): InternalTexture;
  104425. /**
  104426. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  104427. */
  104428. readonly premultipliedAlpha: boolean;
  104429. /**
  104430. * Observable event triggered before each texture is initialized
  104431. */
  104432. onBeforeTextureInitObservable: Observable<Texture>;
  104433. /**
  104434. * Creates a new engine
  104435. * @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
  104436. * @param antialias defines enable antialiasing (default: false)
  104437. * @param options defines further options to be sent to the getContext() function
  104438. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  104439. */
  104440. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  104441. private _rebuildInternalTextures;
  104442. private _rebuildEffects;
  104443. /**
  104444. * Gets a boolean indicating if all created effects are ready
  104445. * @returns true if all effects are ready
  104446. */
  104447. areAllEffectsReady(): boolean;
  104448. protected _rebuildBuffers(): void;
  104449. private _initGLContext;
  104450. /**
  104451. * Gets version of the current webGL context
  104452. */
  104453. get webGLVersion(): number;
  104454. /**
  104455. * Gets a string idenfifying the name of the class
  104456. * @returns "Engine" string
  104457. */
  104458. getClassName(): string;
  104459. /**
  104460. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  104461. */
  104462. get isStencilEnable(): boolean;
  104463. /** @hidden */
  104464. _prepareWorkingCanvas(): void;
  104465. /**
  104466. * Reset the texture cache to empty state
  104467. */
  104468. resetTextureCache(): void;
  104469. /**
  104470. * Gets an object containing information about the current webGL context
  104471. * @returns an object containing the vender, the renderer and the version of the current webGL context
  104472. */
  104473. getGlInfo(): {
  104474. vendor: string;
  104475. renderer: string;
  104476. version: string;
  104477. };
  104478. /**
  104479. * Defines the hardware scaling level.
  104480. * By default the hardware scaling level is computed from the window device ratio.
  104481. * 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.
  104482. * @param level defines the level to use
  104483. */
  104484. setHardwareScalingLevel(level: number): void;
  104485. /**
  104486. * Gets the current hardware scaling level.
  104487. * By default the hardware scaling level is computed from the window device ratio.
  104488. * 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.
  104489. * @returns a number indicating the current hardware scaling level
  104490. */
  104491. getHardwareScalingLevel(): number;
  104492. /**
  104493. * Gets the list of loaded textures
  104494. * @returns an array containing all loaded textures
  104495. */
  104496. getLoadedTexturesCache(): InternalTexture[];
  104497. /**
  104498. * Gets the object containing all engine capabilities
  104499. * @returns the EngineCapabilities object
  104500. */
  104501. getCaps(): EngineCapabilities;
  104502. /**
  104503. * stop executing a render loop function and remove it from the execution array
  104504. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  104505. */
  104506. stopRenderLoop(renderFunction?: () => void): void;
  104507. /** @hidden */
  104508. _renderLoop(): void;
  104509. /**
  104510. * Gets the HTML canvas attached with the current webGL context
  104511. * @returns a HTML canvas
  104512. */
  104513. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  104514. /**
  104515. * Gets host window
  104516. * @returns the host window object
  104517. */
  104518. getHostWindow(): Nullable<Window>;
  104519. /**
  104520. * Gets the current render width
  104521. * @param useScreen defines if screen size must be used (or the current render target if any)
  104522. * @returns a number defining the current render width
  104523. */
  104524. getRenderWidth(useScreen?: boolean): number;
  104525. /**
  104526. * Gets the current render height
  104527. * @param useScreen defines if screen size must be used (or the current render target if any)
  104528. * @returns a number defining the current render height
  104529. */
  104530. getRenderHeight(useScreen?: boolean): number;
  104531. /**
  104532. * Can be used to override the current requestAnimationFrame requester.
  104533. * @hidden
  104534. */
  104535. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  104536. /**
  104537. * Register and execute a render loop. The engine can have more than one render function
  104538. * @param renderFunction defines the function to continuously execute
  104539. */
  104540. runRenderLoop(renderFunction: () => void): void;
  104541. /**
  104542. * Clear the current render buffer or the current render target (if any is set up)
  104543. * @param color defines the color to use
  104544. * @param backBuffer defines if the back buffer must be cleared
  104545. * @param depth defines if the depth buffer must be cleared
  104546. * @param stencil defines if the stencil buffer must be cleared
  104547. */
  104548. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  104549. private _viewportCached;
  104550. /** @hidden */
  104551. _viewport(x: number, y: number, width: number, height: number): void;
  104552. /**
  104553. * Set the WebGL's viewport
  104554. * @param viewport defines the viewport element to be used
  104555. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  104556. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  104557. */
  104558. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  104559. /**
  104560. * Begin a new frame
  104561. */
  104562. beginFrame(): void;
  104563. /**
  104564. * Enf the current frame
  104565. */
  104566. endFrame(): void;
  104567. /**
  104568. * Resize the view according to the canvas' size
  104569. */
  104570. resize(): void;
  104571. /**
  104572. * Force a specific size of the canvas
  104573. * @param width defines the new canvas' width
  104574. * @param height defines the new canvas' height
  104575. */
  104576. setSize(width: number, height: number): void;
  104577. /**
  104578. * Binds the frame buffer to the specified texture.
  104579. * @param texture The texture to render to or null for the default canvas
  104580. * @param faceIndex The face of the texture to render to in case of cube texture
  104581. * @param requiredWidth The width of the target to render to
  104582. * @param requiredHeight The height of the target to render to
  104583. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  104584. * @param lodLevel defines the lod level to bind to the frame buffer
  104585. * @param layer defines the 2d array index to bind to frame buffer to
  104586. */
  104587. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  104588. /** @hidden */
  104589. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  104590. /**
  104591. * Unbind the current render target texture from the webGL context
  104592. * @param texture defines the render target texture to unbind
  104593. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  104594. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  104595. */
  104596. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  104597. /**
  104598. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  104599. */
  104600. flushFramebuffer(): void;
  104601. /**
  104602. * Unbind the current render target and bind the default framebuffer
  104603. */
  104604. restoreDefaultFramebuffer(): void;
  104605. /** @hidden */
  104606. protected _resetVertexBufferBinding(): void;
  104607. /**
  104608. * Creates a vertex buffer
  104609. * @param data the data for the vertex buffer
  104610. * @returns the new WebGL static buffer
  104611. */
  104612. createVertexBuffer(data: DataArray): DataBuffer;
  104613. private _createVertexBuffer;
  104614. /**
  104615. * Creates a dynamic vertex buffer
  104616. * @param data the data for the dynamic vertex buffer
  104617. * @returns the new WebGL dynamic buffer
  104618. */
  104619. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  104620. protected _resetIndexBufferBinding(): void;
  104621. /**
  104622. * Creates a new index buffer
  104623. * @param indices defines the content of the index buffer
  104624. * @param updatable defines if the index buffer must be updatable
  104625. * @returns a new webGL buffer
  104626. */
  104627. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  104628. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  104629. /**
  104630. * Bind a webGL buffer to the webGL context
  104631. * @param buffer defines the buffer to bind
  104632. */
  104633. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  104634. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  104635. private bindBuffer;
  104636. /**
  104637. * update the bound buffer with the given data
  104638. * @param data defines the data to update
  104639. */
  104640. updateArrayBuffer(data: Float32Array): void;
  104641. private _vertexAttribPointer;
  104642. /** @hidden */
  104643. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  104644. private _bindVertexBuffersAttributes;
  104645. /**
  104646. * Records a vertex array object
  104647. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  104648. * @param vertexBuffers defines the list of vertex buffers to store
  104649. * @param indexBuffer defines the index buffer to store
  104650. * @param effect defines the effect to store
  104651. * @returns the new vertex array object
  104652. */
  104653. recordVertexArrayObject(vertexBuffers: {
  104654. [key: string]: VertexBuffer;
  104655. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  104656. /**
  104657. * Bind a specific vertex array object
  104658. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  104659. * @param vertexArrayObject defines the vertex array object to bind
  104660. * @param indexBuffer defines the index buffer to bind
  104661. */
  104662. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  104663. /**
  104664. * Bind webGl buffers directly to the webGL context
  104665. * @param vertexBuffer defines the vertex buffer to bind
  104666. * @param indexBuffer defines the index buffer to bind
  104667. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  104668. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  104669. * @param effect defines the effect associated with the vertex buffer
  104670. */
  104671. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  104672. private _unbindVertexArrayObject;
  104673. /**
  104674. * Bind a list of vertex buffers to the webGL context
  104675. * @param vertexBuffers defines the list of vertex buffers to bind
  104676. * @param indexBuffer defines the index buffer to bind
  104677. * @param effect defines the effect associated with the vertex buffers
  104678. */
  104679. bindBuffers(vertexBuffers: {
  104680. [key: string]: Nullable<VertexBuffer>;
  104681. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  104682. /**
  104683. * Unbind all instance attributes
  104684. */
  104685. unbindInstanceAttributes(): void;
  104686. /**
  104687. * Release and free the memory of a vertex array object
  104688. * @param vao defines the vertex array object to delete
  104689. */
  104690. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  104691. /** @hidden */
  104692. _releaseBuffer(buffer: DataBuffer): boolean;
  104693. protected _deleteBuffer(buffer: DataBuffer): void;
  104694. /**
  104695. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  104696. * @param instancesBuffer defines the webGL buffer to update and bind
  104697. * @param data defines the data to store in the buffer
  104698. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  104699. */
  104700. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  104701. /**
  104702. * Bind the content of a webGL buffer used with instantiation
  104703. * @param instancesBuffer defines the webGL buffer to bind
  104704. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  104705. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  104706. */
  104707. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  104708. /**
  104709. * Disable the instance attribute corresponding to the name in parameter
  104710. * @param name defines the name of the attribute to disable
  104711. */
  104712. disableInstanceAttributeByName(name: string): void;
  104713. /**
  104714. * Disable the instance attribute corresponding to the location in parameter
  104715. * @param attributeLocation defines the attribute location of the attribute to disable
  104716. */
  104717. disableInstanceAttribute(attributeLocation: number): void;
  104718. /**
  104719. * Disable the attribute corresponding to the location in parameter
  104720. * @param attributeLocation defines the attribute location of the attribute to disable
  104721. */
  104722. disableAttributeByIndex(attributeLocation: number): void;
  104723. /**
  104724. * Send a draw order
  104725. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  104726. * @param indexStart defines the starting index
  104727. * @param indexCount defines the number of index to draw
  104728. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104729. */
  104730. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  104731. /**
  104732. * Draw a list of points
  104733. * @param verticesStart defines the index of first vertex to draw
  104734. * @param verticesCount defines the count of vertices to draw
  104735. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104736. */
  104737. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104738. /**
  104739. * Draw a list of unindexed primitives
  104740. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  104741. * @param verticesStart defines the index of first vertex to draw
  104742. * @param verticesCount defines the count of vertices to draw
  104743. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104744. */
  104745. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104746. /**
  104747. * Draw a list of indexed primitives
  104748. * @param fillMode defines the primitive to use
  104749. * @param indexStart defines the starting index
  104750. * @param indexCount defines the number of index to draw
  104751. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104752. */
  104753. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  104754. /**
  104755. * Draw a list of unindexed primitives
  104756. * @param fillMode defines the primitive to use
  104757. * @param verticesStart defines the index of first vertex to draw
  104758. * @param verticesCount defines the count of vertices to draw
  104759. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104760. */
  104761. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104762. private _drawMode;
  104763. /** @hidden */
  104764. protected _reportDrawCall(): void;
  104765. /** @hidden */
  104766. _releaseEffect(effect: Effect): void;
  104767. /** @hidden */
  104768. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  104769. /**
  104770. * Create a new effect (used to store vertex/fragment shaders)
  104771. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  104772. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  104773. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  104774. * @param samplers defines an array of string used to represent textures
  104775. * @param defines defines the string containing the defines to use to compile the shaders
  104776. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  104777. * @param onCompiled defines a function to call when the effect creation is successful
  104778. * @param onError defines a function to call when the effect creation has failed
  104779. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  104780. * @returns the new Effect
  104781. */
  104782. 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;
  104783. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  104784. private _compileShader;
  104785. private _compileRawShader;
  104786. /**
  104787. * Directly creates a webGL program
  104788. * @param pipelineContext defines the pipeline context to attach to
  104789. * @param vertexCode defines the vertex shader code to use
  104790. * @param fragmentCode defines the fragment shader code to use
  104791. * @param context defines the webGL context to use (if not set, the current one will be used)
  104792. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  104793. * @returns the new webGL program
  104794. */
  104795. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104796. /**
  104797. * Creates a webGL program
  104798. * @param pipelineContext defines the pipeline context to attach to
  104799. * @param vertexCode defines the vertex shader code to use
  104800. * @param fragmentCode defines the fragment shader code to use
  104801. * @param defines defines the string containing the defines to use to compile the shaders
  104802. * @param context defines the webGL context to use (if not set, the current one will be used)
  104803. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  104804. * @returns the new webGL program
  104805. */
  104806. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104807. /**
  104808. * Creates a new pipeline context
  104809. * @returns the new pipeline
  104810. */
  104811. createPipelineContext(): IPipelineContext;
  104812. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104813. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  104814. /** @hidden */
  104815. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  104816. /** @hidden */
  104817. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  104818. /** @hidden */
  104819. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  104820. /**
  104821. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  104822. * @param pipelineContext defines the pipeline context to use
  104823. * @param uniformsNames defines the list of uniform names
  104824. * @returns an array of webGL uniform locations
  104825. */
  104826. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  104827. /**
  104828. * Gets the lsit of active attributes for a given webGL program
  104829. * @param pipelineContext defines the pipeline context to use
  104830. * @param attributesNames defines the list of attribute names to get
  104831. * @returns an array of indices indicating the offset of each attribute
  104832. */
  104833. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  104834. /**
  104835. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  104836. * @param effect defines the effect to activate
  104837. */
  104838. enableEffect(effect: Nullable<Effect>): void;
  104839. /**
  104840. * Set the value of an uniform to a number (int)
  104841. * @param uniform defines the webGL uniform location where to store the value
  104842. * @param value defines the int number to store
  104843. */
  104844. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  104845. /**
  104846. * Set the value of an uniform to an array of int32
  104847. * @param uniform defines the webGL uniform location where to store the value
  104848. * @param array defines the array of int32 to store
  104849. */
  104850. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104851. /**
  104852. * Set the value of an uniform to an array of int32 (stored as vec2)
  104853. * @param uniform defines the webGL uniform location where to store the value
  104854. * @param array defines the array of int32 to store
  104855. */
  104856. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104857. /**
  104858. * Set the value of an uniform to an array of int32 (stored as vec3)
  104859. * @param uniform defines the webGL uniform location where to store the value
  104860. * @param array defines the array of int32 to store
  104861. */
  104862. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104863. /**
  104864. * Set the value of an uniform to an array of int32 (stored as vec4)
  104865. * @param uniform defines the webGL uniform location where to store the value
  104866. * @param array defines the array of int32 to store
  104867. */
  104868. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104869. /**
  104870. * Set the value of an uniform to an array of number
  104871. * @param uniform defines the webGL uniform location where to store the value
  104872. * @param array defines the array of number to store
  104873. */
  104874. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104875. /**
  104876. * Set the value of an uniform to an array of number (stored as vec2)
  104877. * @param uniform defines the webGL uniform location where to store the value
  104878. * @param array defines the array of number to store
  104879. */
  104880. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104881. /**
  104882. * Set the value of an uniform to an array of number (stored as vec3)
  104883. * @param uniform defines the webGL uniform location where to store the value
  104884. * @param array defines the array of number to store
  104885. */
  104886. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104887. /**
  104888. * Set the value of an uniform to an array of number (stored as vec4)
  104889. * @param uniform defines the webGL uniform location where to store the value
  104890. * @param array defines the array of number to store
  104891. */
  104892. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104893. /**
  104894. * Set the value of an uniform to an array of float32 (stored as matrices)
  104895. * @param uniform defines the webGL uniform location where to store the value
  104896. * @param matrices defines the array of float32 to store
  104897. */
  104898. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  104899. /**
  104900. * Set the value of an uniform to a matrix (3x3)
  104901. * @param uniform defines the webGL uniform location where to store the value
  104902. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  104903. */
  104904. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  104905. /**
  104906. * Set the value of an uniform to a matrix (2x2)
  104907. * @param uniform defines the webGL uniform location where to store the value
  104908. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  104909. */
  104910. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  104911. /**
  104912. * Set the value of an uniform to a number (float)
  104913. * @param uniform defines the webGL uniform location where to store the value
  104914. * @param value defines the float number to store
  104915. */
  104916. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  104917. /**
  104918. * Set the value of an uniform to a vec2
  104919. * @param uniform defines the webGL uniform location where to store the value
  104920. * @param x defines the 1st component of the value
  104921. * @param y defines the 2nd component of the value
  104922. */
  104923. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  104924. /**
  104925. * Set the value of an uniform to a vec3
  104926. * @param uniform defines the webGL uniform location where to store the value
  104927. * @param x defines the 1st component of the value
  104928. * @param y defines the 2nd component of the value
  104929. * @param z defines the 3rd component of the value
  104930. */
  104931. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  104932. /**
  104933. * Set the value of an uniform to a vec4
  104934. * @param uniform defines the webGL uniform location where to store the value
  104935. * @param x defines the 1st component of the value
  104936. * @param y defines the 2nd component of the value
  104937. * @param z defines the 3rd component of the value
  104938. * @param w defines the 4th component of the value
  104939. */
  104940. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  104941. /**
  104942. * Apply all cached states (depth, culling, stencil and alpha)
  104943. */
  104944. applyStates(): void;
  104945. /**
  104946. * Enable or disable color writing
  104947. * @param enable defines the state to set
  104948. */
  104949. setColorWrite(enable: boolean): void;
  104950. /**
  104951. * Gets a boolean indicating if color writing is enabled
  104952. * @returns the current color writing state
  104953. */
  104954. getColorWrite(): boolean;
  104955. /**
  104956. * Gets the depth culling state manager
  104957. */
  104958. get depthCullingState(): DepthCullingState;
  104959. /**
  104960. * Gets the alpha state manager
  104961. */
  104962. get alphaState(): AlphaState;
  104963. /**
  104964. * Gets the stencil state manager
  104965. */
  104966. get stencilState(): StencilState;
  104967. /**
  104968. * Clears the list of texture accessible through engine.
  104969. * This can help preventing texture load conflict due to name collision.
  104970. */
  104971. clearInternalTexturesCache(): void;
  104972. /**
  104973. * Force the entire cache to be cleared
  104974. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  104975. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  104976. */
  104977. wipeCaches(bruteForce?: boolean): void;
  104978. /** @hidden */
  104979. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  104980. min: number;
  104981. mag: number;
  104982. };
  104983. /** @hidden */
  104984. _createTexture(): WebGLTexture;
  104985. /**
  104986. * Usually called from Texture.ts.
  104987. * Passed information to create a WebGLTexture
  104988. * @param urlArg defines a value which contains one of the following:
  104989. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  104990. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  104991. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  104992. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  104993. * @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)
  104994. * @param scene needed for loading to the correct scene
  104995. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  104996. * @param onLoad optional callback to be called upon successful completion
  104997. * @param onError optional callback to be called upon failure
  104998. * @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
  104999. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  105000. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  105001. * @param forcedExtension defines the extension to use to pick the right loader
  105002. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  105003. * @param mimeType defines an optional mime type
  105004. * @returns a InternalTexture for assignment back into BABYLON.Texture
  105005. */
  105006. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  105007. /**
  105008. * Loads an image as an HTMLImageElement.
  105009. * @param input url string, ArrayBuffer, or Blob to load
  105010. * @param onLoad callback called when the image successfully loads
  105011. * @param onError callback called when the image fails to load
  105012. * @param offlineProvider offline provider for caching
  105013. * @param mimeType optional mime type
  105014. * @returns the HTMLImageElement of the loaded image
  105015. * @hidden
  105016. */
  105017. 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>;
  105018. /**
  105019. * @hidden
  105020. */
  105021. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  105022. /**
  105023. * Creates a raw texture
  105024. * @param data defines the data to store in the texture
  105025. * @param width defines the width of the texture
  105026. * @param height defines the height of the texture
  105027. * @param format defines the format of the data
  105028. * @param generateMipMaps defines if the engine should generate the mip levels
  105029. * @param invertY defines if data must be stored with Y axis inverted
  105030. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  105031. * @param compression defines the compression used (null by default)
  105032. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  105033. * @returns the raw texture inside an InternalTexture
  105034. */
  105035. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  105036. /**
  105037. * Creates a new raw cube texture
  105038. * @param data defines the array of data to use to create each face
  105039. * @param size defines the size of the textures
  105040. * @param format defines the format of the data
  105041. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  105042. * @param generateMipMaps defines if the engine should generate the mip levels
  105043. * @param invertY defines if data must be stored with Y axis inverted
  105044. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  105045. * @param compression defines the compression used (null by default)
  105046. * @returns the cube texture as an InternalTexture
  105047. */
  105048. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  105049. /**
  105050. * Creates a new raw 3D texture
  105051. * @param data defines the data used to create the texture
  105052. * @param width defines the width of the texture
  105053. * @param height defines the height of the texture
  105054. * @param depth defines the depth of the texture
  105055. * @param format defines the format of the texture
  105056. * @param generateMipMaps defines if the engine must generate mip levels
  105057. * @param invertY defines if data must be stored with Y axis inverted
  105058. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  105059. * @param compression defines the compressed used (can be null)
  105060. * @param textureType defines the compressed used (can be null)
  105061. * @returns a new raw 3D texture (stored in an InternalTexture)
  105062. */
  105063. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  105064. /**
  105065. * Creates a new raw 2D array texture
  105066. * @param data defines the data used to create the texture
  105067. * @param width defines the width of the texture
  105068. * @param height defines the height of the texture
  105069. * @param depth defines the number of layers of the texture
  105070. * @param format defines the format of the texture
  105071. * @param generateMipMaps defines if the engine must generate mip levels
  105072. * @param invertY defines if data must be stored with Y axis inverted
  105073. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  105074. * @param compression defines the compressed used (can be null)
  105075. * @param textureType defines the compressed used (can be null)
  105076. * @returns a new raw 2D array texture (stored in an InternalTexture)
  105077. */
  105078. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  105079. private _unpackFlipYCached;
  105080. /**
  105081. * In case you are sharing the context with other applications, it might
  105082. * be interested to not cache the unpack flip y state to ensure a consistent
  105083. * value would be set.
  105084. */
  105085. enableUnpackFlipYCached: boolean;
  105086. /** @hidden */
  105087. _unpackFlipY(value: boolean): void;
  105088. /** @hidden */
  105089. _getUnpackAlignement(): number;
  105090. private _getTextureTarget;
  105091. /**
  105092. * Update the sampling mode of a given texture
  105093. * @param samplingMode defines the required sampling mode
  105094. * @param texture defines the texture to update
  105095. * @param generateMipMaps defines whether to generate mipmaps for the texture
  105096. */
  105097. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  105098. /**
  105099. * Update the sampling mode of a given texture
  105100. * @param texture defines the texture to update
  105101. * @param wrapU defines the texture wrap mode of the u coordinates
  105102. * @param wrapV defines the texture wrap mode of the v coordinates
  105103. * @param wrapR defines the texture wrap mode of the r coordinates
  105104. */
  105105. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  105106. /** @hidden */
  105107. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  105108. width: number;
  105109. height: number;
  105110. layers?: number;
  105111. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  105112. /** @hidden */
  105113. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  105114. /** @hidden */
  105115. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  105116. /**
  105117. * Update a portion of an internal texture
  105118. * @param texture defines the texture to update
  105119. * @param imageData defines the data to store into the texture
  105120. * @param xOffset defines the x coordinates of the update rectangle
  105121. * @param yOffset defines the y coordinates of the update rectangle
  105122. * @param width defines the width of the update rectangle
  105123. * @param height defines the height of the update rectangle
  105124. * @param faceIndex defines the face index if texture is a cube (0 by default)
  105125. * @param lod defines the lod level to update (0 by default)
  105126. */
  105127. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  105128. /** @hidden */
  105129. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  105130. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  105131. private _prepareWebGLTexture;
  105132. /** @hidden */
  105133. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  105134. private _getDepthStencilBuffer;
  105135. /** @hidden */
  105136. _releaseFramebufferObjects(texture: InternalTexture): void;
  105137. /** @hidden */
  105138. _releaseTexture(texture: InternalTexture): void;
  105139. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  105140. protected _setProgram(program: WebGLProgram): void;
  105141. protected _boundUniforms: {
  105142. [key: number]: WebGLUniformLocation;
  105143. };
  105144. /**
  105145. * Binds an effect to the webGL context
  105146. * @param effect defines the effect to bind
  105147. */
  105148. bindSamplers(effect: Effect): void;
  105149. private _activateCurrentTexture;
  105150. /** @hidden */
  105151. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  105152. /** @hidden */
  105153. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  105154. /**
  105155. * Unbind all textures from the webGL context
  105156. */
  105157. unbindAllTextures(): void;
  105158. /**
  105159. * Sets a texture to the according uniform.
  105160. * @param channel The texture channel
  105161. * @param uniform The uniform to set
  105162. * @param texture The texture to apply
  105163. */
  105164. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  105165. private _bindSamplerUniformToChannel;
  105166. private _getTextureWrapMode;
  105167. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  105168. /**
  105169. * Sets an array of texture to the webGL context
  105170. * @param channel defines the channel where the texture array must be set
  105171. * @param uniform defines the associated uniform location
  105172. * @param textures defines the array of textures to bind
  105173. */
  105174. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  105175. /** @hidden */
  105176. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  105177. private _setTextureParameterFloat;
  105178. private _setTextureParameterInteger;
  105179. /**
  105180. * Unbind all vertex attributes from the webGL context
  105181. */
  105182. unbindAllAttributes(): void;
  105183. /**
  105184. * 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
  105185. */
  105186. releaseEffects(): void;
  105187. /**
  105188. * Dispose and release all associated resources
  105189. */
  105190. dispose(): void;
  105191. /**
  105192. * Attach a new callback raised when context lost event is fired
  105193. * @param callback defines the callback to call
  105194. */
  105195. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  105196. /**
  105197. * Attach a new callback raised when context restored event is fired
  105198. * @param callback defines the callback to call
  105199. */
  105200. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  105201. /**
  105202. * Get the current error code of the webGL context
  105203. * @returns the error code
  105204. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  105205. */
  105206. getError(): number;
  105207. private _canRenderToFloatFramebuffer;
  105208. private _canRenderToHalfFloatFramebuffer;
  105209. private _canRenderToFramebuffer;
  105210. /** @hidden */
  105211. _getWebGLTextureType(type: number): number;
  105212. /** @hidden */
  105213. _getInternalFormat(format: number): number;
  105214. /** @hidden */
  105215. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  105216. /** @hidden */
  105217. _getRGBAMultiSampleBufferFormat(type: number): number;
  105218. /** @hidden */
  105219. _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;
  105220. /**
  105221. * Loads a file from a url
  105222. * @param url url to load
  105223. * @param onSuccess callback called when the file successfully loads
  105224. * @param onProgress callback called while file is loading (if the server supports this mode)
  105225. * @param offlineProvider defines the offline provider for caching
  105226. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  105227. * @param onError callback called when the file fails to load
  105228. * @returns a file request object
  105229. * @hidden
  105230. */
  105231. 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;
  105232. /**
  105233. * Reads pixels from the current frame buffer. Please note that this function can be slow
  105234. * @param x defines the x coordinate of the rectangle where pixels must be read
  105235. * @param y defines the y coordinate of the rectangle where pixels must be read
  105236. * @param width defines the width of the rectangle where pixels must be read
  105237. * @param height defines the height of the rectangle where pixels must be read
  105238. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  105239. * @returns a Uint8Array containing RGBA colors
  105240. */
  105241. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  105242. private static _isSupported;
  105243. /**
  105244. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  105245. * @returns true if the engine can be created
  105246. * @ignorenaming
  105247. */
  105248. static isSupported(): boolean;
  105249. /**
  105250. * Find the next highest power of two.
  105251. * @param x Number to start search from.
  105252. * @return Next highest power of two.
  105253. */
  105254. static CeilingPOT(x: number): number;
  105255. /**
  105256. * Find the next lowest power of two.
  105257. * @param x Number to start search from.
  105258. * @return Next lowest power of two.
  105259. */
  105260. static FloorPOT(x: number): number;
  105261. /**
  105262. * Find the nearest power of two.
  105263. * @param x Number to start search from.
  105264. * @return Next nearest power of two.
  105265. */
  105266. static NearestPOT(x: number): number;
  105267. /**
  105268. * Get the closest exponent of two
  105269. * @param value defines the value to approximate
  105270. * @param max defines the maximum value to return
  105271. * @param mode defines how to define the closest value
  105272. * @returns closest exponent of two of the given value
  105273. */
  105274. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  105275. /**
  105276. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  105277. * @param func - the function to be called
  105278. * @param requester - the object that will request the next frame. Falls back to window.
  105279. * @returns frame number
  105280. */
  105281. static QueueNewFrame(func: () => void, requester?: any): number;
  105282. /**
  105283. * Gets host document
  105284. * @returns the host document object
  105285. */
  105286. getHostDocument(): Nullable<Document>;
  105287. }
  105288. }
  105289. declare module BABYLON {
  105290. /**
  105291. * Class representing spherical harmonics coefficients to the 3rd degree
  105292. */
  105293. export class SphericalHarmonics {
  105294. /**
  105295. * Defines whether or not the harmonics have been prescaled for rendering.
  105296. */
  105297. preScaled: boolean;
  105298. /**
  105299. * The l0,0 coefficients of the spherical harmonics
  105300. */
  105301. l00: Vector3;
  105302. /**
  105303. * The l1,-1 coefficients of the spherical harmonics
  105304. */
  105305. l1_1: Vector3;
  105306. /**
  105307. * The l1,0 coefficients of the spherical harmonics
  105308. */
  105309. l10: Vector3;
  105310. /**
  105311. * The l1,1 coefficients of the spherical harmonics
  105312. */
  105313. l11: Vector3;
  105314. /**
  105315. * The l2,-2 coefficients of the spherical harmonics
  105316. */
  105317. l2_2: Vector3;
  105318. /**
  105319. * The l2,-1 coefficients of the spherical harmonics
  105320. */
  105321. l2_1: Vector3;
  105322. /**
  105323. * The l2,0 coefficients of the spherical harmonics
  105324. */
  105325. l20: Vector3;
  105326. /**
  105327. * The l2,1 coefficients of the spherical harmonics
  105328. */
  105329. l21: Vector3;
  105330. /**
  105331. * The l2,2 coefficients of the spherical harmonics
  105332. */
  105333. l22: Vector3;
  105334. /**
  105335. * Adds a light to the spherical harmonics
  105336. * @param direction the direction of the light
  105337. * @param color the color of the light
  105338. * @param deltaSolidAngle the delta solid angle of the light
  105339. */
  105340. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  105341. /**
  105342. * Scales the spherical harmonics by the given amount
  105343. * @param scale the amount to scale
  105344. */
  105345. scaleInPlace(scale: number): void;
  105346. /**
  105347. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  105348. *
  105349. * ```
  105350. * E_lm = A_l * L_lm
  105351. * ```
  105352. *
  105353. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  105354. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  105355. * the scaling factors are given in equation 9.
  105356. */
  105357. convertIncidentRadianceToIrradiance(): void;
  105358. /**
  105359. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  105360. *
  105361. * ```
  105362. * L = (1/pi) * E * rho
  105363. * ```
  105364. *
  105365. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  105366. */
  105367. convertIrradianceToLambertianRadiance(): void;
  105368. /**
  105369. * Integrates the reconstruction coefficients directly in to the SH preventing further
  105370. * required operations at run time.
  105371. *
  105372. * This is simply done by scaling back the SH with Ylm constants parameter.
  105373. * The trigonometric part being applied by the shader at run time.
  105374. */
  105375. preScaleForRendering(): void;
  105376. /**
  105377. * Constructs a spherical harmonics from an array.
  105378. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  105379. * @returns the spherical harmonics
  105380. */
  105381. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  105382. /**
  105383. * Gets the spherical harmonics from polynomial
  105384. * @param polynomial the spherical polynomial
  105385. * @returns the spherical harmonics
  105386. */
  105387. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  105388. }
  105389. /**
  105390. * Class representing spherical polynomial coefficients to the 3rd degree
  105391. */
  105392. export class SphericalPolynomial {
  105393. private _harmonics;
  105394. /**
  105395. * The spherical harmonics used to create the polynomials.
  105396. */
  105397. get preScaledHarmonics(): SphericalHarmonics;
  105398. /**
  105399. * The x coefficients of the spherical polynomial
  105400. */
  105401. x: Vector3;
  105402. /**
  105403. * The y coefficients of the spherical polynomial
  105404. */
  105405. y: Vector3;
  105406. /**
  105407. * The z coefficients of the spherical polynomial
  105408. */
  105409. z: Vector3;
  105410. /**
  105411. * The xx coefficients of the spherical polynomial
  105412. */
  105413. xx: Vector3;
  105414. /**
  105415. * The yy coefficients of the spherical polynomial
  105416. */
  105417. yy: Vector3;
  105418. /**
  105419. * The zz coefficients of the spherical polynomial
  105420. */
  105421. zz: Vector3;
  105422. /**
  105423. * The xy coefficients of the spherical polynomial
  105424. */
  105425. xy: Vector3;
  105426. /**
  105427. * The yz coefficients of the spherical polynomial
  105428. */
  105429. yz: Vector3;
  105430. /**
  105431. * The zx coefficients of the spherical polynomial
  105432. */
  105433. zx: Vector3;
  105434. /**
  105435. * Adds an ambient color to the spherical polynomial
  105436. * @param color the color to add
  105437. */
  105438. addAmbient(color: Color3): void;
  105439. /**
  105440. * Scales the spherical polynomial by the given amount
  105441. * @param scale the amount to scale
  105442. */
  105443. scaleInPlace(scale: number): void;
  105444. /**
  105445. * Gets the spherical polynomial from harmonics
  105446. * @param harmonics the spherical harmonics
  105447. * @returns the spherical polynomial
  105448. */
  105449. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  105450. /**
  105451. * Constructs a spherical polynomial from an array.
  105452. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  105453. * @returns the spherical polynomial
  105454. */
  105455. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  105456. }
  105457. }
  105458. declare module BABYLON {
  105459. /**
  105460. * Defines the source of the internal texture
  105461. */
  105462. export enum InternalTextureSource {
  105463. /**
  105464. * The source of the texture data is unknown
  105465. */
  105466. Unknown = 0,
  105467. /**
  105468. * Texture data comes from an URL
  105469. */
  105470. Url = 1,
  105471. /**
  105472. * Texture data is only used for temporary storage
  105473. */
  105474. Temp = 2,
  105475. /**
  105476. * Texture data comes from raw data (ArrayBuffer)
  105477. */
  105478. Raw = 3,
  105479. /**
  105480. * Texture content is dynamic (video or dynamic texture)
  105481. */
  105482. Dynamic = 4,
  105483. /**
  105484. * Texture content is generated by rendering to it
  105485. */
  105486. RenderTarget = 5,
  105487. /**
  105488. * Texture content is part of a multi render target process
  105489. */
  105490. MultiRenderTarget = 6,
  105491. /**
  105492. * Texture data comes from a cube data file
  105493. */
  105494. Cube = 7,
  105495. /**
  105496. * Texture data comes from a raw cube data
  105497. */
  105498. CubeRaw = 8,
  105499. /**
  105500. * Texture data come from a prefiltered cube data file
  105501. */
  105502. CubePrefiltered = 9,
  105503. /**
  105504. * Texture content is raw 3D data
  105505. */
  105506. Raw3D = 10,
  105507. /**
  105508. * Texture content is raw 2D array data
  105509. */
  105510. Raw2DArray = 11,
  105511. /**
  105512. * Texture content is a depth texture
  105513. */
  105514. Depth = 12,
  105515. /**
  105516. * Texture data comes from a raw cube data encoded with RGBD
  105517. */
  105518. CubeRawRGBD = 13
  105519. }
  105520. /**
  105521. * Class used to store data associated with WebGL texture data for the engine
  105522. * This class should not be used directly
  105523. */
  105524. export class InternalTexture {
  105525. /** @hidden */
  105526. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  105527. /**
  105528. * Defines if the texture is ready
  105529. */
  105530. isReady: boolean;
  105531. /**
  105532. * Defines if the texture is a cube texture
  105533. */
  105534. isCube: boolean;
  105535. /**
  105536. * Defines if the texture contains 3D data
  105537. */
  105538. is3D: boolean;
  105539. /**
  105540. * Defines if the texture contains 2D array data
  105541. */
  105542. is2DArray: boolean;
  105543. /**
  105544. * Defines if the texture contains multiview data
  105545. */
  105546. isMultiview: boolean;
  105547. /**
  105548. * Gets the URL used to load this texture
  105549. */
  105550. url: string;
  105551. /**
  105552. * Gets the sampling mode of the texture
  105553. */
  105554. samplingMode: number;
  105555. /**
  105556. * Gets a boolean indicating if the texture needs mipmaps generation
  105557. */
  105558. generateMipMaps: boolean;
  105559. /**
  105560. * Gets the number of samples used by the texture (WebGL2+ only)
  105561. */
  105562. samples: number;
  105563. /**
  105564. * Gets the type of the texture (int, float...)
  105565. */
  105566. type: number;
  105567. /**
  105568. * Gets the format of the texture (RGB, RGBA...)
  105569. */
  105570. format: number;
  105571. /**
  105572. * Observable called when the texture is loaded
  105573. */
  105574. onLoadedObservable: Observable<InternalTexture>;
  105575. /**
  105576. * Gets the width of the texture
  105577. */
  105578. width: number;
  105579. /**
  105580. * Gets the height of the texture
  105581. */
  105582. height: number;
  105583. /**
  105584. * Gets the depth of the texture
  105585. */
  105586. depth: number;
  105587. /**
  105588. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  105589. */
  105590. baseWidth: number;
  105591. /**
  105592. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  105593. */
  105594. baseHeight: number;
  105595. /**
  105596. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  105597. */
  105598. baseDepth: number;
  105599. /**
  105600. * Gets a boolean indicating if the texture is inverted on Y axis
  105601. */
  105602. invertY: boolean;
  105603. /** @hidden */
  105604. _invertVScale: boolean;
  105605. /** @hidden */
  105606. _associatedChannel: number;
  105607. /** @hidden */
  105608. _source: InternalTextureSource;
  105609. /** @hidden */
  105610. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  105611. /** @hidden */
  105612. _bufferView: Nullable<ArrayBufferView>;
  105613. /** @hidden */
  105614. _bufferViewArray: Nullable<ArrayBufferView[]>;
  105615. /** @hidden */
  105616. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  105617. /** @hidden */
  105618. _size: number;
  105619. /** @hidden */
  105620. _extension: string;
  105621. /** @hidden */
  105622. _files: Nullable<string[]>;
  105623. /** @hidden */
  105624. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  105625. /** @hidden */
  105626. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  105627. /** @hidden */
  105628. _framebuffer: Nullable<WebGLFramebuffer>;
  105629. /** @hidden */
  105630. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  105631. /** @hidden */
  105632. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  105633. /** @hidden */
  105634. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  105635. /** @hidden */
  105636. _attachments: Nullable<number[]>;
  105637. /** @hidden */
  105638. _cachedCoordinatesMode: Nullable<number>;
  105639. /** @hidden */
  105640. _cachedWrapU: Nullable<number>;
  105641. /** @hidden */
  105642. _cachedWrapV: Nullable<number>;
  105643. /** @hidden */
  105644. _cachedWrapR: Nullable<number>;
  105645. /** @hidden */
  105646. _cachedAnisotropicFilteringLevel: Nullable<number>;
  105647. /** @hidden */
  105648. _isDisabled: boolean;
  105649. /** @hidden */
  105650. _compression: Nullable<string>;
  105651. /** @hidden */
  105652. _generateStencilBuffer: boolean;
  105653. /** @hidden */
  105654. _generateDepthBuffer: boolean;
  105655. /** @hidden */
  105656. _comparisonFunction: number;
  105657. /** @hidden */
  105658. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  105659. /** @hidden */
  105660. _lodGenerationScale: number;
  105661. /** @hidden */
  105662. _lodGenerationOffset: number;
  105663. /** @hidden */
  105664. _depthStencilTexture: Nullable<InternalTexture>;
  105665. /** @hidden */
  105666. _colorTextureArray: Nullable<WebGLTexture>;
  105667. /** @hidden */
  105668. _depthStencilTextureArray: Nullable<WebGLTexture>;
  105669. /** @hidden */
  105670. _lodTextureHigh: Nullable<BaseTexture>;
  105671. /** @hidden */
  105672. _lodTextureMid: Nullable<BaseTexture>;
  105673. /** @hidden */
  105674. _lodTextureLow: Nullable<BaseTexture>;
  105675. /** @hidden */
  105676. _isRGBD: boolean;
  105677. /** @hidden */
  105678. _linearSpecularLOD: boolean;
  105679. /** @hidden */
  105680. _irradianceTexture: Nullable<BaseTexture>;
  105681. /** @hidden */
  105682. _webGLTexture: Nullable<WebGLTexture>;
  105683. /** @hidden */
  105684. _references: number;
  105685. private _engine;
  105686. /**
  105687. * Gets the Engine the texture belongs to.
  105688. * @returns The babylon engine
  105689. */
  105690. getEngine(): ThinEngine;
  105691. /**
  105692. * Gets the data source type of the texture
  105693. */
  105694. get source(): InternalTextureSource;
  105695. /**
  105696. * Creates a new InternalTexture
  105697. * @param engine defines the engine to use
  105698. * @param source defines the type of data that will be used
  105699. * @param delayAllocation if the texture allocation should be delayed (default: false)
  105700. */
  105701. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  105702. /**
  105703. * Increments the number of references (ie. the number of Texture that point to it)
  105704. */
  105705. incrementReferences(): void;
  105706. /**
  105707. * Change the size of the texture (not the size of the content)
  105708. * @param width defines the new width
  105709. * @param height defines the new height
  105710. * @param depth defines the new depth (1 by default)
  105711. */
  105712. updateSize(width: int, height: int, depth?: int): void;
  105713. /** @hidden */
  105714. _rebuild(): void;
  105715. /** @hidden */
  105716. _swapAndDie(target: InternalTexture): void;
  105717. /**
  105718. * Dispose the current allocated resources
  105719. */
  105720. dispose(): void;
  105721. }
  105722. }
  105723. declare module BABYLON {
  105724. /**
  105725. * Class used to work with sound analyzer using fast fourier transform (FFT)
  105726. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105727. */
  105728. export class Analyser {
  105729. /**
  105730. * Gets or sets the smoothing
  105731. * @ignorenaming
  105732. */
  105733. SMOOTHING: number;
  105734. /**
  105735. * Gets or sets the FFT table size
  105736. * @ignorenaming
  105737. */
  105738. FFT_SIZE: number;
  105739. /**
  105740. * Gets or sets the bar graph amplitude
  105741. * @ignorenaming
  105742. */
  105743. BARGRAPHAMPLITUDE: number;
  105744. /**
  105745. * Gets or sets the position of the debug canvas
  105746. * @ignorenaming
  105747. */
  105748. DEBUGCANVASPOS: {
  105749. x: number;
  105750. y: number;
  105751. };
  105752. /**
  105753. * Gets or sets the debug canvas size
  105754. * @ignorenaming
  105755. */
  105756. DEBUGCANVASSIZE: {
  105757. width: number;
  105758. height: number;
  105759. };
  105760. private _byteFreqs;
  105761. private _byteTime;
  105762. private _floatFreqs;
  105763. private _webAudioAnalyser;
  105764. private _debugCanvas;
  105765. private _debugCanvasContext;
  105766. private _scene;
  105767. private _registerFunc;
  105768. private _audioEngine;
  105769. /**
  105770. * Creates a new analyser
  105771. * @param scene defines hosting scene
  105772. */
  105773. constructor(scene: Scene);
  105774. /**
  105775. * Get the number of data values you will have to play with for the visualization
  105776. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  105777. * @returns a number
  105778. */
  105779. getFrequencyBinCount(): number;
  105780. /**
  105781. * Gets the current frequency data as a byte array
  105782. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  105783. * @returns a Uint8Array
  105784. */
  105785. getByteFrequencyData(): Uint8Array;
  105786. /**
  105787. * Gets the current waveform as a byte array
  105788. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  105789. * @returns a Uint8Array
  105790. */
  105791. getByteTimeDomainData(): Uint8Array;
  105792. /**
  105793. * Gets the current frequency data as a float array
  105794. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  105795. * @returns a Float32Array
  105796. */
  105797. getFloatFrequencyData(): Float32Array;
  105798. /**
  105799. * Renders the debug canvas
  105800. */
  105801. drawDebugCanvas(): void;
  105802. /**
  105803. * Stops rendering the debug canvas and removes it
  105804. */
  105805. stopDebugCanvas(): void;
  105806. /**
  105807. * Connects two audio nodes
  105808. * @param inputAudioNode defines first node to connect
  105809. * @param outputAudioNode defines second node to connect
  105810. */
  105811. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  105812. /**
  105813. * Releases all associated resources
  105814. */
  105815. dispose(): void;
  105816. }
  105817. }
  105818. declare module BABYLON {
  105819. /**
  105820. * This represents an audio engine and it is responsible
  105821. * to play, synchronize and analyse sounds throughout the application.
  105822. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105823. */
  105824. export interface IAudioEngine extends IDisposable {
  105825. /**
  105826. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  105827. */
  105828. readonly canUseWebAudio: boolean;
  105829. /**
  105830. * Gets the current AudioContext if available.
  105831. */
  105832. readonly audioContext: Nullable<AudioContext>;
  105833. /**
  105834. * The master gain node defines the global audio volume of your audio engine.
  105835. */
  105836. readonly masterGain: GainNode;
  105837. /**
  105838. * Gets whether or not mp3 are supported by your browser.
  105839. */
  105840. readonly isMP3supported: boolean;
  105841. /**
  105842. * Gets whether or not ogg are supported by your browser.
  105843. */
  105844. readonly isOGGsupported: boolean;
  105845. /**
  105846. * Defines if Babylon should emit a warning if WebAudio is not supported.
  105847. * @ignoreNaming
  105848. */
  105849. WarnedWebAudioUnsupported: boolean;
  105850. /**
  105851. * Defines if the audio engine relies on a custom unlocked button.
  105852. * In this case, the embedded button will not be displayed.
  105853. */
  105854. useCustomUnlockedButton: boolean;
  105855. /**
  105856. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  105857. */
  105858. readonly unlocked: boolean;
  105859. /**
  105860. * Event raised when audio has been unlocked on the browser.
  105861. */
  105862. onAudioUnlockedObservable: Observable<AudioEngine>;
  105863. /**
  105864. * Event raised when audio has been locked on the browser.
  105865. */
  105866. onAudioLockedObservable: Observable<AudioEngine>;
  105867. /**
  105868. * Flags the audio engine in Locked state.
  105869. * This happens due to new browser policies preventing audio to autoplay.
  105870. */
  105871. lock(): void;
  105872. /**
  105873. * Unlocks the audio engine once a user action has been done on the dom.
  105874. * This is helpful to resume play once browser policies have been satisfied.
  105875. */
  105876. unlock(): void;
  105877. }
  105878. /**
  105879. * This represents the default audio engine used in babylon.
  105880. * It is responsible to play, synchronize and analyse sounds throughout the application.
  105881. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105882. */
  105883. export class AudioEngine implements IAudioEngine {
  105884. private _audioContext;
  105885. private _audioContextInitialized;
  105886. private _muteButton;
  105887. private _hostElement;
  105888. /**
  105889. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  105890. */
  105891. canUseWebAudio: boolean;
  105892. /**
  105893. * The master gain node defines the global audio volume of your audio engine.
  105894. */
  105895. masterGain: GainNode;
  105896. /**
  105897. * Defines if Babylon should emit a warning if WebAudio is not supported.
  105898. * @ignoreNaming
  105899. */
  105900. WarnedWebAudioUnsupported: boolean;
  105901. /**
  105902. * Gets whether or not mp3 are supported by your browser.
  105903. */
  105904. isMP3supported: boolean;
  105905. /**
  105906. * Gets whether or not ogg are supported by your browser.
  105907. */
  105908. isOGGsupported: boolean;
  105909. /**
  105910. * Gets whether audio has been unlocked on the device.
  105911. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  105912. * a user interaction has happened.
  105913. */
  105914. unlocked: boolean;
  105915. /**
  105916. * Defines if the audio engine relies on a custom unlocked button.
  105917. * In this case, the embedded button will not be displayed.
  105918. */
  105919. useCustomUnlockedButton: boolean;
  105920. /**
  105921. * Event raised when audio has been unlocked on the browser.
  105922. */
  105923. onAudioUnlockedObservable: Observable<AudioEngine>;
  105924. /**
  105925. * Event raised when audio has been locked on the browser.
  105926. */
  105927. onAudioLockedObservable: Observable<AudioEngine>;
  105928. /**
  105929. * Gets the current AudioContext if available.
  105930. */
  105931. get audioContext(): Nullable<AudioContext>;
  105932. private _connectedAnalyser;
  105933. /**
  105934. * Instantiates a new audio engine.
  105935. *
  105936. * There should be only one per page as some browsers restrict the number
  105937. * of audio contexts you can create.
  105938. * @param hostElement defines the host element where to display the mute icon if necessary
  105939. */
  105940. constructor(hostElement?: Nullable<HTMLElement>);
  105941. /**
  105942. * Flags the audio engine in Locked state.
  105943. * This happens due to new browser policies preventing audio to autoplay.
  105944. */
  105945. lock(): void;
  105946. /**
  105947. * Unlocks the audio engine once a user action has been done on the dom.
  105948. * This is helpful to resume play once browser policies have been satisfied.
  105949. */
  105950. unlock(): void;
  105951. private _resumeAudioContext;
  105952. private _initializeAudioContext;
  105953. private _tryToRun;
  105954. private _triggerRunningState;
  105955. private _triggerSuspendedState;
  105956. private _displayMuteButton;
  105957. private _moveButtonToTopLeft;
  105958. private _onResize;
  105959. private _hideMuteButton;
  105960. /**
  105961. * Destroy and release the resources associated with the audio ccontext.
  105962. */
  105963. dispose(): void;
  105964. /**
  105965. * Gets the global volume sets on the master gain.
  105966. * @returns the global volume if set or -1 otherwise
  105967. */
  105968. getGlobalVolume(): number;
  105969. /**
  105970. * Sets the global volume of your experience (sets on the master gain).
  105971. * @param newVolume Defines the new global volume of the application
  105972. */
  105973. setGlobalVolume(newVolume: number): void;
  105974. /**
  105975. * Connect the audio engine to an audio analyser allowing some amazing
  105976. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  105977. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  105978. * @param analyser The analyser to connect to the engine
  105979. */
  105980. connectToAnalyser(analyser: Analyser): void;
  105981. }
  105982. }
  105983. declare module BABYLON {
  105984. /**
  105985. * Interface used to present a loading screen while loading a scene
  105986. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  105987. */
  105988. export interface ILoadingScreen {
  105989. /**
  105990. * Function called to display the loading screen
  105991. */
  105992. displayLoadingUI: () => void;
  105993. /**
  105994. * Function called to hide the loading screen
  105995. */
  105996. hideLoadingUI: () => void;
  105997. /**
  105998. * Gets or sets the color to use for the background
  105999. */
  106000. loadingUIBackgroundColor: string;
  106001. /**
  106002. * Gets or sets the text to display while loading
  106003. */
  106004. loadingUIText: string;
  106005. }
  106006. /**
  106007. * Class used for the default loading screen
  106008. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  106009. */
  106010. export class DefaultLoadingScreen implements ILoadingScreen {
  106011. private _renderingCanvas;
  106012. private _loadingText;
  106013. private _loadingDivBackgroundColor;
  106014. private _loadingDiv;
  106015. private _loadingTextDiv;
  106016. /** Gets or sets the logo url to use for the default loading screen */
  106017. static DefaultLogoUrl: string;
  106018. /** Gets or sets the spinner url to use for the default loading screen */
  106019. static DefaultSpinnerUrl: string;
  106020. /**
  106021. * Creates a new default loading screen
  106022. * @param _renderingCanvas defines the canvas used to render the scene
  106023. * @param _loadingText defines the default text to display
  106024. * @param _loadingDivBackgroundColor defines the default background color
  106025. */
  106026. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  106027. /**
  106028. * Function called to display the loading screen
  106029. */
  106030. displayLoadingUI(): void;
  106031. /**
  106032. * Function called to hide the loading screen
  106033. */
  106034. hideLoadingUI(): void;
  106035. /**
  106036. * Gets or sets the text to display while loading
  106037. */
  106038. set loadingUIText(text: string);
  106039. get loadingUIText(): string;
  106040. /**
  106041. * Gets or sets the color to use for the background
  106042. */
  106043. get loadingUIBackgroundColor(): string;
  106044. set loadingUIBackgroundColor(color: string);
  106045. private _resizeLoadingUI;
  106046. }
  106047. }
  106048. declare module BABYLON {
  106049. /**
  106050. * Interface for any object that can request an animation frame
  106051. */
  106052. export interface ICustomAnimationFrameRequester {
  106053. /**
  106054. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  106055. */
  106056. renderFunction?: Function;
  106057. /**
  106058. * Called to request the next frame to render to
  106059. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  106060. */
  106061. requestAnimationFrame: Function;
  106062. /**
  106063. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  106064. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  106065. */
  106066. requestID?: number;
  106067. }
  106068. }
  106069. declare module BABYLON {
  106070. /**
  106071. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  106072. */
  106073. export class PerformanceMonitor {
  106074. private _enabled;
  106075. private _rollingFrameTime;
  106076. private _lastFrameTimeMs;
  106077. /**
  106078. * constructor
  106079. * @param frameSampleSize The number of samples required to saturate the sliding window
  106080. */
  106081. constructor(frameSampleSize?: number);
  106082. /**
  106083. * Samples current frame
  106084. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  106085. */
  106086. sampleFrame(timeMs?: number): void;
  106087. /**
  106088. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  106089. */
  106090. get averageFrameTime(): number;
  106091. /**
  106092. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  106093. */
  106094. get averageFrameTimeVariance(): number;
  106095. /**
  106096. * Returns the frame time of the most recent frame
  106097. */
  106098. get instantaneousFrameTime(): number;
  106099. /**
  106100. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  106101. */
  106102. get averageFPS(): number;
  106103. /**
  106104. * Returns the average framerate in frames per second using the most recent frame time
  106105. */
  106106. get instantaneousFPS(): number;
  106107. /**
  106108. * Returns true if enough samples have been taken to completely fill the sliding window
  106109. */
  106110. get isSaturated(): boolean;
  106111. /**
  106112. * Enables contributions to the sliding window sample set
  106113. */
  106114. enable(): void;
  106115. /**
  106116. * Disables contributions to the sliding window sample set
  106117. * Samples will not be interpolated over the disabled period
  106118. */
  106119. disable(): void;
  106120. /**
  106121. * Returns true if sampling is enabled
  106122. */
  106123. get isEnabled(): boolean;
  106124. /**
  106125. * Resets performance monitor
  106126. */
  106127. reset(): void;
  106128. }
  106129. /**
  106130. * RollingAverage
  106131. *
  106132. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  106133. */
  106134. export class RollingAverage {
  106135. /**
  106136. * Current average
  106137. */
  106138. average: number;
  106139. /**
  106140. * Current variance
  106141. */
  106142. variance: number;
  106143. protected _samples: Array<number>;
  106144. protected _sampleCount: number;
  106145. protected _pos: number;
  106146. protected _m2: number;
  106147. /**
  106148. * constructor
  106149. * @param length The number of samples required to saturate the sliding window
  106150. */
  106151. constructor(length: number);
  106152. /**
  106153. * Adds a sample to the sample set
  106154. * @param v The sample value
  106155. */
  106156. add(v: number): void;
  106157. /**
  106158. * Returns previously added values or null if outside of history or outside the sliding window domain
  106159. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  106160. * @return Value previously recorded with add() or null if outside of range
  106161. */
  106162. history(i: number): number;
  106163. /**
  106164. * Returns true if enough samples have been taken to completely fill the sliding window
  106165. * @return true if sample-set saturated
  106166. */
  106167. isSaturated(): boolean;
  106168. /**
  106169. * Resets the rolling average (equivalent to 0 samples taken so far)
  106170. */
  106171. reset(): void;
  106172. /**
  106173. * Wraps a value around the sample range boundaries
  106174. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  106175. * @return Wrapped position in sample range
  106176. */
  106177. protected _wrapPosition(i: number): number;
  106178. }
  106179. }
  106180. declare module BABYLON {
  106181. /**
  106182. * This class is used to track a performance counter which is number based.
  106183. * The user has access to many properties which give statistics of different nature.
  106184. *
  106185. * The implementer can track two kinds of Performance Counter: time and count.
  106186. * 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.
  106187. * 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.
  106188. */
  106189. export class PerfCounter {
  106190. /**
  106191. * Gets or sets a global boolean to turn on and off all the counters
  106192. */
  106193. static Enabled: boolean;
  106194. /**
  106195. * Returns the smallest value ever
  106196. */
  106197. get min(): number;
  106198. /**
  106199. * Returns the biggest value ever
  106200. */
  106201. get max(): number;
  106202. /**
  106203. * Returns the average value since the performance counter is running
  106204. */
  106205. get average(): number;
  106206. /**
  106207. * Returns the average value of the last second the counter was monitored
  106208. */
  106209. get lastSecAverage(): number;
  106210. /**
  106211. * Returns the current value
  106212. */
  106213. get current(): number;
  106214. /**
  106215. * Gets the accumulated total
  106216. */
  106217. get total(): number;
  106218. /**
  106219. * Gets the total value count
  106220. */
  106221. get count(): number;
  106222. /**
  106223. * Creates a new counter
  106224. */
  106225. constructor();
  106226. /**
  106227. * Call this method to start monitoring a new frame.
  106228. * 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.
  106229. */
  106230. fetchNewFrame(): void;
  106231. /**
  106232. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  106233. * @param newCount the count value to add to the monitored count
  106234. * @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.
  106235. */
  106236. addCount(newCount: number, fetchResult: boolean): void;
  106237. /**
  106238. * Start monitoring this performance counter
  106239. */
  106240. beginMonitoring(): void;
  106241. /**
  106242. * Compute the time lapsed since the previous beginMonitoring() call.
  106243. * @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
  106244. */
  106245. endMonitoring(newFrame?: boolean): void;
  106246. private _fetchResult;
  106247. private _startMonitoringTime;
  106248. private _min;
  106249. private _max;
  106250. private _average;
  106251. private _current;
  106252. private _totalValueCount;
  106253. private _totalAccumulated;
  106254. private _lastSecAverage;
  106255. private _lastSecAccumulated;
  106256. private _lastSecTime;
  106257. private _lastSecValueCount;
  106258. }
  106259. }
  106260. declare module BABYLON {
  106261. interface ThinEngine {
  106262. /**
  106263. * Sets alpha constants used by some alpha blending modes
  106264. * @param r defines the red component
  106265. * @param g defines the green component
  106266. * @param b defines the blue component
  106267. * @param a defines the alpha component
  106268. */
  106269. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  106270. /**
  106271. * Sets the current alpha mode
  106272. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  106273. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  106274. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  106275. */
  106276. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  106277. /**
  106278. * Gets the current alpha mode
  106279. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  106280. * @returns the current alpha mode
  106281. */
  106282. getAlphaMode(): number;
  106283. /**
  106284. * Sets the current alpha equation
  106285. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  106286. */
  106287. setAlphaEquation(equation: number): void;
  106288. /**
  106289. * Gets the current alpha equation.
  106290. * @returns the current alpha equation
  106291. */
  106292. getAlphaEquation(): number;
  106293. }
  106294. }
  106295. declare module BABYLON {
  106296. /**
  106297. * Defines the interface used by display changed events
  106298. */
  106299. export interface IDisplayChangedEventArgs {
  106300. /** Gets the vrDisplay object (if any) */
  106301. vrDisplay: Nullable<any>;
  106302. /** Gets a boolean indicating if webVR is supported */
  106303. vrSupported: boolean;
  106304. }
  106305. /**
  106306. * Defines the interface used by objects containing a viewport (like a camera)
  106307. */
  106308. interface IViewportOwnerLike {
  106309. /**
  106310. * Gets or sets the viewport
  106311. */
  106312. viewport: IViewportLike;
  106313. }
  106314. /**
  106315. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  106316. */
  106317. export class Engine extends ThinEngine {
  106318. /** Defines that alpha blending is disabled */
  106319. static readonly ALPHA_DISABLE: number;
  106320. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  106321. static readonly ALPHA_ADD: number;
  106322. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  106323. static readonly ALPHA_COMBINE: number;
  106324. /** Defines that alpha blending to DEST - SRC * DEST */
  106325. static readonly ALPHA_SUBTRACT: number;
  106326. /** Defines that alpha blending to SRC * DEST */
  106327. static readonly ALPHA_MULTIPLY: number;
  106328. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  106329. static readonly ALPHA_MAXIMIZED: number;
  106330. /** Defines that alpha blending to SRC + DEST */
  106331. static readonly ALPHA_ONEONE: number;
  106332. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  106333. static readonly ALPHA_PREMULTIPLIED: number;
  106334. /**
  106335. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  106336. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  106337. */
  106338. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  106339. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  106340. static readonly ALPHA_INTERPOLATE: number;
  106341. /**
  106342. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  106343. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  106344. */
  106345. static readonly ALPHA_SCREENMODE: number;
  106346. /** Defines that the ressource is not delayed*/
  106347. static readonly DELAYLOADSTATE_NONE: number;
  106348. /** Defines that the ressource was successfully delay loaded */
  106349. static readonly DELAYLOADSTATE_LOADED: number;
  106350. /** Defines that the ressource is currently delay loading */
  106351. static readonly DELAYLOADSTATE_LOADING: number;
  106352. /** Defines that the ressource is delayed and has not started loading */
  106353. static readonly DELAYLOADSTATE_NOTLOADED: number;
  106354. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  106355. static readonly NEVER: number;
  106356. /** 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 */
  106357. static readonly ALWAYS: number;
  106358. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  106359. static readonly LESS: number;
  106360. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  106361. static readonly EQUAL: number;
  106362. /** 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 */
  106363. static readonly LEQUAL: number;
  106364. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  106365. static readonly GREATER: number;
  106366. /** 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 */
  106367. static readonly GEQUAL: number;
  106368. /** 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 */
  106369. static readonly NOTEQUAL: number;
  106370. /** Passed to stencilOperation to specify that stencil value must be kept */
  106371. static readonly KEEP: number;
  106372. /** Passed to stencilOperation to specify that stencil value must be replaced */
  106373. static readonly REPLACE: number;
  106374. /** Passed to stencilOperation to specify that stencil value must be incremented */
  106375. static readonly INCR: number;
  106376. /** Passed to stencilOperation to specify that stencil value must be decremented */
  106377. static readonly DECR: number;
  106378. /** Passed to stencilOperation to specify that stencil value must be inverted */
  106379. static readonly INVERT: number;
  106380. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  106381. static readonly INCR_WRAP: number;
  106382. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  106383. static readonly DECR_WRAP: number;
  106384. /** Texture is not repeating outside of 0..1 UVs */
  106385. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  106386. /** Texture is repeating outside of 0..1 UVs */
  106387. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  106388. /** Texture is repeating and mirrored */
  106389. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  106390. /** ALPHA */
  106391. static readonly TEXTUREFORMAT_ALPHA: number;
  106392. /** LUMINANCE */
  106393. static readonly TEXTUREFORMAT_LUMINANCE: number;
  106394. /** LUMINANCE_ALPHA */
  106395. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  106396. /** RGB */
  106397. static readonly TEXTUREFORMAT_RGB: number;
  106398. /** RGBA */
  106399. static readonly TEXTUREFORMAT_RGBA: number;
  106400. /** RED */
  106401. static readonly TEXTUREFORMAT_RED: number;
  106402. /** RED (2nd reference) */
  106403. static readonly TEXTUREFORMAT_R: number;
  106404. /** RG */
  106405. static readonly TEXTUREFORMAT_RG: number;
  106406. /** RED_INTEGER */
  106407. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  106408. /** RED_INTEGER (2nd reference) */
  106409. static readonly TEXTUREFORMAT_R_INTEGER: number;
  106410. /** RG_INTEGER */
  106411. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  106412. /** RGB_INTEGER */
  106413. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  106414. /** RGBA_INTEGER */
  106415. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  106416. /** UNSIGNED_BYTE */
  106417. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  106418. /** UNSIGNED_BYTE (2nd reference) */
  106419. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  106420. /** FLOAT */
  106421. static readonly TEXTURETYPE_FLOAT: number;
  106422. /** HALF_FLOAT */
  106423. static readonly TEXTURETYPE_HALF_FLOAT: number;
  106424. /** BYTE */
  106425. static readonly TEXTURETYPE_BYTE: number;
  106426. /** SHORT */
  106427. static readonly TEXTURETYPE_SHORT: number;
  106428. /** UNSIGNED_SHORT */
  106429. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  106430. /** INT */
  106431. static readonly TEXTURETYPE_INT: number;
  106432. /** UNSIGNED_INT */
  106433. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  106434. /** UNSIGNED_SHORT_4_4_4_4 */
  106435. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  106436. /** UNSIGNED_SHORT_5_5_5_1 */
  106437. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  106438. /** UNSIGNED_SHORT_5_6_5 */
  106439. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  106440. /** UNSIGNED_INT_2_10_10_10_REV */
  106441. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  106442. /** UNSIGNED_INT_24_8 */
  106443. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  106444. /** UNSIGNED_INT_10F_11F_11F_REV */
  106445. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  106446. /** UNSIGNED_INT_5_9_9_9_REV */
  106447. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  106448. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  106449. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  106450. /** nearest is mag = nearest and min = nearest and mip = linear */
  106451. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  106452. /** Bilinear is mag = linear and min = linear and mip = nearest */
  106453. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  106454. /** Trilinear is mag = linear and min = linear and mip = linear */
  106455. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  106456. /** nearest is mag = nearest and min = nearest and mip = linear */
  106457. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  106458. /** Bilinear is mag = linear and min = linear and mip = nearest */
  106459. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  106460. /** Trilinear is mag = linear and min = linear and mip = linear */
  106461. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  106462. /** mag = nearest and min = nearest and mip = nearest */
  106463. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  106464. /** mag = nearest and min = linear and mip = nearest */
  106465. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  106466. /** mag = nearest and min = linear and mip = linear */
  106467. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  106468. /** mag = nearest and min = linear and mip = none */
  106469. static readonly TEXTURE_NEAREST_LINEAR: number;
  106470. /** mag = nearest and min = nearest and mip = none */
  106471. static readonly TEXTURE_NEAREST_NEAREST: number;
  106472. /** mag = linear and min = nearest and mip = nearest */
  106473. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  106474. /** mag = linear and min = nearest and mip = linear */
  106475. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  106476. /** mag = linear and min = linear and mip = none */
  106477. static readonly TEXTURE_LINEAR_LINEAR: number;
  106478. /** mag = linear and min = nearest and mip = none */
  106479. static readonly TEXTURE_LINEAR_NEAREST: number;
  106480. /** Explicit coordinates mode */
  106481. static readonly TEXTURE_EXPLICIT_MODE: number;
  106482. /** Spherical coordinates mode */
  106483. static readonly TEXTURE_SPHERICAL_MODE: number;
  106484. /** Planar coordinates mode */
  106485. static readonly TEXTURE_PLANAR_MODE: number;
  106486. /** Cubic coordinates mode */
  106487. static readonly TEXTURE_CUBIC_MODE: number;
  106488. /** Projection coordinates mode */
  106489. static readonly TEXTURE_PROJECTION_MODE: number;
  106490. /** Skybox coordinates mode */
  106491. static readonly TEXTURE_SKYBOX_MODE: number;
  106492. /** Inverse Cubic coordinates mode */
  106493. static readonly TEXTURE_INVCUBIC_MODE: number;
  106494. /** Equirectangular coordinates mode */
  106495. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  106496. /** Equirectangular Fixed coordinates mode */
  106497. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  106498. /** Equirectangular Fixed Mirrored coordinates mode */
  106499. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  106500. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  106501. static readonly SCALEMODE_FLOOR: number;
  106502. /** Defines that texture rescaling will look for the nearest power of 2 size */
  106503. static readonly SCALEMODE_NEAREST: number;
  106504. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  106505. static readonly SCALEMODE_CEILING: number;
  106506. /**
  106507. * Returns the current npm package of the sdk
  106508. */
  106509. static get NpmPackage(): string;
  106510. /**
  106511. * Returns the current version of the framework
  106512. */
  106513. static get Version(): string;
  106514. /** Gets the list of created engines */
  106515. static get Instances(): Engine[];
  106516. /**
  106517. * Gets the latest created engine
  106518. */
  106519. static get LastCreatedEngine(): Nullable<Engine>;
  106520. /**
  106521. * Gets the latest created scene
  106522. */
  106523. static get LastCreatedScene(): Nullable<Scene>;
  106524. /**
  106525. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  106526. * @param flag defines which part of the materials must be marked as dirty
  106527. * @param predicate defines a predicate used to filter which materials should be affected
  106528. */
  106529. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  106530. /**
  106531. * Method called to create the default loading screen.
  106532. * This can be overriden in your own app.
  106533. * @param canvas The rendering canvas element
  106534. * @returns The loading screen
  106535. */
  106536. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  106537. /**
  106538. * Method called to create the default rescale post process on each engine.
  106539. */
  106540. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  106541. /**
  106542. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  106543. **/
  106544. enableOfflineSupport: boolean;
  106545. /**
  106546. * 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)
  106547. **/
  106548. disableManifestCheck: boolean;
  106549. /**
  106550. * Gets the list of created scenes
  106551. */
  106552. scenes: Scene[];
  106553. /**
  106554. * Event raised when a new scene is created
  106555. */
  106556. onNewSceneAddedObservable: Observable<Scene>;
  106557. /**
  106558. * Gets the list of created postprocesses
  106559. */
  106560. postProcesses: PostProcess[];
  106561. /**
  106562. * Gets a boolean indicating if the pointer is currently locked
  106563. */
  106564. isPointerLock: boolean;
  106565. /**
  106566. * Observable event triggered each time the rendering canvas is resized
  106567. */
  106568. onResizeObservable: Observable<Engine>;
  106569. /**
  106570. * Observable event triggered each time the canvas loses focus
  106571. */
  106572. onCanvasBlurObservable: Observable<Engine>;
  106573. /**
  106574. * Observable event triggered each time the canvas gains focus
  106575. */
  106576. onCanvasFocusObservable: Observable<Engine>;
  106577. /**
  106578. * Observable event triggered each time the canvas receives pointerout event
  106579. */
  106580. onCanvasPointerOutObservable: Observable<PointerEvent>;
  106581. /**
  106582. * Observable raised when the engine begins a new frame
  106583. */
  106584. onBeginFrameObservable: Observable<Engine>;
  106585. /**
  106586. * If set, will be used to request the next animation frame for the render loop
  106587. */
  106588. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  106589. /**
  106590. * Observable raised when the engine ends the current frame
  106591. */
  106592. onEndFrameObservable: Observable<Engine>;
  106593. /**
  106594. * Observable raised when the engine is about to compile a shader
  106595. */
  106596. onBeforeShaderCompilationObservable: Observable<Engine>;
  106597. /**
  106598. * Observable raised when the engine has jsut compiled a shader
  106599. */
  106600. onAfterShaderCompilationObservable: Observable<Engine>;
  106601. /**
  106602. * Gets the audio engine
  106603. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  106604. * @ignorenaming
  106605. */
  106606. static audioEngine: IAudioEngine;
  106607. /**
  106608. * Default AudioEngine factory responsible of creating the Audio Engine.
  106609. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  106610. */
  106611. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  106612. /**
  106613. * Default offline support factory responsible of creating a tool used to store data locally.
  106614. * By default, this will create a Database object if the workload has been embedded.
  106615. */
  106616. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  106617. private _loadingScreen;
  106618. private _pointerLockRequested;
  106619. private _dummyFramebuffer;
  106620. private _rescalePostProcess;
  106621. private _deterministicLockstep;
  106622. private _lockstepMaxSteps;
  106623. private _timeStep;
  106624. protected get _supportsHardwareTextureRescaling(): boolean;
  106625. private _fps;
  106626. private _deltaTime;
  106627. /** @hidden */
  106628. _drawCalls: PerfCounter;
  106629. /** 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 */
  106630. canvasTabIndex: number;
  106631. /**
  106632. * Turn this value on if you want to pause FPS computation when in background
  106633. */
  106634. disablePerformanceMonitorInBackground: boolean;
  106635. private _performanceMonitor;
  106636. /**
  106637. * Gets the performance monitor attached to this engine
  106638. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  106639. */
  106640. get performanceMonitor(): PerformanceMonitor;
  106641. private _onFocus;
  106642. private _onBlur;
  106643. private _onCanvasPointerOut;
  106644. private _onCanvasBlur;
  106645. private _onCanvasFocus;
  106646. private _onFullscreenChange;
  106647. private _onPointerLockChange;
  106648. /**
  106649. * Gets the HTML element used to attach event listeners
  106650. * @returns a HTML element
  106651. */
  106652. getInputElement(): Nullable<HTMLElement>;
  106653. /**
  106654. * Creates a new engine
  106655. * @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
  106656. * @param antialias defines enable antialiasing (default: false)
  106657. * @param options defines further options to be sent to the getContext() function
  106658. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  106659. */
  106660. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  106661. /**
  106662. * Gets current aspect ratio
  106663. * @param viewportOwner defines the camera to use to get the aspect ratio
  106664. * @param useScreen defines if screen size must be used (or the current render target if any)
  106665. * @returns a number defining the aspect ratio
  106666. */
  106667. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  106668. /**
  106669. * Gets current screen aspect ratio
  106670. * @returns a number defining the aspect ratio
  106671. */
  106672. getScreenAspectRatio(): number;
  106673. /**
  106674. * Gets the client rect of the HTML canvas attached with the current webGL context
  106675. * @returns a client rectanglee
  106676. */
  106677. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  106678. /**
  106679. * Gets the client rect of the HTML element used for events
  106680. * @returns a client rectanglee
  106681. */
  106682. getInputElementClientRect(): Nullable<ClientRect>;
  106683. /**
  106684. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  106685. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106686. * @returns true if engine is in deterministic lock step mode
  106687. */
  106688. isDeterministicLockStep(): boolean;
  106689. /**
  106690. * Gets the max steps when engine is running in deterministic lock step
  106691. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106692. * @returns the max steps
  106693. */
  106694. getLockstepMaxSteps(): number;
  106695. /**
  106696. * Returns the time in ms between steps when using deterministic lock step.
  106697. * @returns time step in (ms)
  106698. */
  106699. getTimeStep(): number;
  106700. /**
  106701. * Force the mipmap generation for the given render target texture
  106702. * @param texture defines the render target texture to use
  106703. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  106704. */
  106705. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  106706. /** States */
  106707. /**
  106708. * Set various states to the webGL context
  106709. * @param culling defines backface culling state
  106710. * @param zOffset defines the value to apply to zOffset (0 by default)
  106711. * @param force defines if states must be applied even if cache is up to date
  106712. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  106713. */
  106714. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  106715. /**
  106716. * Set the z offset to apply to current rendering
  106717. * @param value defines the offset to apply
  106718. */
  106719. setZOffset(value: number): void;
  106720. /**
  106721. * Gets the current value of the zOffset
  106722. * @returns the current zOffset state
  106723. */
  106724. getZOffset(): number;
  106725. /**
  106726. * Enable or disable depth buffering
  106727. * @param enable defines the state to set
  106728. */
  106729. setDepthBuffer(enable: boolean): void;
  106730. /**
  106731. * Gets a boolean indicating if depth writing is enabled
  106732. * @returns the current depth writing state
  106733. */
  106734. getDepthWrite(): boolean;
  106735. /**
  106736. * Enable or disable depth writing
  106737. * @param enable defines the state to set
  106738. */
  106739. setDepthWrite(enable: boolean): void;
  106740. /**
  106741. * Gets a boolean indicating if stencil buffer is enabled
  106742. * @returns the current stencil buffer state
  106743. */
  106744. getStencilBuffer(): boolean;
  106745. /**
  106746. * Enable or disable the stencil buffer
  106747. * @param enable defines if the stencil buffer must be enabled or disabled
  106748. */
  106749. setStencilBuffer(enable: boolean): void;
  106750. /**
  106751. * Gets the current stencil mask
  106752. * @returns a number defining the new stencil mask to use
  106753. */
  106754. getStencilMask(): number;
  106755. /**
  106756. * Sets the current stencil mask
  106757. * @param mask defines the new stencil mask to use
  106758. */
  106759. setStencilMask(mask: number): void;
  106760. /**
  106761. * Gets the current stencil function
  106762. * @returns a number defining the stencil function to use
  106763. */
  106764. getStencilFunction(): number;
  106765. /**
  106766. * Gets the current stencil reference value
  106767. * @returns a number defining the stencil reference value to use
  106768. */
  106769. getStencilFunctionReference(): number;
  106770. /**
  106771. * Gets the current stencil mask
  106772. * @returns a number defining the stencil mask to use
  106773. */
  106774. getStencilFunctionMask(): number;
  106775. /**
  106776. * Sets the current stencil function
  106777. * @param stencilFunc defines the new stencil function to use
  106778. */
  106779. setStencilFunction(stencilFunc: number): void;
  106780. /**
  106781. * Sets the current stencil reference
  106782. * @param reference defines the new stencil reference to use
  106783. */
  106784. setStencilFunctionReference(reference: number): void;
  106785. /**
  106786. * Sets the current stencil mask
  106787. * @param mask defines the new stencil mask to use
  106788. */
  106789. setStencilFunctionMask(mask: number): void;
  106790. /**
  106791. * Gets the current stencil operation when stencil fails
  106792. * @returns a number defining stencil operation to use when stencil fails
  106793. */
  106794. getStencilOperationFail(): number;
  106795. /**
  106796. * Gets the current stencil operation when depth fails
  106797. * @returns a number defining stencil operation to use when depth fails
  106798. */
  106799. getStencilOperationDepthFail(): number;
  106800. /**
  106801. * Gets the current stencil operation when stencil passes
  106802. * @returns a number defining stencil operation to use when stencil passes
  106803. */
  106804. getStencilOperationPass(): number;
  106805. /**
  106806. * Sets the stencil operation to use when stencil fails
  106807. * @param operation defines the stencil operation to use when stencil fails
  106808. */
  106809. setStencilOperationFail(operation: number): void;
  106810. /**
  106811. * Sets the stencil operation to use when depth fails
  106812. * @param operation defines the stencil operation to use when depth fails
  106813. */
  106814. setStencilOperationDepthFail(operation: number): void;
  106815. /**
  106816. * Sets the stencil operation to use when stencil passes
  106817. * @param operation defines the stencil operation to use when stencil passes
  106818. */
  106819. setStencilOperationPass(operation: number): void;
  106820. /**
  106821. * Sets a boolean indicating if the dithering state is enabled or disabled
  106822. * @param value defines the dithering state
  106823. */
  106824. setDitheringState(value: boolean): void;
  106825. /**
  106826. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  106827. * @param value defines the rasterizer state
  106828. */
  106829. setRasterizerState(value: boolean): void;
  106830. /**
  106831. * Gets the current depth function
  106832. * @returns a number defining the depth function
  106833. */
  106834. getDepthFunction(): Nullable<number>;
  106835. /**
  106836. * Sets the current depth function
  106837. * @param depthFunc defines the function to use
  106838. */
  106839. setDepthFunction(depthFunc: number): void;
  106840. /**
  106841. * Sets the current depth function to GREATER
  106842. */
  106843. setDepthFunctionToGreater(): void;
  106844. /**
  106845. * Sets the current depth function to GEQUAL
  106846. */
  106847. setDepthFunctionToGreaterOrEqual(): void;
  106848. /**
  106849. * Sets the current depth function to LESS
  106850. */
  106851. setDepthFunctionToLess(): void;
  106852. /**
  106853. * Sets the current depth function to LEQUAL
  106854. */
  106855. setDepthFunctionToLessOrEqual(): void;
  106856. private _cachedStencilBuffer;
  106857. private _cachedStencilFunction;
  106858. private _cachedStencilMask;
  106859. private _cachedStencilOperationPass;
  106860. private _cachedStencilOperationFail;
  106861. private _cachedStencilOperationDepthFail;
  106862. private _cachedStencilReference;
  106863. /**
  106864. * Caches the the state of the stencil buffer
  106865. */
  106866. cacheStencilState(): void;
  106867. /**
  106868. * Restores the state of the stencil buffer
  106869. */
  106870. restoreStencilState(): void;
  106871. /**
  106872. * Directly set the WebGL Viewport
  106873. * @param x defines the x coordinate of the viewport (in screen space)
  106874. * @param y defines the y coordinate of the viewport (in screen space)
  106875. * @param width defines the width of the viewport (in screen space)
  106876. * @param height defines the height of the viewport (in screen space)
  106877. * @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
  106878. */
  106879. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  106880. /**
  106881. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  106882. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  106883. * @param y defines the y-coordinate of the corner of the clear rectangle
  106884. * @param width defines the width of the clear rectangle
  106885. * @param height defines the height of the clear rectangle
  106886. * @param clearColor defines the clear color
  106887. */
  106888. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  106889. /**
  106890. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  106891. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  106892. * @param y defines the y-coordinate of the corner of the clear rectangle
  106893. * @param width defines the width of the clear rectangle
  106894. * @param height defines the height of the clear rectangle
  106895. */
  106896. enableScissor(x: number, y: number, width: number, height: number): void;
  106897. /**
  106898. * Disable previously set scissor test rectangle
  106899. */
  106900. disableScissor(): void;
  106901. protected _reportDrawCall(): void;
  106902. /**
  106903. * Initializes a webVR display and starts listening to display change events
  106904. * The onVRDisplayChangedObservable will be notified upon these changes
  106905. * @returns The onVRDisplayChangedObservable
  106906. */
  106907. initWebVR(): Observable<IDisplayChangedEventArgs>;
  106908. /** @hidden */
  106909. _prepareVRComponent(): void;
  106910. /** @hidden */
  106911. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  106912. /** @hidden */
  106913. _submitVRFrame(): void;
  106914. /**
  106915. * Call this function to leave webVR mode
  106916. * Will do nothing if webVR is not supported or if there is no webVR device
  106917. * @see http://doc.babylonjs.com/how_to/webvr_camera
  106918. */
  106919. disableVR(): void;
  106920. /**
  106921. * Gets a boolean indicating that the system is in VR mode and is presenting
  106922. * @returns true if VR mode is engaged
  106923. */
  106924. isVRPresenting(): boolean;
  106925. /** @hidden */
  106926. _requestVRFrame(): void;
  106927. /** @hidden */
  106928. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  106929. /**
  106930. * Gets the source code of the vertex shader associated with a specific webGL program
  106931. * @param program defines the program to use
  106932. * @returns a string containing the source code of the vertex shader associated with the program
  106933. */
  106934. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  106935. /**
  106936. * Gets the source code of the fragment shader associated with a specific webGL program
  106937. * @param program defines the program to use
  106938. * @returns a string containing the source code of the fragment shader associated with the program
  106939. */
  106940. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  106941. /**
  106942. * Sets a depth stencil texture from a render target to the according uniform.
  106943. * @param channel The texture channel
  106944. * @param uniform The uniform to set
  106945. * @param texture The render target texture containing the depth stencil texture to apply
  106946. */
  106947. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  106948. /**
  106949. * Sets a texture to the webGL context from a postprocess
  106950. * @param channel defines the channel to use
  106951. * @param postProcess defines the source postprocess
  106952. */
  106953. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  106954. /**
  106955. * Binds the output of the passed in post process to the texture channel specified
  106956. * @param channel The channel the texture should be bound to
  106957. * @param postProcess The post process which's output should be bound
  106958. */
  106959. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  106960. /** @hidden */
  106961. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  106962. protected _rebuildBuffers(): void;
  106963. /** @hidden */
  106964. _renderFrame(): void;
  106965. _renderLoop(): void;
  106966. /** @hidden */
  106967. _renderViews(): boolean;
  106968. /**
  106969. * Toggle full screen mode
  106970. * @param requestPointerLock defines if a pointer lock should be requested from the user
  106971. */
  106972. switchFullscreen(requestPointerLock: boolean): void;
  106973. /**
  106974. * Enters full screen mode
  106975. * @param requestPointerLock defines if a pointer lock should be requested from the user
  106976. */
  106977. enterFullscreen(requestPointerLock: boolean): void;
  106978. /**
  106979. * Exits full screen mode
  106980. */
  106981. exitFullscreen(): void;
  106982. /**
  106983. * Enters Pointerlock mode
  106984. */
  106985. enterPointerlock(): void;
  106986. /**
  106987. * Exits Pointerlock mode
  106988. */
  106989. exitPointerlock(): void;
  106990. /**
  106991. * Begin a new frame
  106992. */
  106993. beginFrame(): void;
  106994. /**
  106995. * Enf the current frame
  106996. */
  106997. endFrame(): void;
  106998. resize(): void;
  106999. /**
  107000. * Set the compressed texture format to use, based on the formats you have, and the formats
  107001. * supported by the hardware / browser.
  107002. *
  107003. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  107004. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  107005. * to API arguments needed to compressed textures. This puts the burden on the container
  107006. * generator to house the arcane code for determining these for current & future formats.
  107007. *
  107008. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  107009. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  107010. *
  107011. * Note: The result of this call is not taken into account when a texture is base64.
  107012. *
  107013. * @param formatsAvailable defines the list of those format families you have created
  107014. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  107015. *
  107016. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  107017. * @returns The extension selected.
  107018. */
  107019. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  107020. /**
  107021. * Set the compressed texture extensions or file names to skip.
  107022. *
  107023. * @param skippedFiles defines the list of those texture files you want to skip
  107024. * Example: [".dds", ".env", "myfile.png"]
  107025. */
  107026. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  107027. /**
  107028. * Force a specific size of the canvas
  107029. * @param width defines the new canvas' width
  107030. * @param height defines the new canvas' height
  107031. */
  107032. setSize(width: number, height: number): void;
  107033. /**
  107034. * Updates a dynamic vertex buffer.
  107035. * @param vertexBuffer the vertex buffer to update
  107036. * @param data the data used to update the vertex buffer
  107037. * @param byteOffset the byte offset of the data
  107038. * @param byteLength the byte length of the data
  107039. */
  107040. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  107041. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  107042. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  107043. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  107044. _releaseTexture(texture: InternalTexture): void;
  107045. /**
  107046. * @hidden
  107047. * Rescales a texture
  107048. * @param source input texutre
  107049. * @param destination destination texture
  107050. * @param scene scene to use to render the resize
  107051. * @param internalFormat format to use when resizing
  107052. * @param onComplete callback to be called when resize has completed
  107053. */
  107054. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  107055. /**
  107056. * Gets the current framerate
  107057. * @returns a number representing the framerate
  107058. */
  107059. getFps(): number;
  107060. /**
  107061. * Gets the time spent between current and previous frame
  107062. * @returns a number representing the delta time in ms
  107063. */
  107064. getDeltaTime(): number;
  107065. private _measureFps;
  107066. /** @hidden */
  107067. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  107068. /**
  107069. * Update a dynamic index buffer
  107070. * @param indexBuffer defines the target index buffer
  107071. * @param indices defines the data to update
  107072. * @param offset defines the offset in the target index buffer where update should start
  107073. */
  107074. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  107075. /**
  107076. * Updates the sample count of a render target texture
  107077. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  107078. * @param texture defines the texture to update
  107079. * @param samples defines the sample count to set
  107080. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  107081. */
  107082. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  107083. /**
  107084. * Updates a depth texture Comparison Mode and Function.
  107085. * If the comparison Function is equal to 0, the mode will be set to none.
  107086. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  107087. * @param texture The texture to set the comparison function for
  107088. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  107089. */
  107090. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  107091. /**
  107092. * Creates a webGL buffer to use with instanciation
  107093. * @param capacity defines the size of the buffer
  107094. * @returns the webGL buffer
  107095. */
  107096. createInstancesBuffer(capacity: number): DataBuffer;
  107097. /**
  107098. * Delete a webGL buffer used with instanciation
  107099. * @param buffer defines the webGL buffer to delete
  107100. */
  107101. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  107102. /** @hidden */
  107103. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  107104. dispose(): void;
  107105. private _disableTouchAction;
  107106. /**
  107107. * Display the loading screen
  107108. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107109. */
  107110. displayLoadingUI(): void;
  107111. /**
  107112. * Hide the loading screen
  107113. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107114. */
  107115. hideLoadingUI(): void;
  107116. /**
  107117. * Gets the current loading screen object
  107118. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107119. */
  107120. get loadingScreen(): ILoadingScreen;
  107121. /**
  107122. * Sets the current loading screen object
  107123. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107124. */
  107125. set loadingScreen(loadingScreen: ILoadingScreen);
  107126. /**
  107127. * Sets the current loading screen text
  107128. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107129. */
  107130. set loadingUIText(text: string);
  107131. /**
  107132. * Sets the current loading screen background color
  107133. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107134. */
  107135. set loadingUIBackgroundColor(color: string);
  107136. /** Pointerlock and fullscreen */
  107137. /**
  107138. * Ask the browser to promote the current element to pointerlock mode
  107139. * @param element defines the DOM element to promote
  107140. */
  107141. static _RequestPointerlock(element: HTMLElement): void;
  107142. /**
  107143. * Asks the browser to exit pointerlock mode
  107144. */
  107145. static _ExitPointerlock(): void;
  107146. /**
  107147. * Ask the browser to promote the current element to fullscreen rendering mode
  107148. * @param element defines the DOM element to promote
  107149. */
  107150. static _RequestFullscreen(element: HTMLElement): void;
  107151. /**
  107152. * Asks the browser to exit fullscreen mode
  107153. */
  107154. static _ExitFullscreen(): void;
  107155. }
  107156. }
  107157. declare module BABYLON {
  107158. /**
  107159. * The engine store class is responsible to hold all the instances of Engine and Scene created
  107160. * during the life time of the application.
  107161. */
  107162. export class EngineStore {
  107163. /** Gets the list of created engines */
  107164. static Instances: Engine[];
  107165. /** @hidden */
  107166. static _LastCreatedScene: Nullable<Scene>;
  107167. /**
  107168. * Gets the latest created engine
  107169. */
  107170. static get LastCreatedEngine(): Nullable<Engine>;
  107171. /**
  107172. * Gets the latest created scene
  107173. */
  107174. static get LastCreatedScene(): Nullable<Scene>;
  107175. /**
  107176. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  107177. * @ignorenaming
  107178. */
  107179. static UseFallbackTexture: boolean;
  107180. /**
  107181. * Texture content used if a texture cannot loaded
  107182. * @ignorenaming
  107183. */
  107184. static FallbackTexture: string;
  107185. }
  107186. }
  107187. declare module BABYLON {
  107188. /**
  107189. * Helper class that provides a small promise polyfill
  107190. */
  107191. export class PromisePolyfill {
  107192. /**
  107193. * Static function used to check if the polyfill is required
  107194. * If this is the case then the function will inject the polyfill to window.Promise
  107195. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  107196. */
  107197. static Apply(force?: boolean): void;
  107198. }
  107199. }
  107200. declare module BABYLON {
  107201. /**
  107202. * Interface for screenshot methods with describe argument called `size` as object with options
  107203. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  107204. */
  107205. export interface IScreenshotSize {
  107206. /**
  107207. * number in pixels for canvas height
  107208. */
  107209. height?: number;
  107210. /**
  107211. * multiplier allowing render at a higher or lower resolution
  107212. * If value is defined then height and width will be ignored and taken from camera
  107213. */
  107214. precision?: number;
  107215. /**
  107216. * number in pixels for canvas width
  107217. */
  107218. width?: number;
  107219. }
  107220. }
  107221. declare module BABYLON {
  107222. interface IColor4Like {
  107223. r: float;
  107224. g: float;
  107225. b: float;
  107226. a: float;
  107227. }
  107228. /**
  107229. * Class containing a set of static utilities functions
  107230. */
  107231. export class Tools {
  107232. /**
  107233. * Gets or sets the base URL to use to load assets
  107234. */
  107235. static get BaseUrl(): string;
  107236. static set BaseUrl(value: string);
  107237. /**
  107238. * Enable/Disable Custom HTTP Request Headers globally.
  107239. * default = false
  107240. * @see CustomRequestHeaders
  107241. */
  107242. static UseCustomRequestHeaders: boolean;
  107243. /**
  107244. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  107245. * i.e. when loading files, where the server/service expects an Authorization header
  107246. */
  107247. static CustomRequestHeaders: {
  107248. [key: string]: string;
  107249. };
  107250. /**
  107251. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  107252. */
  107253. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  107254. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  107255. /**
  107256. * Default behaviour for cors in the application.
  107257. * It can be a string if the expected behavior is identical in the entire app.
  107258. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  107259. */
  107260. static CorsBehavior: string | ((url: string | string[]) => string);
  107261. /**
  107262. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  107263. * @ignorenaming
  107264. */
  107265. static get UseFallbackTexture(): boolean;
  107266. static set UseFallbackTexture(value: boolean);
  107267. /**
  107268. * Use this object to register external classes like custom textures or material
  107269. * to allow the laoders to instantiate them
  107270. */
  107271. static get RegisteredExternalClasses(): {
  107272. [key: string]: Object;
  107273. };
  107274. static set RegisteredExternalClasses(classes: {
  107275. [key: string]: Object;
  107276. });
  107277. /**
  107278. * Texture content used if a texture cannot loaded
  107279. * @ignorenaming
  107280. */
  107281. static get fallbackTexture(): string;
  107282. static set fallbackTexture(value: string);
  107283. /**
  107284. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  107285. * @param u defines the coordinate on X axis
  107286. * @param v defines the coordinate on Y axis
  107287. * @param width defines the width of the source data
  107288. * @param height defines the height of the source data
  107289. * @param pixels defines the source byte array
  107290. * @param color defines the output color
  107291. */
  107292. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  107293. /**
  107294. * Interpolates between a and b via alpha
  107295. * @param a The lower value (returned when alpha = 0)
  107296. * @param b The upper value (returned when alpha = 1)
  107297. * @param alpha The interpolation-factor
  107298. * @return The mixed value
  107299. */
  107300. static Mix(a: number, b: number, alpha: number): number;
  107301. /**
  107302. * Tries to instantiate a new object from a given class name
  107303. * @param className defines the class name to instantiate
  107304. * @returns the new object or null if the system was not able to do the instantiation
  107305. */
  107306. static Instantiate(className: string): any;
  107307. /**
  107308. * Provides a slice function that will work even on IE
  107309. * @param data defines the array to slice
  107310. * @param start defines the start of the data (optional)
  107311. * @param end defines the end of the data (optional)
  107312. * @returns the new sliced array
  107313. */
  107314. static Slice<T>(data: T, start?: number, end?: number): T;
  107315. /**
  107316. * Polyfill for setImmediate
  107317. * @param action defines the action to execute after the current execution block
  107318. */
  107319. static SetImmediate(action: () => void): void;
  107320. /**
  107321. * Function indicating if a number is an exponent of 2
  107322. * @param value defines the value to test
  107323. * @returns true if the value is an exponent of 2
  107324. */
  107325. static IsExponentOfTwo(value: number): boolean;
  107326. private static _tmpFloatArray;
  107327. /**
  107328. * Returns the nearest 32-bit single precision float representation of a Number
  107329. * @param value A Number. If the parameter is of a different type, it will get converted
  107330. * to a number or to NaN if it cannot be converted
  107331. * @returns number
  107332. */
  107333. static FloatRound(value: number): number;
  107334. /**
  107335. * Extracts the filename from a path
  107336. * @param path defines the path to use
  107337. * @returns the filename
  107338. */
  107339. static GetFilename(path: string): string;
  107340. /**
  107341. * Extracts the "folder" part of a path (everything before the filename).
  107342. * @param uri The URI to extract the info from
  107343. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  107344. * @returns The "folder" part of the path
  107345. */
  107346. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  107347. /**
  107348. * Extracts text content from a DOM element hierarchy
  107349. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  107350. */
  107351. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  107352. /**
  107353. * Convert an angle in radians to degrees
  107354. * @param angle defines the angle to convert
  107355. * @returns the angle in degrees
  107356. */
  107357. static ToDegrees(angle: number): number;
  107358. /**
  107359. * Convert an angle in degrees to radians
  107360. * @param angle defines the angle to convert
  107361. * @returns the angle in radians
  107362. */
  107363. static ToRadians(angle: number): number;
  107364. /**
  107365. * Returns an array if obj is not an array
  107366. * @param obj defines the object to evaluate as an array
  107367. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  107368. * @returns either obj directly if obj is an array or a new array containing obj
  107369. */
  107370. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  107371. /**
  107372. * Gets the pointer prefix to use
  107373. * @returns "pointer" if touch is enabled. Else returns "mouse"
  107374. */
  107375. static GetPointerPrefix(): string;
  107376. /**
  107377. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  107378. * @param url define the url we are trying
  107379. * @param element define the dom element where to configure the cors policy
  107380. */
  107381. static SetCorsBehavior(url: string | string[], element: {
  107382. crossOrigin: string | null;
  107383. }): void;
  107384. /**
  107385. * Removes unwanted characters from an url
  107386. * @param url defines the url to clean
  107387. * @returns the cleaned url
  107388. */
  107389. static CleanUrl(url: string): string;
  107390. /**
  107391. * Gets or sets a function used to pre-process url before using them to load assets
  107392. */
  107393. static get PreprocessUrl(): (url: string) => string;
  107394. static set PreprocessUrl(processor: (url: string) => string);
  107395. /**
  107396. * Loads an image as an HTMLImageElement.
  107397. * @param input url string, ArrayBuffer, or Blob to load
  107398. * @param onLoad callback called when the image successfully loads
  107399. * @param onError callback called when the image fails to load
  107400. * @param offlineProvider offline provider for caching
  107401. * @param mimeType optional mime type
  107402. * @returns the HTMLImageElement of the loaded image
  107403. */
  107404. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  107405. /**
  107406. * Loads a file from a url
  107407. * @param url url string, ArrayBuffer, or Blob to load
  107408. * @param onSuccess callback called when the file successfully loads
  107409. * @param onProgress callback called while file is loading (if the server supports this mode)
  107410. * @param offlineProvider defines the offline provider for caching
  107411. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  107412. * @param onError callback called when the file fails to load
  107413. * @returns a file request object
  107414. */
  107415. 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;
  107416. /**
  107417. * Loads a file from a url
  107418. * @param url the file url to load
  107419. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  107420. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  107421. */
  107422. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  107423. /**
  107424. * Load a script (identified by an url). When the url returns, the
  107425. * content of this file is added into a new script element, attached to the DOM (body element)
  107426. * @param scriptUrl defines the url of the script to laod
  107427. * @param onSuccess defines the callback called when the script is loaded
  107428. * @param onError defines the callback to call if an error occurs
  107429. * @param scriptId defines the id of the script element
  107430. */
  107431. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  107432. /**
  107433. * Load an asynchronous script (identified by an url). When the url returns, the
  107434. * content of this file is added into a new script element, attached to the DOM (body element)
  107435. * @param scriptUrl defines the url of the script to laod
  107436. * @param scriptId defines the id of the script element
  107437. * @returns a promise request object
  107438. */
  107439. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  107440. /**
  107441. * Loads a file from a blob
  107442. * @param fileToLoad defines the blob to use
  107443. * @param callback defines the callback to call when data is loaded
  107444. * @param progressCallback defines the callback to call during loading process
  107445. * @returns a file request object
  107446. */
  107447. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  107448. /**
  107449. * Reads a file from a File object
  107450. * @param file defines the file to load
  107451. * @param onSuccess defines the callback to call when data is loaded
  107452. * @param onProgress defines the callback to call during loading process
  107453. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  107454. * @param onError defines the callback to call when an error occurs
  107455. * @returns a file request object
  107456. */
  107457. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  107458. /**
  107459. * Creates a data url from a given string content
  107460. * @param content defines the content to convert
  107461. * @returns the new data url link
  107462. */
  107463. static FileAsURL(content: string): string;
  107464. /**
  107465. * Format the given number to a specific decimal format
  107466. * @param value defines the number to format
  107467. * @param decimals defines the number of decimals to use
  107468. * @returns the formatted string
  107469. */
  107470. static Format(value: number, decimals?: number): string;
  107471. /**
  107472. * Tries to copy an object by duplicating every property
  107473. * @param source defines the source object
  107474. * @param destination defines the target object
  107475. * @param doNotCopyList defines a list of properties to avoid
  107476. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  107477. */
  107478. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  107479. /**
  107480. * Gets a boolean indicating if the given object has no own property
  107481. * @param obj defines the object to test
  107482. * @returns true if object has no own property
  107483. */
  107484. static IsEmpty(obj: any): boolean;
  107485. /**
  107486. * Function used to register events at window level
  107487. * @param windowElement defines the Window object to use
  107488. * @param events defines the events to register
  107489. */
  107490. static RegisterTopRootEvents(windowElement: Window, events: {
  107491. name: string;
  107492. handler: Nullable<(e: FocusEvent) => any>;
  107493. }[]): void;
  107494. /**
  107495. * Function used to unregister events from window level
  107496. * @param windowElement defines the Window object to use
  107497. * @param events defines the events to unregister
  107498. */
  107499. static UnregisterTopRootEvents(windowElement: Window, events: {
  107500. name: string;
  107501. handler: Nullable<(e: FocusEvent) => any>;
  107502. }[]): void;
  107503. /**
  107504. * @ignore
  107505. */
  107506. static _ScreenshotCanvas: HTMLCanvasElement;
  107507. /**
  107508. * Dumps the current bound framebuffer
  107509. * @param width defines the rendering width
  107510. * @param height defines the rendering height
  107511. * @param engine defines the hosting engine
  107512. * @param successCallback defines the callback triggered once the data are available
  107513. * @param mimeType defines the mime type of the result
  107514. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  107515. */
  107516. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  107517. /**
  107518. * Converts the canvas data to blob.
  107519. * This acts as a polyfill for browsers not supporting the to blob function.
  107520. * @param canvas Defines the canvas to extract the data from
  107521. * @param successCallback Defines the callback triggered once the data are available
  107522. * @param mimeType Defines the mime type of the result
  107523. */
  107524. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  107525. /**
  107526. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  107527. * @param successCallback defines the callback triggered once the data are available
  107528. * @param mimeType defines the mime type of the result
  107529. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  107530. */
  107531. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  107532. /**
  107533. * Downloads a blob in the browser
  107534. * @param blob defines the blob to download
  107535. * @param fileName defines the name of the downloaded file
  107536. */
  107537. static Download(blob: Blob, fileName: string): void;
  107538. /**
  107539. * Captures a screenshot of the current rendering
  107540. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107541. * @param engine defines the rendering engine
  107542. * @param camera defines the source camera
  107543. * @param size This parameter can be set to a single number or to an object with the
  107544. * following (optional) properties: precision, width, height. If a single number is passed,
  107545. * it will be used for both width and height. If an object is passed, the screenshot size
  107546. * will be derived from the parameters. The precision property is a multiplier allowing
  107547. * rendering at a higher or lower resolution
  107548. * @param successCallback defines the callback receives a single parameter which contains the
  107549. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  107550. * src parameter of an <img> to display it
  107551. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  107552. * Check your browser for supported MIME types
  107553. */
  107554. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  107555. /**
  107556. * Captures a screenshot of the current rendering
  107557. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107558. * @param engine defines the rendering engine
  107559. * @param camera defines the source camera
  107560. * @param size This parameter can be set to a single number or to an object with the
  107561. * following (optional) properties: precision, width, height. If a single number is passed,
  107562. * it will be used for both width and height. If an object is passed, the screenshot size
  107563. * will be derived from the parameters. The precision property is a multiplier allowing
  107564. * rendering at a higher or lower resolution
  107565. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  107566. * Check your browser for supported MIME types
  107567. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  107568. * to the src parameter of an <img> to display it
  107569. */
  107570. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  107571. /**
  107572. * Generates an image screenshot from the specified camera.
  107573. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107574. * @param engine The engine to use for rendering
  107575. * @param camera The camera to use for rendering
  107576. * @param size This parameter can be set to a single number or to an object with the
  107577. * following (optional) properties: precision, width, height. If a single number is passed,
  107578. * it will be used for both width and height. If an object is passed, the screenshot size
  107579. * will be derived from the parameters. The precision property is a multiplier allowing
  107580. * rendering at a higher or lower resolution
  107581. * @param successCallback The callback receives a single parameter which contains the
  107582. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  107583. * src parameter of an <img> to display it
  107584. * @param mimeType The MIME type of the screenshot image (default: image/png).
  107585. * Check your browser for supported MIME types
  107586. * @param samples Texture samples (default: 1)
  107587. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  107588. * @param fileName A name for for the downloaded file.
  107589. */
  107590. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  107591. /**
  107592. * Generates an image screenshot from the specified camera.
  107593. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107594. * @param engine The engine to use for rendering
  107595. * @param camera The camera to use for rendering
  107596. * @param size This parameter can be set to a single number or to an object with the
  107597. * following (optional) properties: precision, width, height. If a single number is passed,
  107598. * it will be used for both width and height. If an object is passed, the screenshot size
  107599. * will be derived from the parameters. The precision property is a multiplier allowing
  107600. * rendering at a higher or lower resolution
  107601. * @param mimeType The MIME type of the screenshot image (default: image/png).
  107602. * Check your browser for supported MIME types
  107603. * @param samples Texture samples (default: 1)
  107604. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  107605. * @param fileName A name for for the downloaded file.
  107606. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  107607. * to the src parameter of an <img> to display it
  107608. */
  107609. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  107610. /**
  107611. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  107612. * Be aware Math.random() could cause collisions, but:
  107613. * "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"
  107614. * @returns a pseudo random id
  107615. */
  107616. static RandomId(): string;
  107617. /**
  107618. * Test if the given uri is a base64 string
  107619. * @param uri The uri to test
  107620. * @return True if the uri is a base64 string or false otherwise
  107621. */
  107622. static IsBase64(uri: string): boolean;
  107623. /**
  107624. * Decode the given base64 uri.
  107625. * @param uri The uri to decode
  107626. * @return The decoded base64 data.
  107627. */
  107628. static DecodeBase64(uri: string): ArrayBuffer;
  107629. /**
  107630. * Gets the absolute url.
  107631. * @param url the input url
  107632. * @return the absolute url
  107633. */
  107634. static GetAbsoluteUrl(url: string): string;
  107635. /**
  107636. * No log
  107637. */
  107638. static readonly NoneLogLevel: number;
  107639. /**
  107640. * Only message logs
  107641. */
  107642. static readonly MessageLogLevel: number;
  107643. /**
  107644. * Only warning logs
  107645. */
  107646. static readonly WarningLogLevel: number;
  107647. /**
  107648. * Only error logs
  107649. */
  107650. static readonly ErrorLogLevel: number;
  107651. /**
  107652. * All logs
  107653. */
  107654. static readonly AllLogLevel: number;
  107655. /**
  107656. * Gets a value indicating the number of loading errors
  107657. * @ignorenaming
  107658. */
  107659. static get errorsCount(): number;
  107660. /**
  107661. * Callback called when a new log is added
  107662. */
  107663. static OnNewCacheEntry: (entry: string) => void;
  107664. /**
  107665. * Log a message to the console
  107666. * @param message defines the message to log
  107667. */
  107668. static Log(message: string): void;
  107669. /**
  107670. * Write a warning message to the console
  107671. * @param message defines the message to log
  107672. */
  107673. static Warn(message: string): void;
  107674. /**
  107675. * Write an error message to the console
  107676. * @param message defines the message to log
  107677. */
  107678. static Error(message: string): void;
  107679. /**
  107680. * Gets current log cache (list of logs)
  107681. */
  107682. static get LogCache(): string;
  107683. /**
  107684. * Clears the log cache
  107685. */
  107686. static ClearLogCache(): void;
  107687. /**
  107688. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  107689. */
  107690. static set LogLevels(level: number);
  107691. /**
  107692. * Checks if the window object exists
  107693. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  107694. */
  107695. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  107696. /**
  107697. * No performance log
  107698. */
  107699. static readonly PerformanceNoneLogLevel: number;
  107700. /**
  107701. * Use user marks to log performance
  107702. */
  107703. static readonly PerformanceUserMarkLogLevel: number;
  107704. /**
  107705. * Log performance to the console
  107706. */
  107707. static readonly PerformanceConsoleLogLevel: number;
  107708. private static _performance;
  107709. /**
  107710. * Sets the current performance log level
  107711. */
  107712. static set PerformanceLogLevel(level: number);
  107713. private static _StartPerformanceCounterDisabled;
  107714. private static _EndPerformanceCounterDisabled;
  107715. private static _StartUserMark;
  107716. private static _EndUserMark;
  107717. private static _StartPerformanceConsole;
  107718. private static _EndPerformanceConsole;
  107719. /**
  107720. * Starts a performance counter
  107721. */
  107722. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  107723. /**
  107724. * Ends a specific performance coutner
  107725. */
  107726. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  107727. /**
  107728. * Gets either window.performance.now() if supported or Date.now() else
  107729. */
  107730. static get Now(): number;
  107731. /**
  107732. * This method will return the name of the class used to create the instance of the given object.
  107733. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  107734. * @param object the object to get the class name from
  107735. * @param isType defines if the object is actually a type
  107736. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  107737. */
  107738. static GetClassName(object: any, isType?: boolean): string;
  107739. /**
  107740. * Gets the first element of an array satisfying a given predicate
  107741. * @param array defines the array to browse
  107742. * @param predicate defines the predicate to use
  107743. * @returns null if not found or the element
  107744. */
  107745. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  107746. /**
  107747. * This method will return the name of the full name of the class, including its owning module (if any).
  107748. * 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).
  107749. * @param object the object to get the class name from
  107750. * @param isType defines if the object is actually a type
  107751. * @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.
  107752. * @ignorenaming
  107753. */
  107754. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  107755. /**
  107756. * Returns a promise that resolves after the given amount of time.
  107757. * @param delay Number of milliseconds to delay
  107758. * @returns Promise that resolves after the given amount of time
  107759. */
  107760. static DelayAsync(delay: number): Promise<void>;
  107761. /**
  107762. * Utility function to detect if the current user agent is Safari
  107763. * @returns whether or not the current user agent is safari
  107764. */
  107765. static IsSafari(): boolean;
  107766. }
  107767. /**
  107768. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  107769. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  107770. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  107771. * @param name The name of the class, case should be preserved
  107772. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  107773. */
  107774. export function className(name: string, module?: string): (target: Object) => void;
  107775. /**
  107776. * An implementation of a loop for asynchronous functions.
  107777. */
  107778. export class AsyncLoop {
  107779. /**
  107780. * Defines the number of iterations for the loop
  107781. */
  107782. iterations: number;
  107783. /**
  107784. * Defines the current index of the loop.
  107785. */
  107786. index: number;
  107787. private _done;
  107788. private _fn;
  107789. private _successCallback;
  107790. /**
  107791. * Constructor.
  107792. * @param iterations the number of iterations.
  107793. * @param func the function to run each iteration
  107794. * @param successCallback the callback that will be called upon succesful execution
  107795. * @param offset starting offset.
  107796. */
  107797. constructor(
  107798. /**
  107799. * Defines the number of iterations for the loop
  107800. */
  107801. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  107802. /**
  107803. * Execute the next iteration. Must be called after the last iteration was finished.
  107804. */
  107805. executeNext(): void;
  107806. /**
  107807. * Break the loop and run the success callback.
  107808. */
  107809. breakLoop(): void;
  107810. /**
  107811. * Create and run an async loop.
  107812. * @param iterations the number of iterations.
  107813. * @param fn the function to run each iteration
  107814. * @param successCallback the callback that will be called upon succesful execution
  107815. * @param offset starting offset.
  107816. * @returns the created async loop object
  107817. */
  107818. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  107819. /**
  107820. * A for-loop that will run a given number of iterations synchronous and the rest async.
  107821. * @param iterations total number of iterations
  107822. * @param syncedIterations number of synchronous iterations in each async iteration.
  107823. * @param fn the function to call each iteration.
  107824. * @param callback a success call back that will be called when iterating stops.
  107825. * @param breakFunction a break condition (optional)
  107826. * @param timeout timeout settings for the setTimeout function. default - 0.
  107827. * @returns the created async loop object
  107828. */
  107829. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  107830. }
  107831. }
  107832. declare module BABYLON {
  107833. /**
  107834. * This class implement a typical dictionary using a string as key and the generic type T as value.
  107835. * The underlying implementation relies on an associative array to ensure the best performances.
  107836. * The value can be anything including 'null' but except 'undefined'
  107837. */
  107838. export class StringDictionary<T> {
  107839. /**
  107840. * This will clear this dictionary and copy the content from the 'source' one.
  107841. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  107842. * @param source the dictionary to take the content from and copy to this dictionary
  107843. */
  107844. copyFrom(source: StringDictionary<T>): void;
  107845. /**
  107846. * Get a value based from its key
  107847. * @param key the given key to get the matching value from
  107848. * @return the value if found, otherwise undefined is returned
  107849. */
  107850. get(key: string): T | undefined;
  107851. /**
  107852. * Get a value from its key or add it if it doesn't exist.
  107853. * This method will ensure you that a given key/data will be present in the dictionary.
  107854. * @param key the given key to get the matching value from
  107855. * @param factory the factory that will create the value if the key is not present in the dictionary.
  107856. * The factory will only be invoked if there's no data for the given key.
  107857. * @return the value corresponding to the key.
  107858. */
  107859. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  107860. /**
  107861. * Get a value from its key if present in the dictionary otherwise add it
  107862. * @param key the key to get the value from
  107863. * @param val if there's no such key/value pair in the dictionary add it with this value
  107864. * @return the value corresponding to the key
  107865. */
  107866. getOrAdd(key: string, val: T): T;
  107867. /**
  107868. * Check if there's a given key in the dictionary
  107869. * @param key the key to check for
  107870. * @return true if the key is present, false otherwise
  107871. */
  107872. contains(key: string): boolean;
  107873. /**
  107874. * Add a new key and its corresponding value
  107875. * @param key the key to add
  107876. * @param value the value corresponding to the key
  107877. * @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
  107878. */
  107879. add(key: string, value: T): boolean;
  107880. /**
  107881. * Update a specific value associated to a key
  107882. * @param key defines the key to use
  107883. * @param value defines the value to store
  107884. * @returns true if the value was updated (or false if the key was not found)
  107885. */
  107886. set(key: string, value: T): boolean;
  107887. /**
  107888. * Get the element of the given key and remove it from the dictionary
  107889. * @param key defines the key to search
  107890. * @returns the value associated with the key or null if not found
  107891. */
  107892. getAndRemove(key: string): Nullable<T>;
  107893. /**
  107894. * Remove a key/value from the dictionary.
  107895. * @param key the key to remove
  107896. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  107897. */
  107898. remove(key: string): boolean;
  107899. /**
  107900. * Clear the whole content of the dictionary
  107901. */
  107902. clear(): void;
  107903. /**
  107904. * Gets the current count
  107905. */
  107906. get count(): number;
  107907. /**
  107908. * Execute a callback on each key/val of the dictionary.
  107909. * Note that you can remove any element in this dictionary in the callback implementation
  107910. * @param callback the callback to execute on a given key/value pair
  107911. */
  107912. forEach(callback: (key: string, val: T) => void): void;
  107913. /**
  107914. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  107915. * If the callback returns null or undefined the method will iterate to the next key/value pair
  107916. * Note that you can remove any element in this dictionary in the callback implementation
  107917. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  107918. * @returns the first item
  107919. */
  107920. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  107921. private _count;
  107922. private _data;
  107923. }
  107924. }
  107925. declare module BABYLON {
  107926. /** @hidden */
  107927. export interface ICollisionCoordinator {
  107928. createCollider(): Collider;
  107929. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  107930. init(scene: Scene): void;
  107931. }
  107932. /** @hidden */
  107933. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  107934. private _scene;
  107935. private _scaledPosition;
  107936. private _scaledVelocity;
  107937. private _finalPosition;
  107938. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  107939. createCollider(): Collider;
  107940. init(scene: Scene): void;
  107941. private _collideWithWorld;
  107942. }
  107943. }
  107944. declare module BABYLON {
  107945. /**
  107946. * Class used to manage all inputs for the scene.
  107947. */
  107948. export class InputManager {
  107949. /** The distance in pixel that you have to move to prevent some events */
  107950. static DragMovementThreshold: number;
  107951. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  107952. static LongPressDelay: number;
  107953. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  107954. static DoubleClickDelay: number;
  107955. /** If you need to check double click without raising a single click at first click, enable this flag */
  107956. static ExclusiveDoubleClickMode: boolean;
  107957. private _wheelEventName;
  107958. private _onPointerMove;
  107959. private _onPointerDown;
  107960. private _onPointerUp;
  107961. private _initClickEvent;
  107962. private _initActionManager;
  107963. private _delayedSimpleClick;
  107964. private _delayedSimpleClickTimeout;
  107965. private _previousDelayedSimpleClickTimeout;
  107966. private _meshPickProceed;
  107967. private _previousButtonPressed;
  107968. private _currentPickResult;
  107969. private _previousPickResult;
  107970. private _totalPointersPressed;
  107971. private _doubleClickOccured;
  107972. private _pointerOverMesh;
  107973. private _pickedDownMesh;
  107974. private _pickedUpMesh;
  107975. private _pointerX;
  107976. private _pointerY;
  107977. private _unTranslatedPointerX;
  107978. private _unTranslatedPointerY;
  107979. private _startingPointerPosition;
  107980. private _previousStartingPointerPosition;
  107981. private _startingPointerTime;
  107982. private _previousStartingPointerTime;
  107983. private _pointerCaptures;
  107984. private _onKeyDown;
  107985. private _onKeyUp;
  107986. private _onCanvasFocusObserver;
  107987. private _onCanvasBlurObserver;
  107988. private _scene;
  107989. /**
  107990. * Creates a new InputManager
  107991. * @param scene defines the hosting scene
  107992. */
  107993. constructor(scene: Scene);
  107994. /**
  107995. * Gets the mesh that is currently under the pointer
  107996. */
  107997. get meshUnderPointer(): Nullable<AbstractMesh>;
  107998. /**
  107999. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  108000. */
  108001. get unTranslatedPointer(): Vector2;
  108002. /**
  108003. * Gets or sets the current on-screen X position of the pointer
  108004. */
  108005. get pointerX(): number;
  108006. set pointerX(value: number);
  108007. /**
  108008. * Gets or sets the current on-screen Y position of the pointer
  108009. */
  108010. get pointerY(): number;
  108011. set pointerY(value: number);
  108012. private _updatePointerPosition;
  108013. private _processPointerMove;
  108014. private _setRayOnPointerInfo;
  108015. private _checkPrePointerObservable;
  108016. /**
  108017. * Use this method to simulate a pointer move on a mesh
  108018. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  108019. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  108020. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  108021. */
  108022. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  108023. /**
  108024. * Use this method to simulate a pointer down on a mesh
  108025. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  108026. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  108027. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  108028. */
  108029. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  108030. private _processPointerDown;
  108031. /** @hidden */
  108032. _isPointerSwiping(): boolean;
  108033. /**
  108034. * Use this method to simulate a pointer up on a mesh
  108035. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  108036. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  108037. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  108038. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  108039. */
  108040. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  108041. private _processPointerUp;
  108042. /**
  108043. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  108044. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  108045. * @returns true if the pointer was captured
  108046. */
  108047. isPointerCaptured(pointerId?: number): boolean;
  108048. /**
  108049. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  108050. * @param attachUp defines if you want to attach events to pointerup
  108051. * @param attachDown defines if you want to attach events to pointerdown
  108052. * @param attachMove defines if you want to attach events to pointermove
  108053. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  108054. */
  108055. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  108056. /**
  108057. * Detaches all event handlers
  108058. */
  108059. detachControl(): void;
  108060. /**
  108061. * Force the value of meshUnderPointer
  108062. * @param mesh defines the mesh to use
  108063. */
  108064. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  108065. /**
  108066. * Gets the mesh under the pointer
  108067. * @returns a Mesh or null if no mesh is under the pointer
  108068. */
  108069. getPointerOverMesh(): Nullable<AbstractMesh>;
  108070. }
  108071. }
  108072. declare module BABYLON {
  108073. /**
  108074. * Helper class used to generate session unique ID
  108075. */
  108076. export class UniqueIdGenerator {
  108077. private static _UniqueIdCounter;
  108078. /**
  108079. * Gets an unique (relatively to the current scene) Id
  108080. */
  108081. static get UniqueId(): number;
  108082. }
  108083. }
  108084. declare module BABYLON {
  108085. /**
  108086. * This class defines the direct association between an animation and a target
  108087. */
  108088. export class TargetedAnimation {
  108089. /**
  108090. * Animation to perform
  108091. */
  108092. animation: Animation;
  108093. /**
  108094. * Target to animate
  108095. */
  108096. target: any;
  108097. /**
  108098. * Serialize the object
  108099. * @returns the JSON object representing the current entity
  108100. */
  108101. serialize(): any;
  108102. }
  108103. /**
  108104. * Use this class to create coordinated animations on multiple targets
  108105. */
  108106. export class AnimationGroup implements IDisposable {
  108107. /** The name of the animation group */
  108108. name: string;
  108109. private _scene;
  108110. private _targetedAnimations;
  108111. private _animatables;
  108112. private _from;
  108113. private _to;
  108114. private _isStarted;
  108115. private _isPaused;
  108116. private _speedRatio;
  108117. private _loopAnimation;
  108118. /**
  108119. * Gets or sets the unique id of the node
  108120. */
  108121. uniqueId: number;
  108122. /**
  108123. * This observable will notify when one animation have ended
  108124. */
  108125. onAnimationEndObservable: Observable<TargetedAnimation>;
  108126. /**
  108127. * Observer raised when one animation loops
  108128. */
  108129. onAnimationLoopObservable: Observable<TargetedAnimation>;
  108130. /**
  108131. * Observer raised when all animations have looped
  108132. */
  108133. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  108134. /**
  108135. * This observable will notify when all animations have ended.
  108136. */
  108137. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  108138. /**
  108139. * This observable will notify when all animations have paused.
  108140. */
  108141. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  108142. /**
  108143. * This observable will notify when all animations are playing.
  108144. */
  108145. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  108146. /**
  108147. * Gets the first frame
  108148. */
  108149. get from(): number;
  108150. /**
  108151. * Gets the last frame
  108152. */
  108153. get to(): number;
  108154. /**
  108155. * Define if the animations are started
  108156. */
  108157. get isStarted(): boolean;
  108158. /**
  108159. * Gets a value indicating that the current group is playing
  108160. */
  108161. get isPlaying(): boolean;
  108162. /**
  108163. * Gets or sets the speed ratio to use for all animations
  108164. */
  108165. get speedRatio(): number;
  108166. /**
  108167. * Gets or sets the speed ratio to use for all animations
  108168. */
  108169. set speedRatio(value: number);
  108170. /**
  108171. * Gets or sets if all animations should loop or not
  108172. */
  108173. get loopAnimation(): boolean;
  108174. set loopAnimation(value: boolean);
  108175. /**
  108176. * Gets the targeted animations for this animation group
  108177. */
  108178. get targetedAnimations(): Array<TargetedAnimation>;
  108179. /**
  108180. * returning the list of animatables controlled by this animation group.
  108181. */
  108182. get animatables(): Array<Animatable>;
  108183. /**
  108184. * Instantiates a new Animation Group.
  108185. * This helps managing several animations at once.
  108186. * @see http://doc.babylonjs.com/how_to/group
  108187. * @param name Defines the name of the group
  108188. * @param scene Defines the scene the group belongs to
  108189. */
  108190. constructor(
  108191. /** The name of the animation group */
  108192. name: string, scene?: Nullable<Scene>);
  108193. /**
  108194. * Add an animation (with its target) in the group
  108195. * @param animation defines the animation we want to add
  108196. * @param target defines the target of the animation
  108197. * @returns the TargetedAnimation object
  108198. */
  108199. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  108200. /**
  108201. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  108202. * It can add constant keys at begin or end
  108203. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  108204. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  108205. * @returns the animation group
  108206. */
  108207. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  108208. private _animationLoopCount;
  108209. private _animationLoopFlags;
  108210. private _processLoop;
  108211. /**
  108212. * Start all animations on given targets
  108213. * @param loop defines if animations must loop
  108214. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  108215. * @param from defines the from key (optional)
  108216. * @param to defines the to key (optional)
  108217. * @returns the current animation group
  108218. */
  108219. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  108220. /**
  108221. * Pause all animations
  108222. * @returns the animation group
  108223. */
  108224. pause(): AnimationGroup;
  108225. /**
  108226. * Play all animations to initial state
  108227. * This function will start() the animations if they were not started or will restart() them if they were paused
  108228. * @param loop defines if animations must loop
  108229. * @returns the animation group
  108230. */
  108231. play(loop?: boolean): AnimationGroup;
  108232. /**
  108233. * Reset all animations to initial state
  108234. * @returns the animation group
  108235. */
  108236. reset(): AnimationGroup;
  108237. /**
  108238. * Restart animations from key 0
  108239. * @returns the animation group
  108240. */
  108241. restart(): AnimationGroup;
  108242. /**
  108243. * Stop all animations
  108244. * @returns the animation group
  108245. */
  108246. stop(): AnimationGroup;
  108247. /**
  108248. * Set animation weight for all animatables
  108249. * @param weight defines the weight to use
  108250. * @return the animationGroup
  108251. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  108252. */
  108253. setWeightForAllAnimatables(weight: number): AnimationGroup;
  108254. /**
  108255. * Synchronize and normalize all animatables with a source animatable
  108256. * @param root defines the root animatable to synchronize with
  108257. * @return the animationGroup
  108258. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  108259. */
  108260. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  108261. /**
  108262. * Goes to a specific frame in this animation group
  108263. * @param frame the frame number to go to
  108264. * @return the animationGroup
  108265. */
  108266. goToFrame(frame: number): AnimationGroup;
  108267. /**
  108268. * Dispose all associated resources
  108269. */
  108270. dispose(): void;
  108271. private _checkAnimationGroupEnded;
  108272. /**
  108273. * Clone the current animation group and returns a copy
  108274. * @param newName defines the name of the new group
  108275. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  108276. * @returns the new aniamtion group
  108277. */
  108278. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  108279. /**
  108280. * Serializes the animationGroup to an object
  108281. * @returns Serialized object
  108282. */
  108283. serialize(): any;
  108284. /**
  108285. * Returns a new AnimationGroup object parsed from the source provided.
  108286. * @param parsedAnimationGroup defines the source
  108287. * @param scene defines the scene that will receive the animationGroup
  108288. * @returns a new AnimationGroup
  108289. */
  108290. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  108291. /**
  108292. * Returns the string "AnimationGroup"
  108293. * @returns "AnimationGroup"
  108294. */
  108295. getClassName(): string;
  108296. /**
  108297. * Creates a detailled string about the object
  108298. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  108299. * @returns a string representing the object
  108300. */
  108301. toString(fullDetails?: boolean): string;
  108302. }
  108303. }
  108304. declare module BABYLON {
  108305. /**
  108306. * Define an interface for all classes that will hold resources
  108307. */
  108308. export interface IDisposable {
  108309. /**
  108310. * Releases all held resources
  108311. */
  108312. dispose(): void;
  108313. }
  108314. /** Interface defining initialization parameters for Scene class */
  108315. export interface SceneOptions {
  108316. /**
  108317. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  108318. * It will improve performance when the number of geometries becomes important.
  108319. */
  108320. useGeometryUniqueIdsMap?: boolean;
  108321. /**
  108322. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  108323. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  108324. */
  108325. useMaterialMeshMap?: boolean;
  108326. /**
  108327. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  108328. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  108329. */
  108330. useClonedMeshMap?: boolean;
  108331. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  108332. virtual?: boolean;
  108333. }
  108334. /**
  108335. * Represents a scene to be rendered by the engine.
  108336. * @see http://doc.babylonjs.com/features/scene
  108337. */
  108338. export class Scene extends AbstractScene implements IAnimatable {
  108339. /** The fog is deactivated */
  108340. static readonly FOGMODE_NONE: number;
  108341. /** The fog density is following an exponential function */
  108342. static readonly FOGMODE_EXP: number;
  108343. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  108344. static readonly FOGMODE_EXP2: number;
  108345. /** The fog density is following a linear function. */
  108346. static readonly FOGMODE_LINEAR: number;
  108347. /**
  108348. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  108349. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108350. */
  108351. static MinDeltaTime: number;
  108352. /**
  108353. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  108354. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108355. */
  108356. static MaxDeltaTime: number;
  108357. /**
  108358. * Factory used to create the default material.
  108359. * @param name The name of the material to create
  108360. * @param scene The scene to create the material for
  108361. * @returns The default material
  108362. */
  108363. static DefaultMaterialFactory(scene: Scene): Material;
  108364. /**
  108365. * Factory used to create the a collision coordinator.
  108366. * @returns The collision coordinator
  108367. */
  108368. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  108369. /** @hidden */
  108370. _inputManager: InputManager;
  108371. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  108372. cameraToUseForPointers: Nullable<Camera>;
  108373. /** @hidden */
  108374. readonly _isScene: boolean;
  108375. /** @hidden */
  108376. _blockEntityCollection: boolean;
  108377. /**
  108378. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  108379. */
  108380. autoClear: boolean;
  108381. /**
  108382. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  108383. */
  108384. autoClearDepthAndStencil: boolean;
  108385. /**
  108386. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  108387. */
  108388. clearColor: Color4;
  108389. /**
  108390. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  108391. */
  108392. ambientColor: Color3;
  108393. /**
  108394. * This is use to store the default BRDF lookup for PBR materials in your scene.
  108395. * It should only be one of the following (if not the default embedded one):
  108396. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  108397. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  108398. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  108399. * The material properties need to be setup according to the type of texture in use.
  108400. */
  108401. environmentBRDFTexture: BaseTexture;
  108402. /** @hidden */
  108403. protected _environmentTexture: Nullable<BaseTexture>;
  108404. /**
  108405. * Texture used in all pbr material as the reflection texture.
  108406. * As in the majority of the scene they are the same (exception for multi room and so on),
  108407. * this is easier to reference from here than from all the materials.
  108408. */
  108409. get environmentTexture(): Nullable<BaseTexture>;
  108410. /**
  108411. * Texture used in all pbr material as the reflection texture.
  108412. * As in the majority of the scene they are the same (exception for multi room and so on),
  108413. * this is easier to set here than in all the materials.
  108414. */
  108415. set environmentTexture(value: Nullable<BaseTexture>);
  108416. /** @hidden */
  108417. protected _environmentIntensity: number;
  108418. /**
  108419. * Intensity of the environment in all pbr material.
  108420. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  108421. * As in the majority of the scene they are the same (exception for multi room and so on),
  108422. * this is easier to reference from here than from all the materials.
  108423. */
  108424. get environmentIntensity(): number;
  108425. /**
  108426. * Intensity of the environment in all pbr material.
  108427. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  108428. * As in the majority of the scene they are the same (exception for multi room and so on),
  108429. * this is easier to set here than in all the materials.
  108430. */
  108431. set environmentIntensity(value: number);
  108432. /** @hidden */
  108433. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  108434. /**
  108435. * Default image processing configuration used either in the rendering
  108436. * Forward main pass or through the imageProcessingPostProcess if present.
  108437. * As in the majority of the scene they are the same (exception for multi camera),
  108438. * this is easier to reference from here than from all the materials and post process.
  108439. *
  108440. * No setter as we it is a shared configuration, you can set the values instead.
  108441. */
  108442. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  108443. private _forceWireframe;
  108444. /**
  108445. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  108446. */
  108447. set forceWireframe(value: boolean);
  108448. get forceWireframe(): boolean;
  108449. private _skipFrustumClipping;
  108450. /**
  108451. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  108452. */
  108453. set skipFrustumClipping(value: boolean);
  108454. get skipFrustumClipping(): boolean;
  108455. private _forcePointsCloud;
  108456. /**
  108457. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  108458. */
  108459. set forcePointsCloud(value: boolean);
  108460. get forcePointsCloud(): boolean;
  108461. /**
  108462. * Gets or sets the active clipplane 1
  108463. */
  108464. clipPlane: Nullable<Plane>;
  108465. /**
  108466. * Gets or sets the active clipplane 2
  108467. */
  108468. clipPlane2: Nullable<Plane>;
  108469. /**
  108470. * Gets or sets the active clipplane 3
  108471. */
  108472. clipPlane3: Nullable<Plane>;
  108473. /**
  108474. * Gets or sets the active clipplane 4
  108475. */
  108476. clipPlane4: Nullable<Plane>;
  108477. /**
  108478. * Gets or sets the active clipplane 5
  108479. */
  108480. clipPlane5: Nullable<Plane>;
  108481. /**
  108482. * Gets or sets the active clipplane 6
  108483. */
  108484. clipPlane6: Nullable<Plane>;
  108485. /**
  108486. * Gets or sets a boolean indicating if animations are enabled
  108487. */
  108488. animationsEnabled: boolean;
  108489. private _animationPropertiesOverride;
  108490. /**
  108491. * Gets or sets the animation properties override
  108492. */
  108493. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  108494. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  108495. /**
  108496. * Gets or sets a boolean indicating if a constant deltatime has to be used
  108497. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  108498. */
  108499. useConstantAnimationDeltaTime: boolean;
  108500. /**
  108501. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  108502. * Please note that it requires to run a ray cast through the scene on every frame
  108503. */
  108504. constantlyUpdateMeshUnderPointer: boolean;
  108505. /**
  108506. * Defines the HTML cursor to use when hovering over interactive elements
  108507. */
  108508. hoverCursor: string;
  108509. /**
  108510. * Defines the HTML default cursor to use (empty by default)
  108511. */
  108512. defaultCursor: string;
  108513. /**
  108514. * Defines whether cursors are handled by the scene.
  108515. */
  108516. doNotHandleCursors: boolean;
  108517. /**
  108518. * This is used to call preventDefault() on pointer down
  108519. * in order to block unwanted artifacts like system double clicks
  108520. */
  108521. preventDefaultOnPointerDown: boolean;
  108522. /**
  108523. * This is used to call preventDefault() on pointer up
  108524. * in order to block unwanted artifacts like system double clicks
  108525. */
  108526. preventDefaultOnPointerUp: boolean;
  108527. /**
  108528. * Gets or sets user defined metadata
  108529. */
  108530. metadata: any;
  108531. /**
  108532. * For internal use only. Please do not use.
  108533. */
  108534. reservedDataStore: any;
  108535. /**
  108536. * Gets the name of the plugin used to load this scene (null by default)
  108537. */
  108538. loadingPluginName: string;
  108539. /**
  108540. * Use this array to add regular expressions used to disable offline support for specific urls
  108541. */
  108542. disableOfflineSupportExceptionRules: RegExp[];
  108543. /**
  108544. * An event triggered when the scene is disposed.
  108545. */
  108546. onDisposeObservable: Observable<Scene>;
  108547. private _onDisposeObserver;
  108548. /** Sets a function to be executed when this scene is disposed. */
  108549. set onDispose(callback: () => void);
  108550. /**
  108551. * An event triggered before rendering the scene (right after animations and physics)
  108552. */
  108553. onBeforeRenderObservable: Observable<Scene>;
  108554. private _onBeforeRenderObserver;
  108555. /** Sets a function to be executed before rendering this scene */
  108556. set beforeRender(callback: Nullable<() => void>);
  108557. /**
  108558. * An event triggered after rendering the scene
  108559. */
  108560. onAfterRenderObservable: Observable<Scene>;
  108561. /**
  108562. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  108563. */
  108564. onAfterRenderCameraObservable: Observable<Camera>;
  108565. private _onAfterRenderObserver;
  108566. /** Sets a function to be executed after rendering this scene */
  108567. set afterRender(callback: Nullable<() => void>);
  108568. /**
  108569. * An event triggered before animating the scene
  108570. */
  108571. onBeforeAnimationsObservable: Observable<Scene>;
  108572. /**
  108573. * An event triggered after animations processing
  108574. */
  108575. onAfterAnimationsObservable: Observable<Scene>;
  108576. /**
  108577. * An event triggered before draw calls are ready to be sent
  108578. */
  108579. onBeforeDrawPhaseObservable: Observable<Scene>;
  108580. /**
  108581. * An event triggered after draw calls have been sent
  108582. */
  108583. onAfterDrawPhaseObservable: Observable<Scene>;
  108584. /**
  108585. * An event triggered when the scene is ready
  108586. */
  108587. onReadyObservable: Observable<Scene>;
  108588. /**
  108589. * An event triggered before rendering a camera
  108590. */
  108591. onBeforeCameraRenderObservable: Observable<Camera>;
  108592. private _onBeforeCameraRenderObserver;
  108593. /** Sets a function to be executed before rendering a camera*/
  108594. set beforeCameraRender(callback: () => void);
  108595. /**
  108596. * An event triggered after rendering a camera
  108597. */
  108598. onAfterCameraRenderObservable: Observable<Camera>;
  108599. private _onAfterCameraRenderObserver;
  108600. /** Sets a function to be executed after rendering a camera*/
  108601. set afterCameraRender(callback: () => void);
  108602. /**
  108603. * An event triggered when active meshes evaluation is about to start
  108604. */
  108605. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  108606. /**
  108607. * An event triggered when active meshes evaluation is done
  108608. */
  108609. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  108610. /**
  108611. * An event triggered when particles rendering is about to start
  108612. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  108613. */
  108614. onBeforeParticlesRenderingObservable: Observable<Scene>;
  108615. /**
  108616. * An event triggered when particles rendering is done
  108617. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  108618. */
  108619. onAfterParticlesRenderingObservable: Observable<Scene>;
  108620. /**
  108621. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  108622. */
  108623. onDataLoadedObservable: Observable<Scene>;
  108624. /**
  108625. * An event triggered when a camera is created
  108626. */
  108627. onNewCameraAddedObservable: Observable<Camera>;
  108628. /**
  108629. * An event triggered when a camera is removed
  108630. */
  108631. onCameraRemovedObservable: Observable<Camera>;
  108632. /**
  108633. * An event triggered when a light is created
  108634. */
  108635. onNewLightAddedObservable: Observable<Light>;
  108636. /**
  108637. * An event triggered when a light is removed
  108638. */
  108639. onLightRemovedObservable: Observable<Light>;
  108640. /**
  108641. * An event triggered when a geometry is created
  108642. */
  108643. onNewGeometryAddedObservable: Observable<Geometry>;
  108644. /**
  108645. * An event triggered when a geometry is removed
  108646. */
  108647. onGeometryRemovedObservable: Observable<Geometry>;
  108648. /**
  108649. * An event triggered when a transform node is created
  108650. */
  108651. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  108652. /**
  108653. * An event triggered when a transform node is removed
  108654. */
  108655. onTransformNodeRemovedObservable: Observable<TransformNode>;
  108656. /**
  108657. * An event triggered when a mesh is created
  108658. */
  108659. onNewMeshAddedObservable: Observable<AbstractMesh>;
  108660. /**
  108661. * An event triggered when a mesh is removed
  108662. */
  108663. onMeshRemovedObservable: Observable<AbstractMesh>;
  108664. /**
  108665. * An event triggered when a skeleton is created
  108666. */
  108667. onNewSkeletonAddedObservable: Observable<Skeleton>;
  108668. /**
  108669. * An event triggered when a skeleton is removed
  108670. */
  108671. onSkeletonRemovedObservable: Observable<Skeleton>;
  108672. /**
  108673. * An event triggered when a material is created
  108674. */
  108675. onNewMaterialAddedObservable: Observable<Material>;
  108676. /**
  108677. * An event triggered when a material is removed
  108678. */
  108679. onMaterialRemovedObservable: Observable<Material>;
  108680. /**
  108681. * An event triggered when a texture is created
  108682. */
  108683. onNewTextureAddedObservable: Observable<BaseTexture>;
  108684. /**
  108685. * An event triggered when a texture is removed
  108686. */
  108687. onTextureRemovedObservable: Observable<BaseTexture>;
  108688. /**
  108689. * An event triggered when render targets are about to be rendered
  108690. * Can happen multiple times per frame.
  108691. */
  108692. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  108693. /**
  108694. * An event triggered when render targets were rendered.
  108695. * Can happen multiple times per frame.
  108696. */
  108697. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  108698. /**
  108699. * An event triggered before calculating deterministic simulation step
  108700. */
  108701. onBeforeStepObservable: Observable<Scene>;
  108702. /**
  108703. * An event triggered after calculating deterministic simulation step
  108704. */
  108705. onAfterStepObservable: Observable<Scene>;
  108706. /**
  108707. * An event triggered when the activeCamera property is updated
  108708. */
  108709. onActiveCameraChanged: Observable<Scene>;
  108710. /**
  108711. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  108712. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  108713. * 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)
  108714. */
  108715. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  108716. /**
  108717. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  108718. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  108719. * 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)
  108720. */
  108721. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  108722. /**
  108723. * This Observable will when a mesh has been imported into the scene.
  108724. */
  108725. onMeshImportedObservable: Observable<AbstractMesh>;
  108726. /**
  108727. * This Observable will when an animation file has been imported into the scene.
  108728. */
  108729. onAnimationFileImportedObservable: Observable<Scene>;
  108730. /**
  108731. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  108732. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  108733. */
  108734. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  108735. /** @hidden */
  108736. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  108737. /**
  108738. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  108739. */
  108740. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  108741. /**
  108742. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  108743. */
  108744. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  108745. /**
  108746. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  108747. */
  108748. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  108749. /** Callback called when a pointer move is detected */
  108750. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  108751. /** Callback called when a pointer down is detected */
  108752. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  108753. /** Callback called when a pointer up is detected */
  108754. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  108755. /** Callback called when a pointer pick is detected */
  108756. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  108757. /**
  108758. * 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).
  108759. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  108760. */
  108761. onPrePointerObservable: Observable<PointerInfoPre>;
  108762. /**
  108763. * Observable event triggered each time an input event is received from the rendering canvas
  108764. */
  108765. onPointerObservable: Observable<PointerInfo>;
  108766. /**
  108767. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  108768. */
  108769. get unTranslatedPointer(): Vector2;
  108770. /**
  108771. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  108772. */
  108773. static get DragMovementThreshold(): number;
  108774. static set DragMovementThreshold(value: number);
  108775. /**
  108776. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  108777. */
  108778. static get LongPressDelay(): number;
  108779. static set LongPressDelay(value: number);
  108780. /**
  108781. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  108782. */
  108783. static get DoubleClickDelay(): number;
  108784. static set DoubleClickDelay(value: number);
  108785. /** If you need to check double click without raising a single click at first click, enable this flag */
  108786. static get ExclusiveDoubleClickMode(): boolean;
  108787. static set ExclusiveDoubleClickMode(value: boolean);
  108788. /** @hidden */
  108789. _mirroredCameraPosition: Nullable<Vector3>;
  108790. /**
  108791. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  108792. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  108793. */
  108794. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  108795. /**
  108796. * Observable event triggered each time an keyboard event is received from the hosting window
  108797. */
  108798. onKeyboardObservable: Observable<KeyboardInfo>;
  108799. private _useRightHandedSystem;
  108800. /**
  108801. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  108802. */
  108803. set useRightHandedSystem(value: boolean);
  108804. get useRightHandedSystem(): boolean;
  108805. private _timeAccumulator;
  108806. private _currentStepId;
  108807. private _currentInternalStep;
  108808. /**
  108809. * Sets the step Id used by deterministic lock step
  108810. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108811. * @param newStepId defines the step Id
  108812. */
  108813. setStepId(newStepId: number): void;
  108814. /**
  108815. * Gets the step Id used by deterministic lock step
  108816. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108817. * @returns the step Id
  108818. */
  108819. getStepId(): number;
  108820. /**
  108821. * Gets the internal step used by deterministic lock step
  108822. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108823. * @returns the internal step
  108824. */
  108825. getInternalStep(): number;
  108826. private _fogEnabled;
  108827. /**
  108828. * Gets or sets a boolean indicating if fog is enabled on this scene
  108829. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108830. * (Default is true)
  108831. */
  108832. set fogEnabled(value: boolean);
  108833. get fogEnabled(): boolean;
  108834. private _fogMode;
  108835. /**
  108836. * Gets or sets the fog mode to use
  108837. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108838. * | mode | value |
  108839. * | --- | --- |
  108840. * | FOGMODE_NONE | 0 |
  108841. * | FOGMODE_EXP | 1 |
  108842. * | FOGMODE_EXP2 | 2 |
  108843. * | FOGMODE_LINEAR | 3 |
  108844. */
  108845. set fogMode(value: number);
  108846. get fogMode(): number;
  108847. /**
  108848. * Gets or sets the fog color to use
  108849. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108850. * (Default is Color3(0.2, 0.2, 0.3))
  108851. */
  108852. fogColor: Color3;
  108853. /**
  108854. * Gets or sets the fog density to use
  108855. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108856. * (Default is 0.1)
  108857. */
  108858. fogDensity: number;
  108859. /**
  108860. * Gets or sets the fog start distance to use
  108861. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108862. * (Default is 0)
  108863. */
  108864. fogStart: number;
  108865. /**
  108866. * Gets or sets the fog end distance to use
  108867. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108868. * (Default is 1000)
  108869. */
  108870. fogEnd: number;
  108871. private _shadowsEnabled;
  108872. /**
  108873. * Gets or sets a boolean indicating if shadows are enabled on this scene
  108874. */
  108875. set shadowsEnabled(value: boolean);
  108876. get shadowsEnabled(): boolean;
  108877. private _lightsEnabled;
  108878. /**
  108879. * Gets or sets a boolean indicating if lights are enabled on this scene
  108880. */
  108881. set lightsEnabled(value: boolean);
  108882. get lightsEnabled(): boolean;
  108883. /** All of the active cameras added to this scene. */
  108884. activeCameras: Camera[];
  108885. /** @hidden */
  108886. _activeCamera: Nullable<Camera>;
  108887. /** Gets or sets the current active camera */
  108888. get activeCamera(): Nullable<Camera>;
  108889. set activeCamera(value: Nullable<Camera>);
  108890. private _defaultMaterial;
  108891. /** The default material used on meshes when no material is affected */
  108892. get defaultMaterial(): Material;
  108893. /** The default material used on meshes when no material is affected */
  108894. set defaultMaterial(value: Material);
  108895. private _texturesEnabled;
  108896. /**
  108897. * Gets or sets a boolean indicating if textures are enabled on this scene
  108898. */
  108899. set texturesEnabled(value: boolean);
  108900. get texturesEnabled(): boolean;
  108901. /**
  108902. * Gets or sets a boolean indicating if particles are enabled on this scene
  108903. */
  108904. particlesEnabled: boolean;
  108905. /**
  108906. * Gets or sets a boolean indicating if sprites are enabled on this scene
  108907. */
  108908. spritesEnabled: boolean;
  108909. private _skeletonsEnabled;
  108910. /**
  108911. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  108912. */
  108913. set skeletonsEnabled(value: boolean);
  108914. get skeletonsEnabled(): boolean;
  108915. /**
  108916. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  108917. */
  108918. lensFlaresEnabled: boolean;
  108919. /**
  108920. * Gets or sets a boolean indicating if collisions are enabled on this scene
  108921. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108922. */
  108923. collisionsEnabled: boolean;
  108924. private _collisionCoordinator;
  108925. /** @hidden */
  108926. get collisionCoordinator(): ICollisionCoordinator;
  108927. /**
  108928. * Defines the gravity applied to this scene (used only for collisions)
  108929. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108930. */
  108931. gravity: Vector3;
  108932. /**
  108933. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  108934. */
  108935. postProcessesEnabled: boolean;
  108936. /**
  108937. * The list of postprocesses added to the scene
  108938. */
  108939. postProcesses: PostProcess[];
  108940. /**
  108941. * Gets the current postprocess manager
  108942. */
  108943. postProcessManager: PostProcessManager;
  108944. /**
  108945. * Gets or sets a boolean indicating if render targets are enabled on this scene
  108946. */
  108947. renderTargetsEnabled: boolean;
  108948. /**
  108949. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  108950. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  108951. */
  108952. dumpNextRenderTargets: boolean;
  108953. /**
  108954. * The list of user defined render targets added to the scene
  108955. */
  108956. customRenderTargets: RenderTargetTexture[];
  108957. /**
  108958. * Defines if texture loading must be delayed
  108959. * If true, textures will only be loaded when they need to be rendered
  108960. */
  108961. useDelayedTextureLoading: boolean;
  108962. /**
  108963. * Gets the list of meshes imported to the scene through SceneLoader
  108964. */
  108965. importedMeshesFiles: String[];
  108966. /**
  108967. * Gets or sets a boolean indicating if probes are enabled on this scene
  108968. */
  108969. probesEnabled: boolean;
  108970. /**
  108971. * Gets or sets the current offline provider to use to store scene data
  108972. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  108973. */
  108974. offlineProvider: IOfflineProvider;
  108975. /**
  108976. * Gets or sets the action manager associated with the scene
  108977. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  108978. */
  108979. actionManager: AbstractActionManager;
  108980. private _meshesForIntersections;
  108981. /**
  108982. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  108983. */
  108984. proceduralTexturesEnabled: boolean;
  108985. private _engine;
  108986. private _totalVertices;
  108987. /** @hidden */
  108988. _activeIndices: PerfCounter;
  108989. /** @hidden */
  108990. _activeParticles: PerfCounter;
  108991. /** @hidden */
  108992. _activeBones: PerfCounter;
  108993. private _animationRatio;
  108994. /** @hidden */
  108995. _animationTimeLast: number;
  108996. /** @hidden */
  108997. _animationTime: number;
  108998. /**
  108999. * Gets or sets a general scale for animation speed
  109000. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  109001. */
  109002. animationTimeScale: number;
  109003. /** @hidden */
  109004. _cachedMaterial: Nullable<Material>;
  109005. /** @hidden */
  109006. _cachedEffect: Nullable<Effect>;
  109007. /** @hidden */
  109008. _cachedVisibility: Nullable<number>;
  109009. private _renderId;
  109010. private _frameId;
  109011. private _executeWhenReadyTimeoutId;
  109012. private _intermediateRendering;
  109013. private _viewUpdateFlag;
  109014. private _projectionUpdateFlag;
  109015. /** @hidden */
  109016. _toBeDisposed: Nullable<IDisposable>[];
  109017. private _activeRequests;
  109018. /** @hidden */
  109019. _pendingData: any[];
  109020. private _isDisposed;
  109021. /**
  109022. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  109023. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  109024. */
  109025. dispatchAllSubMeshesOfActiveMeshes: boolean;
  109026. private _activeMeshes;
  109027. private _processedMaterials;
  109028. private _renderTargets;
  109029. /** @hidden */
  109030. _activeParticleSystems: SmartArray<IParticleSystem>;
  109031. private _activeSkeletons;
  109032. private _softwareSkinnedMeshes;
  109033. private _renderingManager;
  109034. /** @hidden */
  109035. _activeAnimatables: Animatable[];
  109036. private _transformMatrix;
  109037. private _sceneUbo;
  109038. /** @hidden */
  109039. _viewMatrix: Matrix;
  109040. private _projectionMatrix;
  109041. /** @hidden */
  109042. _forcedViewPosition: Nullable<Vector3>;
  109043. /** @hidden */
  109044. _frustumPlanes: Plane[];
  109045. /**
  109046. * Gets the list of frustum planes (built from the active camera)
  109047. */
  109048. get frustumPlanes(): Plane[];
  109049. /**
  109050. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  109051. * This is useful if there are more lights that the maximum simulteanous authorized
  109052. */
  109053. requireLightSorting: boolean;
  109054. /** @hidden */
  109055. readonly useMaterialMeshMap: boolean;
  109056. /** @hidden */
  109057. readonly useClonedMeshMap: boolean;
  109058. private _externalData;
  109059. private _uid;
  109060. /**
  109061. * @hidden
  109062. * Backing store of defined scene components.
  109063. */
  109064. _components: ISceneComponent[];
  109065. /**
  109066. * @hidden
  109067. * Backing store of defined scene components.
  109068. */
  109069. _serializableComponents: ISceneSerializableComponent[];
  109070. /**
  109071. * List of components to register on the next registration step.
  109072. */
  109073. private _transientComponents;
  109074. /**
  109075. * Registers the transient components if needed.
  109076. */
  109077. private _registerTransientComponents;
  109078. /**
  109079. * @hidden
  109080. * Add a component to the scene.
  109081. * Note that the ccomponent could be registered on th next frame if this is called after
  109082. * the register component stage.
  109083. * @param component Defines the component to add to the scene
  109084. */
  109085. _addComponent(component: ISceneComponent): void;
  109086. /**
  109087. * @hidden
  109088. * Gets a component from the scene.
  109089. * @param name defines the name of the component to retrieve
  109090. * @returns the component or null if not present
  109091. */
  109092. _getComponent(name: string): Nullable<ISceneComponent>;
  109093. /**
  109094. * @hidden
  109095. * Defines the actions happening before camera updates.
  109096. */
  109097. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  109098. /**
  109099. * @hidden
  109100. * Defines the actions happening before clear the canvas.
  109101. */
  109102. _beforeClearStage: Stage<SimpleStageAction>;
  109103. /**
  109104. * @hidden
  109105. * Defines the actions when collecting render targets for the frame.
  109106. */
  109107. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  109108. /**
  109109. * @hidden
  109110. * Defines the actions happening for one camera in the frame.
  109111. */
  109112. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  109113. /**
  109114. * @hidden
  109115. * Defines the actions happening during the per mesh ready checks.
  109116. */
  109117. _isReadyForMeshStage: Stage<MeshStageAction>;
  109118. /**
  109119. * @hidden
  109120. * Defines the actions happening before evaluate active mesh checks.
  109121. */
  109122. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  109123. /**
  109124. * @hidden
  109125. * Defines the actions happening during the evaluate sub mesh checks.
  109126. */
  109127. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  109128. /**
  109129. * @hidden
  109130. * Defines the actions happening during the active mesh stage.
  109131. */
  109132. _activeMeshStage: Stage<ActiveMeshStageAction>;
  109133. /**
  109134. * @hidden
  109135. * Defines the actions happening during the per camera render target step.
  109136. */
  109137. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  109138. /**
  109139. * @hidden
  109140. * Defines the actions happening just before the active camera is drawing.
  109141. */
  109142. _beforeCameraDrawStage: Stage<CameraStageAction>;
  109143. /**
  109144. * @hidden
  109145. * Defines the actions happening just before a render target is drawing.
  109146. */
  109147. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  109148. /**
  109149. * @hidden
  109150. * Defines the actions happening just before a rendering group is drawing.
  109151. */
  109152. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  109153. /**
  109154. * @hidden
  109155. * Defines the actions happening just before a mesh is drawing.
  109156. */
  109157. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  109158. /**
  109159. * @hidden
  109160. * Defines the actions happening just after a mesh has been drawn.
  109161. */
  109162. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  109163. /**
  109164. * @hidden
  109165. * Defines the actions happening just after a rendering group has been drawn.
  109166. */
  109167. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  109168. /**
  109169. * @hidden
  109170. * Defines the actions happening just after the active camera has been drawn.
  109171. */
  109172. _afterCameraDrawStage: Stage<CameraStageAction>;
  109173. /**
  109174. * @hidden
  109175. * Defines the actions happening just after a render target has been drawn.
  109176. */
  109177. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  109178. /**
  109179. * @hidden
  109180. * Defines the actions happening just after rendering all cameras and computing intersections.
  109181. */
  109182. _afterRenderStage: Stage<SimpleStageAction>;
  109183. /**
  109184. * @hidden
  109185. * Defines the actions happening when a pointer move event happens.
  109186. */
  109187. _pointerMoveStage: Stage<PointerMoveStageAction>;
  109188. /**
  109189. * @hidden
  109190. * Defines the actions happening when a pointer down event happens.
  109191. */
  109192. _pointerDownStage: Stage<PointerUpDownStageAction>;
  109193. /**
  109194. * @hidden
  109195. * Defines the actions happening when a pointer up event happens.
  109196. */
  109197. _pointerUpStage: Stage<PointerUpDownStageAction>;
  109198. /**
  109199. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  109200. */
  109201. private geometriesByUniqueId;
  109202. /**
  109203. * Creates a new Scene
  109204. * @param engine defines the engine to use to render this scene
  109205. * @param options defines the scene options
  109206. */
  109207. constructor(engine: Engine, options?: SceneOptions);
  109208. /**
  109209. * Gets a string idenfifying the name of the class
  109210. * @returns "Scene" string
  109211. */
  109212. getClassName(): string;
  109213. private _defaultMeshCandidates;
  109214. /**
  109215. * @hidden
  109216. */
  109217. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  109218. private _defaultSubMeshCandidates;
  109219. /**
  109220. * @hidden
  109221. */
  109222. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  109223. /**
  109224. * Sets the default candidate providers for the scene.
  109225. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  109226. * and getCollidingSubMeshCandidates to their default function
  109227. */
  109228. setDefaultCandidateProviders(): void;
  109229. /**
  109230. * Gets the mesh that is currently under the pointer
  109231. */
  109232. get meshUnderPointer(): Nullable<AbstractMesh>;
  109233. /**
  109234. * Gets or sets the current on-screen X position of the pointer
  109235. */
  109236. get pointerX(): number;
  109237. set pointerX(value: number);
  109238. /**
  109239. * Gets or sets the current on-screen Y position of the pointer
  109240. */
  109241. get pointerY(): number;
  109242. set pointerY(value: number);
  109243. /**
  109244. * Gets the cached material (ie. the latest rendered one)
  109245. * @returns the cached material
  109246. */
  109247. getCachedMaterial(): Nullable<Material>;
  109248. /**
  109249. * Gets the cached effect (ie. the latest rendered one)
  109250. * @returns the cached effect
  109251. */
  109252. getCachedEffect(): Nullable<Effect>;
  109253. /**
  109254. * Gets the cached visibility state (ie. the latest rendered one)
  109255. * @returns the cached visibility state
  109256. */
  109257. getCachedVisibility(): Nullable<number>;
  109258. /**
  109259. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  109260. * @param material defines the current material
  109261. * @param effect defines the current effect
  109262. * @param visibility defines the current visibility state
  109263. * @returns true if one parameter is not cached
  109264. */
  109265. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  109266. /**
  109267. * Gets the engine associated with the scene
  109268. * @returns an Engine
  109269. */
  109270. getEngine(): Engine;
  109271. /**
  109272. * Gets the total number of vertices rendered per frame
  109273. * @returns the total number of vertices rendered per frame
  109274. */
  109275. getTotalVertices(): number;
  109276. /**
  109277. * Gets the performance counter for total vertices
  109278. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109279. */
  109280. get totalVerticesPerfCounter(): PerfCounter;
  109281. /**
  109282. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  109283. * @returns the total number of active indices rendered per frame
  109284. */
  109285. getActiveIndices(): number;
  109286. /**
  109287. * Gets the performance counter for active indices
  109288. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109289. */
  109290. get totalActiveIndicesPerfCounter(): PerfCounter;
  109291. /**
  109292. * Gets the total number of active particles rendered per frame
  109293. * @returns the total number of active particles rendered per frame
  109294. */
  109295. getActiveParticles(): number;
  109296. /**
  109297. * Gets the performance counter for active particles
  109298. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109299. */
  109300. get activeParticlesPerfCounter(): PerfCounter;
  109301. /**
  109302. * Gets the total number of active bones rendered per frame
  109303. * @returns the total number of active bones rendered per frame
  109304. */
  109305. getActiveBones(): number;
  109306. /**
  109307. * Gets the performance counter for active bones
  109308. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109309. */
  109310. get activeBonesPerfCounter(): PerfCounter;
  109311. /**
  109312. * Gets the array of active meshes
  109313. * @returns an array of AbstractMesh
  109314. */
  109315. getActiveMeshes(): SmartArray<AbstractMesh>;
  109316. /**
  109317. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  109318. * @returns a number
  109319. */
  109320. getAnimationRatio(): number;
  109321. /**
  109322. * Gets an unique Id for the current render phase
  109323. * @returns a number
  109324. */
  109325. getRenderId(): number;
  109326. /**
  109327. * Gets an unique Id for the current frame
  109328. * @returns a number
  109329. */
  109330. getFrameId(): number;
  109331. /** Call this function if you want to manually increment the render Id*/
  109332. incrementRenderId(): void;
  109333. private _createUbo;
  109334. /**
  109335. * Use this method to simulate a pointer move on a mesh
  109336. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109337. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109338. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109339. * @returns the current scene
  109340. */
  109341. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  109342. /**
  109343. * Use this method to simulate a pointer down on a mesh
  109344. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109345. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109346. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109347. * @returns the current scene
  109348. */
  109349. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  109350. /**
  109351. * Use this method to simulate a pointer up on a mesh
  109352. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109353. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109354. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109355. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  109356. * @returns the current scene
  109357. */
  109358. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  109359. /**
  109360. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  109361. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  109362. * @returns true if the pointer was captured
  109363. */
  109364. isPointerCaptured(pointerId?: number): boolean;
  109365. /**
  109366. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  109367. * @param attachUp defines if you want to attach events to pointerup
  109368. * @param attachDown defines if you want to attach events to pointerdown
  109369. * @param attachMove defines if you want to attach events to pointermove
  109370. */
  109371. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  109372. /** Detaches all event handlers*/
  109373. detachControl(): void;
  109374. /**
  109375. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  109376. * Delay loaded resources are not taking in account
  109377. * @return true if all required resources are ready
  109378. */
  109379. isReady(): boolean;
  109380. /** Resets all cached information relative to material (including effect and visibility) */
  109381. resetCachedMaterial(): void;
  109382. /**
  109383. * Registers a function to be called before every frame render
  109384. * @param func defines the function to register
  109385. */
  109386. registerBeforeRender(func: () => void): void;
  109387. /**
  109388. * Unregisters a function called before every frame render
  109389. * @param func defines the function to unregister
  109390. */
  109391. unregisterBeforeRender(func: () => void): void;
  109392. /**
  109393. * Registers a function to be called after every frame render
  109394. * @param func defines the function to register
  109395. */
  109396. registerAfterRender(func: () => void): void;
  109397. /**
  109398. * Unregisters a function called after every frame render
  109399. * @param func defines the function to unregister
  109400. */
  109401. unregisterAfterRender(func: () => void): void;
  109402. private _executeOnceBeforeRender;
  109403. /**
  109404. * The provided function will run before render once and will be disposed afterwards.
  109405. * A timeout delay can be provided so that the function will be executed in N ms.
  109406. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  109407. * @param func The function to be executed.
  109408. * @param timeout optional delay in ms
  109409. */
  109410. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  109411. /** @hidden */
  109412. _addPendingData(data: any): void;
  109413. /** @hidden */
  109414. _removePendingData(data: any): void;
  109415. /**
  109416. * Returns the number of items waiting to be loaded
  109417. * @returns the number of items waiting to be loaded
  109418. */
  109419. getWaitingItemsCount(): number;
  109420. /**
  109421. * Returns a boolean indicating if the scene is still loading data
  109422. */
  109423. get isLoading(): boolean;
  109424. /**
  109425. * Registers a function to be executed when the scene is ready
  109426. * @param {Function} func - the function to be executed
  109427. */
  109428. executeWhenReady(func: () => void): void;
  109429. /**
  109430. * Returns a promise that resolves when the scene is ready
  109431. * @returns A promise that resolves when the scene is ready
  109432. */
  109433. whenReadyAsync(): Promise<void>;
  109434. /** @hidden */
  109435. _checkIsReady(): void;
  109436. /**
  109437. * Gets all animatable attached to the scene
  109438. */
  109439. get animatables(): Animatable[];
  109440. /**
  109441. * Resets the last animation time frame.
  109442. * Useful to override when animations start running when loading a scene for the first time.
  109443. */
  109444. resetLastAnimationTimeFrame(): void;
  109445. /**
  109446. * Gets the current view matrix
  109447. * @returns a Matrix
  109448. */
  109449. getViewMatrix(): Matrix;
  109450. /**
  109451. * Gets the current projection matrix
  109452. * @returns a Matrix
  109453. */
  109454. getProjectionMatrix(): Matrix;
  109455. /**
  109456. * Gets the current transform matrix
  109457. * @returns a Matrix made of View * Projection
  109458. */
  109459. getTransformMatrix(): Matrix;
  109460. /**
  109461. * Sets the current transform matrix
  109462. * @param viewL defines the View matrix to use
  109463. * @param projectionL defines the Projection matrix to use
  109464. * @param viewR defines the right View matrix to use (if provided)
  109465. * @param projectionR defines the right Projection matrix to use (if provided)
  109466. */
  109467. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  109468. /**
  109469. * Gets the uniform buffer used to store scene data
  109470. * @returns a UniformBuffer
  109471. */
  109472. getSceneUniformBuffer(): UniformBuffer;
  109473. /**
  109474. * Gets an unique (relatively to the current scene) Id
  109475. * @returns an unique number for the scene
  109476. */
  109477. getUniqueId(): number;
  109478. /**
  109479. * Add a mesh to the list of scene's meshes
  109480. * @param newMesh defines the mesh to add
  109481. * @param recursive if all child meshes should also be added to the scene
  109482. */
  109483. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  109484. /**
  109485. * Remove a mesh for the list of scene's meshes
  109486. * @param toRemove defines the mesh to remove
  109487. * @param recursive if all child meshes should also be removed from the scene
  109488. * @returns the index where the mesh was in the mesh list
  109489. */
  109490. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  109491. /**
  109492. * Add a transform node to the list of scene's transform nodes
  109493. * @param newTransformNode defines the transform node to add
  109494. */
  109495. addTransformNode(newTransformNode: TransformNode): void;
  109496. /**
  109497. * Remove a transform node for the list of scene's transform nodes
  109498. * @param toRemove defines the transform node to remove
  109499. * @returns the index where the transform node was in the transform node list
  109500. */
  109501. removeTransformNode(toRemove: TransformNode): number;
  109502. /**
  109503. * Remove a skeleton for the list of scene's skeletons
  109504. * @param toRemove defines the skeleton to remove
  109505. * @returns the index where the skeleton was in the skeleton list
  109506. */
  109507. removeSkeleton(toRemove: Skeleton): number;
  109508. /**
  109509. * Remove a morph target for the list of scene's morph targets
  109510. * @param toRemove defines the morph target to remove
  109511. * @returns the index where the morph target was in the morph target list
  109512. */
  109513. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  109514. /**
  109515. * Remove a light for the list of scene's lights
  109516. * @param toRemove defines the light to remove
  109517. * @returns the index where the light was in the light list
  109518. */
  109519. removeLight(toRemove: Light): number;
  109520. /**
  109521. * Remove a camera for the list of scene's cameras
  109522. * @param toRemove defines the camera to remove
  109523. * @returns the index where the camera was in the camera list
  109524. */
  109525. removeCamera(toRemove: Camera): number;
  109526. /**
  109527. * Remove a particle system for the list of scene's particle systems
  109528. * @param toRemove defines the particle system to remove
  109529. * @returns the index where the particle system was in the particle system list
  109530. */
  109531. removeParticleSystem(toRemove: IParticleSystem): number;
  109532. /**
  109533. * Remove a animation for the list of scene's animations
  109534. * @param toRemove defines the animation to remove
  109535. * @returns the index where the animation was in the animation list
  109536. */
  109537. removeAnimation(toRemove: Animation): number;
  109538. /**
  109539. * Will stop the animation of the given target
  109540. * @param target - the target
  109541. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  109542. * @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)
  109543. */
  109544. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  109545. /**
  109546. * Removes the given animation group from this scene.
  109547. * @param toRemove The animation group to remove
  109548. * @returns The index of the removed animation group
  109549. */
  109550. removeAnimationGroup(toRemove: AnimationGroup): number;
  109551. /**
  109552. * Removes the given multi-material from this scene.
  109553. * @param toRemove The multi-material to remove
  109554. * @returns The index of the removed multi-material
  109555. */
  109556. removeMultiMaterial(toRemove: MultiMaterial): number;
  109557. /**
  109558. * Removes the given material from this scene.
  109559. * @param toRemove The material to remove
  109560. * @returns The index of the removed material
  109561. */
  109562. removeMaterial(toRemove: Material): number;
  109563. /**
  109564. * Removes the given action manager from this scene.
  109565. * @param toRemove The action manager to remove
  109566. * @returns The index of the removed action manager
  109567. */
  109568. removeActionManager(toRemove: AbstractActionManager): number;
  109569. /**
  109570. * Removes the given texture from this scene.
  109571. * @param toRemove The texture to remove
  109572. * @returns The index of the removed texture
  109573. */
  109574. removeTexture(toRemove: BaseTexture): number;
  109575. /**
  109576. * Adds the given light to this scene
  109577. * @param newLight The light to add
  109578. */
  109579. addLight(newLight: Light): void;
  109580. /**
  109581. * Sorts the list list based on light priorities
  109582. */
  109583. sortLightsByPriority(): void;
  109584. /**
  109585. * Adds the given camera to this scene
  109586. * @param newCamera The camera to add
  109587. */
  109588. addCamera(newCamera: Camera): void;
  109589. /**
  109590. * Adds the given skeleton to this scene
  109591. * @param newSkeleton The skeleton to add
  109592. */
  109593. addSkeleton(newSkeleton: Skeleton): void;
  109594. /**
  109595. * Adds the given particle system to this scene
  109596. * @param newParticleSystem The particle system to add
  109597. */
  109598. addParticleSystem(newParticleSystem: IParticleSystem): void;
  109599. /**
  109600. * Adds the given animation to this scene
  109601. * @param newAnimation The animation to add
  109602. */
  109603. addAnimation(newAnimation: Animation): void;
  109604. /**
  109605. * Adds the given animation group to this scene.
  109606. * @param newAnimationGroup The animation group to add
  109607. */
  109608. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  109609. /**
  109610. * Adds the given multi-material to this scene
  109611. * @param newMultiMaterial The multi-material to add
  109612. */
  109613. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  109614. /**
  109615. * Adds the given material to this scene
  109616. * @param newMaterial The material to add
  109617. */
  109618. addMaterial(newMaterial: Material): void;
  109619. /**
  109620. * Adds the given morph target to this scene
  109621. * @param newMorphTargetManager The morph target to add
  109622. */
  109623. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  109624. /**
  109625. * Adds the given geometry to this scene
  109626. * @param newGeometry The geometry to add
  109627. */
  109628. addGeometry(newGeometry: Geometry): void;
  109629. /**
  109630. * Adds the given action manager to this scene
  109631. * @param newActionManager The action manager to add
  109632. */
  109633. addActionManager(newActionManager: AbstractActionManager): void;
  109634. /**
  109635. * Adds the given texture to this scene.
  109636. * @param newTexture The texture to add
  109637. */
  109638. addTexture(newTexture: BaseTexture): void;
  109639. /**
  109640. * Switch active camera
  109641. * @param newCamera defines the new active camera
  109642. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  109643. */
  109644. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  109645. /**
  109646. * sets the active camera of the scene using its ID
  109647. * @param id defines the camera's ID
  109648. * @return the new active camera or null if none found.
  109649. */
  109650. setActiveCameraByID(id: string): Nullable<Camera>;
  109651. /**
  109652. * sets the active camera of the scene using its name
  109653. * @param name defines the camera's name
  109654. * @returns the new active camera or null if none found.
  109655. */
  109656. setActiveCameraByName(name: string): Nullable<Camera>;
  109657. /**
  109658. * get an animation group using its name
  109659. * @param name defines the material's name
  109660. * @return the animation group or null if none found.
  109661. */
  109662. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  109663. /**
  109664. * Get a material using its unique id
  109665. * @param uniqueId defines the material's unique id
  109666. * @return the material or null if none found.
  109667. */
  109668. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  109669. /**
  109670. * get a material using its id
  109671. * @param id defines the material's ID
  109672. * @return the material or null if none found.
  109673. */
  109674. getMaterialByID(id: string): Nullable<Material>;
  109675. /**
  109676. * Gets a the last added material using a given id
  109677. * @param id defines the material's ID
  109678. * @return the last material with the given id or null if none found.
  109679. */
  109680. getLastMaterialByID(id: string): Nullable<Material>;
  109681. /**
  109682. * Gets a material using its name
  109683. * @param name defines the material's name
  109684. * @return the material or null if none found.
  109685. */
  109686. getMaterialByName(name: string): Nullable<Material>;
  109687. /**
  109688. * Get a texture using its unique id
  109689. * @param uniqueId defines the texture's unique id
  109690. * @return the texture or null if none found.
  109691. */
  109692. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  109693. /**
  109694. * Gets a camera using its id
  109695. * @param id defines the id to look for
  109696. * @returns the camera or null if not found
  109697. */
  109698. getCameraByID(id: string): Nullable<Camera>;
  109699. /**
  109700. * Gets a camera using its unique id
  109701. * @param uniqueId defines the unique id to look for
  109702. * @returns the camera or null if not found
  109703. */
  109704. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  109705. /**
  109706. * Gets a camera using its name
  109707. * @param name defines the camera's name
  109708. * @return the camera or null if none found.
  109709. */
  109710. getCameraByName(name: string): Nullable<Camera>;
  109711. /**
  109712. * Gets a bone using its id
  109713. * @param id defines the bone's id
  109714. * @return the bone or null if not found
  109715. */
  109716. getBoneByID(id: string): Nullable<Bone>;
  109717. /**
  109718. * Gets a bone using its id
  109719. * @param name defines the bone's name
  109720. * @return the bone or null if not found
  109721. */
  109722. getBoneByName(name: string): Nullable<Bone>;
  109723. /**
  109724. * Gets a light node using its name
  109725. * @param name defines the the light's name
  109726. * @return the light or null if none found.
  109727. */
  109728. getLightByName(name: string): Nullable<Light>;
  109729. /**
  109730. * Gets a light node using its id
  109731. * @param id defines the light's id
  109732. * @return the light or null if none found.
  109733. */
  109734. getLightByID(id: string): Nullable<Light>;
  109735. /**
  109736. * Gets a light node using its scene-generated unique ID
  109737. * @param uniqueId defines the light's unique id
  109738. * @return the light or null if none found.
  109739. */
  109740. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  109741. /**
  109742. * Gets a particle system by id
  109743. * @param id defines the particle system id
  109744. * @return the corresponding system or null if none found
  109745. */
  109746. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  109747. /**
  109748. * Gets a geometry using its ID
  109749. * @param id defines the geometry's id
  109750. * @return the geometry or null if none found.
  109751. */
  109752. getGeometryByID(id: string): Nullable<Geometry>;
  109753. private _getGeometryByUniqueID;
  109754. /**
  109755. * Add a new geometry to this scene
  109756. * @param geometry defines the geometry to be added to the scene.
  109757. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  109758. * @return a boolean defining if the geometry was added or not
  109759. */
  109760. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  109761. /**
  109762. * Removes an existing geometry
  109763. * @param geometry defines the geometry to be removed from the scene
  109764. * @return a boolean defining if the geometry was removed or not
  109765. */
  109766. removeGeometry(geometry: Geometry): boolean;
  109767. /**
  109768. * Gets the list of geometries attached to the scene
  109769. * @returns an array of Geometry
  109770. */
  109771. getGeometries(): Geometry[];
  109772. /**
  109773. * Gets the first added mesh found of a given ID
  109774. * @param id defines the id to search for
  109775. * @return the mesh found or null if not found at all
  109776. */
  109777. getMeshByID(id: string): Nullable<AbstractMesh>;
  109778. /**
  109779. * Gets a list of meshes using their id
  109780. * @param id defines the id to search for
  109781. * @returns a list of meshes
  109782. */
  109783. getMeshesByID(id: string): Array<AbstractMesh>;
  109784. /**
  109785. * Gets the first added transform node found of a given ID
  109786. * @param id defines the id to search for
  109787. * @return the found transform node or null if not found at all.
  109788. */
  109789. getTransformNodeByID(id: string): Nullable<TransformNode>;
  109790. /**
  109791. * Gets a transform node with its auto-generated unique id
  109792. * @param uniqueId efines the unique id to search for
  109793. * @return the found transform node or null if not found at all.
  109794. */
  109795. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  109796. /**
  109797. * Gets a list of transform nodes using their id
  109798. * @param id defines the id to search for
  109799. * @returns a list of transform nodes
  109800. */
  109801. getTransformNodesByID(id: string): Array<TransformNode>;
  109802. /**
  109803. * Gets a mesh with its auto-generated unique id
  109804. * @param uniqueId defines the unique id to search for
  109805. * @return the found mesh or null if not found at all.
  109806. */
  109807. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  109808. /**
  109809. * Gets a the last added mesh using a given id
  109810. * @param id defines the id to search for
  109811. * @return the found mesh or null if not found at all.
  109812. */
  109813. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  109814. /**
  109815. * Gets a the last added node (Mesh, Camera, Light) using a given id
  109816. * @param id defines the id to search for
  109817. * @return the found node or null if not found at all
  109818. */
  109819. getLastEntryByID(id: string): Nullable<Node>;
  109820. /**
  109821. * Gets a node (Mesh, Camera, Light) using a given id
  109822. * @param id defines the id to search for
  109823. * @return the found node or null if not found at all
  109824. */
  109825. getNodeByID(id: string): Nullable<Node>;
  109826. /**
  109827. * Gets a node (Mesh, Camera, Light) using a given name
  109828. * @param name defines the name to search for
  109829. * @return the found node or null if not found at all.
  109830. */
  109831. getNodeByName(name: string): Nullable<Node>;
  109832. /**
  109833. * Gets a mesh using a given name
  109834. * @param name defines the name to search for
  109835. * @return the found mesh or null if not found at all.
  109836. */
  109837. getMeshByName(name: string): Nullable<AbstractMesh>;
  109838. /**
  109839. * Gets a transform node using a given name
  109840. * @param name defines the name to search for
  109841. * @return the found transform node or null if not found at all.
  109842. */
  109843. getTransformNodeByName(name: string): Nullable<TransformNode>;
  109844. /**
  109845. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  109846. * @param id defines the id to search for
  109847. * @return the found skeleton or null if not found at all.
  109848. */
  109849. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  109850. /**
  109851. * Gets a skeleton using a given auto generated unique id
  109852. * @param uniqueId defines the unique id to search for
  109853. * @return the found skeleton or null if not found at all.
  109854. */
  109855. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  109856. /**
  109857. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  109858. * @param id defines the id to search for
  109859. * @return the found skeleton or null if not found at all.
  109860. */
  109861. getSkeletonById(id: string): Nullable<Skeleton>;
  109862. /**
  109863. * Gets a skeleton using a given name
  109864. * @param name defines the name to search for
  109865. * @return the found skeleton or null if not found at all.
  109866. */
  109867. getSkeletonByName(name: string): Nullable<Skeleton>;
  109868. /**
  109869. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  109870. * @param id defines the id to search for
  109871. * @return the found morph target manager or null if not found at all.
  109872. */
  109873. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  109874. /**
  109875. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  109876. * @param id defines the id to search for
  109877. * @return the found morph target or null if not found at all.
  109878. */
  109879. getMorphTargetById(id: string): Nullable<MorphTarget>;
  109880. /**
  109881. * Gets a boolean indicating if the given mesh is active
  109882. * @param mesh defines the mesh to look for
  109883. * @returns true if the mesh is in the active list
  109884. */
  109885. isActiveMesh(mesh: AbstractMesh): boolean;
  109886. /**
  109887. * Return a unique id as a string which can serve as an identifier for the scene
  109888. */
  109889. get uid(): string;
  109890. /**
  109891. * Add an externaly attached data from its key.
  109892. * This method call will fail and return false, if such key already exists.
  109893. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  109894. * @param key the unique key that identifies the data
  109895. * @param data the data object to associate to the key for this Engine instance
  109896. * @return true if no such key were already present and the data was added successfully, false otherwise
  109897. */
  109898. addExternalData<T>(key: string, data: T): boolean;
  109899. /**
  109900. * Get an externaly attached data from its key
  109901. * @param key the unique key that identifies the data
  109902. * @return the associated data, if present (can be null), or undefined if not present
  109903. */
  109904. getExternalData<T>(key: string): Nullable<T>;
  109905. /**
  109906. * Get an externaly attached data from its key, create it using a factory if it's not already present
  109907. * @param key the unique key that identifies the data
  109908. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  109909. * @return the associated data, can be null if the factory returned null.
  109910. */
  109911. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  109912. /**
  109913. * Remove an externaly attached data from the Engine instance
  109914. * @param key the unique key that identifies the data
  109915. * @return true if the data was successfully removed, false if it doesn't exist
  109916. */
  109917. removeExternalData(key: string): boolean;
  109918. private _evaluateSubMesh;
  109919. /**
  109920. * Clear the processed materials smart array preventing retention point in material dispose.
  109921. */
  109922. freeProcessedMaterials(): void;
  109923. private _preventFreeActiveMeshesAndRenderingGroups;
  109924. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  109925. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  109926. * when disposing several meshes in a row or a hierarchy of meshes.
  109927. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  109928. */
  109929. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  109930. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  109931. /**
  109932. * Clear the active meshes smart array preventing retention point in mesh dispose.
  109933. */
  109934. freeActiveMeshes(): void;
  109935. /**
  109936. * Clear the info related to rendering groups preventing retention points during dispose.
  109937. */
  109938. freeRenderingGroups(): void;
  109939. /** @hidden */
  109940. _isInIntermediateRendering(): boolean;
  109941. /**
  109942. * Lambda returning the list of potentially active meshes.
  109943. */
  109944. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  109945. /**
  109946. * Lambda returning the list of potentially active sub meshes.
  109947. */
  109948. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  109949. /**
  109950. * Lambda returning the list of potentially intersecting sub meshes.
  109951. */
  109952. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  109953. /**
  109954. * Lambda returning the list of potentially colliding sub meshes.
  109955. */
  109956. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  109957. private _activeMeshesFrozen;
  109958. private _skipEvaluateActiveMeshesCompletely;
  109959. /**
  109960. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  109961. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  109962. * @returns the current scene
  109963. */
  109964. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  109965. /**
  109966. * Use this function to restart evaluating active meshes on every frame
  109967. * @returns the current scene
  109968. */
  109969. unfreezeActiveMeshes(): Scene;
  109970. private _evaluateActiveMeshes;
  109971. private _activeMesh;
  109972. /**
  109973. * Update the transform matrix to update from the current active camera
  109974. * @param force defines a boolean used to force the update even if cache is up to date
  109975. */
  109976. updateTransformMatrix(force?: boolean): void;
  109977. private _bindFrameBuffer;
  109978. /** @hidden */
  109979. _allowPostProcessClearColor: boolean;
  109980. /** @hidden */
  109981. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  109982. private _processSubCameras;
  109983. private _checkIntersections;
  109984. /** @hidden */
  109985. _advancePhysicsEngineStep(step: number): void;
  109986. /**
  109987. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  109988. */
  109989. getDeterministicFrameTime: () => number;
  109990. /** @hidden */
  109991. _animate(): void;
  109992. /** Execute all animations (for a frame) */
  109993. animate(): void;
  109994. /**
  109995. * Render the scene
  109996. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  109997. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  109998. */
  109999. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  110000. /**
  110001. * Freeze all materials
  110002. * A frozen material will not be updatable but should be faster to render
  110003. */
  110004. freezeMaterials(): void;
  110005. /**
  110006. * Unfreeze all materials
  110007. * A frozen material will not be updatable but should be faster to render
  110008. */
  110009. unfreezeMaterials(): void;
  110010. /**
  110011. * Releases all held ressources
  110012. */
  110013. dispose(): void;
  110014. /**
  110015. * Gets if the scene is already disposed
  110016. */
  110017. get isDisposed(): boolean;
  110018. /**
  110019. * Call this function to reduce memory footprint of the scene.
  110020. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  110021. */
  110022. clearCachedVertexData(): void;
  110023. /**
  110024. * This function will remove the local cached buffer data from texture.
  110025. * It will save memory but will prevent the texture from being rebuilt
  110026. */
  110027. cleanCachedTextureBuffer(): void;
  110028. /**
  110029. * Get the world extend vectors with an optional filter
  110030. *
  110031. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  110032. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  110033. */
  110034. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  110035. min: Vector3;
  110036. max: Vector3;
  110037. };
  110038. /**
  110039. * Creates a ray that can be used to pick in the scene
  110040. * @param x defines the x coordinate of the origin (on-screen)
  110041. * @param y defines the y coordinate of the origin (on-screen)
  110042. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  110043. * @param camera defines the camera to use for the picking
  110044. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  110045. * @returns a Ray
  110046. */
  110047. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  110048. /**
  110049. * Creates a ray that can be used to pick in the scene
  110050. * @param x defines the x coordinate of the origin (on-screen)
  110051. * @param y defines the y coordinate of the origin (on-screen)
  110052. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  110053. * @param result defines the ray where to store the picking ray
  110054. * @param camera defines the camera to use for the picking
  110055. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  110056. * @returns the current scene
  110057. */
  110058. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  110059. /**
  110060. * Creates a ray that can be used to pick in the scene
  110061. * @param x defines the x coordinate of the origin (on-screen)
  110062. * @param y defines the y coordinate of the origin (on-screen)
  110063. * @param camera defines the camera to use for the picking
  110064. * @returns a Ray
  110065. */
  110066. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  110067. /**
  110068. * Creates a ray that can be used to pick in the scene
  110069. * @param x defines the x coordinate of the origin (on-screen)
  110070. * @param y defines the y coordinate of the origin (on-screen)
  110071. * @param result defines the ray where to store the picking ray
  110072. * @param camera defines the camera to use for the picking
  110073. * @returns the current scene
  110074. */
  110075. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  110076. /** Launch a ray to try to pick a mesh in the scene
  110077. * @param x position on screen
  110078. * @param y position on screen
  110079. * @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
  110080. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  110081. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  110082. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110083. * @returns a PickingInfo
  110084. */
  110085. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  110086. /** Use the given ray to pick a mesh in the scene
  110087. * @param ray The ray to use to pick meshes
  110088. * @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
  110089. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  110090. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110091. * @returns a PickingInfo
  110092. */
  110093. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  110094. /**
  110095. * Launch a ray to try to pick a mesh in the scene
  110096. * @param x X position on screen
  110097. * @param y Y position on screen
  110098. * @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
  110099. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  110100. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110101. * @returns an array of PickingInfo
  110102. */
  110103. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  110104. /**
  110105. * Launch a ray to try to pick a mesh in the scene
  110106. * @param ray Ray to use
  110107. * @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
  110108. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110109. * @returns an array of PickingInfo
  110110. */
  110111. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  110112. /**
  110113. * Force the value of meshUnderPointer
  110114. * @param mesh defines the mesh to use
  110115. */
  110116. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  110117. /**
  110118. * Gets the mesh under the pointer
  110119. * @returns a Mesh or null if no mesh is under the pointer
  110120. */
  110121. getPointerOverMesh(): Nullable<AbstractMesh>;
  110122. /** @hidden */
  110123. _rebuildGeometries(): void;
  110124. /** @hidden */
  110125. _rebuildTextures(): void;
  110126. private _getByTags;
  110127. /**
  110128. * Get a list of meshes by tags
  110129. * @param tagsQuery defines the tags query to use
  110130. * @param forEach defines a predicate used to filter results
  110131. * @returns an array of Mesh
  110132. */
  110133. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  110134. /**
  110135. * Get a list of cameras by tags
  110136. * @param tagsQuery defines the tags query to use
  110137. * @param forEach defines a predicate used to filter results
  110138. * @returns an array of Camera
  110139. */
  110140. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  110141. /**
  110142. * Get a list of lights by tags
  110143. * @param tagsQuery defines the tags query to use
  110144. * @param forEach defines a predicate used to filter results
  110145. * @returns an array of Light
  110146. */
  110147. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  110148. /**
  110149. * Get a list of materials by tags
  110150. * @param tagsQuery defines the tags query to use
  110151. * @param forEach defines a predicate used to filter results
  110152. * @returns an array of Material
  110153. */
  110154. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  110155. /**
  110156. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  110157. * This allowed control for front to back rendering or reversly depending of the special needs.
  110158. *
  110159. * @param renderingGroupId The rendering group id corresponding to its index
  110160. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  110161. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  110162. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  110163. */
  110164. 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;
  110165. /**
  110166. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  110167. *
  110168. * @param renderingGroupId The rendering group id corresponding to its index
  110169. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  110170. * @param depth Automatically clears depth between groups if true and autoClear is true.
  110171. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  110172. */
  110173. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  110174. /**
  110175. * Gets the current auto clear configuration for one rendering group of the rendering
  110176. * manager.
  110177. * @param index the rendering group index to get the information for
  110178. * @returns The auto clear setup for the requested rendering group
  110179. */
  110180. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  110181. private _blockMaterialDirtyMechanism;
  110182. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  110183. get blockMaterialDirtyMechanism(): boolean;
  110184. set blockMaterialDirtyMechanism(value: boolean);
  110185. /**
  110186. * Will flag all materials as dirty to trigger new shader compilation
  110187. * @param flag defines the flag used to specify which material part must be marked as dirty
  110188. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  110189. */
  110190. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  110191. /** @hidden */
  110192. _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;
  110193. /** @hidden */
  110194. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  110195. /** @hidden */
  110196. _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;
  110197. /** @hidden */
  110198. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  110199. /** @hidden */
  110200. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  110201. /** @hidden */
  110202. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  110203. }
  110204. }
  110205. declare module BABYLON {
  110206. /**
  110207. * Set of assets to keep when moving a scene into an asset container.
  110208. */
  110209. export class KeepAssets extends AbstractScene {
  110210. }
  110211. /**
  110212. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  110213. */
  110214. export class InstantiatedEntries {
  110215. /**
  110216. * List of new root nodes (eg. nodes with no parent)
  110217. */
  110218. rootNodes: TransformNode[];
  110219. /**
  110220. * List of new skeletons
  110221. */
  110222. skeletons: Skeleton[];
  110223. /**
  110224. * List of new animation groups
  110225. */
  110226. animationGroups: AnimationGroup[];
  110227. }
  110228. /**
  110229. * Container with a set of assets that can be added or removed from a scene.
  110230. */
  110231. export class AssetContainer extends AbstractScene {
  110232. private _wasAddedToScene;
  110233. /**
  110234. * The scene the AssetContainer belongs to.
  110235. */
  110236. scene: Scene;
  110237. /**
  110238. * Instantiates an AssetContainer.
  110239. * @param scene The scene the AssetContainer belongs to.
  110240. */
  110241. constructor(scene: Scene);
  110242. /**
  110243. * Instantiate or clone all meshes and add the new ones to the scene.
  110244. * Skeletons and animation groups will all be cloned
  110245. * @param nameFunction defines an optional function used to get new names for clones
  110246. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  110247. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  110248. */
  110249. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  110250. /**
  110251. * Adds all the assets from the container to the scene.
  110252. */
  110253. addAllToScene(): void;
  110254. /**
  110255. * Removes all the assets in the container from the scene
  110256. */
  110257. removeAllFromScene(): void;
  110258. /**
  110259. * Disposes all the assets in the container
  110260. */
  110261. dispose(): void;
  110262. private _moveAssets;
  110263. /**
  110264. * Removes all the assets contained in the scene and adds them to the container.
  110265. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  110266. */
  110267. moveAllFromScene(keepAssets?: KeepAssets): void;
  110268. /**
  110269. * 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.
  110270. * @returns the root mesh
  110271. */
  110272. createRootMesh(): Mesh;
  110273. /**
  110274. * Merge animations from this asset container into a scene
  110275. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  110276. * @param animatables set of animatables to retarget to a node from the scene
  110277. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  110278. */
  110279. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  110280. }
  110281. }
  110282. declare module BABYLON {
  110283. /**
  110284. * Defines how the parser contract is defined.
  110285. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  110286. */
  110287. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  110288. /**
  110289. * Defines how the individual parser contract is defined.
  110290. * These parser can parse an individual asset
  110291. */
  110292. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  110293. /**
  110294. * Base class of the scene acting as a container for the different elements composing a scene.
  110295. * This class is dynamically extended by the different components of the scene increasing
  110296. * flexibility and reducing coupling
  110297. */
  110298. export abstract class AbstractScene {
  110299. /**
  110300. * Stores the list of available parsers in the application.
  110301. */
  110302. private static _BabylonFileParsers;
  110303. /**
  110304. * Stores the list of available individual parsers in the application.
  110305. */
  110306. private static _IndividualBabylonFileParsers;
  110307. /**
  110308. * Adds a parser in the list of available ones
  110309. * @param name Defines the name of the parser
  110310. * @param parser Defines the parser to add
  110311. */
  110312. static AddParser(name: string, parser: BabylonFileParser): void;
  110313. /**
  110314. * Gets a general parser from the list of avaialble ones
  110315. * @param name Defines the name of the parser
  110316. * @returns the requested parser or null
  110317. */
  110318. static GetParser(name: string): Nullable<BabylonFileParser>;
  110319. /**
  110320. * Adds n individual parser in the list of available ones
  110321. * @param name Defines the name of the parser
  110322. * @param parser Defines the parser to add
  110323. */
  110324. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  110325. /**
  110326. * Gets an individual parser from the list of avaialble ones
  110327. * @param name Defines the name of the parser
  110328. * @returns the requested parser or null
  110329. */
  110330. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  110331. /**
  110332. * Parser json data and populate both a scene and its associated container object
  110333. * @param jsonData Defines the data to parse
  110334. * @param scene Defines the scene to parse the data for
  110335. * @param container Defines the container attached to the parsing sequence
  110336. * @param rootUrl Defines the root url of the data
  110337. */
  110338. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  110339. /**
  110340. * Gets the list of root nodes (ie. nodes with no parent)
  110341. */
  110342. rootNodes: Node[];
  110343. /** All of the cameras added to this scene
  110344. * @see http://doc.babylonjs.com/babylon101/cameras
  110345. */
  110346. cameras: Camera[];
  110347. /**
  110348. * All of the lights added to this scene
  110349. * @see http://doc.babylonjs.com/babylon101/lights
  110350. */
  110351. lights: Light[];
  110352. /**
  110353. * All of the (abstract) meshes added to this scene
  110354. */
  110355. meshes: AbstractMesh[];
  110356. /**
  110357. * The list of skeletons added to the scene
  110358. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  110359. */
  110360. skeletons: Skeleton[];
  110361. /**
  110362. * All of the particle systems added to this scene
  110363. * @see http://doc.babylonjs.com/babylon101/particles
  110364. */
  110365. particleSystems: IParticleSystem[];
  110366. /**
  110367. * Gets a list of Animations associated with the scene
  110368. */
  110369. animations: Animation[];
  110370. /**
  110371. * All of the animation groups added to this scene
  110372. * @see http://doc.babylonjs.com/how_to/group
  110373. */
  110374. animationGroups: AnimationGroup[];
  110375. /**
  110376. * All of the multi-materials added to this scene
  110377. * @see http://doc.babylonjs.com/how_to/multi_materials
  110378. */
  110379. multiMaterials: MultiMaterial[];
  110380. /**
  110381. * All of the materials added to this scene
  110382. * In the context of a Scene, it is not supposed to be modified manually.
  110383. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  110384. * Note also that the order of the Material within the array is not significant and might change.
  110385. * @see http://doc.babylonjs.com/babylon101/materials
  110386. */
  110387. materials: Material[];
  110388. /**
  110389. * The list of morph target managers added to the scene
  110390. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  110391. */
  110392. morphTargetManagers: MorphTargetManager[];
  110393. /**
  110394. * The list of geometries used in the scene.
  110395. */
  110396. geometries: Geometry[];
  110397. /**
  110398. * All of the tranform nodes added to this scene
  110399. * In the context of a Scene, it is not supposed to be modified manually.
  110400. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  110401. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  110402. * @see http://doc.babylonjs.com/how_to/transformnode
  110403. */
  110404. transformNodes: TransformNode[];
  110405. /**
  110406. * ActionManagers available on the scene.
  110407. */
  110408. actionManagers: AbstractActionManager[];
  110409. /**
  110410. * Textures to keep.
  110411. */
  110412. textures: BaseTexture[];
  110413. /**
  110414. * Environment texture for the scene
  110415. */
  110416. environmentTexture: Nullable<BaseTexture>;
  110417. /**
  110418. * @returns all meshes, lights, cameras, transformNodes and bones
  110419. */
  110420. getNodes(): Array<Node>;
  110421. }
  110422. }
  110423. declare module BABYLON {
  110424. /**
  110425. * Interface used to define options for Sound class
  110426. */
  110427. export interface ISoundOptions {
  110428. /**
  110429. * Does the sound autoplay once loaded.
  110430. */
  110431. autoplay?: boolean;
  110432. /**
  110433. * Does the sound loop after it finishes playing once.
  110434. */
  110435. loop?: boolean;
  110436. /**
  110437. * Sound's volume
  110438. */
  110439. volume?: number;
  110440. /**
  110441. * Is it a spatial sound?
  110442. */
  110443. spatialSound?: boolean;
  110444. /**
  110445. * Maximum distance to hear that sound
  110446. */
  110447. maxDistance?: number;
  110448. /**
  110449. * Uses user defined attenuation function
  110450. */
  110451. useCustomAttenuation?: boolean;
  110452. /**
  110453. * Define the roll off factor of spatial sounds.
  110454. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110455. */
  110456. rolloffFactor?: number;
  110457. /**
  110458. * Define the reference distance the sound should be heard perfectly.
  110459. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110460. */
  110461. refDistance?: number;
  110462. /**
  110463. * Define the distance attenuation model the sound will follow.
  110464. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110465. */
  110466. distanceModel?: string;
  110467. /**
  110468. * Defines the playback speed (1 by default)
  110469. */
  110470. playbackRate?: number;
  110471. /**
  110472. * Defines if the sound is from a streaming source
  110473. */
  110474. streaming?: boolean;
  110475. /**
  110476. * Defines an optional length (in seconds) inside the sound file
  110477. */
  110478. length?: number;
  110479. /**
  110480. * Defines an optional offset (in seconds) inside the sound file
  110481. */
  110482. offset?: number;
  110483. /**
  110484. * If true, URLs will not be required to state the audio file codec to use.
  110485. */
  110486. skipCodecCheck?: boolean;
  110487. }
  110488. /**
  110489. * Defines a sound that can be played in the application.
  110490. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  110491. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110492. */
  110493. export class Sound {
  110494. /**
  110495. * The name of the sound in the scene.
  110496. */
  110497. name: string;
  110498. /**
  110499. * Does the sound autoplay once loaded.
  110500. */
  110501. autoplay: boolean;
  110502. /**
  110503. * Does the sound loop after it finishes playing once.
  110504. */
  110505. loop: boolean;
  110506. /**
  110507. * Does the sound use a custom attenuation curve to simulate the falloff
  110508. * happening when the source gets further away from the camera.
  110509. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  110510. */
  110511. useCustomAttenuation: boolean;
  110512. /**
  110513. * The sound track id this sound belongs to.
  110514. */
  110515. soundTrackId: number;
  110516. /**
  110517. * Is this sound currently played.
  110518. */
  110519. isPlaying: boolean;
  110520. /**
  110521. * Is this sound currently paused.
  110522. */
  110523. isPaused: boolean;
  110524. /**
  110525. * Does this sound enables spatial sound.
  110526. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110527. */
  110528. spatialSound: boolean;
  110529. /**
  110530. * Define the reference distance the sound should be heard perfectly.
  110531. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110532. */
  110533. refDistance: number;
  110534. /**
  110535. * Define the roll off factor of spatial sounds.
  110536. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110537. */
  110538. rolloffFactor: number;
  110539. /**
  110540. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  110541. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110542. */
  110543. maxDistance: number;
  110544. /**
  110545. * Define the distance attenuation model the sound will follow.
  110546. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110547. */
  110548. distanceModel: string;
  110549. /**
  110550. * @hidden
  110551. * Back Compat
  110552. **/
  110553. onended: () => any;
  110554. /**
  110555. * Observable event when the current playing sound finishes.
  110556. */
  110557. onEndedObservable: Observable<Sound>;
  110558. private _panningModel;
  110559. private _playbackRate;
  110560. private _streaming;
  110561. private _startTime;
  110562. private _startOffset;
  110563. private _position;
  110564. /** @hidden */
  110565. _positionInEmitterSpace: boolean;
  110566. private _localDirection;
  110567. private _volume;
  110568. private _isReadyToPlay;
  110569. private _isDirectional;
  110570. private _readyToPlayCallback;
  110571. private _audioBuffer;
  110572. private _soundSource;
  110573. private _streamingSource;
  110574. private _soundPanner;
  110575. private _soundGain;
  110576. private _inputAudioNode;
  110577. private _outputAudioNode;
  110578. private _coneInnerAngle;
  110579. private _coneOuterAngle;
  110580. private _coneOuterGain;
  110581. private _scene;
  110582. private _connectedTransformNode;
  110583. private _customAttenuationFunction;
  110584. private _registerFunc;
  110585. private _isOutputConnected;
  110586. private _htmlAudioElement;
  110587. private _urlType;
  110588. private _length?;
  110589. private _offset?;
  110590. /** @hidden */
  110591. static _SceneComponentInitialization: (scene: Scene) => void;
  110592. /**
  110593. * Create a sound and attach it to a scene
  110594. * @param name Name of your sound
  110595. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  110596. * @param scene defines the scene the sound belongs to
  110597. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  110598. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  110599. */
  110600. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  110601. /**
  110602. * Release the sound and its associated resources
  110603. */
  110604. dispose(): void;
  110605. /**
  110606. * Gets if the sounds is ready to be played or not.
  110607. * @returns true if ready, otherwise false
  110608. */
  110609. isReady(): boolean;
  110610. private _soundLoaded;
  110611. /**
  110612. * Sets the data of the sound from an audiobuffer
  110613. * @param audioBuffer The audioBuffer containing the data
  110614. */
  110615. setAudioBuffer(audioBuffer: AudioBuffer): void;
  110616. /**
  110617. * Updates the current sounds options such as maxdistance, loop...
  110618. * @param options A JSON object containing values named as the object properties
  110619. */
  110620. updateOptions(options: ISoundOptions): void;
  110621. private _createSpatialParameters;
  110622. private _updateSpatialParameters;
  110623. /**
  110624. * Switch the panning model to HRTF:
  110625. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  110626. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110627. */
  110628. switchPanningModelToHRTF(): void;
  110629. /**
  110630. * Switch the panning model to Equal Power:
  110631. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  110632. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110633. */
  110634. switchPanningModelToEqualPower(): void;
  110635. private _switchPanningModel;
  110636. /**
  110637. * Connect this sound to a sound track audio node like gain...
  110638. * @param soundTrackAudioNode the sound track audio node to connect to
  110639. */
  110640. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  110641. /**
  110642. * Transform this sound into a directional source
  110643. * @param coneInnerAngle Size of the inner cone in degree
  110644. * @param coneOuterAngle Size of the outer cone in degree
  110645. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  110646. */
  110647. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  110648. /**
  110649. * Gets or sets the inner angle for the directional cone.
  110650. */
  110651. get directionalConeInnerAngle(): number;
  110652. /**
  110653. * Gets or sets the inner angle for the directional cone.
  110654. */
  110655. set directionalConeInnerAngle(value: number);
  110656. /**
  110657. * Gets or sets the outer angle for the directional cone.
  110658. */
  110659. get directionalConeOuterAngle(): number;
  110660. /**
  110661. * Gets or sets the outer angle for the directional cone.
  110662. */
  110663. set directionalConeOuterAngle(value: number);
  110664. /**
  110665. * Sets the position of the emitter if spatial sound is enabled
  110666. * @param newPosition Defines the new posisiton
  110667. */
  110668. setPosition(newPosition: Vector3): void;
  110669. /**
  110670. * Sets the local direction of the emitter if spatial sound is enabled
  110671. * @param newLocalDirection Defines the new local direction
  110672. */
  110673. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  110674. private _updateDirection;
  110675. /** @hidden */
  110676. updateDistanceFromListener(): void;
  110677. /**
  110678. * Sets a new custom attenuation function for the sound.
  110679. * @param callback Defines the function used for the attenuation
  110680. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  110681. */
  110682. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  110683. /**
  110684. * Play the sound
  110685. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  110686. * @param offset (optional) Start the sound at a specific time in seconds
  110687. * @param length (optional) Sound duration (in seconds)
  110688. */
  110689. play(time?: number, offset?: number, length?: number): void;
  110690. private _onended;
  110691. /**
  110692. * Stop the sound
  110693. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  110694. */
  110695. stop(time?: number): void;
  110696. /**
  110697. * Put the sound in pause
  110698. */
  110699. pause(): void;
  110700. /**
  110701. * Sets a dedicated volume for this sounds
  110702. * @param newVolume Define the new volume of the sound
  110703. * @param time Define time for gradual change to new volume
  110704. */
  110705. setVolume(newVolume: number, time?: number): void;
  110706. /**
  110707. * Set the sound play back rate
  110708. * @param newPlaybackRate Define the playback rate the sound should be played at
  110709. */
  110710. setPlaybackRate(newPlaybackRate: number): void;
  110711. /**
  110712. * Gets the volume of the sound.
  110713. * @returns the volume of the sound
  110714. */
  110715. getVolume(): number;
  110716. /**
  110717. * Attach the sound to a dedicated mesh
  110718. * @param transformNode The transform node to connect the sound with
  110719. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  110720. */
  110721. attachToMesh(transformNode: TransformNode): void;
  110722. /**
  110723. * Detach the sound from the previously attached mesh
  110724. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  110725. */
  110726. detachFromMesh(): void;
  110727. private _onRegisterAfterWorldMatrixUpdate;
  110728. /**
  110729. * Clone the current sound in the scene.
  110730. * @returns the new sound clone
  110731. */
  110732. clone(): Nullable<Sound>;
  110733. /**
  110734. * Gets the current underlying audio buffer containing the data
  110735. * @returns the audio buffer
  110736. */
  110737. getAudioBuffer(): Nullable<AudioBuffer>;
  110738. /**
  110739. * Serializes the Sound in a JSON representation
  110740. * @returns the JSON representation of the sound
  110741. */
  110742. serialize(): any;
  110743. /**
  110744. * Parse a JSON representation of a sound to innstantiate in a given scene
  110745. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  110746. * @param scene Define the scene the new parsed sound should be created in
  110747. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  110748. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  110749. * @returns the newly parsed sound
  110750. */
  110751. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  110752. }
  110753. }
  110754. declare module BABYLON {
  110755. /**
  110756. * This defines an action helpful to play a defined sound on a triggered action.
  110757. */
  110758. export class PlaySoundAction extends Action {
  110759. private _sound;
  110760. /**
  110761. * Instantiate the action
  110762. * @param triggerOptions defines the trigger options
  110763. * @param sound defines the sound to play
  110764. * @param condition defines the trigger related conditions
  110765. */
  110766. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  110767. /** @hidden */
  110768. _prepare(): void;
  110769. /**
  110770. * Execute the action and play the sound.
  110771. */
  110772. execute(): void;
  110773. /**
  110774. * Serializes the actions and its related information.
  110775. * @param parent defines the object to serialize in
  110776. * @returns the serialized object
  110777. */
  110778. serialize(parent: any): any;
  110779. }
  110780. /**
  110781. * This defines an action helpful to stop a defined sound on a triggered action.
  110782. */
  110783. export class StopSoundAction extends Action {
  110784. private _sound;
  110785. /**
  110786. * Instantiate the action
  110787. * @param triggerOptions defines the trigger options
  110788. * @param sound defines the sound to stop
  110789. * @param condition defines the trigger related conditions
  110790. */
  110791. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  110792. /** @hidden */
  110793. _prepare(): void;
  110794. /**
  110795. * Execute the action and stop the sound.
  110796. */
  110797. execute(): void;
  110798. /**
  110799. * Serializes the actions and its related information.
  110800. * @param parent defines the object to serialize in
  110801. * @returns the serialized object
  110802. */
  110803. serialize(parent: any): any;
  110804. }
  110805. }
  110806. declare module BABYLON {
  110807. /**
  110808. * This defines an action responsible to change the value of a property
  110809. * by interpolating between its current value and the newly set one once triggered.
  110810. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  110811. */
  110812. export class InterpolateValueAction extends Action {
  110813. /**
  110814. * Defines the path of the property where the value should be interpolated
  110815. */
  110816. propertyPath: string;
  110817. /**
  110818. * Defines the target value at the end of the interpolation.
  110819. */
  110820. value: any;
  110821. /**
  110822. * Defines the time it will take for the property to interpolate to the value.
  110823. */
  110824. duration: number;
  110825. /**
  110826. * Defines if the other scene animations should be stopped when the action has been triggered
  110827. */
  110828. stopOtherAnimations?: boolean;
  110829. /**
  110830. * Defines a callback raised once the interpolation animation has been done.
  110831. */
  110832. onInterpolationDone?: () => void;
  110833. /**
  110834. * Observable triggered once the interpolation animation has been done.
  110835. */
  110836. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  110837. private _target;
  110838. private _effectiveTarget;
  110839. private _property;
  110840. /**
  110841. * Instantiate the action
  110842. * @param triggerOptions defines the trigger options
  110843. * @param target defines the object containing the value to interpolate
  110844. * @param propertyPath defines the path to the property in the target object
  110845. * @param value defines the target value at the end of the interpolation
  110846. * @param duration deines the time it will take for the property to interpolate to the value.
  110847. * @param condition defines the trigger related conditions
  110848. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  110849. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  110850. */
  110851. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  110852. /** @hidden */
  110853. _prepare(): void;
  110854. /**
  110855. * Execute the action starts the value interpolation.
  110856. */
  110857. execute(): void;
  110858. /**
  110859. * Serializes the actions and its related information.
  110860. * @param parent defines the object to serialize in
  110861. * @returns the serialized object
  110862. */
  110863. serialize(parent: any): any;
  110864. }
  110865. }
  110866. declare module BABYLON {
  110867. /**
  110868. * Options allowed during the creation of a sound track.
  110869. */
  110870. export interface ISoundTrackOptions {
  110871. /**
  110872. * The volume the sound track should take during creation
  110873. */
  110874. volume?: number;
  110875. /**
  110876. * Define if the sound track is the main sound track of the scene
  110877. */
  110878. mainTrack?: boolean;
  110879. }
  110880. /**
  110881. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  110882. * It will be also used in a future release to apply effects on a specific track.
  110883. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  110884. */
  110885. export class SoundTrack {
  110886. /**
  110887. * The unique identifier of the sound track in the scene.
  110888. */
  110889. id: number;
  110890. /**
  110891. * The list of sounds included in the sound track.
  110892. */
  110893. soundCollection: Array<Sound>;
  110894. private _outputAudioNode;
  110895. private _scene;
  110896. private _connectedAnalyser;
  110897. private _options;
  110898. private _isInitialized;
  110899. /**
  110900. * Creates a new sound track.
  110901. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  110902. * @param scene Define the scene the sound track belongs to
  110903. * @param options
  110904. */
  110905. constructor(scene: Scene, options?: ISoundTrackOptions);
  110906. private _initializeSoundTrackAudioGraph;
  110907. /**
  110908. * Release the sound track and its associated resources
  110909. */
  110910. dispose(): void;
  110911. /**
  110912. * Adds a sound to this sound track
  110913. * @param sound define the cound to add
  110914. * @ignoreNaming
  110915. */
  110916. AddSound(sound: Sound): void;
  110917. /**
  110918. * Removes a sound to this sound track
  110919. * @param sound define the cound to remove
  110920. * @ignoreNaming
  110921. */
  110922. RemoveSound(sound: Sound): void;
  110923. /**
  110924. * Set a global volume for the full sound track.
  110925. * @param newVolume Define the new volume of the sound track
  110926. */
  110927. setVolume(newVolume: number): void;
  110928. /**
  110929. * Switch the panning model to HRTF:
  110930. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  110931. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110932. */
  110933. switchPanningModelToHRTF(): void;
  110934. /**
  110935. * Switch the panning model to Equal Power:
  110936. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  110937. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110938. */
  110939. switchPanningModelToEqualPower(): void;
  110940. /**
  110941. * Connect the sound track to an audio analyser allowing some amazing
  110942. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  110943. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  110944. * @param analyser The analyser to connect to the engine
  110945. */
  110946. connectToAnalyser(analyser: Analyser): void;
  110947. }
  110948. }
  110949. declare module BABYLON {
  110950. interface AbstractScene {
  110951. /**
  110952. * The list of sounds used in the scene.
  110953. */
  110954. sounds: Nullable<Array<Sound>>;
  110955. }
  110956. interface Scene {
  110957. /**
  110958. * @hidden
  110959. * Backing field
  110960. */
  110961. _mainSoundTrack: SoundTrack;
  110962. /**
  110963. * The main sound track played by the scene.
  110964. * It cotains your primary collection of sounds.
  110965. */
  110966. mainSoundTrack: SoundTrack;
  110967. /**
  110968. * The list of sound tracks added to the scene
  110969. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110970. */
  110971. soundTracks: Nullable<Array<SoundTrack>>;
  110972. /**
  110973. * Gets a sound using a given name
  110974. * @param name defines the name to search for
  110975. * @return the found sound or null if not found at all.
  110976. */
  110977. getSoundByName(name: string): Nullable<Sound>;
  110978. /**
  110979. * Gets or sets if audio support is enabled
  110980. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110981. */
  110982. audioEnabled: boolean;
  110983. /**
  110984. * Gets or sets if audio will be output to headphones
  110985. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110986. */
  110987. headphone: boolean;
  110988. /**
  110989. * Gets or sets custom audio listener position provider
  110990. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110991. */
  110992. audioListenerPositionProvider: Nullable<() => Vector3>;
  110993. /**
  110994. * Gets or sets a refresh rate when using 3D audio positioning
  110995. */
  110996. audioPositioningRefreshRate: number;
  110997. }
  110998. /**
  110999. * Defines the sound scene component responsible to manage any sounds
  111000. * in a given scene.
  111001. */
  111002. export class AudioSceneComponent implements ISceneSerializableComponent {
  111003. /**
  111004. * The component name helpfull to identify the component in the list of scene components.
  111005. */
  111006. readonly name: string;
  111007. /**
  111008. * The scene the component belongs to.
  111009. */
  111010. scene: Scene;
  111011. private _audioEnabled;
  111012. /**
  111013. * Gets whether audio is enabled or not.
  111014. * Please use related enable/disable method to switch state.
  111015. */
  111016. get audioEnabled(): boolean;
  111017. private _headphone;
  111018. /**
  111019. * Gets whether audio is outputing to headphone or not.
  111020. * Please use the according Switch methods to change output.
  111021. */
  111022. get headphone(): boolean;
  111023. /**
  111024. * Gets or sets a refresh rate when using 3D audio positioning
  111025. */
  111026. audioPositioningRefreshRate: number;
  111027. private _audioListenerPositionProvider;
  111028. /**
  111029. * Gets the current audio listener position provider
  111030. */
  111031. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  111032. /**
  111033. * Sets a custom listener position for all sounds in the scene
  111034. * By default, this is the position of the first active camera
  111035. */
  111036. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  111037. /**
  111038. * Creates a new instance of the component for the given scene
  111039. * @param scene Defines the scene to register the component in
  111040. */
  111041. constructor(scene: Scene);
  111042. /**
  111043. * Registers the component in a given scene
  111044. */
  111045. register(): void;
  111046. /**
  111047. * Rebuilds the elements related to this component in case of
  111048. * context lost for instance.
  111049. */
  111050. rebuild(): void;
  111051. /**
  111052. * Serializes the component data to the specified json object
  111053. * @param serializationObject The object to serialize to
  111054. */
  111055. serialize(serializationObject: any): void;
  111056. /**
  111057. * Adds all the elements from the container to the scene
  111058. * @param container the container holding the elements
  111059. */
  111060. addFromContainer(container: AbstractScene): void;
  111061. /**
  111062. * Removes all the elements in the container from the scene
  111063. * @param container contains the elements to remove
  111064. * @param dispose if the removed element should be disposed (default: false)
  111065. */
  111066. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  111067. /**
  111068. * Disposes the component and the associated ressources.
  111069. */
  111070. dispose(): void;
  111071. /**
  111072. * Disables audio in the associated scene.
  111073. */
  111074. disableAudio(): void;
  111075. /**
  111076. * Enables audio in the associated scene.
  111077. */
  111078. enableAudio(): void;
  111079. /**
  111080. * Switch audio to headphone output.
  111081. */
  111082. switchAudioModeForHeadphones(): void;
  111083. /**
  111084. * Switch audio to normal speakers.
  111085. */
  111086. switchAudioModeForNormalSpeakers(): void;
  111087. private _cachedCameraDirection;
  111088. private _cachedCameraPosition;
  111089. private _lastCheck;
  111090. private _afterRender;
  111091. }
  111092. }
  111093. declare module BABYLON {
  111094. /**
  111095. * Wraps one or more Sound objects and selects one with random weight for playback.
  111096. */
  111097. export class WeightedSound {
  111098. /** When true a Sound will be selected and played when the current playing Sound completes. */
  111099. loop: boolean;
  111100. private _coneInnerAngle;
  111101. private _coneOuterAngle;
  111102. private _volume;
  111103. /** A Sound is currently playing. */
  111104. isPlaying: boolean;
  111105. /** A Sound is currently paused. */
  111106. isPaused: boolean;
  111107. private _sounds;
  111108. private _weights;
  111109. private _currentIndex?;
  111110. /**
  111111. * Creates a new WeightedSound from the list of sounds given.
  111112. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  111113. * @param sounds Array of Sounds that will be selected from.
  111114. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  111115. */
  111116. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  111117. /**
  111118. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  111119. */
  111120. get directionalConeInnerAngle(): number;
  111121. /**
  111122. * The size of cone in degress for a directional sound in which there will be no attenuation.
  111123. */
  111124. set directionalConeInnerAngle(value: number);
  111125. /**
  111126. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  111127. * Listener angles between innerAngle and outerAngle will falloff linearly.
  111128. */
  111129. get directionalConeOuterAngle(): number;
  111130. /**
  111131. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  111132. * Listener angles between innerAngle and outerAngle will falloff linearly.
  111133. */
  111134. set directionalConeOuterAngle(value: number);
  111135. /**
  111136. * Playback volume.
  111137. */
  111138. get volume(): number;
  111139. /**
  111140. * Playback volume.
  111141. */
  111142. set volume(value: number);
  111143. private _onended;
  111144. /**
  111145. * Suspend playback
  111146. */
  111147. pause(): void;
  111148. /**
  111149. * Stop playback
  111150. */
  111151. stop(): void;
  111152. /**
  111153. * Start playback.
  111154. * @param startOffset Position the clip head at a specific time in seconds.
  111155. */
  111156. play(startOffset?: number): void;
  111157. }
  111158. }
  111159. declare module BABYLON {
  111160. /**
  111161. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  111162. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  111163. */
  111164. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  111165. /**
  111166. * Gets the name of the behavior.
  111167. */
  111168. get name(): string;
  111169. /**
  111170. * The easing function used by animations
  111171. */
  111172. static EasingFunction: BackEase;
  111173. /**
  111174. * The easing mode used by animations
  111175. */
  111176. static EasingMode: number;
  111177. /**
  111178. * The duration of the animation, in milliseconds
  111179. */
  111180. transitionDuration: number;
  111181. /**
  111182. * Length of the distance animated by the transition when lower radius is reached
  111183. */
  111184. lowerRadiusTransitionRange: number;
  111185. /**
  111186. * Length of the distance animated by the transition when upper radius is reached
  111187. */
  111188. upperRadiusTransitionRange: number;
  111189. private _autoTransitionRange;
  111190. /**
  111191. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  111192. */
  111193. get autoTransitionRange(): boolean;
  111194. /**
  111195. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  111196. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  111197. */
  111198. set autoTransitionRange(value: boolean);
  111199. private _attachedCamera;
  111200. private _onAfterCheckInputsObserver;
  111201. private _onMeshTargetChangedObserver;
  111202. /**
  111203. * Initializes the behavior.
  111204. */
  111205. init(): void;
  111206. /**
  111207. * Attaches the behavior to its arc rotate camera.
  111208. * @param camera Defines the camera to attach the behavior to
  111209. */
  111210. attach(camera: ArcRotateCamera): void;
  111211. /**
  111212. * Detaches the behavior from its current arc rotate camera.
  111213. */
  111214. detach(): void;
  111215. private _radiusIsAnimating;
  111216. private _radiusBounceTransition;
  111217. private _animatables;
  111218. private _cachedWheelPrecision;
  111219. /**
  111220. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  111221. * @param radiusLimit The limit to check against.
  111222. * @return Bool to indicate if at limit.
  111223. */
  111224. private _isRadiusAtLimit;
  111225. /**
  111226. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  111227. * @param radiusDelta The delta by which to animate to. Can be negative.
  111228. */
  111229. private _applyBoundRadiusAnimation;
  111230. /**
  111231. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  111232. */
  111233. protected _clearAnimationLocks(): void;
  111234. /**
  111235. * Stops and removes all animations that have been applied to the camera
  111236. */
  111237. stopAllAnimations(): void;
  111238. }
  111239. }
  111240. declare module BABYLON {
  111241. /**
  111242. * 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.
  111243. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  111244. */
  111245. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  111246. /**
  111247. * Gets the name of the behavior.
  111248. */
  111249. get name(): string;
  111250. private _mode;
  111251. private _radiusScale;
  111252. private _positionScale;
  111253. private _defaultElevation;
  111254. private _elevationReturnTime;
  111255. private _elevationReturnWaitTime;
  111256. private _zoomStopsAnimation;
  111257. private _framingTime;
  111258. /**
  111259. * The easing function used by animations
  111260. */
  111261. static EasingFunction: ExponentialEase;
  111262. /**
  111263. * The easing mode used by animations
  111264. */
  111265. static EasingMode: number;
  111266. /**
  111267. * Sets the current mode used by the behavior
  111268. */
  111269. set mode(mode: number);
  111270. /**
  111271. * Gets current mode used by the behavior.
  111272. */
  111273. get mode(): number;
  111274. /**
  111275. * Sets the scale applied to the radius (1 by default)
  111276. */
  111277. set radiusScale(radius: number);
  111278. /**
  111279. * Gets the scale applied to the radius
  111280. */
  111281. get radiusScale(): number;
  111282. /**
  111283. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  111284. */
  111285. set positionScale(scale: number);
  111286. /**
  111287. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  111288. */
  111289. get positionScale(): number;
  111290. /**
  111291. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  111292. * behaviour is triggered, in radians.
  111293. */
  111294. set defaultElevation(elevation: number);
  111295. /**
  111296. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  111297. * behaviour is triggered, in radians.
  111298. */
  111299. get defaultElevation(): number;
  111300. /**
  111301. * Sets the time (in milliseconds) taken to return to the default beta position.
  111302. * Negative value indicates camera should not return to default.
  111303. */
  111304. set elevationReturnTime(speed: number);
  111305. /**
  111306. * Gets the time (in milliseconds) taken to return to the default beta position.
  111307. * Negative value indicates camera should not return to default.
  111308. */
  111309. get elevationReturnTime(): number;
  111310. /**
  111311. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  111312. */
  111313. set elevationReturnWaitTime(time: number);
  111314. /**
  111315. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  111316. */
  111317. get elevationReturnWaitTime(): number;
  111318. /**
  111319. * Sets the flag that indicates if user zooming should stop animation.
  111320. */
  111321. set zoomStopsAnimation(flag: boolean);
  111322. /**
  111323. * Gets the flag that indicates if user zooming should stop animation.
  111324. */
  111325. get zoomStopsAnimation(): boolean;
  111326. /**
  111327. * Sets the transition time when framing the mesh, in milliseconds
  111328. */
  111329. set framingTime(time: number);
  111330. /**
  111331. * Gets the transition time when framing the mesh, in milliseconds
  111332. */
  111333. get framingTime(): number;
  111334. /**
  111335. * Define if the behavior should automatically change the configured
  111336. * camera limits and sensibilities.
  111337. */
  111338. autoCorrectCameraLimitsAndSensibility: boolean;
  111339. private _onPrePointerObservableObserver;
  111340. private _onAfterCheckInputsObserver;
  111341. private _onMeshTargetChangedObserver;
  111342. private _attachedCamera;
  111343. private _isPointerDown;
  111344. private _lastInteractionTime;
  111345. /**
  111346. * Initializes the behavior.
  111347. */
  111348. init(): void;
  111349. /**
  111350. * Attaches the behavior to its arc rotate camera.
  111351. * @param camera Defines the camera to attach the behavior to
  111352. */
  111353. attach(camera: ArcRotateCamera): void;
  111354. /**
  111355. * Detaches the behavior from its current arc rotate camera.
  111356. */
  111357. detach(): void;
  111358. private _animatables;
  111359. private _betaIsAnimating;
  111360. private _betaTransition;
  111361. private _radiusTransition;
  111362. private _vectorTransition;
  111363. /**
  111364. * Targets the given mesh and updates zoom level accordingly.
  111365. * @param mesh The mesh to target.
  111366. * @param radius Optional. If a cached radius position already exists, overrides default.
  111367. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  111368. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111369. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111370. */
  111371. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111372. /**
  111373. * Targets the given mesh with its children and updates zoom level accordingly.
  111374. * @param mesh The mesh to target.
  111375. * @param radius Optional. If a cached radius position already exists, overrides default.
  111376. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  111377. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111378. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111379. */
  111380. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111381. /**
  111382. * Targets the given meshes with their children and updates zoom level accordingly.
  111383. * @param meshes The mesh to target.
  111384. * @param radius Optional. If a cached radius position already exists, overrides default.
  111385. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  111386. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111387. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111388. */
  111389. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111390. /**
  111391. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  111392. * @param minimumWorld Determines the smaller position of the bounding box extend
  111393. * @param maximumWorld Determines the bigger position of the bounding box extend
  111394. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111395. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111396. */
  111397. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111398. /**
  111399. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  111400. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  111401. * frustum width.
  111402. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  111403. * to fully enclose the mesh in the viewing frustum.
  111404. */
  111405. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  111406. /**
  111407. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  111408. * is automatically returned to its default position (expected to be above ground plane).
  111409. */
  111410. private _maintainCameraAboveGround;
  111411. /**
  111412. * Returns the frustum slope based on the canvas ratio and camera FOV
  111413. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  111414. */
  111415. private _getFrustumSlope;
  111416. /**
  111417. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  111418. */
  111419. private _clearAnimationLocks;
  111420. /**
  111421. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  111422. */
  111423. private _applyUserInteraction;
  111424. /**
  111425. * Stops and removes all animations that have been applied to the camera
  111426. */
  111427. stopAllAnimations(): void;
  111428. /**
  111429. * Gets a value indicating if the user is moving the camera
  111430. */
  111431. get isUserIsMoving(): boolean;
  111432. /**
  111433. * The camera can move all the way towards the mesh.
  111434. */
  111435. static IgnoreBoundsSizeMode: number;
  111436. /**
  111437. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  111438. */
  111439. static FitFrustumSidesMode: number;
  111440. }
  111441. }
  111442. declare module BABYLON {
  111443. /**
  111444. * Base class for Camera Pointer Inputs.
  111445. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  111446. * for example usage.
  111447. */
  111448. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  111449. /**
  111450. * Defines the camera the input is attached to.
  111451. */
  111452. abstract camera: Camera;
  111453. /**
  111454. * Whether keyboard modifier keys are pressed at time of last mouse event.
  111455. */
  111456. protected _altKey: boolean;
  111457. protected _ctrlKey: boolean;
  111458. protected _metaKey: boolean;
  111459. protected _shiftKey: boolean;
  111460. /**
  111461. * Which mouse buttons were pressed at time of last mouse event.
  111462. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  111463. */
  111464. protected _buttonsPressed: number;
  111465. /**
  111466. * Defines the buttons associated with the input to handle camera move.
  111467. */
  111468. buttons: number[];
  111469. /**
  111470. * Attach the input controls to a specific dom element to get the input from.
  111471. * @param element Defines the element the controls should be listened from
  111472. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111473. */
  111474. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111475. /**
  111476. * Detach the current controls from the specified dom element.
  111477. * @param element Defines the element to stop listening the inputs from
  111478. */
  111479. detachControl(element: Nullable<HTMLElement>): void;
  111480. /**
  111481. * Gets the class name of the current input.
  111482. * @returns the class name
  111483. */
  111484. getClassName(): string;
  111485. /**
  111486. * Get the friendly name associated with the input class.
  111487. * @returns the input friendly name
  111488. */
  111489. getSimpleName(): string;
  111490. /**
  111491. * Called on pointer POINTERDOUBLETAP event.
  111492. * Override this method to provide functionality on POINTERDOUBLETAP event.
  111493. */
  111494. protected onDoubleTap(type: string): void;
  111495. /**
  111496. * Called on pointer POINTERMOVE event if only a single touch is active.
  111497. * Override this method to provide functionality.
  111498. */
  111499. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  111500. /**
  111501. * Called on pointer POINTERMOVE event if multiple touches are active.
  111502. * Override this method to provide functionality.
  111503. */
  111504. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  111505. /**
  111506. * Called on JS contextmenu event.
  111507. * Override this method to provide functionality.
  111508. */
  111509. protected onContextMenu(evt: PointerEvent): void;
  111510. /**
  111511. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  111512. * press.
  111513. * Override this method to provide functionality.
  111514. */
  111515. protected onButtonDown(evt: PointerEvent): void;
  111516. /**
  111517. * Called each time a new POINTERUP event occurs. Ie, for each button
  111518. * release.
  111519. * Override this method to provide functionality.
  111520. */
  111521. protected onButtonUp(evt: PointerEvent): void;
  111522. /**
  111523. * Called when window becomes inactive.
  111524. * Override this method to provide functionality.
  111525. */
  111526. protected onLostFocus(): void;
  111527. private _pointerInput;
  111528. private _observer;
  111529. private _onLostFocus;
  111530. private pointA;
  111531. private pointB;
  111532. }
  111533. }
  111534. declare module BABYLON {
  111535. /**
  111536. * Manage the pointers inputs to control an arc rotate camera.
  111537. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111538. */
  111539. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  111540. /**
  111541. * Defines the camera the input is attached to.
  111542. */
  111543. camera: ArcRotateCamera;
  111544. /**
  111545. * Gets the class name of the current input.
  111546. * @returns the class name
  111547. */
  111548. getClassName(): string;
  111549. /**
  111550. * Defines the buttons associated with the input to handle camera move.
  111551. */
  111552. buttons: number[];
  111553. /**
  111554. * Defines the pointer angular sensibility along the X axis or how fast is
  111555. * the camera rotating.
  111556. */
  111557. angularSensibilityX: number;
  111558. /**
  111559. * Defines the pointer angular sensibility along the Y axis or how fast is
  111560. * the camera rotating.
  111561. */
  111562. angularSensibilityY: number;
  111563. /**
  111564. * Defines the pointer pinch precision or how fast is the camera zooming.
  111565. */
  111566. pinchPrecision: number;
  111567. /**
  111568. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  111569. * from 0.
  111570. * It defines the percentage of current camera.radius to use as delta when
  111571. * pinch zoom is used.
  111572. */
  111573. pinchDeltaPercentage: number;
  111574. /**
  111575. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  111576. * that any object in the plane at the camera's target point will scale
  111577. * perfectly with finger motion.
  111578. * Overrides pinchDeltaPercentage and pinchPrecision.
  111579. */
  111580. useNaturalPinchZoom: boolean;
  111581. /**
  111582. * Defines the pointer panning sensibility or how fast is the camera moving.
  111583. */
  111584. panningSensibility: number;
  111585. /**
  111586. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  111587. */
  111588. multiTouchPanning: boolean;
  111589. /**
  111590. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  111591. * zoom (pinch) through multitouch.
  111592. */
  111593. multiTouchPanAndZoom: boolean;
  111594. /**
  111595. * Revers pinch action direction.
  111596. */
  111597. pinchInwards: boolean;
  111598. private _isPanClick;
  111599. private _twoFingerActivityCount;
  111600. private _isPinching;
  111601. /**
  111602. * Called on pointer POINTERMOVE event if only a single touch is active.
  111603. */
  111604. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  111605. /**
  111606. * Called on pointer POINTERDOUBLETAP event.
  111607. */
  111608. protected onDoubleTap(type: string): void;
  111609. /**
  111610. * Called on pointer POINTERMOVE event if multiple touches are active.
  111611. */
  111612. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  111613. /**
  111614. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  111615. * press.
  111616. */
  111617. protected onButtonDown(evt: PointerEvent): void;
  111618. /**
  111619. * Called each time a new POINTERUP event occurs. Ie, for each button
  111620. * release.
  111621. */
  111622. protected onButtonUp(evt: PointerEvent): void;
  111623. /**
  111624. * Called when window becomes inactive.
  111625. */
  111626. protected onLostFocus(): void;
  111627. }
  111628. }
  111629. declare module BABYLON {
  111630. /**
  111631. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  111632. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111633. */
  111634. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  111635. /**
  111636. * Defines the camera the input is attached to.
  111637. */
  111638. camera: ArcRotateCamera;
  111639. /**
  111640. * Defines the list of key codes associated with the up action (increase alpha)
  111641. */
  111642. keysUp: number[];
  111643. /**
  111644. * Defines the list of key codes associated with the down action (decrease alpha)
  111645. */
  111646. keysDown: number[];
  111647. /**
  111648. * Defines the list of key codes associated with the left action (increase beta)
  111649. */
  111650. keysLeft: number[];
  111651. /**
  111652. * Defines the list of key codes associated with the right action (decrease beta)
  111653. */
  111654. keysRight: number[];
  111655. /**
  111656. * Defines the list of key codes associated with the reset action.
  111657. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  111658. */
  111659. keysReset: number[];
  111660. /**
  111661. * Defines the panning sensibility of the inputs.
  111662. * (How fast is the camera panning)
  111663. */
  111664. panningSensibility: number;
  111665. /**
  111666. * Defines the zooming sensibility of the inputs.
  111667. * (How fast is the camera zooming)
  111668. */
  111669. zoomingSensibility: number;
  111670. /**
  111671. * Defines whether maintaining the alt key down switch the movement mode from
  111672. * orientation to zoom.
  111673. */
  111674. useAltToZoom: boolean;
  111675. /**
  111676. * Rotation speed of the camera
  111677. */
  111678. angularSpeed: number;
  111679. private _keys;
  111680. private _ctrlPressed;
  111681. private _altPressed;
  111682. private _onCanvasBlurObserver;
  111683. private _onKeyboardObserver;
  111684. private _engine;
  111685. private _scene;
  111686. /**
  111687. * Attach the input controls to a specific dom element to get the input from.
  111688. * @param element Defines the element the controls should be listened from
  111689. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111690. */
  111691. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111692. /**
  111693. * Detach the current controls from the specified dom element.
  111694. * @param element Defines the element to stop listening the inputs from
  111695. */
  111696. detachControl(element: Nullable<HTMLElement>): void;
  111697. /**
  111698. * Update the current camera state depending on the inputs that have been used this frame.
  111699. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  111700. */
  111701. checkInputs(): void;
  111702. /**
  111703. * Gets the class name of the current intput.
  111704. * @returns the class name
  111705. */
  111706. getClassName(): string;
  111707. /**
  111708. * Get the friendly name associated with the input class.
  111709. * @returns the input friendly name
  111710. */
  111711. getSimpleName(): string;
  111712. }
  111713. }
  111714. declare module BABYLON {
  111715. /**
  111716. * Manage the mouse wheel inputs to control an arc rotate camera.
  111717. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111718. */
  111719. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  111720. /**
  111721. * Defines the camera the input is attached to.
  111722. */
  111723. camera: ArcRotateCamera;
  111724. /**
  111725. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  111726. */
  111727. wheelPrecision: number;
  111728. /**
  111729. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  111730. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  111731. */
  111732. wheelDeltaPercentage: number;
  111733. private _wheel;
  111734. private _observer;
  111735. private computeDeltaFromMouseWheelLegacyEvent;
  111736. /**
  111737. * Attach the input controls to a specific dom element to get the input from.
  111738. * @param element Defines the element the controls should be listened from
  111739. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111740. */
  111741. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111742. /**
  111743. * Detach the current controls from the specified dom element.
  111744. * @param element Defines the element to stop listening the inputs from
  111745. */
  111746. detachControl(element: Nullable<HTMLElement>): void;
  111747. /**
  111748. * Gets the class name of the current intput.
  111749. * @returns the class name
  111750. */
  111751. getClassName(): string;
  111752. /**
  111753. * Get the friendly name associated with the input class.
  111754. * @returns the input friendly name
  111755. */
  111756. getSimpleName(): string;
  111757. }
  111758. }
  111759. declare module BABYLON {
  111760. /**
  111761. * Default Inputs manager for the ArcRotateCamera.
  111762. * It groups all the default supported inputs for ease of use.
  111763. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111764. */
  111765. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  111766. /**
  111767. * Instantiates a new ArcRotateCameraInputsManager.
  111768. * @param camera Defines the camera the inputs belong to
  111769. */
  111770. constructor(camera: ArcRotateCamera);
  111771. /**
  111772. * Add mouse wheel input support to the input manager.
  111773. * @returns the current input manager
  111774. */
  111775. addMouseWheel(): ArcRotateCameraInputsManager;
  111776. /**
  111777. * Add pointers input support to the input manager.
  111778. * @returns the current input manager
  111779. */
  111780. addPointers(): ArcRotateCameraInputsManager;
  111781. /**
  111782. * Add keyboard input support to the input manager.
  111783. * @returns the current input manager
  111784. */
  111785. addKeyboard(): ArcRotateCameraInputsManager;
  111786. }
  111787. }
  111788. declare module BABYLON {
  111789. /**
  111790. * This represents an orbital type of camera.
  111791. *
  111792. * 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.
  111793. * 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.
  111794. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  111795. */
  111796. export class ArcRotateCamera extends TargetCamera {
  111797. /**
  111798. * Defines the rotation angle of the camera along the longitudinal axis.
  111799. */
  111800. alpha: number;
  111801. /**
  111802. * Defines the rotation angle of the camera along the latitudinal axis.
  111803. */
  111804. beta: number;
  111805. /**
  111806. * Defines the radius of the camera from it s target point.
  111807. */
  111808. radius: number;
  111809. protected _target: Vector3;
  111810. protected _targetHost: Nullable<AbstractMesh>;
  111811. /**
  111812. * Defines the target point of the camera.
  111813. * The camera looks towards it form the radius distance.
  111814. */
  111815. get target(): Vector3;
  111816. set target(value: Vector3);
  111817. /**
  111818. * Define the current local position of the camera in the scene
  111819. */
  111820. get position(): Vector3;
  111821. set position(newPosition: Vector3);
  111822. protected _upVector: Vector3;
  111823. protected _upToYMatrix: Matrix;
  111824. protected _YToUpMatrix: Matrix;
  111825. /**
  111826. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  111827. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  111828. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  111829. */
  111830. set upVector(vec: Vector3);
  111831. get upVector(): Vector3;
  111832. /**
  111833. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  111834. */
  111835. setMatUp(): void;
  111836. /**
  111837. * Current inertia value on the longitudinal axis.
  111838. * The bigger this number the longer it will take for the camera to stop.
  111839. */
  111840. inertialAlphaOffset: number;
  111841. /**
  111842. * Current inertia value on the latitudinal axis.
  111843. * The bigger this number the longer it will take for the camera to stop.
  111844. */
  111845. inertialBetaOffset: number;
  111846. /**
  111847. * Current inertia value on the radius axis.
  111848. * The bigger this number the longer it will take for the camera to stop.
  111849. */
  111850. inertialRadiusOffset: number;
  111851. /**
  111852. * Minimum allowed angle on the longitudinal axis.
  111853. * This can help limiting how the Camera is able to move in the scene.
  111854. */
  111855. lowerAlphaLimit: Nullable<number>;
  111856. /**
  111857. * Maximum allowed angle on the longitudinal axis.
  111858. * This can help limiting how the Camera is able to move in the scene.
  111859. */
  111860. upperAlphaLimit: Nullable<number>;
  111861. /**
  111862. * Minimum allowed angle on the latitudinal axis.
  111863. * This can help limiting how the Camera is able to move in the scene.
  111864. */
  111865. lowerBetaLimit: number;
  111866. /**
  111867. * Maximum allowed angle on the latitudinal axis.
  111868. * This can help limiting how the Camera is able to move in the scene.
  111869. */
  111870. upperBetaLimit: number;
  111871. /**
  111872. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  111873. * This can help limiting how the Camera is able to move in the scene.
  111874. */
  111875. lowerRadiusLimit: Nullable<number>;
  111876. /**
  111877. * Maximum allowed distance of the camera to the target (The camera can not get further).
  111878. * This can help limiting how the Camera is able to move in the scene.
  111879. */
  111880. upperRadiusLimit: Nullable<number>;
  111881. /**
  111882. * Defines the current inertia value used during panning of the camera along the X axis.
  111883. */
  111884. inertialPanningX: number;
  111885. /**
  111886. * Defines the current inertia value used during panning of the camera along the Y axis.
  111887. */
  111888. inertialPanningY: number;
  111889. /**
  111890. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  111891. * Basically if your fingers moves away from more than this distance you will be considered
  111892. * in pinch mode.
  111893. */
  111894. pinchToPanMaxDistance: number;
  111895. /**
  111896. * Defines the maximum distance the camera can pan.
  111897. * This could help keeping the cammera always in your scene.
  111898. */
  111899. panningDistanceLimit: Nullable<number>;
  111900. /**
  111901. * Defines the target of the camera before paning.
  111902. */
  111903. panningOriginTarget: Vector3;
  111904. /**
  111905. * Defines the value of the inertia used during panning.
  111906. * 0 would mean stop inertia and one would mean no decelleration at all.
  111907. */
  111908. panningInertia: number;
  111909. /**
  111910. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  111911. */
  111912. get angularSensibilityX(): number;
  111913. set angularSensibilityX(value: number);
  111914. /**
  111915. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  111916. */
  111917. get angularSensibilityY(): number;
  111918. set angularSensibilityY(value: number);
  111919. /**
  111920. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  111921. */
  111922. get pinchPrecision(): number;
  111923. set pinchPrecision(value: number);
  111924. /**
  111925. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  111926. * It will be used instead of pinchDeltaPrecision if different from 0.
  111927. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  111928. */
  111929. get pinchDeltaPercentage(): number;
  111930. set pinchDeltaPercentage(value: number);
  111931. /**
  111932. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  111933. * and pinch delta percentage.
  111934. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  111935. * that any object in the plane at the camera's target point will scale
  111936. * perfectly with finger motion.
  111937. */
  111938. get useNaturalPinchZoom(): boolean;
  111939. set useNaturalPinchZoom(value: boolean);
  111940. /**
  111941. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  111942. */
  111943. get panningSensibility(): number;
  111944. set panningSensibility(value: number);
  111945. /**
  111946. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  111947. */
  111948. get keysUp(): number[];
  111949. set keysUp(value: number[]);
  111950. /**
  111951. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  111952. */
  111953. get keysDown(): number[];
  111954. set keysDown(value: number[]);
  111955. /**
  111956. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  111957. */
  111958. get keysLeft(): number[];
  111959. set keysLeft(value: number[]);
  111960. /**
  111961. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  111962. */
  111963. get keysRight(): number[];
  111964. set keysRight(value: number[]);
  111965. /**
  111966. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  111967. */
  111968. get wheelPrecision(): number;
  111969. set wheelPrecision(value: number);
  111970. /**
  111971. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  111972. * It will be used instead of pinchDeltaPrecision if different from 0.
  111973. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  111974. */
  111975. get wheelDeltaPercentage(): number;
  111976. set wheelDeltaPercentage(value: number);
  111977. /**
  111978. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  111979. */
  111980. zoomOnFactor: number;
  111981. /**
  111982. * Defines a screen offset for the camera position.
  111983. */
  111984. targetScreenOffset: Vector2;
  111985. /**
  111986. * Allows the camera to be completely reversed.
  111987. * If false the camera can not arrive upside down.
  111988. */
  111989. allowUpsideDown: boolean;
  111990. /**
  111991. * Define if double tap/click is used to restore the previously saved state of the camera.
  111992. */
  111993. useInputToRestoreState: boolean;
  111994. /** @hidden */
  111995. _viewMatrix: Matrix;
  111996. /** @hidden */
  111997. _useCtrlForPanning: boolean;
  111998. /** @hidden */
  111999. _panningMouseButton: number;
  112000. /**
  112001. * Defines the input associated to the camera.
  112002. */
  112003. inputs: ArcRotateCameraInputsManager;
  112004. /** @hidden */
  112005. _reset: () => void;
  112006. /**
  112007. * Defines the allowed panning axis.
  112008. */
  112009. panningAxis: Vector3;
  112010. protected _localDirection: Vector3;
  112011. protected _transformedDirection: Vector3;
  112012. private _bouncingBehavior;
  112013. /**
  112014. * Gets the bouncing behavior of the camera if it has been enabled.
  112015. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  112016. */
  112017. get bouncingBehavior(): Nullable<BouncingBehavior>;
  112018. /**
  112019. * Defines if the bouncing behavior of the camera is enabled on the camera.
  112020. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  112021. */
  112022. get useBouncingBehavior(): boolean;
  112023. set useBouncingBehavior(value: boolean);
  112024. private _framingBehavior;
  112025. /**
  112026. * Gets the framing behavior of the camera if it has been enabled.
  112027. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  112028. */
  112029. get framingBehavior(): Nullable<FramingBehavior>;
  112030. /**
  112031. * Defines if the framing behavior of the camera is enabled on the camera.
  112032. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  112033. */
  112034. get useFramingBehavior(): boolean;
  112035. set useFramingBehavior(value: boolean);
  112036. private _autoRotationBehavior;
  112037. /**
  112038. * Gets the auto rotation behavior of the camera if it has been enabled.
  112039. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  112040. */
  112041. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  112042. /**
  112043. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  112044. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  112045. */
  112046. get useAutoRotationBehavior(): boolean;
  112047. set useAutoRotationBehavior(value: boolean);
  112048. /**
  112049. * Observable triggered when the mesh target has been changed on the camera.
  112050. */
  112051. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  112052. /**
  112053. * Event raised when the camera is colliding with a mesh.
  112054. */
  112055. onCollide: (collidedMesh: AbstractMesh) => void;
  112056. /**
  112057. * Defines whether the camera should check collision with the objects oh the scene.
  112058. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  112059. */
  112060. checkCollisions: boolean;
  112061. /**
  112062. * Defines the collision radius of the camera.
  112063. * This simulates a sphere around the camera.
  112064. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  112065. */
  112066. collisionRadius: Vector3;
  112067. protected _collider: Collider;
  112068. protected _previousPosition: Vector3;
  112069. protected _collisionVelocity: Vector3;
  112070. protected _newPosition: Vector3;
  112071. protected _previousAlpha: number;
  112072. protected _previousBeta: number;
  112073. protected _previousRadius: number;
  112074. protected _collisionTriggered: boolean;
  112075. protected _targetBoundingCenter: Nullable<Vector3>;
  112076. private _computationVector;
  112077. /**
  112078. * Instantiates a new ArcRotateCamera in a given scene
  112079. * @param name Defines the name of the camera
  112080. * @param alpha Defines the camera rotation along the logitudinal axis
  112081. * @param beta Defines the camera rotation along the latitudinal axis
  112082. * @param radius Defines the camera distance from its target
  112083. * @param target Defines the camera target
  112084. * @param scene Defines the scene the camera belongs to
  112085. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  112086. */
  112087. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  112088. /** @hidden */
  112089. _initCache(): void;
  112090. /** @hidden */
  112091. _updateCache(ignoreParentClass?: boolean): void;
  112092. protected _getTargetPosition(): Vector3;
  112093. private _storedAlpha;
  112094. private _storedBeta;
  112095. private _storedRadius;
  112096. private _storedTarget;
  112097. private _storedTargetScreenOffset;
  112098. /**
  112099. * Stores the current state of the camera (alpha, beta, radius and target)
  112100. * @returns the camera itself
  112101. */
  112102. storeState(): Camera;
  112103. /**
  112104. * @hidden
  112105. * Restored camera state. You must call storeState() first
  112106. */
  112107. _restoreStateValues(): boolean;
  112108. /** @hidden */
  112109. _isSynchronizedViewMatrix(): boolean;
  112110. /**
  112111. * Attached controls to the current camera.
  112112. * @param element Defines the element the controls should be listened from
  112113. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112114. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  112115. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  112116. */
  112117. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  112118. /**
  112119. * Detach the current controls from the camera.
  112120. * The camera will stop reacting to inputs.
  112121. * @param element Defines the element to stop listening the inputs from
  112122. */
  112123. detachControl(element: HTMLElement): void;
  112124. /** @hidden */
  112125. _checkInputs(): void;
  112126. protected _checkLimits(): void;
  112127. /**
  112128. * Rebuilds angles (alpha, beta) and radius from the give position and target
  112129. */
  112130. rebuildAnglesAndRadius(): void;
  112131. /**
  112132. * Use a position to define the current camera related information like alpha, beta and radius
  112133. * @param position Defines the position to set the camera at
  112134. */
  112135. setPosition(position: Vector3): void;
  112136. /**
  112137. * Defines the target the camera should look at.
  112138. * This will automatically adapt alpha beta and radius to fit within the new target.
  112139. * @param target Defines the new target as a Vector or a mesh
  112140. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  112141. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  112142. */
  112143. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  112144. /** @hidden */
  112145. _getViewMatrix(): Matrix;
  112146. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  112147. /**
  112148. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  112149. * @param meshes Defines the mesh to zoom on
  112150. * @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)
  112151. */
  112152. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  112153. /**
  112154. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  112155. * The target will be changed but the radius
  112156. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  112157. * @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)
  112158. */
  112159. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  112160. min: Vector3;
  112161. max: Vector3;
  112162. distance: number;
  112163. }, doNotUpdateMaxZ?: boolean): void;
  112164. /**
  112165. * @override
  112166. * Override Camera.createRigCamera
  112167. */
  112168. createRigCamera(name: string, cameraIndex: number): Camera;
  112169. /**
  112170. * @hidden
  112171. * @override
  112172. * Override Camera._updateRigCameras
  112173. */
  112174. _updateRigCameras(): void;
  112175. /**
  112176. * Destroy the camera and release the current resources hold by it.
  112177. */
  112178. dispose(): void;
  112179. /**
  112180. * Gets the current object class name.
  112181. * @return the class name
  112182. */
  112183. getClassName(): string;
  112184. }
  112185. }
  112186. declare module BABYLON {
  112187. /**
  112188. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  112189. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  112190. */
  112191. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  112192. /**
  112193. * Gets the name of the behavior.
  112194. */
  112195. get name(): string;
  112196. private _zoomStopsAnimation;
  112197. private _idleRotationSpeed;
  112198. private _idleRotationWaitTime;
  112199. private _idleRotationSpinupTime;
  112200. /**
  112201. * Sets the flag that indicates if user zooming should stop animation.
  112202. */
  112203. set zoomStopsAnimation(flag: boolean);
  112204. /**
  112205. * Gets the flag that indicates if user zooming should stop animation.
  112206. */
  112207. get zoomStopsAnimation(): boolean;
  112208. /**
  112209. * Sets the default speed at which the camera rotates around the model.
  112210. */
  112211. set idleRotationSpeed(speed: number);
  112212. /**
  112213. * Gets the default speed at which the camera rotates around the model.
  112214. */
  112215. get idleRotationSpeed(): number;
  112216. /**
  112217. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  112218. */
  112219. set idleRotationWaitTime(time: number);
  112220. /**
  112221. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  112222. */
  112223. get idleRotationWaitTime(): number;
  112224. /**
  112225. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  112226. */
  112227. set idleRotationSpinupTime(time: number);
  112228. /**
  112229. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  112230. */
  112231. get idleRotationSpinupTime(): number;
  112232. /**
  112233. * Gets a value indicating if the camera is currently rotating because of this behavior
  112234. */
  112235. get rotationInProgress(): boolean;
  112236. private _onPrePointerObservableObserver;
  112237. private _onAfterCheckInputsObserver;
  112238. private _attachedCamera;
  112239. private _isPointerDown;
  112240. private _lastFrameTime;
  112241. private _lastInteractionTime;
  112242. private _cameraRotationSpeed;
  112243. /**
  112244. * Initializes the behavior.
  112245. */
  112246. init(): void;
  112247. /**
  112248. * Attaches the behavior to its arc rotate camera.
  112249. * @param camera Defines the camera to attach the behavior to
  112250. */
  112251. attach(camera: ArcRotateCamera): void;
  112252. /**
  112253. * Detaches the behavior from its current arc rotate camera.
  112254. */
  112255. detach(): void;
  112256. /**
  112257. * Returns true if user is scrolling.
  112258. * @return true if user is scrolling.
  112259. */
  112260. private _userIsZooming;
  112261. private _lastFrameRadius;
  112262. private _shouldAnimationStopForInteraction;
  112263. /**
  112264. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  112265. */
  112266. private _applyUserInteraction;
  112267. private _userIsMoving;
  112268. }
  112269. }
  112270. declare module BABYLON {
  112271. /**
  112272. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  112273. */
  112274. export class AttachToBoxBehavior implements Behavior<Mesh> {
  112275. private ui;
  112276. /**
  112277. * The name of the behavior
  112278. */
  112279. name: string;
  112280. /**
  112281. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  112282. */
  112283. distanceAwayFromFace: number;
  112284. /**
  112285. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  112286. */
  112287. distanceAwayFromBottomOfFace: number;
  112288. private _faceVectors;
  112289. private _target;
  112290. private _scene;
  112291. private _onRenderObserver;
  112292. private _tmpMatrix;
  112293. private _tmpVector;
  112294. /**
  112295. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  112296. * @param ui The transform node that should be attched to the mesh
  112297. */
  112298. constructor(ui: TransformNode);
  112299. /**
  112300. * Initializes the behavior
  112301. */
  112302. init(): void;
  112303. private _closestFace;
  112304. private _zeroVector;
  112305. private _lookAtTmpMatrix;
  112306. private _lookAtToRef;
  112307. /**
  112308. * Attaches the AttachToBoxBehavior to the passed in mesh
  112309. * @param target The mesh that the specified node will be attached to
  112310. */
  112311. attach(target: Mesh): void;
  112312. /**
  112313. * Detaches the behavior from the mesh
  112314. */
  112315. detach(): void;
  112316. }
  112317. }
  112318. declare module BABYLON {
  112319. /**
  112320. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  112321. */
  112322. export class FadeInOutBehavior implements Behavior<Mesh> {
  112323. /**
  112324. * Time in milliseconds to delay before fading in (Default: 0)
  112325. */
  112326. delay: number;
  112327. /**
  112328. * Time in milliseconds for the mesh to fade in (Default: 300)
  112329. */
  112330. fadeInTime: number;
  112331. private _millisecondsPerFrame;
  112332. private _hovered;
  112333. private _hoverValue;
  112334. private _ownerNode;
  112335. /**
  112336. * Instatiates the FadeInOutBehavior
  112337. */
  112338. constructor();
  112339. /**
  112340. * The name of the behavior
  112341. */
  112342. get name(): string;
  112343. /**
  112344. * Initializes the behavior
  112345. */
  112346. init(): void;
  112347. /**
  112348. * Attaches the fade behavior on the passed in mesh
  112349. * @param ownerNode The mesh that will be faded in/out once attached
  112350. */
  112351. attach(ownerNode: Mesh): void;
  112352. /**
  112353. * Detaches the behavior from the mesh
  112354. */
  112355. detach(): void;
  112356. /**
  112357. * Triggers the mesh to begin fading in or out
  112358. * @param value if the object should fade in or out (true to fade in)
  112359. */
  112360. fadeIn(value: boolean): void;
  112361. private _update;
  112362. private _setAllVisibility;
  112363. }
  112364. }
  112365. declare module BABYLON {
  112366. /**
  112367. * Class containing a set of static utilities functions for managing Pivots
  112368. * @hidden
  112369. */
  112370. export class PivotTools {
  112371. private static _PivotCached;
  112372. private static _OldPivotPoint;
  112373. private static _PivotTranslation;
  112374. private static _PivotTmpVector;
  112375. /** @hidden */
  112376. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  112377. /** @hidden */
  112378. static _RestorePivotPoint(mesh: AbstractMesh): void;
  112379. }
  112380. }
  112381. declare module BABYLON {
  112382. /**
  112383. * Class containing static functions to help procedurally build meshes
  112384. */
  112385. export class PlaneBuilder {
  112386. /**
  112387. * Creates a plane mesh
  112388. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  112389. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  112390. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  112391. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112392. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112393. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112394. * @param name defines the name of the mesh
  112395. * @param options defines the options used to create the mesh
  112396. * @param scene defines the hosting scene
  112397. * @returns the plane mesh
  112398. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  112399. */
  112400. static CreatePlane(name: string, options: {
  112401. size?: number;
  112402. width?: number;
  112403. height?: number;
  112404. sideOrientation?: number;
  112405. frontUVs?: Vector4;
  112406. backUVs?: Vector4;
  112407. updatable?: boolean;
  112408. sourcePlane?: Plane;
  112409. }, scene?: Nullable<Scene>): Mesh;
  112410. }
  112411. }
  112412. declare module BABYLON {
  112413. /**
  112414. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  112415. */
  112416. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  112417. private static _AnyMouseID;
  112418. /**
  112419. * Abstract mesh the behavior is set on
  112420. */
  112421. attachedNode: AbstractMesh;
  112422. private _dragPlane;
  112423. private _scene;
  112424. private _pointerObserver;
  112425. private _beforeRenderObserver;
  112426. private static _planeScene;
  112427. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  112428. /**
  112429. * 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)
  112430. */
  112431. maxDragAngle: number;
  112432. /**
  112433. * @hidden
  112434. */
  112435. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  112436. /**
  112437. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  112438. */
  112439. currentDraggingPointerID: number;
  112440. /**
  112441. * The last position where the pointer hit the drag plane in world space
  112442. */
  112443. lastDragPosition: Vector3;
  112444. /**
  112445. * If the behavior is currently in a dragging state
  112446. */
  112447. dragging: boolean;
  112448. /**
  112449. * 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)
  112450. */
  112451. dragDeltaRatio: number;
  112452. /**
  112453. * If the drag plane orientation should be updated during the dragging (Default: true)
  112454. */
  112455. updateDragPlane: boolean;
  112456. private _debugMode;
  112457. private _moving;
  112458. /**
  112459. * Fires each time the attached mesh is dragged with the pointer
  112460. * * delta between last drag position and current drag position in world space
  112461. * * dragDistance along the drag axis
  112462. * * dragPlaneNormal normal of the current drag plane used during the drag
  112463. * * dragPlanePoint in world space where the drag intersects the drag plane
  112464. */
  112465. onDragObservable: Observable<{
  112466. delta: Vector3;
  112467. dragPlanePoint: Vector3;
  112468. dragPlaneNormal: Vector3;
  112469. dragDistance: number;
  112470. pointerId: number;
  112471. }>;
  112472. /**
  112473. * Fires each time a drag begins (eg. mouse down on mesh)
  112474. */
  112475. onDragStartObservable: Observable<{
  112476. dragPlanePoint: Vector3;
  112477. pointerId: number;
  112478. }>;
  112479. /**
  112480. * Fires each time a drag ends (eg. mouse release after drag)
  112481. */
  112482. onDragEndObservable: Observable<{
  112483. dragPlanePoint: Vector3;
  112484. pointerId: number;
  112485. }>;
  112486. /**
  112487. * If the attached mesh should be moved when dragged
  112488. */
  112489. moveAttached: boolean;
  112490. /**
  112491. * If the drag behavior will react to drag events (Default: true)
  112492. */
  112493. enabled: boolean;
  112494. /**
  112495. * If pointer events should start and release the drag (Default: true)
  112496. */
  112497. startAndReleaseDragOnPointerEvents: boolean;
  112498. /**
  112499. * If camera controls should be detached during the drag
  112500. */
  112501. detachCameraControls: boolean;
  112502. /**
  112503. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  112504. */
  112505. useObjectOrientationForDragging: boolean;
  112506. private _options;
  112507. /**
  112508. * Gets the options used by the behavior
  112509. */
  112510. get options(): {
  112511. dragAxis?: Vector3;
  112512. dragPlaneNormal?: Vector3;
  112513. };
  112514. /**
  112515. * Sets the options used by the behavior
  112516. */
  112517. set options(options: {
  112518. dragAxis?: Vector3;
  112519. dragPlaneNormal?: Vector3;
  112520. });
  112521. /**
  112522. * Creates a pointer drag behavior that can be attached to a mesh
  112523. * @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)
  112524. */
  112525. constructor(options?: {
  112526. dragAxis?: Vector3;
  112527. dragPlaneNormal?: Vector3;
  112528. });
  112529. /**
  112530. * Predicate to determine if it is valid to move the object to a new position when it is moved
  112531. */
  112532. validateDrag: (targetPosition: Vector3) => boolean;
  112533. /**
  112534. * The name of the behavior
  112535. */
  112536. get name(): string;
  112537. /**
  112538. * Initializes the behavior
  112539. */
  112540. init(): void;
  112541. private _tmpVector;
  112542. private _alternatePickedPoint;
  112543. private _worldDragAxis;
  112544. private _targetPosition;
  112545. private _attachedElement;
  112546. /**
  112547. * Attaches the drag behavior the passed in mesh
  112548. * @param ownerNode The mesh that will be dragged around once attached
  112549. * @param predicate Predicate to use for pick filtering
  112550. */
  112551. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  112552. /**
  112553. * Force relase the drag action by code.
  112554. */
  112555. releaseDrag(): void;
  112556. private _startDragRay;
  112557. private _lastPointerRay;
  112558. /**
  112559. * Simulates the start of a pointer drag event on the behavior
  112560. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  112561. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  112562. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  112563. */
  112564. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  112565. private _startDrag;
  112566. private _dragDelta;
  112567. private _moveDrag;
  112568. private _pickWithRayOnDragPlane;
  112569. private _pointA;
  112570. private _pointB;
  112571. private _pointC;
  112572. private _lineA;
  112573. private _lineB;
  112574. private _localAxis;
  112575. private _lookAt;
  112576. private _updateDragPlanePosition;
  112577. /**
  112578. * Detaches the behavior from the mesh
  112579. */
  112580. detach(): void;
  112581. }
  112582. }
  112583. declare module BABYLON {
  112584. /**
  112585. * A behavior that when attached to a mesh will allow the mesh to be scaled
  112586. */
  112587. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  112588. private _dragBehaviorA;
  112589. private _dragBehaviorB;
  112590. private _startDistance;
  112591. private _initialScale;
  112592. private _targetScale;
  112593. private _ownerNode;
  112594. private _sceneRenderObserver;
  112595. /**
  112596. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  112597. */
  112598. constructor();
  112599. /**
  112600. * The name of the behavior
  112601. */
  112602. get name(): string;
  112603. /**
  112604. * Initializes the behavior
  112605. */
  112606. init(): void;
  112607. private _getCurrentDistance;
  112608. /**
  112609. * Attaches the scale behavior the passed in mesh
  112610. * @param ownerNode The mesh that will be scaled around once attached
  112611. */
  112612. attach(ownerNode: Mesh): void;
  112613. /**
  112614. * Detaches the behavior from the mesh
  112615. */
  112616. detach(): void;
  112617. }
  112618. }
  112619. declare module BABYLON {
  112620. /**
  112621. * 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
  112622. */
  112623. export class SixDofDragBehavior implements Behavior<Mesh> {
  112624. private static _virtualScene;
  112625. private _ownerNode;
  112626. private _sceneRenderObserver;
  112627. private _scene;
  112628. private _targetPosition;
  112629. private _virtualOriginMesh;
  112630. private _virtualDragMesh;
  112631. private _pointerObserver;
  112632. private _moving;
  112633. private _startingOrientation;
  112634. /**
  112635. * 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)
  112636. */
  112637. private zDragFactor;
  112638. /**
  112639. * If the object should rotate to face the drag origin
  112640. */
  112641. rotateDraggedObject: boolean;
  112642. /**
  112643. * If the behavior is currently in a dragging state
  112644. */
  112645. dragging: boolean;
  112646. /**
  112647. * 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)
  112648. */
  112649. dragDeltaRatio: number;
  112650. /**
  112651. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  112652. */
  112653. currentDraggingPointerID: number;
  112654. /**
  112655. * If camera controls should be detached during the drag
  112656. */
  112657. detachCameraControls: boolean;
  112658. /**
  112659. * Fires each time a drag starts
  112660. */
  112661. onDragStartObservable: Observable<{}>;
  112662. /**
  112663. * Fires each time a drag ends (eg. mouse release after drag)
  112664. */
  112665. onDragEndObservable: Observable<{}>;
  112666. /**
  112667. * 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
  112668. */
  112669. constructor();
  112670. /**
  112671. * The name of the behavior
  112672. */
  112673. get name(): string;
  112674. /**
  112675. * Initializes the behavior
  112676. */
  112677. init(): void;
  112678. /**
  112679. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  112680. */
  112681. private get _pointerCamera();
  112682. /**
  112683. * Attaches the scale behavior the passed in mesh
  112684. * @param ownerNode The mesh that will be scaled around once attached
  112685. */
  112686. attach(ownerNode: Mesh): void;
  112687. /**
  112688. * Detaches the behavior from the mesh
  112689. */
  112690. detach(): void;
  112691. }
  112692. }
  112693. declare module BABYLON {
  112694. /**
  112695. * Class used to apply inverse kinematics to bones
  112696. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  112697. */
  112698. export class BoneIKController {
  112699. private static _tmpVecs;
  112700. private static _tmpQuat;
  112701. private static _tmpMats;
  112702. /**
  112703. * Gets or sets the target mesh
  112704. */
  112705. targetMesh: AbstractMesh;
  112706. /** Gets or sets the mesh used as pole */
  112707. poleTargetMesh: AbstractMesh;
  112708. /**
  112709. * Gets or sets the bone used as pole
  112710. */
  112711. poleTargetBone: Nullable<Bone>;
  112712. /**
  112713. * Gets or sets the target position
  112714. */
  112715. targetPosition: Vector3;
  112716. /**
  112717. * Gets or sets the pole target position
  112718. */
  112719. poleTargetPosition: Vector3;
  112720. /**
  112721. * Gets or sets the pole target local offset
  112722. */
  112723. poleTargetLocalOffset: Vector3;
  112724. /**
  112725. * Gets or sets the pole angle
  112726. */
  112727. poleAngle: number;
  112728. /**
  112729. * Gets or sets the mesh associated with the controller
  112730. */
  112731. mesh: AbstractMesh;
  112732. /**
  112733. * 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)
  112734. */
  112735. slerpAmount: number;
  112736. private _bone1Quat;
  112737. private _bone1Mat;
  112738. private _bone2Ang;
  112739. private _bone1;
  112740. private _bone2;
  112741. private _bone1Length;
  112742. private _bone2Length;
  112743. private _maxAngle;
  112744. private _maxReach;
  112745. private _rightHandedSystem;
  112746. private _bendAxis;
  112747. private _slerping;
  112748. private _adjustRoll;
  112749. /**
  112750. * Gets or sets maximum allowed angle
  112751. */
  112752. get maxAngle(): number;
  112753. set maxAngle(value: number);
  112754. /**
  112755. * Creates a new BoneIKController
  112756. * @param mesh defines the mesh to control
  112757. * @param bone defines the bone to control
  112758. * @param options defines options to set up the controller
  112759. */
  112760. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  112761. targetMesh?: AbstractMesh;
  112762. poleTargetMesh?: AbstractMesh;
  112763. poleTargetBone?: Bone;
  112764. poleTargetLocalOffset?: Vector3;
  112765. poleAngle?: number;
  112766. bendAxis?: Vector3;
  112767. maxAngle?: number;
  112768. slerpAmount?: number;
  112769. });
  112770. private _setMaxAngle;
  112771. /**
  112772. * Force the controller to update the bones
  112773. */
  112774. update(): void;
  112775. }
  112776. }
  112777. declare module BABYLON {
  112778. /**
  112779. * Class used to make a bone look toward a point in space
  112780. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  112781. */
  112782. export class BoneLookController {
  112783. private static _tmpVecs;
  112784. private static _tmpQuat;
  112785. private static _tmpMats;
  112786. /**
  112787. * The target Vector3 that the bone will look at
  112788. */
  112789. target: Vector3;
  112790. /**
  112791. * The mesh that the bone is attached to
  112792. */
  112793. mesh: AbstractMesh;
  112794. /**
  112795. * The bone that will be looking to the target
  112796. */
  112797. bone: Bone;
  112798. /**
  112799. * The up axis of the coordinate system that is used when the bone is rotated
  112800. */
  112801. upAxis: Vector3;
  112802. /**
  112803. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  112804. */
  112805. upAxisSpace: Space;
  112806. /**
  112807. * Used to make an adjustment to the yaw of the bone
  112808. */
  112809. adjustYaw: number;
  112810. /**
  112811. * Used to make an adjustment to the pitch of the bone
  112812. */
  112813. adjustPitch: number;
  112814. /**
  112815. * Used to make an adjustment to the roll of the bone
  112816. */
  112817. adjustRoll: number;
  112818. /**
  112819. * 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)
  112820. */
  112821. slerpAmount: number;
  112822. private _minYaw;
  112823. private _maxYaw;
  112824. private _minPitch;
  112825. private _maxPitch;
  112826. private _minYawSin;
  112827. private _minYawCos;
  112828. private _maxYawSin;
  112829. private _maxYawCos;
  112830. private _midYawConstraint;
  112831. private _minPitchTan;
  112832. private _maxPitchTan;
  112833. private _boneQuat;
  112834. private _slerping;
  112835. private _transformYawPitch;
  112836. private _transformYawPitchInv;
  112837. private _firstFrameSkipped;
  112838. private _yawRange;
  112839. private _fowardAxis;
  112840. /**
  112841. * Gets or sets the minimum yaw angle that the bone can look to
  112842. */
  112843. get minYaw(): number;
  112844. set minYaw(value: number);
  112845. /**
  112846. * Gets or sets the maximum yaw angle that the bone can look to
  112847. */
  112848. get maxYaw(): number;
  112849. set maxYaw(value: number);
  112850. /**
  112851. * Gets or sets the minimum pitch angle that the bone can look to
  112852. */
  112853. get minPitch(): number;
  112854. set minPitch(value: number);
  112855. /**
  112856. * Gets or sets the maximum pitch angle that the bone can look to
  112857. */
  112858. get maxPitch(): number;
  112859. set maxPitch(value: number);
  112860. /**
  112861. * Create a BoneLookController
  112862. * @param mesh the mesh that the bone belongs to
  112863. * @param bone the bone that will be looking to the target
  112864. * @param target the target Vector3 to look at
  112865. * @param options optional settings:
  112866. * * maxYaw: the maximum angle the bone will yaw to
  112867. * * minYaw: the minimum angle the bone will yaw to
  112868. * * maxPitch: the maximum angle the bone will pitch to
  112869. * * minPitch: the minimum angle the bone will yaw to
  112870. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  112871. * * upAxis: the up axis of the coordinate system
  112872. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  112873. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  112874. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  112875. * * adjustYaw: used to make an adjustment to the yaw of the bone
  112876. * * adjustPitch: used to make an adjustment to the pitch of the bone
  112877. * * adjustRoll: used to make an adjustment to the roll of the bone
  112878. **/
  112879. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  112880. maxYaw?: number;
  112881. minYaw?: number;
  112882. maxPitch?: number;
  112883. minPitch?: number;
  112884. slerpAmount?: number;
  112885. upAxis?: Vector3;
  112886. upAxisSpace?: Space;
  112887. yawAxis?: Vector3;
  112888. pitchAxis?: Vector3;
  112889. adjustYaw?: number;
  112890. adjustPitch?: number;
  112891. adjustRoll?: number;
  112892. });
  112893. /**
  112894. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  112895. */
  112896. update(): void;
  112897. private _getAngleDiff;
  112898. private _getAngleBetween;
  112899. private _isAngleBetween;
  112900. }
  112901. }
  112902. declare module BABYLON {
  112903. /**
  112904. * Manage the gamepad inputs to control an arc rotate camera.
  112905. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112906. */
  112907. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  112908. /**
  112909. * Defines the camera the input is attached to.
  112910. */
  112911. camera: ArcRotateCamera;
  112912. /**
  112913. * Defines the gamepad the input is gathering event from.
  112914. */
  112915. gamepad: Nullable<Gamepad>;
  112916. /**
  112917. * Defines the gamepad rotation sensiblity.
  112918. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  112919. */
  112920. gamepadRotationSensibility: number;
  112921. /**
  112922. * Defines the gamepad move sensiblity.
  112923. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  112924. */
  112925. gamepadMoveSensibility: number;
  112926. private _yAxisScale;
  112927. /**
  112928. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  112929. */
  112930. get invertYAxis(): boolean;
  112931. set invertYAxis(value: boolean);
  112932. private _onGamepadConnectedObserver;
  112933. private _onGamepadDisconnectedObserver;
  112934. /**
  112935. * Attach the input controls to a specific dom element to get the input from.
  112936. * @param element Defines the element the controls should be listened from
  112937. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112938. */
  112939. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112940. /**
  112941. * Detach the current controls from the specified dom element.
  112942. * @param element Defines the element to stop listening the inputs from
  112943. */
  112944. detachControl(element: Nullable<HTMLElement>): void;
  112945. /**
  112946. * Update the current camera state depending on the inputs that have been used this frame.
  112947. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  112948. */
  112949. checkInputs(): void;
  112950. /**
  112951. * Gets the class name of the current intput.
  112952. * @returns the class name
  112953. */
  112954. getClassName(): string;
  112955. /**
  112956. * Get the friendly name associated with the input class.
  112957. * @returns the input friendly name
  112958. */
  112959. getSimpleName(): string;
  112960. }
  112961. }
  112962. declare module BABYLON {
  112963. interface ArcRotateCameraInputsManager {
  112964. /**
  112965. * Add orientation input support to the input manager.
  112966. * @returns the current input manager
  112967. */
  112968. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  112969. }
  112970. /**
  112971. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  112972. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112973. */
  112974. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  112975. /**
  112976. * Defines the camera the input is attached to.
  112977. */
  112978. camera: ArcRotateCamera;
  112979. /**
  112980. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  112981. */
  112982. alphaCorrection: number;
  112983. /**
  112984. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  112985. */
  112986. gammaCorrection: number;
  112987. private _alpha;
  112988. private _gamma;
  112989. private _dirty;
  112990. private _deviceOrientationHandler;
  112991. /**
  112992. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  112993. */
  112994. constructor();
  112995. /**
  112996. * Attach the input controls to a specific dom element to get the input from.
  112997. * @param element Defines the element the controls should be listened from
  112998. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112999. */
  113000. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113001. /** @hidden */
  113002. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  113003. /**
  113004. * Update the current camera state depending on the inputs that have been used this frame.
  113005. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113006. */
  113007. checkInputs(): void;
  113008. /**
  113009. * Detach the current controls from the specified dom element.
  113010. * @param element Defines the element to stop listening the inputs from
  113011. */
  113012. detachControl(element: Nullable<HTMLElement>): void;
  113013. /**
  113014. * Gets the class name of the current intput.
  113015. * @returns the class name
  113016. */
  113017. getClassName(): string;
  113018. /**
  113019. * Get the friendly name associated with the input class.
  113020. * @returns the input friendly name
  113021. */
  113022. getSimpleName(): string;
  113023. }
  113024. }
  113025. declare module BABYLON {
  113026. /**
  113027. * Listen to mouse events to control the camera.
  113028. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113029. */
  113030. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  113031. /**
  113032. * Defines the camera the input is attached to.
  113033. */
  113034. camera: FlyCamera;
  113035. /**
  113036. * Defines if touch is enabled. (Default is true.)
  113037. */
  113038. touchEnabled: boolean;
  113039. /**
  113040. * Defines the buttons associated with the input to handle camera rotation.
  113041. */
  113042. buttons: number[];
  113043. /**
  113044. * Assign buttons for Yaw control.
  113045. */
  113046. buttonsYaw: number[];
  113047. /**
  113048. * Assign buttons for Pitch control.
  113049. */
  113050. buttonsPitch: number[];
  113051. /**
  113052. * Assign buttons for Roll control.
  113053. */
  113054. buttonsRoll: number[];
  113055. /**
  113056. * Detect if any button is being pressed while mouse is moved.
  113057. * -1 = Mouse locked.
  113058. * 0 = Left button.
  113059. * 1 = Middle Button.
  113060. * 2 = Right Button.
  113061. */
  113062. activeButton: number;
  113063. /**
  113064. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  113065. * Higher values reduce its sensitivity.
  113066. */
  113067. angularSensibility: number;
  113068. private _mousemoveCallback;
  113069. private _observer;
  113070. private _rollObserver;
  113071. private previousPosition;
  113072. private noPreventDefault;
  113073. private element;
  113074. /**
  113075. * Listen to mouse events to control the camera.
  113076. * @param touchEnabled Define if touch is enabled. (Default is true.)
  113077. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113078. */
  113079. constructor(touchEnabled?: boolean);
  113080. /**
  113081. * Attach the mouse control to the HTML DOM element.
  113082. * @param element Defines the element that listens to the input events.
  113083. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  113084. */
  113085. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113086. /**
  113087. * Detach the current controls from the specified dom element.
  113088. * @param element Defines the element to stop listening the inputs from
  113089. */
  113090. detachControl(element: Nullable<HTMLElement>): void;
  113091. /**
  113092. * Gets the class name of the current input.
  113093. * @returns the class name.
  113094. */
  113095. getClassName(): string;
  113096. /**
  113097. * Get the friendly name associated with the input class.
  113098. * @returns the input's friendly name.
  113099. */
  113100. getSimpleName(): string;
  113101. private _pointerInput;
  113102. private _onMouseMove;
  113103. /**
  113104. * Rotate camera by mouse offset.
  113105. */
  113106. private rotateCamera;
  113107. }
  113108. }
  113109. declare module BABYLON {
  113110. /**
  113111. * Default Inputs manager for the FlyCamera.
  113112. * It groups all the default supported inputs for ease of use.
  113113. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113114. */
  113115. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  113116. /**
  113117. * Instantiates a new FlyCameraInputsManager.
  113118. * @param camera Defines the camera the inputs belong to.
  113119. */
  113120. constructor(camera: FlyCamera);
  113121. /**
  113122. * Add keyboard input support to the input manager.
  113123. * @returns the new FlyCameraKeyboardMoveInput().
  113124. */
  113125. addKeyboard(): FlyCameraInputsManager;
  113126. /**
  113127. * Add mouse input support to the input manager.
  113128. * @param touchEnabled Enable touch screen support.
  113129. * @returns the new FlyCameraMouseInput().
  113130. */
  113131. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  113132. }
  113133. }
  113134. declare module BABYLON {
  113135. /**
  113136. * This is a flying camera, designed for 3D movement and rotation in all directions,
  113137. * such as in a 3D Space Shooter or a Flight Simulator.
  113138. */
  113139. export class FlyCamera extends TargetCamera {
  113140. /**
  113141. * Define the collision ellipsoid of the camera.
  113142. * This is helpful for simulating a camera body, like a player's body.
  113143. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  113144. */
  113145. ellipsoid: Vector3;
  113146. /**
  113147. * Define an offset for the position of the ellipsoid around the camera.
  113148. * This can be helpful if the camera is attached away from the player's body center,
  113149. * such as at its head.
  113150. */
  113151. ellipsoidOffset: Vector3;
  113152. /**
  113153. * Enable or disable collisions of the camera with the rest of the scene objects.
  113154. */
  113155. checkCollisions: boolean;
  113156. /**
  113157. * Enable or disable gravity on the camera.
  113158. */
  113159. applyGravity: boolean;
  113160. /**
  113161. * Define the current direction the camera is moving to.
  113162. */
  113163. cameraDirection: Vector3;
  113164. /**
  113165. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  113166. * This overrides and empties cameraRotation.
  113167. */
  113168. rotationQuaternion: Quaternion;
  113169. /**
  113170. * Track Roll to maintain the wanted Rolling when looking around.
  113171. */
  113172. _trackRoll: number;
  113173. /**
  113174. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  113175. */
  113176. rollCorrect: number;
  113177. /**
  113178. * Mimic a banked turn, Rolling the camera when Yawing.
  113179. * It's recommended to use rollCorrect = 10 for faster banking correction.
  113180. */
  113181. bankedTurn: boolean;
  113182. /**
  113183. * Limit in radians for how much Roll banking will add. (Default: 90°)
  113184. */
  113185. bankedTurnLimit: number;
  113186. /**
  113187. * Value of 0 disables the banked Roll.
  113188. * Value of 1 is equal to the Yaw angle in radians.
  113189. */
  113190. bankedTurnMultiplier: number;
  113191. /**
  113192. * The inputs manager loads all the input sources, such as keyboard and mouse.
  113193. */
  113194. inputs: FlyCameraInputsManager;
  113195. /**
  113196. * Gets the input sensibility for mouse input.
  113197. * Higher values reduce sensitivity.
  113198. */
  113199. get angularSensibility(): number;
  113200. /**
  113201. * Sets the input sensibility for a mouse input.
  113202. * Higher values reduce sensitivity.
  113203. */
  113204. set angularSensibility(value: number);
  113205. /**
  113206. * Get the keys for camera movement forward.
  113207. */
  113208. get keysForward(): number[];
  113209. /**
  113210. * Set the keys for camera movement forward.
  113211. */
  113212. set keysForward(value: number[]);
  113213. /**
  113214. * Get the keys for camera movement backward.
  113215. */
  113216. get keysBackward(): number[];
  113217. set keysBackward(value: number[]);
  113218. /**
  113219. * Get the keys for camera movement up.
  113220. */
  113221. get keysUp(): number[];
  113222. /**
  113223. * Set the keys for camera movement up.
  113224. */
  113225. set keysUp(value: number[]);
  113226. /**
  113227. * Get the keys for camera movement down.
  113228. */
  113229. get keysDown(): number[];
  113230. /**
  113231. * Set the keys for camera movement down.
  113232. */
  113233. set keysDown(value: number[]);
  113234. /**
  113235. * Get the keys for camera movement left.
  113236. */
  113237. get keysLeft(): number[];
  113238. /**
  113239. * Set the keys for camera movement left.
  113240. */
  113241. set keysLeft(value: number[]);
  113242. /**
  113243. * Set the keys for camera movement right.
  113244. */
  113245. get keysRight(): number[];
  113246. /**
  113247. * Set the keys for camera movement right.
  113248. */
  113249. set keysRight(value: number[]);
  113250. /**
  113251. * Event raised when the camera collides with a mesh in the scene.
  113252. */
  113253. onCollide: (collidedMesh: AbstractMesh) => void;
  113254. private _collider;
  113255. private _needMoveForGravity;
  113256. private _oldPosition;
  113257. private _diffPosition;
  113258. private _newPosition;
  113259. /** @hidden */
  113260. _localDirection: Vector3;
  113261. /** @hidden */
  113262. _transformedDirection: Vector3;
  113263. /**
  113264. * Instantiates a FlyCamera.
  113265. * This is a flying camera, designed for 3D movement and rotation in all directions,
  113266. * such as in a 3D Space Shooter or a Flight Simulator.
  113267. * @param name Define the name of the camera in the scene.
  113268. * @param position Define the starting position of the camera in the scene.
  113269. * @param scene Define the scene the camera belongs to.
  113270. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  113271. */
  113272. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  113273. /**
  113274. * Attach a control to the HTML DOM element.
  113275. * @param element Defines the element that listens to the input events.
  113276. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  113277. */
  113278. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113279. /**
  113280. * Detach a control from the HTML DOM element.
  113281. * The camera will stop reacting to that input.
  113282. * @param element Defines the element that listens to the input events.
  113283. */
  113284. detachControl(element: HTMLElement): void;
  113285. private _collisionMask;
  113286. /**
  113287. * Get the mask that the camera ignores in collision events.
  113288. */
  113289. get collisionMask(): number;
  113290. /**
  113291. * Set the mask that the camera ignores in collision events.
  113292. */
  113293. set collisionMask(mask: number);
  113294. /** @hidden */
  113295. _collideWithWorld(displacement: Vector3): void;
  113296. /** @hidden */
  113297. private _onCollisionPositionChange;
  113298. /** @hidden */
  113299. _checkInputs(): void;
  113300. /** @hidden */
  113301. _decideIfNeedsToMove(): boolean;
  113302. /** @hidden */
  113303. _updatePosition(): void;
  113304. /**
  113305. * Restore the Roll to its target value at the rate specified.
  113306. * @param rate - Higher means slower restoring.
  113307. * @hidden
  113308. */
  113309. restoreRoll(rate: number): void;
  113310. /**
  113311. * Destroy the camera and release the current resources held by it.
  113312. */
  113313. dispose(): void;
  113314. /**
  113315. * Get the current object class name.
  113316. * @returns the class name.
  113317. */
  113318. getClassName(): string;
  113319. }
  113320. }
  113321. declare module BABYLON {
  113322. /**
  113323. * Listen to keyboard events to control the camera.
  113324. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113325. */
  113326. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  113327. /**
  113328. * Defines the camera the input is attached to.
  113329. */
  113330. camera: FlyCamera;
  113331. /**
  113332. * The list of keyboard keys used to control the forward move of the camera.
  113333. */
  113334. keysForward: number[];
  113335. /**
  113336. * The list of keyboard keys used to control the backward move of the camera.
  113337. */
  113338. keysBackward: number[];
  113339. /**
  113340. * The list of keyboard keys used to control the forward move of the camera.
  113341. */
  113342. keysUp: number[];
  113343. /**
  113344. * The list of keyboard keys used to control the backward move of the camera.
  113345. */
  113346. keysDown: number[];
  113347. /**
  113348. * The list of keyboard keys used to control the right strafe move of the camera.
  113349. */
  113350. keysRight: number[];
  113351. /**
  113352. * The list of keyboard keys used to control the left strafe move of the camera.
  113353. */
  113354. keysLeft: number[];
  113355. private _keys;
  113356. private _onCanvasBlurObserver;
  113357. private _onKeyboardObserver;
  113358. private _engine;
  113359. private _scene;
  113360. /**
  113361. * Attach the input controls to a specific dom element to get the input from.
  113362. * @param element Defines the element the controls should be listened from
  113363. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113364. */
  113365. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113366. /**
  113367. * Detach the current controls from the specified dom element.
  113368. * @param element Defines the element to stop listening the inputs from
  113369. */
  113370. detachControl(element: Nullable<HTMLElement>): void;
  113371. /**
  113372. * Gets the class name of the current intput.
  113373. * @returns the class name
  113374. */
  113375. getClassName(): string;
  113376. /** @hidden */
  113377. _onLostFocus(e: FocusEvent): void;
  113378. /**
  113379. * Get the friendly name associated with the input class.
  113380. * @returns the input friendly name
  113381. */
  113382. getSimpleName(): string;
  113383. /**
  113384. * Update the current camera state depending on the inputs that have been used this frame.
  113385. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113386. */
  113387. checkInputs(): void;
  113388. }
  113389. }
  113390. declare module BABYLON {
  113391. /**
  113392. * Manage the mouse wheel inputs to control a follow camera.
  113393. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113394. */
  113395. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  113396. /**
  113397. * Defines the camera the input is attached to.
  113398. */
  113399. camera: FollowCamera;
  113400. /**
  113401. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  113402. */
  113403. axisControlRadius: boolean;
  113404. /**
  113405. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  113406. */
  113407. axisControlHeight: boolean;
  113408. /**
  113409. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  113410. */
  113411. axisControlRotation: boolean;
  113412. /**
  113413. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  113414. * relation to mouseWheel events.
  113415. */
  113416. wheelPrecision: number;
  113417. /**
  113418. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  113419. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  113420. */
  113421. wheelDeltaPercentage: number;
  113422. private _wheel;
  113423. private _observer;
  113424. /**
  113425. * Attach the input controls to a specific dom element to get the input from.
  113426. * @param element Defines the element the controls should be listened from
  113427. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113428. */
  113429. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113430. /**
  113431. * Detach the current controls from the specified dom element.
  113432. * @param element Defines the element to stop listening the inputs from
  113433. */
  113434. detachControl(element: Nullable<HTMLElement>): void;
  113435. /**
  113436. * Gets the class name of the current intput.
  113437. * @returns the class name
  113438. */
  113439. getClassName(): string;
  113440. /**
  113441. * Get the friendly name associated with the input class.
  113442. * @returns the input friendly name
  113443. */
  113444. getSimpleName(): string;
  113445. }
  113446. }
  113447. declare module BABYLON {
  113448. /**
  113449. * Manage the pointers inputs to control an follow camera.
  113450. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113451. */
  113452. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  113453. /**
  113454. * Defines the camera the input is attached to.
  113455. */
  113456. camera: FollowCamera;
  113457. /**
  113458. * Gets the class name of the current input.
  113459. * @returns the class name
  113460. */
  113461. getClassName(): string;
  113462. /**
  113463. * Defines the pointer angular sensibility along the X axis or how fast is
  113464. * the camera rotating.
  113465. * A negative number will reverse the axis direction.
  113466. */
  113467. angularSensibilityX: number;
  113468. /**
  113469. * Defines the pointer angular sensibility along the Y axis or how fast is
  113470. * the camera rotating.
  113471. * A negative number will reverse the axis direction.
  113472. */
  113473. angularSensibilityY: number;
  113474. /**
  113475. * Defines the pointer pinch precision or how fast is the camera zooming.
  113476. * A negative number will reverse the axis direction.
  113477. */
  113478. pinchPrecision: number;
  113479. /**
  113480. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  113481. * from 0.
  113482. * It defines the percentage of current camera.radius to use as delta when
  113483. * pinch zoom is used.
  113484. */
  113485. pinchDeltaPercentage: number;
  113486. /**
  113487. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  113488. */
  113489. axisXControlRadius: boolean;
  113490. /**
  113491. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  113492. */
  113493. axisXControlHeight: boolean;
  113494. /**
  113495. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  113496. */
  113497. axisXControlRotation: boolean;
  113498. /**
  113499. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  113500. */
  113501. axisYControlRadius: boolean;
  113502. /**
  113503. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  113504. */
  113505. axisYControlHeight: boolean;
  113506. /**
  113507. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  113508. */
  113509. axisYControlRotation: boolean;
  113510. /**
  113511. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  113512. */
  113513. axisPinchControlRadius: boolean;
  113514. /**
  113515. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  113516. */
  113517. axisPinchControlHeight: boolean;
  113518. /**
  113519. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  113520. */
  113521. axisPinchControlRotation: boolean;
  113522. /**
  113523. * Log error messages if basic misconfiguration has occurred.
  113524. */
  113525. warningEnable: boolean;
  113526. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  113527. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  113528. private _warningCounter;
  113529. private _warning;
  113530. }
  113531. }
  113532. declare module BABYLON {
  113533. /**
  113534. * Default Inputs manager for the FollowCamera.
  113535. * It groups all the default supported inputs for ease of use.
  113536. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113537. */
  113538. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  113539. /**
  113540. * Instantiates a new FollowCameraInputsManager.
  113541. * @param camera Defines the camera the inputs belong to
  113542. */
  113543. constructor(camera: FollowCamera);
  113544. /**
  113545. * Add keyboard input support to the input manager.
  113546. * @returns the current input manager
  113547. */
  113548. addKeyboard(): FollowCameraInputsManager;
  113549. /**
  113550. * Add mouse wheel input support to the input manager.
  113551. * @returns the current input manager
  113552. */
  113553. addMouseWheel(): FollowCameraInputsManager;
  113554. /**
  113555. * Add pointers input support to the input manager.
  113556. * @returns the current input manager
  113557. */
  113558. addPointers(): FollowCameraInputsManager;
  113559. /**
  113560. * Add orientation input support to the input manager.
  113561. * @returns the current input manager
  113562. */
  113563. addVRDeviceOrientation(): FollowCameraInputsManager;
  113564. }
  113565. }
  113566. declare module BABYLON {
  113567. /**
  113568. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  113569. * an arc rotate version arcFollowCamera are available.
  113570. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113571. */
  113572. export class FollowCamera extends TargetCamera {
  113573. /**
  113574. * Distance the follow camera should follow an object at
  113575. */
  113576. radius: number;
  113577. /**
  113578. * Minimum allowed distance of the camera to the axis of rotation
  113579. * (The camera can not get closer).
  113580. * This can help limiting how the Camera is able to move in the scene.
  113581. */
  113582. lowerRadiusLimit: Nullable<number>;
  113583. /**
  113584. * Maximum allowed distance of the camera to the axis of rotation
  113585. * (The camera can not get further).
  113586. * This can help limiting how the Camera is able to move in the scene.
  113587. */
  113588. upperRadiusLimit: Nullable<number>;
  113589. /**
  113590. * Define a rotation offset between the camera and the object it follows
  113591. */
  113592. rotationOffset: number;
  113593. /**
  113594. * Minimum allowed angle to camera position relative to target object.
  113595. * This can help limiting how the Camera is able to move in the scene.
  113596. */
  113597. lowerRotationOffsetLimit: Nullable<number>;
  113598. /**
  113599. * Maximum allowed angle to camera position relative to target object.
  113600. * This can help limiting how the Camera is able to move in the scene.
  113601. */
  113602. upperRotationOffsetLimit: Nullable<number>;
  113603. /**
  113604. * Define a height offset between the camera and the object it follows.
  113605. * It can help following an object from the top (like a car chaing a plane)
  113606. */
  113607. heightOffset: number;
  113608. /**
  113609. * Minimum allowed height of camera position relative to target object.
  113610. * This can help limiting how the Camera is able to move in the scene.
  113611. */
  113612. lowerHeightOffsetLimit: Nullable<number>;
  113613. /**
  113614. * Maximum allowed height of camera position relative to target object.
  113615. * This can help limiting how the Camera is able to move in the scene.
  113616. */
  113617. upperHeightOffsetLimit: Nullable<number>;
  113618. /**
  113619. * Define how fast the camera can accelerate to follow it s target.
  113620. */
  113621. cameraAcceleration: number;
  113622. /**
  113623. * Define the speed limit of the camera following an object.
  113624. */
  113625. maxCameraSpeed: number;
  113626. /**
  113627. * Define the target of the camera.
  113628. */
  113629. lockedTarget: Nullable<AbstractMesh>;
  113630. /**
  113631. * Defines the input associated with the camera.
  113632. */
  113633. inputs: FollowCameraInputsManager;
  113634. /**
  113635. * Instantiates the follow camera.
  113636. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113637. * @param name Define the name of the camera in the scene
  113638. * @param position Define the position of the camera
  113639. * @param scene Define the scene the camera belong to
  113640. * @param lockedTarget Define the target of the camera
  113641. */
  113642. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  113643. private _follow;
  113644. /**
  113645. * Attached controls to the current camera.
  113646. * @param element Defines the element the controls should be listened from
  113647. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113648. */
  113649. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113650. /**
  113651. * Detach the current controls from the camera.
  113652. * The camera will stop reacting to inputs.
  113653. * @param element Defines the element to stop listening the inputs from
  113654. */
  113655. detachControl(element: HTMLElement): void;
  113656. /** @hidden */
  113657. _checkInputs(): void;
  113658. private _checkLimits;
  113659. /**
  113660. * Gets the camera class name.
  113661. * @returns the class name
  113662. */
  113663. getClassName(): string;
  113664. }
  113665. /**
  113666. * Arc Rotate version of the follow camera.
  113667. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  113668. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113669. */
  113670. export class ArcFollowCamera extends TargetCamera {
  113671. /** The longitudinal angle of the camera */
  113672. alpha: number;
  113673. /** The latitudinal angle of the camera */
  113674. beta: number;
  113675. /** The radius of the camera from its target */
  113676. radius: number;
  113677. /** Define the camera target (the messh it should follow) */
  113678. target: Nullable<AbstractMesh>;
  113679. private _cartesianCoordinates;
  113680. /**
  113681. * Instantiates a new ArcFollowCamera
  113682. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113683. * @param name Define the name of the camera
  113684. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  113685. * @param beta Define the rotation angle of the camera around the elevation axis
  113686. * @param radius Define the radius of the camera from its target point
  113687. * @param target Define the target of the camera
  113688. * @param scene Define the scene the camera belongs to
  113689. */
  113690. constructor(name: string,
  113691. /** The longitudinal angle of the camera */
  113692. alpha: number,
  113693. /** The latitudinal angle of the camera */
  113694. beta: number,
  113695. /** The radius of the camera from its target */
  113696. radius: number,
  113697. /** Define the camera target (the messh it should follow) */
  113698. target: Nullable<AbstractMesh>, scene: Scene);
  113699. private _follow;
  113700. /** @hidden */
  113701. _checkInputs(): void;
  113702. /**
  113703. * Returns the class name of the object.
  113704. * It is mostly used internally for serialization purposes.
  113705. */
  113706. getClassName(): string;
  113707. }
  113708. }
  113709. declare module BABYLON {
  113710. /**
  113711. * Manage the keyboard inputs to control the movement of a follow camera.
  113712. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113713. */
  113714. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  113715. /**
  113716. * Defines the camera the input is attached to.
  113717. */
  113718. camera: FollowCamera;
  113719. /**
  113720. * Defines the list of key codes associated with the up action (increase heightOffset)
  113721. */
  113722. keysHeightOffsetIncr: number[];
  113723. /**
  113724. * Defines the list of key codes associated with the down action (decrease heightOffset)
  113725. */
  113726. keysHeightOffsetDecr: number[];
  113727. /**
  113728. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  113729. */
  113730. keysHeightOffsetModifierAlt: boolean;
  113731. /**
  113732. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  113733. */
  113734. keysHeightOffsetModifierCtrl: boolean;
  113735. /**
  113736. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  113737. */
  113738. keysHeightOffsetModifierShift: boolean;
  113739. /**
  113740. * Defines the list of key codes associated with the left action (increase rotationOffset)
  113741. */
  113742. keysRotationOffsetIncr: number[];
  113743. /**
  113744. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  113745. */
  113746. keysRotationOffsetDecr: number[];
  113747. /**
  113748. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  113749. */
  113750. keysRotationOffsetModifierAlt: boolean;
  113751. /**
  113752. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  113753. */
  113754. keysRotationOffsetModifierCtrl: boolean;
  113755. /**
  113756. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  113757. */
  113758. keysRotationOffsetModifierShift: boolean;
  113759. /**
  113760. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  113761. */
  113762. keysRadiusIncr: number[];
  113763. /**
  113764. * Defines the list of key codes associated with the zoom-out action (increase radius)
  113765. */
  113766. keysRadiusDecr: number[];
  113767. /**
  113768. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  113769. */
  113770. keysRadiusModifierAlt: boolean;
  113771. /**
  113772. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  113773. */
  113774. keysRadiusModifierCtrl: boolean;
  113775. /**
  113776. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  113777. */
  113778. keysRadiusModifierShift: boolean;
  113779. /**
  113780. * Defines the rate of change of heightOffset.
  113781. */
  113782. heightSensibility: number;
  113783. /**
  113784. * Defines the rate of change of rotationOffset.
  113785. */
  113786. rotationSensibility: number;
  113787. /**
  113788. * Defines the rate of change of radius.
  113789. */
  113790. radiusSensibility: number;
  113791. private _keys;
  113792. private _ctrlPressed;
  113793. private _altPressed;
  113794. private _shiftPressed;
  113795. private _onCanvasBlurObserver;
  113796. private _onKeyboardObserver;
  113797. private _engine;
  113798. private _scene;
  113799. /**
  113800. * Attach the input controls to a specific dom element to get the input from.
  113801. * @param element Defines the element the controls should be listened from
  113802. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113803. */
  113804. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113805. /**
  113806. * Detach the current controls from the specified dom element.
  113807. * @param element Defines the element to stop listening the inputs from
  113808. */
  113809. detachControl(element: Nullable<HTMLElement>): void;
  113810. /**
  113811. * Update the current camera state depending on the inputs that have been used this frame.
  113812. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113813. */
  113814. checkInputs(): void;
  113815. /**
  113816. * Gets the class name of the current input.
  113817. * @returns the class name
  113818. */
  113819. getClassName(): string;
  113820. /**
  113821. * Get the friendly name associated with the input class.
  113822. * @returns the input friendly name
  113823. */
  113824. getSimpleName(): string;
  113825. /**
  113826. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  113827. * allow modification of the heightOffset value.
  113828. */
  113829. private _modifierHeightOffset;
  113830. /**
  113831. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  113832. * allow modification of the rotationOffset value.
  113833. */
  113834. private _modifierRotationOffset;
  113835. /**
  113836. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  113837. * allow modification of the radius value.
  113838. */
  113839. private _modifierRadius;
  113840. }
  113841. }
  113842. declare module BABYLON {
  113843. interface FreeCameraInputsManager {
  113844. /**
  113845. * @hidden
  113846. */
  113847. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  113848. /**
  113849. * Add orientation input support to the input manager.
  113850. * @returns the current input manager
  113851. */
  113852. addDeviceOrientation(): FreeCameraInputsManager;
  113853. }
  113854. /**
  113855. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  113856. * Screen rotation is taken into account.
  113857. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113858. */
  113859. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  113860. private _camera;
  113861. private _screenOrientationAngle;
  113862. private _constantTranform;
  113863. private _screenQuaternion;
  113864. private _alpha;
  113865. private _beta;
  113866. private _gamma;
  113867. /**
  113868. * Can be used to detect if a device orientation sensor is available on a device
  113869. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  113870. * @returns a promise that will resolve on orientation change
  113871. */
  113872. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  113873. /**
  113874. * @hidden
  113875. */
  113876. _onDeviceOrientationChangedObservable: Observable<void>;
  113877. /**
  113878. * Instantiates a new input
  113879. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113880. */
  113881. constructor();
  113882. /**
  113883. * Define the camera controlled by the input.
  113884. */
  113885. get camera(): FreeCamera;
  113886. set camera(camera: FreeCamera);
  113887. /**
  113888. * Attach the input controls to a specific dom element to get the input from.
  113889. * @param element Defines the element the controls should be listened from
  113890. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113891. */
  113892. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113893. private _orientationChanged;
  113894. private _deviceOrientation;
  113895. /**
  113896. * Detach the current controls from the specified dom element.
  113897. * @param element Defines the element to stop listening the inputs from
  113898. */
  113899. detachControl(element: Nullable<HTMLElement>): void;
  113900. /**
  113901. * Update the current camera state depending on the inputs that have been used this frame.
  113902. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113903. */
  113904. checkInputs(): void;
  113905. /**
  113906. * Gets the class name of the current intput.
  113907. * @returns the class name
  113908. */
  113909. getClassName(): string;
  113910. /**
  113911. * Get the friendly name associated with the input class.
  113912. * @returns the input friendly name
  113913. */
  113914. getSimpleName(): string;
  113915. }
  113916. }
  113917. declare module BABYLON {
  113918. /**
  113919. * Manage the gamepad inputs to control a free camera.
  113920. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113921. */
  113922. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  113923. /**
  113924. * Define the camera the input is attached to.
  113925. */
  113926. camera: FreeCamera;
  113927. /**
  113928. * Define the Gamepad controlling the input
  113929. */
  113930. gamepad: Nullable<Gamepad>;
  113931. /**
  113932. * Defines the gamepad rotation sensiblity.
  113933. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  113934. */
  113935. gamepadAngularSensibility: number;
  113936. /**
  113937. * Defines the gamepad move sensiblity.
  113938. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  113939. */
  113940. gamepadMoveSensibility: number;
  113941. private _yAxisScale;
  113942. /**
  113943. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  113944. */
  113945. get invertYAxis(): boolean;
  113946. set invertYAxis(value: boolean);
  113947. private _onGamepadConnectedObserver;
  113948. private _onGamepadDisconnectedObserver;
  113949. private _cameraTransform;
  113950. private _deltaTransform;
  113951. private _vector3;
  113952. private _vector2;
  113953. /**
  113954. * Attach the input controls to a specific dom element to get the input from.
  113955. * @param element Defines the element the controls should be listened from
  113956. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113957. */
  113958. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113959. /**
  113960. * Detach the current controls from the specified dom element.
  113961. * @param element Defines the element to stop listening the inputs from
  113962. */
  113963. detachControl(element: Nullable<HTMLElement>): void;
  113964. /**
  113965. * Update the current camera state depending on the inputs that have been used this frame.
  113966. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113967. */
  113968. checkInputs(): void;
  113969. /**
  113970. * Gets the class name of the current intput.
  113971. * @returns the class name
  113972. */
  113973. getClassName(): string;
  113974. /**
  113975. * Get the friendly name associated with the input class.
  113976. * @returns the input friendly name
  113977. */
  113978. getSimpleName(): string;
  113979. }
  113980. }
  113981. declare module BABYLON {
  113982. /**
  113983. * Defines the potential axis of a Joystick
  113984. */
  113985. export enum JoystickAxis {
  113986. /** X axis */
  113987. X = 0,
  113988. /** Y axis */
  113989. Y = 1,
  113990. /** Z axis */
  113991. Z = 2
  113992. }
  113993. /**
  113994. * Class used to define virtual joystick (used in touch mode)
  113995. */
  113996. export class VirtualJoystick {
  113997. /**
  113998. * Gets or sets a boolean indicating that left and right values must be inverted
  113999. */
  114000. reverseLeftRight: boolean;
  114001. /**
  114002. * Gets or sets a boolean indicating that up and down values must be inverted
  114003. */
  114004. reverseUpDown: boolean;
  114005. /**
  114006. * Gets the offset value for the position (ie. the change of the position value)
  114007. */
  114008. deltaPosition: Vector3;
  114009. /**
  114010. * Gets a boolean indicating if the virtual joystick was pressed
  114011. */
  114012. pressed: boolean;
  114013. /**
  114014. * Canvas the virtual joystick will render onto, default z-index of this is 5
  114015. */
  114016. static Canvas: Nullable<HTMLCanvasElement>;
  114017. private static _globalJoystickIndex;
  114018. private static vjCanvasContext;
  114019. private static vjCanvasWidth;
  114020. private static vjCanvasHeight;
  114021. private static halfWidth;
  114022. private _action;
  114023. private _axisTargetedByLeftAndRight;
  114024. private _axisTargetedByUpAndDown;
  114025. private _joystickSensibility;
  114026. private _inversedSensibility;
  114027. private _joystickPointerID;
  114028. private _joystickColor;
  114029. private _joystickPointerPos;
  114030. private _joystickPreviousPointerPos;
  114031. private _joystickPointerStartPos;
  114032. private _deltaJoystickVector;
  114033. private _leftJoystick;
  114034. private _touches;
  114035. private _onPointerDownHandlerRef;
  114036. private _onPointerMoveHandlerRef;
  114037. private _onPointerUpHandlerRef;
  114038. private _onResize;
  114039. /**
  114040. * Creates a new virtual joystick
  114041. * @param leftJoystick defines that the joystick is for left hand (false by default)
  114042. */
  114043. constructor(leftJoystick?: boolean);
  114044. /**
  114045. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  114046. * @param newJoystickSensibility defines the new sensibility
  114047. */
  114048. setJoystickSensibility(newJoystickSensibility: number): void;
  114049. private _onPointerDown;
  114050. private _onPointerMove;
  114051. private _onPointerUp;
  114052. /**
  114053. * Change the color of the virtual joystick
  114054. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  114055. */
  114056. setJoystickColor(newColor: string): void;
  114057. /**
  114058. * Defines a callback to call when the joystick is touched
  114059. * @param action defines the callback
  114060. */
  114061. setActionOnTouch(action: () => any): void;
  114062. /**
  114063. * Defines which axis you'd like to control for left & right
  114064. * @param axis defines the axis to use
  114065. */
  114066. setAxisForLeftRight(axis: JoystickAxis): void;
  114067. /**
  114068. * Defines which axis you'd like to control for up & down
  114069. * @param axis defines the axis to use
  114070. */
  114071. setAxisForUpDown(axis: JoystickAxis): void;
  114072. private _drawVirtualJoystick;
  114073. /**
  114074. * Release internal HTML canvas
  114075. */
  114076. releaseCanvas(): void;
  114077. }
  114078. }
  114079. declare module BABYLON {
  114080. interface FreeCameraInputsManager {
  114081. /**
  114082. * Add virtual joystick input support to the input manager.
  114083. * @returns the current input manager
  114084. */
  114085. addVirtualJoystick(): FreeCameraInputsManager;
  114086. }
  114087. /**
  114088. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  114089. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114090. */
  114091. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  114092. /**
  114093. * Defines the camera the input is attached to.
  114094. */
  114095. camera: FreeCamera;
  114096. private _leftjoystick;
  114097. private _rightjoystick;
  114098. /**
  114099. * Gets the left stick of the virtual joystick.
  114100. * @returns The virtual Joystick
  114101. */
  114102. getLeftJoystick(): VirtualJoystick;
  114103. /**
  114104. * Gets the right stick of the virtual joystick.
  114105. * @returns The virtual Joystick
  114106. */
  114107. getRightJoystick(): VirtualJoystick;
  114108. /**
  114109. * Update the current camera state depending on the inputs that have been used this frame.
  114110. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114111. */
  114112. checkInputs(): void;
  114113. /**
  114114. * Attach the input controls to a specific dom element to get the input from.
  114115. * @param element Defines the element the controls should be listened from
  114116. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114117. */
  114118. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114119. /**
  114120. * Detach the current controls from the specified dom element.
  114121. * @param element Defines the element to stop listening the inputs from
  114122. */
  114123. detachControl(element: Nullable<HTMLElement>): void;
  114124. /**
  114125. * Gets the class name of the current intput.
  114126. * @returns the class name
  114127. */
  114128. getClassName(): string;
  114129. /**
  114130. * Get the friendly name associated with the input class.
  114131. * @returns the input friendly name
  114132. */
  114133. getSimpleName(): string;
  114134. }
  114135. }
  114136. declare module BABYLON {
  114137. /**
  114138. * This represents a FPS type of camera controlled by touch.
  114139. * This is like a universal camera minus the Gamepad controls.
  114140. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114141. */
  114142. export class TouchCamera extends FreeCamera {
  114143. /**
  114144. * Defines the touch sensibility for rotation.
  114145. * The higher the faster.
  114146. */
  114147. get touchAngularSensibility(): number;
  114148. set touchAngularSensibility(value: number);
  114149. /**
  114150. * Defines the touch sensibility for move.
  114151. * The higher the faster.
  114152. */
  114153. get touchMoveSensibility(): number;
  114154. set touchMoveSensibility(value: number);
  114155. /**
  114156. * Instantiates a new touch camera.
  114157. * This represents a FPS type of camera controlled by touch.
  114158. * This is like a universal camera minus the Gamepad controls.
  114159. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114160. * @param name Define the name of the camera in the scene
  114161. * @param position Define the start position of the camera in the scene
  114162. * @param scene Define the scene the camera belongs to
  114163. */
  114164. constructor(name: string, position: Vector3, scene: Scene);
  114165. /**
  114166. * Gets the current object class name.
  114167. * @return the class name
  114168. */
  114169. getClassName(): string;
  114170. /** @hidden */
  114171. _setupInputs(): void;
  114172. }
  114173. }
  114174. declare module BABYLON {
  114175. /**
  114176. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  114177. * being tilted forward or back and left or right.
  114178. */
  114179. export class DeviceOrientationCamera extends FreeCamera {
  114180. private _initialQuaternion;
  114181. private _quaternionCache;
  114182. private _tmpDragQuaternion;
  114183. private _disablePointerInputWhenUsingDeviceOrientation;
  114184. /**
  114185. * Creates a new device orientation camera
  114186. * @param name The name of the camera
  114187. * @param position The start position camera
  114188. * @param scene The scene the camera belongs to
  114189. */
  114190. constructor(name: string, position: Vector3, scene: Scene);
  114191. /**
  114192. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  114193. */
  114194. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  114195. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  114196. private _dragFactor;
  114197. /**
  114198. * Enabled turning on the y axis when the orientation sensor is active
  114199. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  114200. */
  114201. enableHorizontalDragging(dragFactor?: number): void;
  114202. /**
  114203. * Gets the current instance class name ("DeviceOrientationCamera").
  114204. * This helps avoiding instanceof at run time.
  114205. * @returns the class name
  114206. */
  114207. getClassName(): string;
  114208. /**
  114209. * @hidden
  114210. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  114211. */
  114212. _checkInputs(): void;
  114213. /**
  114214. * Reset the camera to its default orientation on the specified axis only.
  114215. * @param axis The axis to reset
  114216. */
  114217. resetToCurrentRotation(axis?: Axis): void;
  114218. }
  114219. }
  114220. declare module BABYLON {
  114221. /**
  114222. * Defines supported buttons for XBox360 compatible gamepads
  114223. */
  114224. export enum Xbox360Button {
  114225. /** A */
  114226. A = 0,
  114227. /** B */
  114228. B = 1,
  114229. /** X */
  114230. X = 2,
  114231. /** Y */
  114232. Y = 3,
  114233. /** Start */
  114234. Start = 4,
  114235. /** Back */
  114236. Back = 5,
  114237. /** Left button */
  114238. LB = 6,
  114239. /** Right button */
  114240. RB = 7,
  114241. /** Left stick */
  114242. LeftStick = 8,
  114243. /** Right stick */
  114244. RightStick = 9
  114245. }
  114246. /** Defines values for XBox360 DPad */
  114247. export enum Xbox360Dpad {
  114248. /** Up */
  114249. Up = 0,
  114250. /** Down */
  114251. Down = 1,
  114252. /** Left */
  114253. Left = 2,
  114254. /** Right */
  114255. Right = 3
  114256. }
  114257. /**
  114258. * Defines a XBox360 gamepad
  114259. */
  114260. export class Xbox360Pad extends Gamepad {
  114261. private _leftTrigger;
  114262. private _rightTrigger;
  114263. private _onlefttriggerchanged;
  114264. private _onrighttriggerchanged;
  114265. private _onbuttondown;
  114266. private _onbuttonup;
  114267. private _ondpaddown;
  114268. private _ondpadup;
  114269. /** Observable raised when a button is pressed */
  114270. onButtonDownObservable: Observable<Xbox360Button>;
  114271. /** Observable raised when a button is released */
  114272. onButtonUpObservable: Observable<Xbox360Button>;
  114273. /** Observable raised when a pad is pressed */
  114274. onPadDownObservable: Observable<Xbox360Dpad>;
  114275. /** Observable raised when a pad is released */
  114276. onPadUpObservable: Observable<Xbox360Dpad>;
  114277. private _buttonA;
  114278. private _buttonB;
  114279. private _buttonX;
  114280. private _buttonY;
  114281. private _buttonBack;
  114282. private _buttonStart;
  114283. private _buttonLB;
  114284. private _buttonRB;
  114285. private _buttonLeftStick;
  114286. private _buttonRightStick;
  114287. private _dPadUp;
  114288. private _dPadDown;
  114289. private _dPadLeft;
  114290. private _dPadRight;
  114291. private _isXboxOnePad;
  114292. /**
  114293. * Creates a new XBox360 gamepad object
  114294. * @param id defines the id of this gamepad
  114295. * @param index defines its index
  114296. * @param gamepad defines the internal HTML gamepad object
  114297. * @param xboxOne defines if it is a XBox One gamepad
  114298. */
  114299. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  114300. /**
  114301. * Defines the callback to call when left trigger is pressed
  114302. * @param callback defines the callback to use
  114303. */
  114304. onlefttriggerchanged(callback: (value: number) => void): void;
  114305. /**
  114306. * Defines the callback to call when right trigger is pressed
  114307. * @param callback defines the callback to use
  114308. */
  114309. onrighttriggerchanged(callback: (value: number) => void): void;
  114310. /**
  114311. * Gets the left trigger value
  114312. */
  114313. get leftTrigger(): number;
  114314. /**
  114315. * Sets the left trigger value
  114316. */
  114317. set leftTrigger(newValue: number);
  114318. /**
  114319. * Gets the right trigger value
  114320. */
  114321. get rightTrigger(): number;
  114322. /**
  114323. * Sets the right trigger value
  114324. */
  114325. set rightTrigger(newValue: number);
  114326. /**
  114327. * Defines the callback to call when a button is pressed
  114328. * @param callback defines the callback to use
  114329. */
  114330. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  114331. /**
  114332. * Defines the callback to call when a button is released
  114333. * @param callback defines the callback to use
  114334. */
  114335. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  114336. /**
  114337. * Defines the callback to call when a pad is pressed
  114338. * @param callback defines the callback to use
  114339. */
  114340. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  114341. /**
  114342. * Defines the callback to call when a pad is released
  114343. * @param callback defines the callback to use
  114344. */
  114345. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  114346. private _setButtonValue;
  114347. private _setDPadValue;
  114348. /**
  114349. * Gets the value of the `A` button
  114350. */
  114351. get buttonA(): number;
  114352. /**
  114353. * Sets the value of the `A` button
  114354. */
  114355. set buttonA(value: number);
  114356. /**
  114357. * Gets the value of the `B` button
  114358. */
  114359. get buttonB(): number;
  114360. /**
  114361. * Sets the value of the `B` button
  114362. */
  114363. set buttonB(value: number);
  114364. /**
  114365. * Gets the value of the `X` button
  114366. */
  114367. get buttonX(): number;
  114368. /**
  114369. * Sets the value of the `X` button
  114370. */
  114371. set buttonX(value: number);
  114372. /**
  114373. * Gets the value of the `Y` button
  114374. */
  114375. get buttonY(): number;
  114376. /**
  114377. * Sets the value of the `Y` button
  114378. */
  114379. set buttonY(value: number);
  114380. /**
  114381. * Gets the value of the `Start` button
  114382. */
  114383. get buttonStart(): number;
  114384. /**
  114385. * Sets the value of the `Start` button
  114386. */
  114387. set buttonStart(value: number);
  114388. /**
  114389. * Gets the value of the `Back` button
  114390. */
  114391. get buttonBack(): number;
  114392. /**
  114393. * Sets the value of the `Back` button
  114394. */
  114395. set buttonBack(value: number);
  114396. /**
  114397. * Gets the value of the `Left` button
  114398. */
  114399. get buttonLB(): number;
  114400. /**
  114401. * Sets the value of the `Left` button
  114402. */
  114403. set buttonLB(value: number);
  114404. /**
  114405. * Gets the value of the `Right` button
  114406. */
  114407. get buttonRB(): number;
  114408. /**
  114409. * Sets the value of the `Right` button
  114410. */
  114411. set buttonRB(value: number);
  114412. /**
  114413. * Gets the value of the Left joystick
  114414. */
  114415. get buttonLeftStick(): number;
  114416. /**
  114417. * Sets the value of the Left joystick
  114418. */
  114419. set buttonLeftStick(value: number);
  114420. /**
  114421. * Gets the value of the Right joystick
  114422. */
  114423. get buttonRightStick(): number;
  114424. /**
  114425. * Sets the value of the Right joystick
  114426. */
  114427. set buttonRightStick(value: number);
  114428. /**
  114429. * Gets the value of D-pad up
  114430. */
  114431. get dPadUp(): number;
  114432. /**
  114433. * Sets the value of D-pad up
  114434. */
  114435. set dPadUp(value: number);
  114436. /**
  114437. * Gets the value of D-pad down
  114438. */
  114439. get dPadDown(): number;
  114440. /**
  114441. * Sets the value of D-pad down
  114442. */
  114443. set dPadDown(value: number);
  114444. /**
  114445. * Gets the value of D-pad left
  114446. */
  114447. get dPadLeft(): number;
  114448. /**
  114449. * Sets the value of D-pad left
  114450. */
  114451. set dPadLeft(value: number);
  114452. /**
  114453. * Gets the value of D-pad right
  114454. */
  114455. get dPadRight(): number;
  114456. /**
  114457. * Sets the value of D-pad right
  114458. */
  114459. set dPadRight(value: number);
  114460. /**
  114461. * Force the gamepad to synchronize with device values
  114462. */
  114463. update(): void;
  114464. /**
  114465. * Disposes the gamepad
  114466. */
  114467. dispose(): void;
  114468. }
  114469. }
  114470. declare module BABYLON {
  114471. /**
  114472. * Defines supported buttons for DualShock compatible gamepads
  114473. */
  114474. export enum DualShockButton {
  114475. /** Cross */
  114476. Cross = 0,
  114477. /** Circle */
  114478. Circle = 1,
  114479. /** Square */
  114480. Square = 2,
  114481. /** Triangle */
  114482. Triangle = 3,
  114483. /** Options */
  114484. Options = 4,
  114485. /** Share */
  114486. Share = 5,
  114487. /** L1 */
  114488. L1 = 6,
  114489. /** R1 */
  114490. R1 = 7,
  114491. /** Left stick */
  114492. LeftStick = 8,
  114493. /** Right stick */
  114494. RightStick = 9
  114495. }
  114496. /** Defines values for DualShock DPad */
  114497. export enum DualShockDpad {
  114498. /** Up */
  114499. Up = 0,
  114500. /** Down */
  114501. Down = 1,
  114502. /** Left */
  114503. Left = 2,
  114504. /** Right */
  114505. Right = 3
  114506. }
  114507. /**
  114508. * Defines a DualShock gamepad
  114509. */
  114510. export class DualShockPad extends Gamepad {
  114511. private _leftTrigger;
  114512. private _rightTrigger;
  114513. private _onlefttriggerchanged;
  114514. private _onrighttriggerchanged;
  114515. private _onbuttondown;
  114516. private _onbuttonup;
  114517. private _ondpaddown;
  114518. private _ondpadup;
  114519. /** Observable raised when a button is pressed */
  114520. onButtonDownObservable: Observable<DualShockButton>;
  114521. /** Observable raised when a button is released */
  114522. onButtonUpObservable: Observable<DualShockButton>;
  114523. /** Observable raised when a pad is pressed */
  114524. onPadDownObservable: Observable<DualShockDpad>;
  114525. /** Observable raised when a pad is released */
  114526. onPadUpObservable: Observable<DualShockDpad>;
  114527. private _buttonCross;
  114528. private _buttonCircle;
  114529. private _buttonSquare;
  114530. private _buttonTriangle;
  114531. private _buttonShare;
  114532. private _buttonOptions;
  114533. private _buttonL1;
  114534. private _buttonR1;
  114535. private _buttonLeftStick;
  114536. private _buttonRightStick;
  114537. private _dPadUp;
  114538. private _dPadDown;
  114539. private _dPadLeft;
  114540. private _dPadRight;
  114541. /**
  114542. * Creates a new DualShock gamepad object
  114543. * @param id defines the id of this gamepad
  114544. * @param index defines its index
  114545. * @param gamepad defines the internal HTML gamepad object
  114546. */
  114547. constructor(id: string, index: number, gamepad: any);
  114548. /**
  114549. * Defines the callback to call when left trigger is pressed
  114550. * @param callback defines the callback to use
  114551. */
  114552. onlefttriggerchanged(callback: (value: number) => void): void;
  114553. /**
  114554. * Defines the callback to call when right trigger is pressed
  114555. * @param callback defines the callback to use
  114556. */
  114557. onrighttriggerchanged(callback: (value: number) => void): void;
  114558. /**
  114559. * Gets the left trigger value
  114560. */
  114561. get leftTrigger(): number;
  114562. /**
  114563. * Sets the left trigger value
  114564. */
  114565. set leftTrigger(newValue: number);
  114566. /**
  114567. * Gets the right trigger value
  114568. */
  114569. get rightTrigger(): number;
  114570. /**
  114571. * Sets the right trigger value
  114572. */
  114573. set rightTrigger(newValue: number);
  114574. /**
  114575. * Defines the callback to call when a button is pressed
  114576. * @param callback defines the callback to use
  114577. */
  114578. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  114579. /**
  114580. * Defines the callback to call when a button is released
  114581. * @param callback defines the callback to use
  114582. */
  114583. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  114584. /**
  114585. * Defines the callback to call when a pad is pressed
  114586. * @param callback defines the callback to use
  114587. */
  114588. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  114589. /**
  114590. * Defines the callback to call when a pad is released
  114591. * @param callback defines the callback to use
  114592. */
  114593. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  114594. private _setButtonValue;
  114595. private _setDPadValue;
  114596. /**
  114597. * Gets the value of the `Cross` button
  114598. */
  114599. get buttonCross(): number;
  114600. /**
  114601. * Sets the value of the `Cross` button
  114602. */
  114603. set buttonCross(value: number);
  114604. /**
  114605. * Gets the value of the `Circle` button
  114606. */
  114607. get buttonCircle(): number;
  114608. /**
  114609. * Sets the value of the `Circle` button
  114610. */
  114611. set buttonCircle(value: number);
  114612. /**
  114613. * Gets the value of the `Square` button
  114614. */
  114615. get buttonSquare(): number;
  114616. /**
  114617. * Sets the value of the `Square` button
  114618. */
  114619. set buttonSquare(value: number);
  114620. /**
  114621. * Gets the value of the `Triangle` button
  114622. */
  114623. get buttonTriangle(): number;
  114624. /**
  114625. * Sets the value of the `Triangle` button
  114626. */
  114627. set buttonTriangle(value: number);
  114628. /**
  114629. * Gets the value of the `Options` button
  114630. */
  114631. get buttonOptions(): number;
  114632. /**
  114633. * Sets the value of the `Options` button
  114634. */
  114635. set buttonOptions(value: number);
  114636. /**
  114637. * Gets the value of the `Share` button
  114638. */
  114639. get buttonShare(): number;
  114640. /**
  114641. * Sets the value of the `Share` button
  114642. */
  114643. set buttonShare(value: number);
  114644. /**
  114645. * Gets the value of the `L1` button
  114646. */
  114647. get buttonL1(): number;
  114648. /**
  114649. * Sets the value of the `L1` button
  114650. */
  114651. set buttonL1(value: number);
  114652. /**
  114653. * Gets the value of the `R1` button
  114654. */
  114655. get buttonR1(): number;
  114656. /**
  114657. * Sets the value of the `R1` button
  114658. */
  114659. set buttonR1(value: number);
  114660. /**
  114661. * Gets the value of the Left joystick
  114662. */
  114663. get buttonLeftStick(): number;
  114664. /**
  114665. * Sets the value of the Left joystick
  114666. */
  114667. set buttonLeftStick(value: number);
  114668. /**
  114669. * Gets the value of the Right joystick
  114670. */
  114671. get buttonRightStick(): number;
  114672. /**
  114673. * Sets the value of the Right joystick
  114674. */
  114675. set buttonRightStick(value: number);
  114676. /**
  114677. * Gets the value of D-pad up
  114678. */
  114679. get dPadUp(): number;
  114680. /**
  114681. * Sets the value of D-pad up
  114682. */
  114683. set dPadUp(value: number);
  114684. /**
  114685. * Gets the value of D-pad down
  114686. */
  114687. get dPadDown(): number;
  114688. /**
  114689. * Sets the value of D-pad down
  114690. */
  114691. set dPadDown(value: number);
  114692. /**
  114693. * Gets the value of D-pad left
  114694. */
  114695. get dPadLeft(): number;
  114696. /**
  114697. * Sets the value of D-pad left
  114698. */
  114699. set dPadLeft(value: number);
  114700. /**
  114701. * Gets the value of D-pad right
  114702. */
  114703. get dPadRight(): number;
  114704. /**
  114705. * Sets the value of D-pad right
  114706. */
  114707. set dPadRight(value: number);
  114708. /**
  114709. * Force the gamepad to synchronize with device values
  114710. */
  114711. update(): void;
  114712. /**
  114713. * Disposes the gamepad
  114714. */
  114715. dispose(): void;
  114716. }
  114717. }
  114718. declare module BABYLON {
  114719. /**
  114720. * Manager for handling gamepads
  114721. */
  114722. export class GamepadManager {
  114723. private _scene?;
  114724. private _babylonGamepads;
  114725. private _oneGamepadConnected;
  114726. /** @hidden */
  114727. _isMonitoring: boolean;
  114728. private _gamepadEventSupported;
  114729. private _gamepadSupport?;
  114730. /**
  114731. * observable to be triggered when the gamepad controller has been connected
  114732. */
  114733. onGamepadConnectedObservable: Observable<Gamepad>;
  114734. /**
  114735. * observable to be triggered when the gamepad controller has been disconnected
  114736. */
  114737. onGamepadDisconnectedObservable: Observable<Gamepad>;
  114738. private _onGamepadConnectedEvent;
  114739. private _onGamepadDisconnectedEvent;
  114740. /**
  114741. * Initializes the gamepad manager
  114742. * @param _scene BabylonJS scene
  114743. */
  114744. constructor(_scene?: Scene | undefined);
  114745. /**
  114746. * The gamepads in the game pad manager
  114747. */
  114748. get gamepads(): Gamepad[];
  114749. /**
  114750. * Get the gamepad controllers based on type
  114751. * @param type The type of gamepad controller
  114752. * @returns Nullable gamepad
  114753. */
  114754. getGamepadByType(type?: number): Nullable<Gamepad>;
  114755. /**
  114756. * Disposes the gamepad manager
  114757. */
  114758. dispose(): void;
  114759. private _addNewGamepad;
  114760. private _startMonitoringGamepads;
  114761. private _stopMonitoringGamepads;
  114762. /** @hidden */
  114763. _checkGamepadsStatus(): void;
  114764. private _updateGamepadObjects;
  114765. }
  114766. }
  114767. declare module BABYLON {
  114768. interface Scene {
  114769. /** @hidden */
  114770. _gamepadManager: Nullable<GamepadManager>;
  114771. /**
  114772. * Gets the gamepad manager associated with the scene
  114773. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  114774. */
  114775. gamepadManager: GamepadManager;
  114776. }
  114777. /**
  114778. * Interface representing a free camera inputs manager
  114779. */
  114780. interface FreeCameraInputsManager {
  114781. /**
  114782. * Adds gamepad input support to the FreeCameraInputsManager.
  114783. * @returns the FreeCameraInputsManager
  114784. */
  114785. addGamepad(): FreeCameraInputsManager;
  114786. }
  114787. /**
  114788. * Interface representing an arc rotate camera inputs manager
  114789. */
  114790. interface ArcRotateCameraInputsManager {
  114791. /**
  114792. * Adds gamepad input support to the ArcRotateCamera InputManager.
  114793. * @returns the camera inputs manager
  114794. */
  114795. addGamepad(): ArcRotateCameraInputsManager;
  114796. }
  114797. /**
  114798. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  114799. */
  114800. export class GamepadSystemSceneComponent implements ISceneComponent {
  114801. /**
  114802. * The component name helpfull to identify the component in the list of scene components.
  114803. */
  114804. readonly name: string;
  114805. /**
  114806. * The scene the component belongs to.
  114807. */
  114808. scene: Scene;
  114809. /**
  114810. * Creates a new instance of the component for the given scene
  114811. * @param scene Defines the scene to register the component in
  114812. */
  114813. constructor(scene: Scene);
  114814. /**
  114815. * Registers the component in a given scene
  114816. */
  114817. register(): void;
  114818. /**
  114819. * Rebuilds the elements related to this component in case of
  114820. * context lost for instance.
  114821. */
  114822. rebuild(): void;
  114823. /**
  114824. * Disposes the component and the associated ressources
  114825. */
  114826. dispose(): void;
  114827. private _beforeCameraUpdate;
  114828. }
  114829. }
  114830. declare module BABYLON {
  114831. /**
  114832. * 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,
  114833. * which still works and will still be found in many Playgrounds.
  114834. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114835. */
  114836. export class UniversalCamera extends TouchCamera {
  114837. /**
  114838. * Defines the gamepad rotation sensiblity.
  114839. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  114840. */
  114841. get gamepadAngularSensibility(): number;
  114842. set gamepadAngularSensibility(value: number);
  114843. /**
  114844. * Defines the gamepad move sensiblity.
  114845. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  114846. */
  114847. get gamepadMoveSensibility(): number;
  114848. set gamepadMoveSensibility(value: number);
  114849. /**
  114850. * 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,
  114851. * which still works and will still be found in many Playgrounds.
  114852. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114853. * @param name Define the name of the camera in the scene
  114854. * @param position Define the start position of the camera in the scene
  114855. * @param scene Define the scene the camera belongs to
  114856. */
  114857. constructor(name: string, position: Vector3, scene: Scene);
  114858. /**
  114859. * Gets the current object class name.
  114860. * @return the class name
  114861. */
  114862. getClassName(): string;
  114863. }
  114864. }
  114865. declare module BABYLON {
  114866. /**
  114867. * This represents a FPS type of camera. This is only here for back compat purpose.
  114868. * Please use the UniversalCamera instead as both are identical.
  114869. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114870. */
  114871. export class GamepadCamera extends UniversalCamera {
  114872. /**
  114873. * Instantiates a new Gamepad Camera
  114874. * This represents a FPS type of camera. This is only here for back compat purpose.
  114875. * Please use the UniversalCamera instead as both are identical.
  114876. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114877. * @param name Define the name of the camera in the scene
  114878. * @param position Define the start position of the camera in the scene
  114879. * @param scene Define the scene the camera belongs to
  114880. */
  114881. constructor(name: string, position: Vector3, scene: Scene);
  114882. /**
  114883. * Gets the current object class name.
  114884. * @return the class name
  114885. */
  114886. getClassName(): string;
  114887. }
  114888. }
  114889. declare module BABYLON {
  114890. /** @hidden */
  114891. export var passPixelShader: {
  114892. name: string;
  114893. shader: string;
  114894. };
  114895. }
  114896. declare module BABYLON {
  114897. /** @hidden */
  114898. export var passCubePixelShader: {
  114899. name: string;
  114900. shader: string;
  114901. };
  114902. }
  114903. declare module BABYLON {
  114904. /**
  114905. * PassPostProcess which produces an output the same as it's input
  114906. */
  114907. export class PassPostProcess extends PostProcess {
  114908. /**
  114909. * Creates the PassPostProcess
  114910. * @param name The name of the effect.
  114911. * @param options The required width/height ratio to downsize to before computing the render pass.
  114912. * @param camera The camera to apply the render pass to.
  114913. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  114914. * @param engine The engine which the post process will be applied. (default: current engine)
  114915. * @param reusable If the post process can be reused on the same frame. (default: false)
  114916. * @param textureType The type of texture to be used when performing the post processing.
  114917. * @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)
  114918. */
  114919. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  114920. }
  114921. /**
  114922. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  114923. */
  114924. export class PassCubePostProcess extends PostProcess {
  114925. private _face;
  114926. /**
  114927. * Gets or sets the cube face to display.
  114928. * * 0 is +X
  114929. * * 1 is -X
  114930. * * 2 is +Y
  114931. * * 3 is -Y
  114932. * * 4 is +Z
  114933. * * 5 is -Z
  114934. */
  114935. get face(): number;
  114936. set face(value: number);
  114937. /**
  114938. * Creates the PassCubePostProcess
  114939. * @param name The name of the effect.
  114940. * @param options The required width/height ratio to downsize to before computing the render pass.
  114941. * @param camera The camera to apply the render pass to.
  114942. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  114943. * @param engine The engine which the post process will be applied. (default: current engine)
  114944. * @param reusable If the post process can be reused on the same frame. (default: false)
  114945. * @param textureType The type of texture to be used when performing the post processing.
  114946. * @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)
  114947. */
  114948. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  114949. }
  114950. }
  114951. declare module BABYLON {
  114952. /** @hidden */
  114953. export var anaglyphPixelShader: {
  114954. name: string;
  114955. shader: string;
  114956. };
  114957. }
  114958. declare module BABYLON {
  114959. /**
  114960. * Postprocess used to generate anaglyphic rendering
  114961. */
  114962. export class AnaglyphPostProcess extends PostProcess {
  114963. private _passedProcess;
  114964. /**
  114965. * Creates a new AnaglyphPostProcess
  114966. * @param name defines postprocess name
  114967. * @param options defines creation options or target ratio scale
  114968. * @param rigCameras defines cameras using this postprocess
  114969. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  114970. * @param engine defines hosting engine
  114971. * @param reusable defines if the postprocess will be reused multiple times per frame
  114972. */
  114973. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  114974. }
  114975. }
  114976. declare module BABYLON {
  114977. /**
  114978. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  114979. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  114980. */
  114981. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  114982. /**
  114983. * Creates a new AnaglyphArcRotateCamera
  114984. * @param name defines camera name
  114985. * @param alpha defines alpha angle (in radians)
  114986. * @param beta defines beta angle (in radians)
  114987. * @param radius defines radius
  114988. * @param target defines camera target
  114989. * @param interaxialDistance defines distance between each color axis
  114990. * @param scene defines the hosting scene
  114991. */
  114992. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  114993. /**
  114994. * Gets camera class name
  114995. * @returns AnaglyphArcRotateCamera
  114996. */
  114997. getClassName(): string;
  114998. }
  114999. }
  115000. declare module BABYLON {
  115001. /**
  115002. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  115003. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  115004. */
  115005. export class AnaglyphFreeCamera extends FreeCamera {
  115006. /**
  115007. * Creates a new AnaglyphFreeCamera
  115008. * @param name defines camera name
  115009. * @param position defines initial position
  115010. * @param interaxialDistance defines distance between each color axis
  115011. * @param scene defines the hosting scene
  115012. */
  115013. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  115014. /**
  115015. * Gets camera class name
  115016. * @returns AnaglyphFreeCamera
  115017. */
  115018. getClassName(): string;
  115019. }
  115020. }
  115021. declare module BABYLON {
  115022. /**
  115023. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  115024. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  115025. */
  115026. export class AnaglyphGamepadCamera extends GamepadCamera {
  115027. /**
  115028. * Creates a new AnaglyphGamepadCamera
  115029. * @param name defines camera name
  115030. * @param position defines initial position
  115031. * @param interaxialDistance defines distance between each color axis
  115032. * @param scene defines the hosting scene
  115033. */
  115034. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  115035. /**
  115036. * Gets camera class name
  115037. * @returns AnaglyphGamepadCamera
  115038. */
  115039. getClassName(): string;
  115040. }
  115041. }
  115042. declare module BABYLON {
  115043. /**
  115044. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  115045. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  115046. */
  115047. export class AnaglyphUniversalCamera extends UniversalCamera {
  115048. /**
  115049. * Creates a new AnaglyphUniversalCamera
  115050. * @param name defines camera name
  115051. * @param position defines initial position
  115052. * @param interaxialDistance defines distance between each color axis
  115053. * @param scene defines the hosting scene
  115054. */
  115055. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  115056. /**
  115057. * Gets camera class name
  115058. * @returns AnaglyphUniversalCamera
  115059. */
  115060. getClassName(): string;
  115061. }
  115062. }
  115063. declare module BABYLON {
  115064. /** @hidden */
  115065. export var stereoscopicInterlacePixelShader: {
  115066. name: string;
  115067. shader: string;
  115068. };
  115069. }
  115070. declare module BABYLON {
  115071. /**
  115072. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  115073. */
  115074. export class StereoscopicInterlacePostProcessI extends PostProcess {
  115075. private _stepSize;
  115076. private _passedProcess;
  115077. /**
  115078. * Initializes a StereoscopicInterlacePostProcessI
  115079. * @param name The name of the effect.
  115080. * @param rigCameras The rig cameras to be appled to the post process
  115081. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  115082. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  115083. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115084. * @param engine The engine which the post process will be applied. (default: current engine)
  115085. * @param reusable If the post process can be reused on the same frame. (default: false)
  115086. */
  115087. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  115088. }
  115089. /**
  115090. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  115091. */
  115092. export class StereoscopicInterlacePostProcess extends PostProcess {
  115093. private _stepSize;
  115094. private _passedProcess;
  115095. /**
  115096. * Initializes a StereoscopicInterlacePostProcess
  115097. * @param name The name of the effect.
  115098. * @param rigCameras The rig cameras to be appled to the post process
  115099. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  115100. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115101. * @param engine The engine which the post process will be applied. (default: current engine)
  115102. * @param reusable If the post process can be reused on the same frame. (default: false)
  115103. */
  115104. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  115105. }
  115106. }
  115107. declare module BABYLON {
  115108. /**
  115109. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  115110. * @see http://doc.babylonjs.com/features/cameras
  115111. */
  115112. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  115113. /**
  115114. * Creates a new StereoscopicArcRotateCamera
  115115. * @param name defines camera name
  115116. * @param alpha defines alpha angle (in radians)
  115117. * @param beta defines beta angle (in radians)
  115118. * @param radius defines radius
  115119. * @param target defines camera target
  115120. * @param interaxialDistance defines distance between each color axis
  115121. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115122. * @param scene defines the hosting scene
  115123. */
  115124. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115125. /**
  115126. * Gets camera class name
  115127. * @returns StereoscopicArcRotateCamera
  115128. */
  115129. getClassName(): string;
  115130. }
  115131. }
  115132. declare module BABYLON {
  115133. /**
  115134. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  115135. * @see http://doc.babylonjs.com/features/cameras
  115136. */
  115137. export class StereoscopicFreeCamera extends FreeCamera {
  115138. /**
  115139. * Creates a new StereoscopicFreeCamera
  115140. * @param name defines camera name
  115141. * @param position defines initial position
  115142. * @param interaxialDistance defines distance between each color axis
  115143. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115144. * @param scene defines the hosting scene
  115145. */
  115146. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115147. /**
  115148. * Gets camera class name
  115149. * @returns StereoscopicFreeCamera
  115150. */
  115151. getClassName(): string;
  115152. }
  115153. }
  115154. declare module BABYLON {
  115155. /**
  115156. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  115157. * @see http://doc.babylonjs.com/features/cameras
  115158. */
  115159. export class StereoscopicGamepadCamera extends GamepadCamera {
  115160. /**
  115161. * Creates a new StereoscopicGamepadCamera
  115162. * @param name defines camera name
  115163. * @param position defines initial position
  115164. * @param interaxialDistance defines distance between each color axis
  115165. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115166. * @param scene defines the hosting scene
  115167. */
  115168. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115169. /**
  115170. * Gets camera class name
  115171. * @returns StereoscopicGamepadCamera
  115172. */
  115173. getClassName(): string;
  115174. }
  115175. }
  115176. declare module BABYLON {
  115177. /**
  115178. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  115179. * @see http://doc.babylonjs.com/features/cameras
  115180. */
  115181. export class StereoscopicUniversalCamera extends UniversalCamera {
  115182. /**
  115183. * Creates a new StereoscopicUniversalCamera
  115184. * @param name defines camera name
  115185. * @param position defines initial position
  115186. * @param interaxialDistance defines distance between each color axis
  115187. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115188. * @param scene defines the hosting scene
  115189. */
  115190. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115191. /**
  115192. * Gets camera class name
  115193. * @returns StereoscopicUniversalCamera
  115194. */
  115195. getClassName(): string;
  115196. }
  115197. }
  115198. declare module BABYLON {
  115199. /**
  115200. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  115201. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  115202. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  115203. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  115204. */
  115205. export class VirtualJoysticksCamera extends FreeCamera {
  115206. /**
  115207. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  115208. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  115209. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  115210. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  115211. * @param name Define the name of the camera in the scene
  115212. * @param position Define the start position of the camera in the scene
  115213. * @param scene Define the scene the camera belongs to
  115214. */
  115215. constructor(name: string, position: Vector3, scene: Scene);
  115216. /**
  115217. * Gets the current object class name.
  115218. * @return the class name
  115219. */
  115220. getClassName(): string;
  115221. }
  115222. }
  115223. declare module BABYLON {
  115224. /**
  115225. * This represents all the required metrics to create a VR camera.
  115226. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  115227. */
  115228. export class VRCameraMetrics {
  115229. /**
  115230. * Define the horizontal resolution off the screen.
  115231. */
  115232. hResolution: number;
  115233. /**
  115234. * Define the vertical resolution off the screen.
  115235. */
  115236. vResolution: number;
  115237. /**
  115238. * Define the horizontal screen size.
  115239. */
  115240. hScreenSize: number;
  115241. /**
  115242. * Define the vertical screen size.
  115243. */
  115244. vScreenSize: number;
  115245. /**
  115246. * Define the vertical screen center position.
  115247. */
  115248. vScreenCenter: number;
  115249. /**
  115250. * Define the distance of the eyes to the screen.
  115251. */
  115252. eyeToScreenDistance: number;
  115253. /**
  115254. * Define the distance between both lenses
  115255. */
  115256. lensSeparationDistance: number;
  115257. /**
  115258. * Define the distance between both viewer's eyes.
  115259. */
  115260. interpupillaryDistance: number;
  115261. /**
  115262. * Define the distortion factor of the VR postprocess.
  115263. * Please, touch with care.
  115264. */
  115265. distortionK: number[];
  115266. /**
  115267. * Define the chromatic aberration correction factors for the VR post process.
  115268. */
  115269. chromaAbCorrection: number[];
  115270. /**
  115271. * Define the scale factor of the post process.
  115272. * The smaller the better but the slower.
  115273. */
  115274. postProcessScaleFactor: number;
  115275. /**
  115276. * Define an offset for the lens center.
  115277. */
  115278. lensCenterOffset: number;
  115279. /**
  115280. * Define if the current vr camera should compensate the distortion of the lense or not.
  115281. */
  115282. compensateDistortion: boolean;
  115283. /**
  115284. * Defines if multiview should be enabled when rendering (Default: false)
  115285. */
  115286. multiviewEnabled: boolean;
  115287. /**
  115288. * Gets the rendering aspect ratio based on the provided resolutions.
  115289. */
  115290. get aspectRatio(): number;
  115291. /**
  115292. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  115293. */
  115294. get aspectRatioFov(): number;
  115295. /**
  115296. * @hidden
  115297. */
  115298. get leftHMatrix(): Matrix;
  115299. /**
  115300. * @hidden
  115301. */
  115302. get rightHMatrix(): Matrix;
  115303. /**
  115304. * @hidden
  115305. */
  115306. get leftPreViewMatrix(): Matrix;
  115307. /**
  115308. * @hidden
  115309. */
  115310. get rightPreViewMatrix(): Matrix;
  115311. /**
  115312. * Get the default VRMetrics based on the most generic setup.
  115313. * @returns the default vr metrics
  115314. */
  115315. static GetDefault(): VRCameraMetrics;
  115316. }
  115317. }
  115318. declare module BABYLON {
  115319. /** @hidden */
  115320. export var vrDistortionCorrectionPixelShader: {
  115321. name: string;
  115322. shader: string;
  115323. };
  115324. }
  115325. declare module BABYLON {
  115326. /**
  115327. * VRDistortionCorrectionPostProcess used for mobile VR
  115328. */
  115329. export class VRDistortionCorrectionPostProcess extends PostProcess {
  115330. private _isRightEye;
  115331. private _distortionFactors;
  115332. private _postProcessScaleFactor;
  115333. private _lensCenterOffset;
  115334. private _scaleIn;
  115335. private _scaleFactor;
  115336. private _lensCenter;
  115337. /**
  115338. * Initializes the VRDistortionCorrectionPostProcess
  115339. * @param name The name of the effect.
  115340. * @param camera The camera to apply the render pass to.
  115341. * @param isRightEye If this is for the right eye distortion
  115342. * @param vrMetrics All the required metrics for the VR camera
  115343. */
  115344. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  115345. }
  115346. }
  115347. declare module BABYLON {
  115348. /**
  115349. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  115350. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  115351. */
  115352. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  115353. /**
  115354. * Creates a new VRDeviceOrientationArcRotateCamera
  115355. * @param name defines camera name
  115356. * @param alpha defines the camera rotation along the logitudinal axis
  115357. * @param beta defines the camera rotation along the latitudinal axis
  115358. * @param radius defines the camera distance from its target
  115359. * @param target defines the camera target
  115360. * @param scene defines the scene the camera belongs to
  115361. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  115362. * @param vrCameraMetrics defines the vr metrics associated to the camera
  115363. */
  115364. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  115365. /**
  115366. * Gets camera class name
  115367. * @returns VRDeviceOrientationArcRotateCamera
  115368. */
  115369. getClassName(): string;
  115370. }
  115371. }
  115372. declare module BABYLON {
  115373. /**
  115374. * Camera used to simulate VR rendering (based on FreeCamera)
  115375. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  115376. */
  115377. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  115378. /**
  115379. * Creates a new VRDeviceOrientationFreeCamera
  115380. * @param name defines camera name
  115381. * @param position defines the start position of the camera
  115382. * @param scene defines the scene the camera belongs to
  115383. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  115384. * @param vrCameraMetrics defines the vr metrics associated to the camera
  115385. */
  115386. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  115387. /**
  115388. * Gets camera class name
  115389. * @returns VRDeviceOrientationFreeCamera
  115390. */
  115391. getClassName(): string;
  115392. }
  115393. }
  115394. declare module BABYLON {
  115395. /**
  115396. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  115397. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  115398. */
  115399. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  115400. /**
  115401. * Creates a new VRDeviceOrientationGamepadCamera
  115402. * @param name defines camera name
  115403. * @param position defines the start position of the camera
  115404. * @param scene defines the scene the camera belongs to
  115405. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  115406. * @param vrCameraMetrics defines the vr metrics associated to the camera
  115407. */
  115408. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  115409. /**
  115410. * Gets camera class name
  115411. * @returns VRDeviceOrientationGamepadCamera
  115412. */
  115413. getClassName(): string;
  115414. }
  115415. }
  115416. declare module BABYLON {
  115417. /** @hidden */
  115418. export var imageProcessingPixelShader: {
  115419. name: string;
  115420. shader: string;
  115421. };
  115422. }
  115423. declare module BABYLON {
  115424. /**
  115425. * ImageProcessingPostProcess
  115426. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  115427. */
  115428. export class ImageProcessingPostProcess extends PostProcess {
  115429. /**
  115430. * Default configuration related to image processing available in the PBR Material.
  115431. */
  115432. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  115433. /**
  115434. * Gets the image processing configuration used either in this material.
  115435. */
  115436. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  115437. /**
  115438. * Sets the Default image processing configuration used either in the this material.
  115439. *
  115440. * If sets to null, the scene one is in use.
  115441. */
  115442. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  115443. /**
  115444. * Keep track of the image processing observer to allow dispose and replace.
  115445. */
  115446. private _imageProcessingObserver;
  115447. /**
  115448. * Attaches a new image processing configuration to the PBR Material.
  115449. * @param configuration
  115450. */
  115451. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  115452. /**
  115453. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  115454. */
  115455. get colorCurves(): Nullable<ColorCurves>;
  115456. /**
  115457. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  115458. */
  115459. set colorCurves(value: Nullable<ColorCurves>);
  115460. /**
  115461. * Gets wether the color curves effect is enabled.
  115462. */
  115463. get colorCurvesEnabled(): boolean;
  115464. /**
  115465. * Sets wether the color curves effect is enabled.
  115466. */
  115467. set colorCurvesEnabled(value: boolean);
  115468. /**
  115469. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  115470. */
  115471. get colorGradingTexture(): Nullable<BaseTexture>;
  115472. /**
  115473. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  115474. */
  115475. set colorGradingTexture(value: Nullable<BaseTexture>);
  115476. /**
  115477. * Gets wether the color grading effect is enabled.
  115478. */
  115479. get colorGradingEnabled(): boolean;
  115480. /**
  115481. * Gets wether the color grading effect is enabled.
  115482. */
  115483. set colorGradingEnabled(value: boolean);
  115484. /**
  115485. * Gets exposure used in the effect.
  115486. */
  115487. get exposure(): number;
  115488. /**
  115489. * Sets exposure used in the effect.
  115490. */
  115491. set exposure(value: number);
  115492. /**
  115493. * Gets wether tonemapping is enabled or not.
  115494. */
  115495. get toneMappingEnabled(): boolean;
  115496. /**
  115497. * Sets wether tonemapping is enabled or not
  115498. */
  115499. set toneMappingEnabled(value: boolean);
  115500. /**
  115501. * Gets the type of tone mapping effect.
  115502. */
  115503. get toneMappingType(): number;
  115504. /**
  115505. * Sets the type of tone mapping effect.
  115506. */
  115507. set toneMappingType(value: number);
  115508. /**
  115509. * Gets contrast used in the effect.
  115510. */
  115511. get contrast(): number;
  115512. /**
  115513. * Sets contrast used in the effect.
  115514. */
  115515. set contrast(value: number);
  115516. /**
  115517. * Gets Vignette stretch size.
  115518. */
  115519. get vignetteStretch(): number;
  115520. /**
  115521. * Sets Vignette stretch size.
  115522. */
  115523. set vignetteStretch(value: number);
  115524. /**
  115525. * Gets Vignette centre X Offset.
  115526. */
  115527. get vignetteCentreX(): number;
  115528. /**
  115529. * Sets Vignette centre X Offset.
  115530. */
  115531. set vignetteCentreX(value: number);
  115532. /**
  115533. * Gets Vignette centre Y Offset.
  115534. */
  115535. get vignetteCentreY(): number;
  115536. /**
  115537. * Sets Vignette centre Y Offset.
  115538. */
  115539. set vignetteCentreY(value: number);
  115540. /**
  115541. * Gets Vignette weight or intensity of the vignette effect.
  115542. */
  115543. get vignetteWeight(): number;
  115544. /**
  115545. * Sets Vignette weight or intensity of the vignette effect.
  115546. */
  115547. set vignetteWeight(value: number);
  115548. /**
  115549. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  115550. * if vignetteEnabled is set to true.
  115551. */
  115552. get vignetteColor(): Color4;
  115553. /**
  115554. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  115555. * if vignetteEnabled is set to true.
  115556. */
  115557. set vignetteColor(value: Color4);
  115558. /**
  115559. * Gets Camera field of view used by the Vignette effect.
  115560. */
  115561. get vignetteCameraFov(): number;
  115562. /**
  115563. * Sets Camera field of view used by the Vignette effect.
  115564. */
  115565. set vignetteCameraFov(value: number);
  115566. /**
  115567. * Gets the vignette blend mode allowing different kind of effect.
  115568. */
  115569. get vignetteBlendMode(): number;
  115570. /**
  115571. * Sets the vignette blend mode allowing different kind of effect.
  115572. */
  115573. set vignetteBlendMode(value: number);
  115574. /**
  115575. * Gets wether the vignette effect is enabled.
  115576. */
  115577. get vignetteEnabled(): boolean;
  115578. /**
  115579. * Sets wether the vignette effect is enabled.
  115580. */
  115581. set vignetteEnabled(value: boolean);
  115582. private _fromLinearSpace;
  115583. /**
  115584. * Gets wether the input of the processing is in Gamma or Linear Space.
  115585. */
  115586. get fromLinearSpace(): boolean;
  115587. /**
  115588. * Sets wether the input of the processing is in Gamma or Linear Space.
  115589. */
  115590. set fromLinearSpace(value: boolean);
  115591. /**
  115592. * Defines cache preventing GC.
  115593. */
  115594. private _defines;
  115595. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  115596. /**
  115597. * "ImageProcessingPostProcess"
  115598. * @returns "ImageProcessingPostProcess"
  115599. */
  115600. getClassName(): string;
  115601. protected _updateParameters(): void;
  115602. dispose(camera?: Camera): void;
  115603. }
  115604. }
  115605. declare module BABYLON {
  115606. /**
  115607. * Class containing static functions to help procedurally build meshes
  115608. */
  115609. export class GroundBuilder {
  115610. /**
  115611. * Creates a ground mesh
  115612. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  115613. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  115614. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115615. * @param name defines the name of the mesh
  115616. * @param options defines the options used to create the mesh
  115617. * @param scene defines the hosting scene
  115618. * @returns the ground mesh
  115619. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  115620. */
  115621. static CreateGround(name: string, options: {
  115622. width?: number;
  115623. height?: number;
  115624. subdivisions?: number;
  115625. subdivisionsX?: number;
  115626. subdivisionsY?: number;
  115627. updatable?: boolean;
  115628. }, scene: any): Mesh;
  115629. /**
  115630. * Creates a tiled ground mesh
  115631. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  115632. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  115633. * * 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
  115634. * * 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
  115635. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115636. * @param name defines the name of the mesh
  115637. * @param options defines the options used to create the mesh
  115638. * @param scene defines the hosting scene
  115639. * @returns the tiled ground mesh
  115640. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  115641. */
  115642. static CreateTiledGround(name: string, options: {
  115643. xmin: number;
  115644. zmin: number;
  115645. xmax: number;
  115646. zmax: number;
  115647. subdivisions?: {
  115648. w: number;
  115649. h: number;
  115650. };
  115651. precision?: {
  115652. w: number;
  115653. h: number;
  115654. };
  115655. updatable?: boolean;
  115656. }, scene?: Nullable<Scene>): Mesh;
  115657. /**
  115658. * Creates a ground mesh from a height map
  115659. * * The parameter `url` sets the URL of the height map image resource.
  115660. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  115661. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  115662. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  115663. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  115664. * * 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.
  115665. * * 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).
  115666. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  115667. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115668. * @param name defines the name of the mesh
  115669. * @param url defines the url to the height map
  115670. * @param options defines the options used to create the mesh
  115671. * @param scene defines the hosting scene
  115672. * @returns the ground mesh
  115673. * @see https://doc.babylonjs.com/babylon101/height_map
  115674. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  115675. */
  115676. static CreateGroundFromHeightMap(name: string, url: string, options: {
  115677. width?: number;
  115678. height?: number;
  115679. subdivisions?: number;
  115680. minHeight?: number;
  115681. maxHeight?: number;
  115682. colorFilter?: Color3;
  115683. alphaFilter?: number;
  115684. updatable?: boolean;
  115685. onReady?: (mesh: GroundMesh) => void;
  115686. }, scene?: Nullable<Scene>): GroundMesh;
  115687. }
  115688. }
  115689. declare module BABYLON {
  115690. /**
  115691. * Class containing static functions to help procedurally build meshes
  115692. */
  115693. export class TorusBuilder {
  115694. /**
  115695. * Creates a torus mesh
  115696. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  115697. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  115698. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  115699. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115700. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115701. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115702. * @param name defines the name of the mesh
  115703. * @param options defines the options used to create the mesh
  115704. * @param scene defines the hosting scene
  115705. * @returns the torus mesh
  115706. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  115707. */
  115708. static CreateTorus(name: string, options: {
  115709. diameter?: number;
  115710. thickness?: number;
  115711. tessellation?: number;
  115712. updatable?: boolean;
  115713. sideOrientation?: number;
  115714. frontUVs?: Vector4;
  115715. backUVs?: Vector4;
  115716. }, scene: any): Mesh;
  115717. }
  115718. }
  115719. declare module BABYLON {
  115720. /**
  115721. * Class containing static functions to help procedurally build meshes
  115722. */
  115723. export class CylinderBuilder {
  115724. /**
  115725. * Creates a cylinder or a cone mesh
  115726. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  115727. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  115728. * * 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.
  115729. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  115730. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  115731. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  115732. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  115733. * * 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).
  115734. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  115735. * * 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).
  115736. * * 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
  115737. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  115738. * * 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
  115739. * * 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.
  115740. * * If `enclose` is false, a ring surface is one element.
  115741. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  115742. * * 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
  115743. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115744. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115745. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115746. * @param name defines the name of the mesh
  115747. * @param options defines the options used to create the mesh
  115748. * @param scene defines the hosting scene
  115749. * @returns the cylinder mesh
  115750. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  115751. */
  115752. static CreateCylinder(name: string, options: {
  115753. height?: number;
  115754. diameterTop?: number;
  115755. diameterBottom?: number;
  115756. diameter?: number;
  115757. tessellation?: number;
  115758. subdivisions?: number;
  115759. arc?: number;
  115760. faceColors?: Color4[];
  115761. faceUV?: Vector4[];
  115762. updatable?: boolean;
  115763. hasRings?: boolean;
  115764. enclose?: boolean;
  115765. cap?: number;
  115766. sideOrientation?: number;
  115767. frontUVs?: Vector4;
  115768. backUVs?: Vector4;
  115769. }, scene: any): Mesh;
  115770. }
  115771. }
  115772. declare module BABYLON {
  115773. /**
  115774. * States of the webXR experience
  115775. */
  115776. export enum WebXRState {
  115777. /**
  115778. * Transitioning to being in XR mode
  115779. */
  115780. ENTERING_XR = 0,
  115781. /**
  115782. * Transitioning to non XR mode
  115783. */
  115784. EXITING_XR = 1,
  115785. /**
  115786. * In XR mode and presenting
  115787. */
  115788. IN_XR = 2,
  115789. /**
  115790. * Not entered XR mode
  115791. */
  115792. NOT_IN_XR = 3
  115793. }
  115794. /**
  115795. * Abstraction of the XR render target
  115796. */
  115797. export interface WebXRRenderTarget extends IDisposable {
  115798. /**
  115799. * xrpresent context of the canvas which can be used to display/mirror xr content
  115800. */
  115801. canvasContext: WebGLRenderingContext;
  115802. /**
  115803. * xr layer for the canvas
  115804. */
  115805. xrLayer: Nullable<XRWebGLLayer>;
  115806. /**
  115807. * Initializes the xr layer for the session
  115808. * @param xrSession xr session
  115809. * @returns a promise that will resolve once the XR Layer has been created
  115810. */
  115811. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  115812. }
  115813. }
  115814. declare module BABYLON {
  115815. /**
  115816. * COnfiguration object for WebXR output canvas
  115817. */
  115818. export class WebXRManagedOutputCanvasOptions {
  115819. /**
  115820. * Options for this XR Layer output
  115821. */
  115822. canvasOptions?: XRWebGLLayerOptions;
  115823. /**
  115824. * CSS styling for a newly created canvas (if not provided)
  115825. */
  115826. newCanvasCssStyle?: string;
  115827. /**
  115828. * An optional canvas in case you wish to create it yourself and provide it here.
  115829. * If not provided, a new canvas will be created
  115830. */
  115831. canvasElement?: HTMLCanvasElement;
  115832. /**
  115833. * Get the default values of the configuration object
  115834. * @returns default values of this configuration object
  115835. */
  115836. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  115837. }
  115838. /**
  115839. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  115840. */
  115841. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  115842. private _options;
  115843. private _engine;
  115844. private _canvas;
  115845. /**
  115846. * Rendering context of the canvas which can be used to display/mirror xr content
  115847. */
  115848. canvasContext: WebGLRenderingContext;
  115849. /**
  115850. * xr layer for the canvas
  115851. */
  115852. xrLayer: Nullable<XRWebGLLayer>;
  115853. /**
  115854. * Initializes the xr layer for the session
  115855. * @param xrSession xr session
  115856. * @returns a promise that will resolve once the XR Layer has been created
  115857. */
  115858. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  115859. /**
  115860. * Initializes the canvas to be added/removed upon entering/exiting xr
  115861. * @param _xrSessionManager The XR Session manager
  115862. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  115863. */
  115864. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  115865. /**
  115866. * Disposes of the object
  115867. */
  115868. dispose(): void;
  115869. private _setManagedOutputCanvas;
  115870. private _addCanvas;
  115871. private _removeCanvas;
  115872. }
  115873. }
  115874. declare module BABYLON {
  115875. /**
  115876. * Manages an XRSession to work with Babylon's engine
  115877. * @see https://doc.babylonjs.com/how_to/webxr
  115878. */
  115879. export class WebXRSessionManager implements IDisposable {
  115880. /** The scene which the session should be created for */
  115881. scene: Scene;
  115882. /**
  115883. * Fires every time a new xrFrame arrives which can be used to update the camera
  115884. */
  115885. onXRFrameObservable: Observable<XRFrame>;
  115886. /**
  115887. * Fires when the xr session is ended either by the device or manually done
  115888. */
  115889. onXRSessionEnded: Observable<any>;
  115890. /**
  115891. * Fires when the xr session is ended either by the device or manually done
  115892. */
  115893. onXRSessionInit: Observable<XRSession>;
  115894. /**
  115895. * Fires when the reference space changed
  115896. */
  115897. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  115898. /**
  115899. * Underlying xr session
  115900. */
  115901. session: XRSession;
  115902. /**
  115903. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  115904. * or get the offset the player is currently at.
  115905. */
  115906. viewerReferenceSpace: XRReferenceSpace;
  115907. private _referenceSpace;
  115908. /**
  115909. * The current reference space used in this session. This reference space can constantly change!
  115910. * It is mainly used to offset the camera's position.
  115911. */
  115912. get referenceSpace(): XRReferenceSpace;
  115913. /**
  115914. * Set a new reference space and triggers the observable
  115915. */
  115916. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  115917. /**
  115918. * The base reference space from which the session started. good if you want to reset your
  115919. * reference space
  115920. */
  115921. baseReferenceSpace: XRReferenceSpace;
  115922. /**
  115923. * Used just in case of a failure to initialize an immersive session.
  115924. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  115925. */
  115926. defaultHeightCompensation: number;
  115927. /**
  115928. * Current XR frame
  115929. */
  115930. currentFrame: Nullable<XRFrame>;
  115931. /** WebXR timestamp updated every frame */
  115932. currentTimestamp: number;
  115933. private _xrNavigator;
  115934. private baseLayer;
  115935. private _rttProvider;
  115936. private _sessionEnded;
  115937. /**
  115938. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  115939. * @param scene The scene which the session should be created for
  115940. */
  115941. constructor(
  115942. /** The scene which the session should be created for */
  115943. scene: Scene);
  115944. /**
  115945. * Initializes the manager
  115946. * After initialization enterXR can be called to start an XR session
  115947. * @returns Promise which resolves after it is initialized
  115948. */
  115949. initializeAsync(): Promise<void>;
  115950. /**
  115951. * Initializes an xr session
  115952. * @param xrSessionMode mode to initialize
  115953. * @param xrSessionInit defines optional and required values to pass to the session builder
  115954. * @returns a promise which will resolve once the session has been initialized
  115955. */
  115956. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  115957. /**
  115958. * Sets the reference space on the xr session
  115959. * @param referenceSpaceType space to set
  115960. * @returns a promise that will resolve once the reference space has been set
  115961. */
  115962. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  115963. /**
  115964. * Resets the reference space to the one started the session
  115965. */
  115966. resetReferenceSpace(): void;
  115967. /**
  115968. * Updates the render state of the session
  115969. * @param state state to set
  115970. * @returns a promise that resolves once the render state has been updated
  115971. */
  115972. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  115973. /**
  115974. * Starts rendering to the xr layer
  115975. */
  115976. runXRRenderLoop(): void;
  115977. /**
  115978. * Gets the correct render target texture to be rendered this frame for this eye
  115979. * @param eye the eye for which to get the render target
  115980. * @returns the render target for the specified eye
  115981. */
  115982. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  115983. /**
  115984. * Stops the xrSession and restores the renderloop
  115985. * @returns Promise which resolves after it exits XR
  115986. */
  115987. exitXRAsync(): Promise<void>;
  115988. /**
  115989. * Checks if a session would be supported for the creation options specified
  115990. * @param sessionMode session mode to check if supported eg. immersive-vr
  115991. * @returns A Promise that resolves to true if supported and false if not
  115992. */
  115993. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  115994. /**
  115995. * Creates a WebXRRenderTarget object for the XR session
  115996. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  115997. * @param options optional options to provide when creating a new render target
  115998. * @returns a WebXR render target to which the session can render
  115999. */
  116000. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  116001. /**
  116002. * @hidden
  116003. * Converts the render layer of xrSession to a render target
  116004. * @param session session to create render target for
  116005. * @param scene scene the new render target should be created for
  116006. * @param baseLayer the webgl layer to create the render target for
  116007. */
  116008. static _CreateRenderTargetTextureFromSession(_session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  116009. /**
  116010. * Disposes of the session manager
  116011. */
  116012. dispose(): void;
  116013. /**
  116014. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  116015. * @param sessionMode defines the session to test
  116016. * @returns a promise with boolean as final value
  116017. */
  116018. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  116019. }
  116020. }
  116021. declare module BABYLON {
  116022. /**
  116023. * WebXR Camera which holds the views for the xrSession
  116024. * @see https://doc.babylonjs.com/how_to/webxr_camera
  116025. */
  116026. export class WebXRCamera extends FreeCamera {
  116027. private _xrSessionManager;
  116028. private _firstFrame;
  116029. private _referenceQuaternion;
  116030. private _referencedPosition;
  116031. private _xrInvPositionCache;
  116032. private _xrInvQuaternionCache;
  116033. /**
  116034. * Should position compensation execute on first frame.
  116035. * This is used when copying the position from a native (non XR) camera
  116036. */
  116037. compensateOnFirstFrame: boolean;
  116038. /**
  116039. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  116040. * @param name the name of the camera
  116041. * @param scene the scene to add the camera to
  116042. * @param _xrSessionManager a constructed xr session manager
  116043. */
  116044. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  116045. /**
  116046. * Return the user's height, unrelated to the current ground.
  116047. * This will be the y position of this camera, when ground level is 0.
  116048. */
  116049. get realWorldHeight(): number;
  116050. /** @hidden */
  116051. _updateForDualEyeDebugging(): void;
  116052. /**
  116053. * Sets this camera's transformation based on a non-vr camera
  116054. * @param otherCamera the non-vr camera to copy the transformation from
  116055. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  116056. */
  116057. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  116058. private _updateFromXRSession;
  116059. private _updateNumberOfRigCameras;
  116060. private _updateReferenceSpace;
  116061. private _updateReferenceSpaceOffset;
  116062. }
  116063. }
  116064. declare module BABYLON {
  116065. /**
  116066. * Defining the interface required for a (webxr) feature
  116067. */
  116068. export interface IWebXRFeature extends IDisposable {
  116069. /**
  116070. * Is this feature attached
  116071. */
  116072. attached: boolean;
  116073. /**
  116074. * Should auto-attach be disabled?
  116075. */
  116076. disableAutoAttach: boolean;
  116077. /**
  116078. * Attach the feature to the session
  116079. * Will usually be called by the features manager
  116080. *
  116081. * @param force should attachment be forced (even when already attached)
  116082. * @returns true if successful.
  116083. */
  116084. attach(force?: boolean): boolean;
  116085. /**
  116086. * Detach the feature from the session
  116087. * Will usually be called by the features manager
  116088. *
  116089. * @returns true if successful.
  116090. */
  116091. detach(): boolean;
  116092. }
  116093. /**
  116094. * A list of the currently available features without referencing them
  116095. */
  116096. export class WebXRFeatureName {
  116097. /**
  116098. * The name of the hit test feature
  116099. */
  116100. static HIT_TEST: string;
  116101. /**
  116102. * The name of the anchor system feature
  116103. */
  116104. static ANCHOR_SYSTEM: string;
  116105. /**
  116106. * The name of the background remover feature
  116107. */
  116108. static BACKGROUND_REMOVER: string;
  116109. /**
  116110. * The name of the pointer selection feature
  116111. */
  116112. static POINTER_SELECTION: string;
  116113. /**
  116114. * The name of the teleportation feature
  116115. */
  116116. static TELEPORTATION: string;
  116117. /**
  116118. * The name of the plane detection feature
  116119. */
  116120. static PLANE_DETECTION: string;
  116121. /**
  116122. * physics impostors for xr controllers feature
  116123. */
  116124. static PHYSICS_CONTROLLERS: string;
  116125. }
  116126. /**
  116127. * Defining the constructor of a feature. Used to register the modules.
  116128. */
  116129. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  116130. /**
  116131. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  116132. * It is mainly used in AR sessions.
  116133. *
  116134. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  116135. */
  116136. export class WebXRFeaturesManager implements IDisposable {
  116137. private _xrSessionManager;
  116138. private static readonly _AvailableFeatures;
  116139. /**
  116140. * Used to register a module. After calling this function a developer can use this feature in the scene.
  116141. * Mainly used internally.
  116142. *
  116143. * @param featureName the name of the feature to register
  116144. * @param constructorFunction the function used to construct the module
  116145. * @param version the (babylon) version of the module
  116146. * @param stable is that a stable version of this module
  116147. */
  116148. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  116149. /**
  116150. * Returns a constructor of a specific feature.
  116151. *
  116152. * @param featureName the name of the feature to construct
  116153. * @param version the version of the feature to load
  116154. * @param xrSessionManager the xrSessionManager. Used to construct the module
  116155. * @param options optional options provided to the module.
  116156. * @returns a function that, when called, will return a new instance of this feature
  116157. */
  116158. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  116159. /**
  116160. * Return the latest unstable version of this feature
  116161. * @param featureName the name of the feature to search
  116162. * @returns the version number. if not found will return -1
  116163. */
  116164. static GetLatestVersionOfFeature(featureName: string): number;
  116165. /**
  116166. * Return the latest stable version of this feature
  116167. * @param featureName the name of the feature to search
  116168. * @returns the version number. if not found will return -1
  116169. */
  116170. static GetStableVersionOfFeature(featureName: string): number;
  116171. /**
  116172. * Can be used to return the list of features currently registered
  116173. *
  116174. * @returns an Array of available features
  116175. */
  116176. static GetAvailableFeatures(): string[];
  116177. /**
  116178. * Gets the versions available for a specific feature
  116179. * @param featureName the name of the feature
  116180. * @returns an array with the available versions
  116181. */
  116182. static GetAvailableVersions(featureName: string): string[];
  116183. private _features;
  116184. /**
  116185. * constructs a new features manages.
  116186. *
  116187. * @param _xrSessionManager an instance of WebXRSessionManager
  116188. */
  116189. constructor(_xrSessionManager: WebXRSessionManager);
  116190. /**
  116191. * 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.
  116192. * 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.
  116193. *
  116194. * @param featureName the name of the feature to load or the class of the feature
  116195. * @param version optional version to load. if not provided the latest version will be enabled
  116196. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  116197. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  116198. * @returns a new constructed feature or throws an error if feature not found.
  116199. */
  116200. enableFeature(featureName: string | {
  116201. Name: string;
  116202. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  116203. /**
  116204. * Used to disable an already-enabled feature
  116205. * The feature will be disposed and will be recreated once enabled.
  116206. * @param featureName the feature to disable
  116207. * @returns true if disable was successful
  116208. */
  116209. disableFeature(featureName: string | {
  116210. Name: string;
  116211. }): boolean;
  116212. /**
  116213. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  116214. * Can be used during a session to start a feature
  116215. * @param featureName the name of feature to attach
  116216. */
  116217. attachFeature(featureName: string): void;
  116218. /**
  116219. * Can be used inside a session or when the session ends to detach a specific feature
  116220. * @param featureName the name of the feature to detach
  116221. */
  116222. detachFeature(featureName: string): void;
  116223. /**
  116224. * Get the list of enabled features
  116225. * @returns an array of enabled features
  116226. */
  116227. getEnabledFeatures(): string[];
  116228. /**
  116229. * get the implementation of an enabled feature.
  116230. * @param featureName the name of the feature to load
  116231. * @returns the feature class, if found
  116232. */
  116233. getEnabledFeature(featureName: string): IWebXRFeature;
  116234. /**
  116235. * dispose this features manager
  116236. */
  116237. dispose(): void;
  116238. }
  116239. }
  116240. declare module BABYLON {
  116241. /**
  116242. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  116243. * @see https://doc.babylonjs.com/how_to/webxr
  116244. */
  116245. export class WebXRExperienceHelper implements IDisposable {
  116246. private scene;
  116247. /**
  116248. * Camera used to render xr content
  116249. */
  116250. camera: WebXRCamera;
  116251. /**
  116252. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  116253. */
  116254. state: WebXRState;
  116255. private _setState;
  116256. /**
  116257. * Fires when the state of the experience helper has changed
  116258. */
  116259. onStateChangedObservable: Observable<WebXRState>;
  116260. /**
  116261. * Observers registered here will be triggered after the camera's initial transformation is set
  116262. * This can be used to set a different ground level or an extra rotation.
  116263. *
  116264. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  116265. * to the position set after this observable is done executing.
  116266. */
  116267. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  116268. /** Session manager used to keep track of xr session */
  116269. sessionManager: WebXRSessionManager;
  116270. /** A features manager for this xr session */
  116271. featuresManager: WebXRFeaturesManager;
  116272. private _nonVRCamera;
  116273. private _originalSceneAutoClear;
  116274. private _supported;
  116275. /**
  116276. * Creates the experience helper
  116277. * @param scene the scene to attach the experience helper to
  116278. * @returns a promise for the experience helper
  116279. */
  116280. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  116281. /**
  116282. * Creates a WebXRExperienceHelper
  116283. * @param scene The scene the helper should be created in
  116284. */
  116285. private constructor();
  116286. /**
  116287. * Exits XR mode and returns the scene to its original state
  116288. * @returns promise that resolves after xr mode has exited
  116289. */
  116290. exitXRAsync(): Promise<void>;
  116291. /**
  116292. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  116293. * @param sessionMode options for the XR session
  116294. * @param referenceSpaceType frame of reference of the XR session
  116295. * @param renderTarget the output canvas that will be used to enter XR mode
  116296. * @returns promise that resolves after xr mode has entered
  116297. */
  116298. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  116299. /**
  116300. * Disposes of the experience helper
  116301. */
  116302. dispose(): void;
  116303. private _nonXRToXRCamera;
  116304. }
  116305. }
  116306. declare module BABYLON {
  116307. /**
  116308. * X-Y values for axes in WebXR
  116309. */
  116310. export interface IWebXRMotionControllerAxesValue {
  116311. /**
  116312. * The value of the x axis
  116313. */
  116314. x: number;
  116315. /**
  116316. * The value of the y-axis
  116317. */
  116318. y: number;
  116319. }
  116320. /**
  116321. * changed / previous values for the values of this component
  116322. */
  116323. export interface IWebXRMotionControllerComponentChangesValues<T> {
  116324. /**
  116325. * current (this frame) value
  116326. */
  116327. current: T;
  116328. /**
  116329. * previous (last change) value
  116330. */
  116331. previous: T;
  116332. }
  116333. /**
  116334. * Represents changes in the component between current frame and last values recorded
  116335. */
  116336. export interface IWebXRMotionControllerComponentChanges {
  116337. /**
  116338. * will be populated with previous and current values if touched changed
  116339. */
  116340. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  116341. /**
  116342. * will be populated with previous and current values if pressed changed
  116343. */
  116344. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  116345. /**
  116346. * will be populated with previous and current values if value changed
  116347. */
  116348. value?: IWebXRMotionControllerComponentChangesValues<number>;
  116349. /**
  116350. * will be populated with previous and current values if axes changed
  116351. */
  116352. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  116353. }
  116354. /**
  116355. * This class represents a single component (for example button or thumbstick) of a motion controller
  116356. */
  116357. export class WebXRControllerComponent implements IDisposable {
  116358. /**
  116359. * the id of this component
  116360. */
  116361. id: string;
  116362. /**
  116363. * the type of the component
  116364. */
  116365. type: MotionControllerComponentType;
  116366. private _buttonIndex;
  116367. private _axesIndices;
  116368. /**
  116369. * Thumbstick component type
  116370. */
  116371. static THUMBSTICK: MotionControllerComponentType;
  116372. /**
  116373. * Touchpad component type
  116374. */
  116375. static TOUCHPAD: MotionControllerComponentType;
  116376. /**
  116377. * trigger component type
  116378. */
  116379. static TRIGGER: MotionControllerComponentType;
  116380. /**
  116381. * squeeze component type
  116382. */
  116383. static SQUEEZE: MotionControllerComponentType;
  116384. /**
  116385. * button component type
  116386. */
  116387. static BUTTON: MotionControllerComponentType;
  116388. /**
  116389. * Observers registered here will be triggered when the state of a button changes
  116390. * State change is either pressed / touched / value
  116391. */
  116392. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  116393. /**
  116394. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  116395. * the axes data changes
  116396. */
  116397. onAxisValueChangedObservable: Observable<{
  116398. x: number;
  116399. y: number;
  116400. }>;
  116401. private _currentValue;
  116402. private _touched;
  116403. private _pressed;
  116404. private _axes;
  116405. private _changes;
  116406. private _hasChanges;
  116407. /**
  116408. * Return whether or not the component changed the last frame
  116409. */
  116410. get hasChanges(): boolean;
  116411. /**
  116412. * Creates a new component for a motion controller.
  116413. * It is created by the motion controller itself
  116414. *
  116415. * @param id the id of this component
  116416. * @param type the type of the component
  116417. * @param _buttonIndex index in the buttons array of the gamepad
  116418. * @param _axesIndices indices of the values in the axes array of the gamepad
  116419. */
  116420. constructor(
  116421. /**
  116422. * the id of this component
  116423. */
  116424. id: string,
  116425. /**
  116426. * the type of the component
  116427. */
  116428. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  116429. /**
  116430. * Get the current value of this component
  116431. */
  116432. get value(): number;
  116433. /**
  116434. * is the button currently pressed
  116435. */
  116436. get pressed(): boolean;
  116437. /**
  116438. * is the button currently touched
  116439. */
  116440. get touched(): boolean;
  116441. /**
  116442. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  116443. */
  116444. get axes(): IWebXRMotionControllerAxesValue;
  116445. /**
  116446. * Get the changes. Elements will be populated only if they changed with their previous and current value
  116447. */
  116448. get changes(): IWebXRMotionControllerComponentChanges;
  116449. /**
  116450. * Is this component a button (hence - pressable)
  116451. * @returns true if can be pressed
  116452. */
  116453. isButton(): boolean;
  116454. /**
  116455. * Are there axes correlating to this component
  116456. * @return true is axes data is available
  116457. */
  116458. isAxes(): boolean;
  116459. /**
  116460. * update this component using the gamepad object it is in. Called on every frame
  116461. * @param nativeController the native gamepad controller object
  116462. */
  116463. update(nativeController: IMinimalMotionControllerObject): void;
  116464. /**
  116465. * Dispose this component
  116466. */
  116467. dispose(): void;
  116468. }
  116469. }
  116470. declare module BABYLON {
  116471. /**
  116472. * Class used to represent data loading progression
  116473. */
  116474. export class SceneLoaderProgressEvent {
  116475. /** defines if data length to load can be evaluated */
  116476. readonly lengthComputable: boolean;
  116477. /** defines the loaded data length */
  116478. readonly loaded: number;
  116479. /** defines the data length to load */
  116480. readonly total: number;
  116481. /**
  116482. * Create a new progress event
  116483. * @param lengthComputable defines if data length to load can be evaluated
  116484. * @param loaded defines the loaded data length
  116485. * @param total defines the data length to load
  116486. */
  116487. constructor(
  116488. /** defines if data length to load can be evaluated */
  116489. lengthComputable: boolean,
  116490. /** defines the loaded data length */
  116491. loaded: number,
  116492. /** defines the data length to load */
  116493. total: number);
  116494. /**
  116495. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  116496. * @param event defines the source event
  116497. * @returns a new SceneLoaderProgressEvent
  116498. */
  116499. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  116500. }
  116501. /**
  116502. * Interface used by SceneLoader plugins to define supported file extensions
  116503. */
  116504. export interface ISceneLoaderPluginExtensions {
  116505. /**
  116506. * Defines the list of supported extensions
  116507. */
  116508. [extension: string]: {
  116509. isBinary: boolean;
  116510. };
  116511. }
  116512. /**
  116513. * Interface used by SceneLoader plugin factory
  116514. */
  116515. export interface ISceneLoaderPluginFactory {
  116516. /**
  116517. * Defines the name of the factory
  116518. */
  116519. name: string;
  116520. /**
  116521. * Function called to create a new plugin
  116522. * @return the new plugin
  116523. */
  116524. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  116525. /**
  116526. * The callback that returns true if the data can be directly loaded.
  116527. * @param data string containing the file data
  116528. * @returns if the data can be loaded directly
  116529. */
  116530. canDirectLoad?(data: string): boolean;
  116531. }
  116532. /**
  116533. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  116534. */
  116535. export interface ISceneLoaderPluginBase {
  116536. /**
  116537. * The friendly name of this plugin.
  116538. */
  116539. name: string;
  116540. /**
  116541. * The file extensions supported by this plugin.
  116542. */
  116543. extensions: string | ISceneLoaderPluginExtensions;
  116544. /**
  116545. * The callback called when loading from a url.
  116546. * @param scene scene loading this url
  116547. * @param url url to load
  116548. * @param onSuccess callback called when the file successfully loads
  116549. * @param onProgress callback called while file is loading (if the server supports this mode)
  116550. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  116551. * @param onError callback called when the file fails to load
  116552. * @returns a file request object
  116553. */
  116554. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  116555. /**
  116556. * The callback called when loading from a file object.
  116557. * @param scene scene loading this file
  116558. * @param file defines the file to load
  116559. * @param onSuccess defines the callback to call when data is loaded
  116560. * @param onProgress defines the callback to call during loading process
  116561. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  116562. * @param onError defines the callback to call when an error occurs
  116563. * @returns a file request object
  116564. */
  116565. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  116566. /**
  116567. * The callback that returns true if the data can be directly loaded.
  116568. * @param data string containing the file data
  116569. * @returns if the data can be loaded directly
  116570. */
  116571. canDirectLoad?(data: string): boolean;
  116572. /**
  116573. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  116574. * @param scene scene loading this data
  116575. * @param data string containing the data
  116576. * @returns data to pass to the plugin
  116577. */
  116578. directLoad?(scene: Scene, data: string): any;
  116579. /**
  116580. * The callback that allows custom handling of the root url based on the response url.
  116581. * @param rootUrl the original root url
  116582. * @param responseURL the response url if available
  116583. * @returns the new root url
  116584. */
  116585. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  116586. }
  116587. /**
  116588. * Interface used to define a SceneLoader plugin
  116589. */
  116590. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  116591. /**
  116592. * Import meshes into a scene.
  116593. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116594. * @param scene The scene to import into
  116595. * @param data The data to import
  116596. * @param rootUrl The root url for scene and resources
  116597. * @param meshes The meshes array to import into
  116598. * @param particleSystems The particle systems array to import into
  116599. * @param skeletons The skeletons array to import into
  116600. * @param onError The callback when import fails
  116601. * @returns True if successful or false otherwise
  116602. */
  116603. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  116604. /**
  116605. * Load into a scene.
  116606. * @param scene The scene to load into
  116607. * @param data The data to import
  116608. * @param rootUrl The root url for scene and resources
  116609. * @param onError The callback when import fails
  116610. * @returns True if successful or false otherwise
  116611. */
  116612. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  116613. /**
  116614. * Load into an asset container.
  116615. * @param scene The scene to load into
  116616. * @param data The data to import
  116617. * @param rootUrl The root url for scene and resources
  116618. * @param onError The callback when import fails
  116619. * @returns The loaded asset container
  116620. */
  116621. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  116622. }
  116623. /**
  116624. * Interface used to define an async SceneLoader plugin
  116625. */
  116626. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  116627. /**
  116628. * Import meshes into a scene.
  116629. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116630. * @param scene The scene to import into
  116631. * @param data The data to import
  116632. * @param rootUrl The root url for scene and resources
  116633. * @param onProgress The callback when the load progresses
  116634. * @param fileName Defines the name of the file to load
  116635. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  116636. */
  116637. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  116638. meshes: AbstractMesh[];
  116639. particleSystems: IParticleSystem[];
  116640. skeletons: Skeleton[];
  116641. animationGroups: AnimationGroup[];
  116642. }>;
  116643. /**
  116644. * Load into a scene.
  116645. * @param scene The scene to load into
  116646. * @param data The data to import
  116647. * @param rootUrl The root url for scene and resources
  116648. * @param onProgress The callback when the load progresses
  116649. * @param fileName Defines the name of the file to load
  116650. * @returns Nothing
  116651. */
  116652. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  116653. /**
  116654. * Load into an asset container.
  116655. * @param scene The scene to load into
  116656. * @param data The data to import
  116657. * @param rootUrl The root url for scene and resources
  116658. * @param onProgress The callback when the load progresses
  116659. * @param fileName Defines the name of the file to load
  116660. * @returns The loaded asset container
  116661. */
  116662. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  116663. }
  116664. /**
  116665. * Mode that determines how to handle old animation groups before loading new ones.
  116666. */
  116667. export enum SceneLoaderAnimationGroupLoadingMode {
  116668. /**
  116669. * Reset all old animations to initial state then dispose them.
  116670. */
  116671. Clean = 0,
  116672. /**
  116673. * Stop all old animations.
  116674. */
  116675. Stop = 1,
  116676. /**
  116677. * Restart old animations from first frame.
  116678. */
  116679. Sync = 2,
  116680. /**
  116681. * Old animations remains untouched.
  116682. */
  116683. NoSync = 3
  116684. }
  116685. /**
  116686. * Class used to load scene from various file formats using registered plugins
  116687. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  116688. */
  116689. export class SceneLoader {
  116690. /**
  116691. * No logging while loading
  116692. */
  116693. static readonly NO_LOGGING: number;
  116694. /**
  116695. * Minimal logging while loading
  116696. */
  116697. static readonly MINIMAL_LOGGING: number;
  116698. /**
  116699. * Summary logging while loading
  116700. */
  116701. static readonly SUMMARY_LOGGING: number;
  116702. /**
  116703. * Detailled logging while loading
  116704. */
  116705. static readonly DETAILED_LOGGING: number;
  116706. /**
  116707. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  116708. */
  116709. static get ForceFullSceneLoadingForIncremental(): boolean;
  116710. static set ForceFullSceneLoadingForIncremental(value: boolean);
  116711. /**
  116712. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  116713. */
  116714. static get ShowLoadingScreen(): boolean;
  116715. static set ShowLoadingScreen(value: boolean);
  116716. /**
  116717. * Defines the current logging level (while loading the scene)
  116718. * @ignorenaming
  116719. */
  116720. static get loggingLevel(): number;
  116721. static set loggingLevel(value: number);
  116722. /**
  116723. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  116724. */
  116725. static get CleanBoneMatrixWeights(): boolean;
  116726. static set CleanBoneMatrixWeights(value: boolean);
  116727. /**
  116728. * Event raised when a plugin is used to load a scene
  116729. */
  116730. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  116731. private static _registeredPlugins;
  116732. private static _getDefaultPlugin;
  116733. private static _getPluginForExtension;
  116734. private static _getPluginForDirectLoad;
  116735. private static _getPluginForFilename;
  116736. private static _getDirectLoad;
  116737. private static _loadData;
  116738. private static _getFileInfo;
  116739. /**
  116740. * Gets a plugin that can load the given extension
  116741. * @param extension defines the extension to load
  116742. * @returns a plugin or null if none works
  116743. */
  116744. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  116745. /**
  116746. * Gets a boolean indicating that the given extension can be loaded
  116747. * @param extension defines the extension to load
  116748. * @returns true if the extension is supported
  116749. */
  116750. static IsPluginForExtensionAvailable(extension: string): boolean;
  116751. /**
  116752. * Adds a new plugin to the list of registered plugins
  116753. * @param plugin defines the plugin to add
  116754. */
  116755. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  116756. /**
  116757. * Import meshes into a scene
  116758. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116759. * @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)
  116760. * @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)
  116761. * @param scene the instance of BABYLON.Scene to append to
  116762. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  116763. * @param onProgress a callback with a progress event for each file being loaded
  116764. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116765. * @param pluginExtension the extension used to determine the plugin
  116766. * @returns The loaded plugin
  116767. */
  116768. 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>;
  116769. /**
  116770. * Import meshes into a scene
  116771. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116772. * @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)
  116773. * @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)
  116774. * @param scene the instance of BABYLON.Scene to append to
  116775. * @param onProgress a callback with a progress event for each file being loaded
  116776. * @param pluginExtension the extension used to determine the plugin
  116777. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  116778. */
  116779. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  116780. meshes: AbstractMesh[];
  116781. particleSystems: IParticleSystem[];
  116782. skeletons: Skeleton[];
  116783. animationGroups: AnimationGroup[];
  116784. }>;
  116785. /**
  116786. * Load a scene
  116787. * @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)
  116788. * @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)
  116789. * @param engine is the instance of BABYLON.Engine to use to create the scene
  116790. * @param onSuccess a callback with the scene when import succeeds
  116791. * @param onProgress a callback with a progress event for each file being loaded
  116792. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116793. * @param pluginExtension the extension used to determine the plugin
  116794. * @returns The loaded plugin
  116795. */
  116796. 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>;
  116797. /**
  116798. * Load a scene
  116799. * @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)
  116800. * @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)
  116801. * @param engine is the instance of BABYLON.Engine to use to create the scene
  116802. * @param onProgress a callback with a progress event for each file being loaded
  116803. * @param pluginExtension the extension used to determine the plugin
  116804. * @returns The loaded scene
  116805. */
  116806. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  116807. /**
  116808. * Append a scene
  116809. * @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)
  116810. * @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)
  116811. * @param scene is the instance of BABYLON.Scene to append to
  116812. * @param onSuccess a callback with the scene when import succeeds
  116813. * @param onProgress a callback with a progress event for each file being loaded
  116814. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116815. * @param pluginExtension the extension used to determine the plugin
  116816. * @returns The loaded plugin
  116817. */
  116818. 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>;
  116819. /**
  116820. * Append a scene
  116821. * @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)
  116822. * @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)
  116823. * @param scene is the instance of BABYLON.Scene to append to
  116824. * @param onProgress a callback with a progress event for each file being loaded
  116825. * @param pluginExtension the extension used to determine the plugin
  116826. * @returns The given scene
  116827. */
  116828. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  116829. /**
  116830. * Load a scene into an asset container
  116831. * @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)
  116832. * @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)
  116833. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  116834. * @param onSuccess a callback with the scene when import succeeds
  116835. * @param onProgress a callback with a progress event for each file being loaded
  116836. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116837. * @param pluginExtension the extension used to determine the plugin
  116838. * @returns The loaded plugin
  116839. */
  116840. 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>;
  116841. /**
  116842. * Load a scene into an asset container
  116843. * @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)
  116844. * @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)
  116845. * @param scene is the instance of Scene to append to
  116846. * @param onProgress a callback with a progress event for each file being loaded
  116847. * @param pluginExtension the extension used to determine the plugin
  116848. * @returns The loaded asset container
  116849. */
  116850. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  116851. /**
  116852. * Import animations from a file into a scene
  116853. * @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)
  116854. * @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)
  116855. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  116856. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  116857. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  116858. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  116859. * @param onSuccess a callback with the scene when import succeeds
  116860. * @param onProgress a callback with a progress event for each file being loaded
  116861. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116862. */
  116863. 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;
  116864. /**
  116865. * Import animations from a file into a scene
  116866. * @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)
  116867. * @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)
  116868. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  116869. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  116870. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  116871. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  116872. * @param onSuccess a callback with the scene when import succeeds
  116873. * @param onProgress a callback with a progress event for each file being loaded
  116874. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116875. * @returns the updated scene with imported animations
  116876. */
  116877. 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>;
  116878. }
  116879. }
  116880. declare module BABYLON {
  116881. /**
  116882. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  116883. */
  116884. export type MotionControllerHandness = "none" | "left" | "right";
  116885. /**
  116886. * The type of components available in motion controllers.
  116887. * This is not the name of the component.
  116888. */
  116889. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  116890. /**
  116891. * The state of a controller component
  116892. */
  116893. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  116894. /**
  116895. * The schema of motion controller layout.
  116896. * No object will be initialized using this interface
  116897. * This is used just to define the profile.
  116898. */
  116899. export interface IMotionControllerLayout {
  116900. /**
  116901. * Defines the main button component id
  116902. */
  116903. selectComponentId: string;
  116904. /**
  116905. * Available components (unsorted)
  116906. */
  116907. components: {
  116908. /**
  116909. * A map of component Ids
  116910. */
  116911. [componentId: string]: {
  116912. /**
  116913. * The type of input the component outputs
  116914. */
  116915. type: MotionControllerComponentType;
  116916. /**
  116917. * The indices of this component in the gamepad object
  116918. */
  116919. gamepadIndices: {
  116920. /**
  116921. * Index of button
  116922. */
  116923. button?: number;
  116924. /**
  116925. * If available, index of x-axis
  116926. */
  116927. xAxis?: number;
  116928. /**
  116929. * If available, index of y-axis
  116930. */
  116931. yAxis?: number;
  116932. };
  116933. /**
  116934. * The mesh's root node name
  116935. */
  116936. rootNodeName: string;
  116937. /**
  116938. * Animation definitions for this model
  116939. */
  116940. visualResponses: {
  116941. [stateKey: string]: {
  116942. /**
  116943. * What property will be animated
  116944. */
  116945. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  116946. /**
  116947. * What states influence this visual reponse
  116948. */
  116949. states: MotionControllerComponentStateType[];
  116950. /**
  116951. * Type of animation - movement or visibility
  116952. */
  116953. valueNodeProperty: "transform" | "visibility";
  116954. /**
  116955. * Base node name to move. Its position will be calculated according to the min and max nodes
  116956. */
  116957. valueNodeName?: string;
  116958. /**
  116959. * Minimum movement node
  116960. */
  116961. minNodeName?: string;
  116962. /**
  116963. * Max movement node
  116964. */
  116965. maxNodeName?: string;
  116966. };
  116967. };
  116968. /**
  116969. * If touch enabled, what is the name of node to display user feedback
  116970. */
  116971. touchPointNodeName?: string;
  116972. };
  116973. };
  116974. /**
  116975. * Is it xr standard mapping or not
  116976. */
  116977. gamepadMapping: "" | "xr-standard";
  116978. /**
  116979. * Base root node of this entire model
  116980. */
  116981. rootNodeName: string;
  116982. /**
  116983. * Path to load the assets. Usually relative to the base path
  116984. */
  116985. assetPath: string;
  116986. }
  116987. /**
  116988. * A definition for the layout map in the input profile
  116989. */
  116990. export interface IMotionControllerLayoutMap {
  116991. /**
  116992. * Layouts with handness type as a key
  116993. */
  116994. [handness: string]: IMotionControllerLayout;
  116995. }
  116996. /**
  116997. * The XR Input profile schema
  116998. * Profiles can be found here:
  116999. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  117000. */
  117001. export interface IMotionControllerProfile {
  117002. /**
  117003. * The id of this profile
  117004. * correlates to the profile(s) in the xrInput.profiles array
  117005. */
  117006. profileId: string;
  117007. /**
  117008. * fallback profiles for this profileId
  117009. */
  117010. fallbackProfileIds: string[];
  117011. /**
  117012. * The layout map, with handness as key
  117013. */
  117014. layouts: IMotionControllerLayoutMap;
  117015. }
  117016. /**
  117017. * A helper-interface for the 3 meshes needed for controller button animation
  117018. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  117019. */
  117020. export interface IMotionControllerButtonMeshMap {
  117021. /**
  117022. * The mesh that will be changed when value changes
  117023. */
  117024. valueMesh: AbstractMesh;
  117025. /**
  117026. * the mesh that defines the pressed value mesh position.
  117027. * This is used to find the max-position of this button
  117028. */
  117029. pressedMesh: AbstractMesh;
  117030. /**
  117031. * the mesh that defines the unpressed value mesh position.
  117032. * This is used to find the min (or initial) position of this button
  117033. */
  117034. unpressedMesh: AbstractMesh;
  117035. }
  117036. /**
  117037. * A helper-interface for the 3 meshes needed for controller axis animation.
  117038. * This will be expanded when touchpad animations are fully supported
  117039. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  117040. */
  117041. export interface IMotionControllerMeshMap {
  117042. /**
  117043. * The mesh that will be changed when axis value changes
  117044. */
  117045. valueMesh: AbstractMesh;
  117046. /**
  117047. * the mesh that defines the minimum value mesh position.
  117048. */
  117049. minMesh?: AbstractMesh;
  117050. /**
  117051. * the mesh that defines the maximum value mesh position.
  117052. */
  117053. maxMesh?: AbstractMesh;
  117054. }
  117055. /**
  117056. * The elements needed for change-detection of the gamepad objects in motion controllers
  117057. */
  117058. export interface IMinimalMotionControllerObject {
  117059. /**
  117060. * An array of available buttons
  117061. */
  117062. buttons: Array<{
  117063. /**
  117064. * Value of the button/trigger
  117065. */
  117066. value: number;
  117067. /**
  117068. * If the button/trigger is currently touched
  117069. */
  117070. touched: boolean;
  117071. /**
  117072. * If the button/trigger is currently pressed
  117073. */
  117074. pressed: boolean;
  117075. }>;
  117076. /**
  117077. * Available axes of this controller
  117078. */
  117079. axes: number[];
  117080. }
  117081. /**
  117082. * An Abstract Motion controller
  117083. * This class receives an xrInput and a profile layout and uses those to initialize the components
  117084. * Each component has an observable to check for changes in value and state
  117085. */
  117086. export abstract class WebXRAbstractMotionController implements IDisposable {
  117087. protected scene: Scene;
  117088. protected layout: IMotionControllerLayout;
  117089. /**
  117090. * The gamepad object correlating to this controller
  117091. */
  117092. gamepadObject: IMinimalMotionControllerObject;
  117093. /**
  117094. * handness (left/right/none) of this controller
  117095. */
  117096. handness: MotionControllerHandness;
  117097. /**
  117098. * The profile id of this motion controller
  117099. */
  117100. abstract profileId: string;
  117101. /**
  117102. * A map of components (WebXRControllerComponent) in this motion controller
  117103. * Components have a ComponentType and can also have both button and axis definitions
  117104. */
  117105. readonly components: {
  117106. [id: string]: WebXRControllerComponent;
  117107. };
  117108. /**
  117109. * Observers registered here will be triggered when the model of this controller is done loading
  117110. */
  117111. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  117112. /**
  117113. * The root mesh of the model. It is null if the model was not yet initialized
  117114. */
  117115. rootMesh: Nullable<AbstractMesh>;
  117116. /**
  117117. * Disable the model's animation. Can be set at any time.
  117118. */
  117119. disableAnimation: boolean;
  117120. private _modelReady;
  117121. /**
  117122. * constructs a new abstract motion controller
  117123. * @param scene the scene to which the model of the controller will be added
  117124. * @param layout The profile layout to load
  117125. * @param gamepadObject The gamepad object correlating to this controller
  117126. * @param handness handness (left/right/none) of this controller
  117127. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  117128. */
  117129. constructor(scene: Scene, layout: IMotionControllerLayout,
  117130. /**
  117131. * The gamepad object correlating to this controller
  117132. */
  117133. gamepadObject: IMinimalMotionControllerObject,
  117134. /**
  117135. * handness (left/right/none) of this controller
  117136. */
  117137. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  117138. private _initComponent;
  117139. /**
  117140. * Update this model using the current XRFrame
  117141. * @param xrFrame the current xr frame to use and update the model
  117142. */
  117143. updateFromXRFrame(xrFrame: XRFrame): void;
  117144. /**
  117145. * Get the list of components available in this motion controller
  117146. * @returns an array of strings correlating to available components
  117147. */
  117148. getComponentIds(): string[];
  117149. /**
  117150. * Get the main (Select) component of this controller as defined in the layout
  117151. * @returns the main component of this controller
  117152. */
  117153. getMainComponent(): WebXRControllerComponent;
  117154. /**
  117155. * get a component based an its component id as defined in layout.components
  117156. * @param id the id of the component
  117157. * @returns the component correlates to the id or undefined if not found
  117158. */
  117159. getComponent(id: string): WebXRControllerComponent;
  117160. /**
  117161. * Get the first component of specific type
  117162. * @param type type of component to find
  117163. * @return a controller component or null if not found
  117164. */
  117165. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  117166. /**
  117167. * Returns all components of specific type
  117168. * @param type the type to search for
  117169. * @return an array of components with this type
  117170. */
  117171. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  117172. /**
  117173. * Loads the model correlating to this controller
  117174. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  117175. * @returns A promise fulfilled with the result of the model loading
  117176. */
  117177. loadModel(): Promise<boolean>;
  117178. /**
  117179. * Update the model itself with the current frame data
  117180. * @param xrFrame the frame to use for updating the model mesh
  117181. */
  117182. protected updateModel(xrFrame: XRFrame): void;
  117183. /**
  117184. * Moves the axis on the controller mesh based on its current state
  117185. * @param axis the index of the axis
  117186. * @param axisValue the value of the axis which determines the meshes new position
  117187. * @hidden
  117188. */
  117189. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  117190. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  117191. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  117192. private _getGenericFilenameAndPath;
  117193. private _getGenericParentMesh;
  117194. /**
  117195. * Get the filename and path for this controller's model
  117196. * @returns a map of filename and path
  117197. */
  117198. protected abstract _getFilenameAndPath(): {
  117199. filename: string;
  117200. path: string;
  117201. };
  117202. /**
  117203. * This function will be called after the model was successfully loaded and can be used
  117204. * for mesh transformations before it is available for the user
  117205. * @param meshes the loaded meshes
  117206. */
  117207. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  117208. /**
  117209. * Set the root mesh for this controller. Important for the WebXR controller class
  117210. * @param meshes the loaded meshes
  117211. */
  117212. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  117213. /**
  117214. * A function executed each frame that updates the mesh (if needed)
  117215. * @param xrFrame the current xrFrame
  117216. */
  117217. protected abstract _updateModel(xrFrame: XRFrame): void;
  117218. /**
  117219. * This function is called before the mesh is loaded. It checks for loading constraints.
  117220. * For example, this function can check if the GLB loader is available
  117221. * If this function returns false, the generic controller will be loaded instead
  117222. * @returns Is the client ready to load the mesh
  117223. */
  117224. protected abstract _getModelLoadingConstraints(): boolean;
  117225. /**
  117226. * Dispose this controller, the model mesh and all its components
  117227. */
  117228. dispose(): void;
  117229. }
  117230. }
  117231. declare module BABYLON {
  117232. /**
  117233. * A generic trigger-only motion controller for WebXR
  117234. */
  117235. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  117236. /**
  117237. * Static version of the profile id of this controller
  117238. */
  117239. static ProfileId: string;
  117240. profileId: string;
  117241. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  117242. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  117243. protected _updateModel(): void;
  117244. protected _getFilenameAndPath(): {
  117245. filename: string;
  117246. path: string;
  117247. };
  117248. protected _setRootMesh(meshes: AbstractMesh[]): void;
  117249. protected _getModelLoadingConstraints(): boolean;
  117250. }
  117251. }
  117252. declare module BABYLON {
  117253. /**
  117254. * Class containing static functions to help procedurally build meshes
  117255. */
  117256. export class SphereBuilder {
  117257. /**
  117258. * Creates a sphere mesh
  117259. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  117260. * * 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`)
  117261. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  117262. * * 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
  117263. * * 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)
  117264. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117265. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117266. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117267. * @param name defines the name of the mesh
  117268. * @param options defines the options used to create the mesh
  117269. * @param scene defines the hosting scene
  117270. * @returns the sphere mesh
  117271. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  117272. */
  117273. static CreateSphere(name: string, options: {
  117274. segments?: number;
  117275. diameter?: number;
  117276. diameterX?: number;
  117277. diameterY?: number;
  117278. diameterZ?: number;
  117279. arc?: number;
  117280. slice?: number;
  117281. sideOrientation?: number;
  117282. frontUVs?: Vector4;
  117283. backUVs?: Vector4;
  117284. updatable?: boolean;
  117285. }, scene?: Nullable<Scene>): Mesh;
  117286. }
  117287. }
  117288. declare module BABYLON {
  117289. /**
  117290. * A profiled motion controller has its profile loaded from an online repository.
  117291. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  117292. */
  117293. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  117294. private _repositoryUrl;
  117295. /**
  117296. * The profile ID of this controller. Will be populated when the controller initializes.
  117297. */
  117298. profileId: string;
  117299. private _buttonMeshMapping;
  117300. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  117301. protected _getFilenameAndPath(): {
  117302. filename: string;
  117303. path: string;
  117304. };
  117305. private _touchDots;
  117306. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  117307. protected _setRootMesh(meshes: AbstractMesh[]): void;
  117308. protected _updateModel(_xrFrame: XRFrame): void;
  117309. protected _getModelLoadingConstraints(): boolean;
  117310. dispose(): void;
  117311. }
  117312. }
  117313. declare module BABYLON {
  117314. /**
  117315. * A construction function type to create a new controller based on an xrInput object
  117316. */
  117317. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  117318. /**
  117319. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  117320. *
  117321. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  117322. * it should be replaced with auto-loaded controllers.
  117323. *
  117324. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  117325. */
  117326. export class WebXRMotionControllerManager {
  117327. /**
  117328. * The base URL of the online controller repository. Can be changed at any time.
  117329. */
  117330. static BaseRepositoryUrl: string;
  117331. /**
  117332. * Use the online repository, or use only locally-defined controllers
  117333. */
  117334. static UseOnlineRepository: boolean;
  117335. /**
  117336. * Which repository gets priority - local or online
  117337. */
  117338. static PrioritizeOnlineRepository: boolean;
  117339. private static _AvailableControllers;
  117340. private static _Fallbacks;
  117341. /**
  117342. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  117343. *
  117344. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  117345. *
  117346. * @param type the profile type to register
  117347. * @param constructFunction the function to be called when loading this profile
  117348. */
  117349. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  117350. /**
  117351. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  117352. * The order of search:
  117353. *
  117354. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  117355. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  117356. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  117357. * 4) return the generic trigger controller if none were found
  117358. *
  117359. * @param xrInput the xrInput to which a new controller is initialized
  117360. * @param scene the scene to which the model will be added
  117361. * @param forceProfile force a certain profile for this controller
  117362. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  117363. */
  117364. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  117365. private static _LoadProfilesFromAvailableControllers;
  117366. private static _ProfilesList;
  117367. private static _ProfileLoadingPromises;
  117368. private static _LoadProfileFromRepository;
  117369. /**
  117370. * Clear the cache used for profile loading and reload when requested again
  117371. */
  117372. static ClearProfilesCache(): void;
  117373. /**
  117374. * Will update the list of profiles available in the repository
  117375. * @return a promise that resolves to a map of profiles available online
  117376. */
  117377. static UpdateProfilesList(): Promise<{
  117378. [profile: string]: string;
  117379. }>;
  117380. /**
  117381. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  117382. * @param profileId the profile to which a fallback needs to be found
  117383. * @return an array with corresponding fallback profiles
  117384. */
  117385. static FindFallbackWithProfileId(profileId: string): string[];
  117386. /**
  117387. * Register a fallback to a specific profile.
  117388. * @param profileId the profileId that will receive the fallbacks
  117389. * @param fallbacks A list of fallback profiles
  117390. */
  117391. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  117392. /**
  117393. * Register the default fallbacks.
  117394. * This function is called automatically when this file is imported.
  117395. */
  117396. static DefaultFallbacks(): void;
  117397. }
  117398. }
  117399. declare module BABYLON {
  117400. /**
  117401. * Configuration options for the WebXR controller creation
  117402. */
  117403. export interface IWebXRControllerOptions {
  117404. /**
  117405. * Force a specific controller type for this controller.
  117406. * This can be used when creating your own profile or when testing different controllers
  117407. */
  117408. forceControllerProfile?: string;
  117409. /**
  117410. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  117411. */
  117412. doNotLoadControllerMesh?: boolean;
  117413. /**
  117414. * Should the controller mesh be animated when a user interacts with it
  117415. * The pressed buttons / thumbstick and touchpad animations will be disabled
  117416. */
  117417. disableMotionControllerAnimation?: boolean;
  117418. }
  117419. /**
  117420. * Represents an XR controller
  117421. */
  117422. export class WebXRInputSource {
  117423. private _scene;
  117424. /** The underlying input source for the controller */
  117425. inputSource: XRInputSource;
  117426. private _options;
  117427. /**
  117428. * 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
  117429. */
  117430. grip?: AbstractMesh;
  117431. /**
  117432. * Pointer which can be used to select objects or attach a visible laser to
  117433. */
  117434. pointer: AbstractMesh;
  117435. /**
  117436. * If available, this is the gamepad object related to this controller.
  117437. * Using this object it is possible to get click events and trackpad changes of the
  117438. * webxr controller that is currently being used.
  117439. */
  117440. motionController?: WebXRAbstractMotionController;
  117441. /**
  117442. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  117443. */
  117444. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  117445. /**
  117446. * Will be triggered when the mesh associated with the motion controller is done loading.
  117447. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  117448. * A shortened version of controller -> motion controller -> on mesh loaded.
  117449. */
  117450. onMeshLoadedObservable: Observable<AbstractMesh>;
  117451. /**
  117452. * Event that fires when the controller is removed/disposed.
  117453. * The object provided as event data is this controller, after associated assets were disposed.
  117454. * uniqueId is still available.
  117455. */
  117456. onDisposeObservable: Observable<WebXRInputSource>;
  117457. private _tmpQuaternion;
  117458. private _tmpVector;
  117459. private _uniqueId;
  117460. /**
  117461. * Creates the controller
  117462. * @see https://doc.babylonjs.com/how_to/webxr
  117463. * @param _scene the scene which the controller should be associated to
  117464. * @param inputSource the underlying input source for the controller
  117465. * @param _options options for this controller creation
  117466. */
  117467. constructor(_scene: Scene,
  117468. /** The underlying input source for the controller */
  117469. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  117470. /**
  117471. * Get this controllers unique id
  117472. */
  117473. get uniqueId(): string;
  117474. /**
  117475. * Updates the controller pose based on the given XRFrame
  117476. * @param xrFrame xr frame to update the pose with
  117477. * @param referenceSpace reference space to use
  117478. */
  117479. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  117480. /**
  117481. * Gets a world space ray coming from the pointer or grip
  117482. * @param result the resulting ray
  117483. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  117484. */
  117485. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  117486. /**
  117487. * Disposes of the object
  117488. */
  117489. dispose(): void;
  117490. }
  117491. }
  117492. declare module BABYLON {
  117493. /**
  117494. * The schema for initialization options of the XR Input class
  117495. */
  117496. export interface IWebXRInputOptions {
  117497. /**
  117498. * If set to true no model will be automatically loaded
  117499. */
  117500. doNotLoadControllerMeshes?: boolean;
  117501. /**
  117502. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  117503. * If not found, the xr input profile data will be used.
  117504. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  117505. */
  117506. forceInputProfile?: string;
  117507. /**
  117508. * Do not send a request to the controlle repository to load the profile.
  117509. *
  117510. * Instead, use the controllers available in babylon itself.
  117511. */
  117512. disableOnlineControllerRepository?: boolean;
  117513. /**
  117514. * A custom URL for the controllers repository
  117515. */
  117516. customControllersRepositoryURL?: string;
  117517. /**
  117518. * Should the controller model's components not move according to the user input
  117519. */
  117520. disableControllerAnimation?: boolean;
  117521. }
  117522. /**
  117523. * XR input used to track XR inputs such as controllers/rays
  117524. */
  117525. export class WebXRInput implements IDisposable {
  117526. /**
  117527. * the xr session manager for this session
  117528. */
  117529. xrSessionManager: WebXRSessionManager;
  117530. /**
  117531. * the WebXR camera for this session. Mainly used for teleportation
  117532. */
  117533. xrCamera: WebXRCamera;
  117534. private readonly options;
  117535. /**
  117536. * XR controllers being tracked
  117537. */
  117538. controllers: Array<WebXRInputSource>;
  117539. private _frameObserver;
  117540. private _sessionEndedObserver;
  117541. private _sessionInitObserver;
  117542. /**
  117543. * Event when a controller has been connected/added
  117544. */
  117545. onControllerAddedObservable: Observable<WebXRInputSource>;
  117546. /**
  117547. * Event when a controller has been removed/disconnected
  117548. */
  117549. onControllerRemovedObservable: Observable<WebXRInputSource>;
  117550. /**
  117551. * Initializes the WebXRInput
  117552. * @param xrSessionManager the xr session manager for this session
  117553. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  117554. * @param options = initialization options for this xr input
  117555. */
  117556. constructor(
  117557. /**
  117558. * the xr session manager for this session
  117559. */
  117560. xrSessionManager: WebXRSessionManager,
  117561. /**
  117562. * the WebXR camera for this session. Mainly used for teleportation
  117563. */
  117564. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  117565. private _onInputSourcesChange;
  117566. private _addAndRemoveControllers;
  117567. /**
  117568. * Disposes of the object
  117569. */
  117570. dispose(): void;
  117571. }
  117572. }
  117573. declare module BABYLON {
  117574. /**
  117575. * This is the base class for all WebXR features.
  117576. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  117577. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  117578. */
  117579. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  117580. protected _xrSessionManager: WebXRSessionManager;
  117581. /**
  117582. * Construct a new (abstract) webxr feature
  117583. * @param _xrSessionManager the xr session manager for this feature
  117584. */
  117585. constructor(_xrSessionManager: WebXRSessionManager);
  117586. private _attached;
  117587. private _removeOnDetach;
  117588. /**
  117589. * Is this feature attached
  117590. */
  117591. get attached(): boolean;
  117592. /**
  117593. * Should auto-attach be disabled?
  117594. */
  117595. disableAutoAttach: boolean;
  117596. /**
  117597. * attach this feature
  117598. *
  117599. * @param force should attachment be forced (even when already attached)
  117600. * @returns true if successful, false is failed or already attached
  117601. */
  117602. attach(force?: boolean): boolean;
  117603. /**
  117604. * detach this feature.
  117605. *
  117606. * @returns true if successful, false if failed or already detached
  117607. */
  117608. detach(): boolean;
  117609. /**
  117610. * Dispose this feature and all of the resources attached
  117611. */
  117612. dispose(): void;
  117613. /**
  117614. * Code in this function will be executed on each xrFrame received from the browser.
  117615. * This function will not execute after the feature is detached.
  117616. * @param _xrFrame the current frame
  117617. */
  117618. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  117619. /**
  117620. * This is used to register callbacks that will automatically be removed when detach is called.
  117621. * @param observable the observable to which the observer will be attached
  117622. * @param callback the callback to register
  117623. */
  117624. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  117625. }
  117626. }
  117627. declare module BABYLON {
  117628. /**
  117629. * Renders a layer on top of an existing scene
  117630. */
  117631. export class UtilityLayerRenderer implements IDisposable {
  117632. /** the original scene that will be rendered on top of */
  117633. originalScene: Scene;
  117634. private _pointerCaptures;
  117635. private _lastPointerEvents;
  117636. private static _DefaultUtilityLayer;
  117637. private static _DefaultKeepDepthUtilityLayer;
  117638. private _sharedGizmoLight;
  117639. private _renderCamera;
  117640. /**
  117641. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  117642. * @returns the camera that is used when rendering the utility layer
  117643. */
  117644. getRenderCamera(): Camera;
  117645. /**
  117646. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  117647. * @param cam the camera that should be used when rendering the utility layer
  117648. */
  117649. setRenderCamera(cam: Nullable<Camera>): void;
  117650. /**
  117651. * @hidden
  117652. * Light which used by gizmos to get light shading
  117653. */
  117654. _getSharedGizmoLight(): HemisphericLight;
  117655. /**
  117656. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  117657. */
  117658. pickUtilitySceneFirst: boolean;
  117659. /**
  117660. * 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)
  117661. */
  117662. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  117663. /**
  117664. * 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)
  117665. */
  117666. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  117667. /**
  117668. * The scene that is rendered on top of the original scene
  117669. */
  117670. utilityLayerScene: Scene;
  117671. /**
  117672. * If the utility layer should automatically be rendered on top of existing scene
  117673. */
  117674. shouldRender: boolean;
  117675. /**
  117676. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  117677. */
  117678. onlyCheckPointerDownEvents: boolean;
  117679. /**
  117680. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  117681. */
  117682. processAllEvents: boolean;
  117683. /**
  117684. * Observable raised when the pointer move from the utility layer scene to the main scene
  117685. */
  117686. onPointerOutObservable: Observable<number>;
  117687. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  117688. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  117689. private _afterRenderObserver;
  117690. private _sceneDisposeObserver;
  117691. private _originalPointerObserver;
  117692. /**
  117693. * Instantiates a UtilityLayerRenderer
  117694. * @param originalScene the original scene that will be rendered on top of
  117695. * @param handleEvents boolean indicating if the utility layer should handle events
  117696. */
  117697. constructor(
  117698. /** the original scene that will be rendered on top of */
  117699. originalScene: Scene, handleEvents?: boolean);
  117700. private _notifyObservers;
  117701. /**
  117702. * Renders the utility layers scene on top of the original scene
  117703. */
  117704. render(): void;
  117705. /**
  117706. * Disposes of the renderer
  117707. */
  117708. dispose(): void;
  117709. private _updateCamera;
  117710. }
  117711. }
  117712. declare module BABYLON {
  117713. /**
  117714. * Options interface for the pointer selection module
  117715. */
  117716. export interface IWebXRControllerPointerSelectionOptions {
  117717. /**
  117718. * the xr input to use with this pointer selection
  117719. */
  117720. xrInput: WebXRInput;
  117721. /**
  117722. * Different button type to use instead of the main component
  117723. */
  117724. overrideButtonId?: string;
  117725. /**
  117726. * The amount of time in miliseconds it takes between pick found something to a pointer down event.
  117727. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  117728. * 3000 means 3 seconds between pointing at something and selecting it
  117729. */
  117730. timeToSelect?: number;
  117731. /**
  117732. * 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)
  117733. * If not disabled, the last picked point will be used to execute a pointer up event
  117734. * If disabled, pointer up event will be triggered right after the pointer down event.
  117735. * Used in screen and gaze target ray mode only
  117736. */
  117737. disablePointerUpOnTouchOut: boolean;
  117738. /**
  117739. * For gaze mode (time to select instead of press)
  117740. */
  117741. forceGazeMode: boolean;
  117742. /**
  117743. * 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
  117744. * to start a new countdown to the pointer down event.
  117745. * Defaults to 1.
  117746. */
  117747. gazeModePointerMovedFactor?: number;
  117748. /**
  117749. * Should meshes created here be added to a utility layer or the main scene
  117750. */
  117751. useUtilityLayer?: boolean;
  117752. /**
  117753. * if provided, this scene will be used to render meshes.
  117754. */
  117755. customUtilityLayerScene?: Scene;
  117756. }
  117757. /**
  117758. * A module that will enable pointer selection for motion controllers of XR Input Sources
  117759. */
  117760. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  117761. private readonly _options;
  117762. /**
  117763. * The module's name
  117764. */
  117765. static readonly Name: string;
  117766. /**
  117767. * The (Babylon) version of this module.
  117768. * This is an integer representing the implementation version.
  117769. * This number does not correspond to the webxr specs version
  117770. */
  117771. static readonly Version: number;
  117772. /**
  117773. * This color will be set to the laser pointer when selection is triggered
  117774. */
  117775. laserPointerPickedColor: Color3;
  117776. /**
  117777. * This color will be applied to the selection ring when selection is triggered
  117778. */
  117779. selectionMeshPickedColor: Color3;
  117780. /**
  117781. * default color of the selection ring
  117782. */
  117783. selectionMeshDefaultColor: Color3;
  117784. /**
  117785. * Default color of the laser pointer
  117786. */
  117787. lasterPointerDefaultColor: Color3;
  117788. /**
  117789. * Should the laser pointer be displayed
  117790. */
  117791. displayLaserPointer: boolean;
  117792. /**
  117793. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  117794. */
  117795. displaySelectionMesh: boolean;
  117796. /**
  117797. * Disable lighting on the laser pointer (so it will always be visible)
  117798. */
  117799. disablePointerLighting: boolean;
  117800. /**
  117801. * Disable lighting on the selection mesh (so it will always be visible)
  117802. */
  117803. disableSelectionMeshLighting: boolean;
  117804. private static _idCounter;
  117805. private _tmpRay;
  117806. private _controllers;
  117807. private _scene;
  117808. /**
  117809. * constructs a new background remover module
  117810. * @param _xrSessionManager the session manager for this module
  117811. * @param _options read-only options to be used in this module
  117812. */
  117813. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  117814. /**
  117815. * attach this feature
  117816. * Will usually be called by the features manager
  117817. *
  117818. * @returns true if successful.
  117819. */
  117820. attach(): boolean;
  117821. /**
  117822. * detach this feature.
  117823. * Will usually be called by the features manager
  117824. *
  117825. * @returns true if successful.
  117826. */
  117827. detach(): boolean;
  117828. /**
  117829. * Get the xr controller that correlates to the pointer id in the pointer event
  117830. *
  117831. * @param id the pointer id to search for
  117832. * @returns the controller that correlates to this id or null if not found
  117833. */
  117834. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  117835. protected _onXRFrame(_xrFrame: XRFrame): void;
  117836. private _attachController;
  117837. private _attachScreenRayMode;
  117838. private _attachGazeMode;
  117839. private _tmpVectorForPickCompare;
  117840. private _pickingMoved;
  117841. private _attachTrackedPointerRayMode;
  117842. private _detachController;
  117843. private _generateNewMeshPair;
  117844. private _convertNormalToDirectionOfRay;
  117845. private _updatePointerDistance;
  117846. }
  117847. }
  117848. declare module BABYLON {
  117849. /**
  117850. * Button which can be used to enter a different mode of XR
  117851. */
  117852. export class WebXREnterExitUIButton {
  117853. /** button element */
  117854. element: HTMLElement;
  117855. /** XR initialization options for the button */
  117856. sessionMode: XRSessionMode;
  117857. /** Reference space type */
  117858. referenceSpaceType: XRReferenceSpaceType;
  117859. /**
  117860. * Creates a WebXREnterExitUIButton
  117861. * @param element button element
  117862. * @param sessionMode XR initialization session mode
  117863. * @param referenceSpaceType the type of reference space to be used
  117864. */
  117865. constructor(
  117866. /** button element */
  117867. element: HTMLElement,
  117868. /** XR initialization options for the button */
  117869. sessionMode: XRSessionMode,
  117870. /** Reference space type */
  117871. referenceSpaceType: XRReferenceSpaceType);
  117872. /**
  117873. * Overwritable function which can be used to update the button's visuals when the state changes
  117874. * @param activeButton the current active button in the UI
  117875. */
  117876. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  117877. }
  117878. /**
  117879. * Options to create the webXR UI
  117880. */
  117881. export class WebXREnterExitUIOptions {
  117882. /**
  117883. * Context to enter xr with
  117884. */
  117885. renderTarget?: Nullable<WebXRRenderTarget>;
  117886. /**
  117887. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  117888. */
  117889. customButtons?: Array<WebXREnterExitUIButton>;
  117890. /**
  117891. * A session mode to use when creating the default button.
  117892. * Default is immersive-vr
  117893. */
  117894. sessionMode?: XRSessionMode;
  117895. /**
  117896. * A reference space type to use when creating the default button.
  117897. * Default is local-floor
  117898. */
  117899. referenceSpaceType?: XRReferenceSpaceType;
  117900. }
  117901. /**
  117902. * UI to allow the user to enter/exit XR mode
  117903. */
  117904. export class WebXREnterExitUI implements IDisposable {
  117905. private scene;
  117906. /** version of the options passed to this UI */
  117907. options: WebXREnterExitUIOptions;
  117908. private _overlay;
  117909. private _buttons;
  117910. private _activeButton;
  117911. /**
  117912. * Fired every time the active button is changed.
  117913. *
  117914. * When xr is entered via a button that launches xr that button will be the callback parameter
  117915. *
  117916. * When exiting xr the callback parameter will be null)
  117917. */
  117918. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  117919. /**
  117920. * Creates UI to allow the user to enter/exit XR mode
  117921. * @param scene the scene to add the ui to
  117922. * @param helper the xr experience helper to enter/exit xr with
  117923. * @param options options to configure the UI
  117924. * @returns the created ui
  117925. */
  117926. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  117927. /**
  117928. *
  117929. * @param scene babylon scene object to use
  117930. * @param options (read-only) version of the options passed to this UI
  117931. */
  117932. private constructor();
  117933. private _updateButtons;
  117934. /**
  117935. * Disposes of the object
  117936. */
  117937. dispose(): void;
  117938. }
  117939. }
  117940. declare module BABYLON {
  117941. /**
  117942. * Class containing static functions to help procedurally build meshes
  117943. */
  117944. export class LinesBuilder {
  117945. /**
  117946. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  117947. * * 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
  117948. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  117949. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  117950. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  117951. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  117952. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  117953. * * 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
  117954. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  117955. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117956. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  117957. * @param name defines the name of the new line system
  117958. * @param options defines the options used to create the line system
  117959. * @param scene defines the hosting scene
  117960. * @returns a new line system mesh
  117961. */
  117962. static CreateLineSystem(name: string, options: {
  117963. lines: Vector3[][];
  117964. updatable?: boolean;
  117965. instance?: Nullable<LinesMesh>;
  117966. colors?: Nullable<Color4[][]>;
  117967. useVertexAlpha?: boolean;
  117968. }, scene: Nullable<Scene>): LinesMesh;
  117969. /**
  117970. * Creates a line mesh
  117971. * 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
  117972. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  117973. * * The parameter `points` is an array successive Vector3
  117974. * * 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
  117975. * * The optional parameter `colors` is an array of successive Color4, one per line point
  117976. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  117977. * * When updating an instance, remember that only point positions can change, not the number of points
  117978. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117979. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  117980. * @param name defines the name of the new line system
  117981. * @param options defines the options used to create the line system
  117982. * @param scene defines the hosting scene
  117983. * @returns a new line mesh
  117984. */
  117985. static CreateLines(name: string, options: {
  117986. points: Vector3[];
  117987. updatable?: boolean;
  117988. instance?: Nullable<LinesMesh>;
  117989. colors?: Color4[];
  117990. useVertexAlpha?: boolean;
  117991. }, scene?: Nullable<Scene>): LinesMesh;
  117992. /**
  117993. * Creates a dashed line mesh
  117994. * * 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
  117995. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  117996. * * The parameter `points` is an array successive Vector3
  117997. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  117998. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  117999. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  118000. * * 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
  118001. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  118002. * * When updating an instance, remember that only point positions can change, not the number of points
  118003. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118004. * @param name defines the name of the mesh
  118005. * @param options defines the options used to create the mesh
  118006. * @param scene defines the hosting scene
  118007. * @returns the dashed line mesh
  118008. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  118009. */
  118010. static CreateDashedLines(name: string, options: {
  118011. points: Vector3[];
  118012. dashSize?: number;
  118013. gapSize?: number;
  118014. dashNb?: number;
  118015. updatable?: boolean;
  118016. instance?: LinesMesh;
  118017. useVertexAlpha?: boolean;
  118018. }, scene?: Nullable<Scene>): LinesMesh;
  118019. }
  118020. }
  118021. declare module BABYLON {
  118022. /**
  118023. * The options container for the teleportation module
  118024. */
  118025. export interface IWebXRTeleportationOptions {
  118026. /**
  118027. * Babylon XR Input class for controller
  118028. */
  118029. xrInput: WebXRInput;
  118030. /**
  118031. * A list of meshes to use as floor meshes.
  118032. * Meshes can be added and removed after initializing the feature using the
  118033. * addFloorMesh and removeFloorMesh functions
  118034. * If empty, rotation will still work
  118035. */
  118036. floorMeshes?: AbstractMesh[];
  118037. /**
  118038. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  118039. * If you want to support rotation, make sure your mesh has a direction indicator.
  118040. *
  118041. * When left untouched, the default mesh will be initialized.
  118042. */
  118043. teleportationTargetMesh?: AbstractMesh;
  118044. /**
  118045. * Values to configure the default target mesh
  118046. */
  118047. defaultTargetMeshOptions?: {
  118048. /**
  118049. * Fill color of the teleportation area
  118050. */
  118051. teleportationFillColor?: string;
  118052. /**
  118053. * Border color for the teleportation area
  118054. */
  118055. teleportationBorderColor?: string;
  118056. /**
  118057. * Disable the mesh's animation sequence
  118058. */
  118059. disableAnimation?: boolean;
  118060. /**
  118061. * Disable lighting on the material or the ring and arrow
  118062. */
  118063. disableLighting?: boolean;
  118064. /**
  118065. * Override the default material of the torus and arrow
  118066. */
  118067. torusArrowMaterial?: Material;
  118068. };
  118069. /**
  118070. * Disable using the thumbstick and use the main component (usuallly trigger) on long press.
  118071. * This will be automatically true if the controller doesnt have a thumbstick or touchpad.
  118072. */
  118073. useMainComponentOnly?: boolean;
  118074. /**
  118075. * If main component is used (no thumbstick), how long should the "long press" take before teleporting
  118076. */
  118077. timeToTeleport?: number;
  118078. /**
  118079. * Should meshes created here be added to a utility layer or the main scene
  118080. */
  118081. useUtilityLayer?: boolean;
  118082. /**
  118083. * if provided, this scene will be used to render meshes.
  118084. */
  118085. customUtilityLayerScene?: Scene;
  118086. }
  118087. /**
  118088. * This is a teleportation feature to be used with webxr-enabled motion controllers.
  118089. * When enabled and attached, the feature will allow a user to move aroundand rotate in the scene using
  118090. * the input of the attached controllers.
  118091. */
  118092. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  118093. private _options;
  118094. /**
  118095. * The module's name
  118096. */
  118097. static readonly Name: string;
  118098. /**
  118099. * The (Babylon) version of this module.
  118100. * This is an integer representing the implementation version.
  118101. * This number does not correspond to the webxr specs version
  118102. */
  118103. static readonly Version: number;
  118104. /**
  118105. * Is rotation enabled when moving forward?
  118106. * Disabling this feature will prevent the user from deciding the direction when teleporting
  118107. */
  118108. rotationEnabled: boolean;
  118109. /**
  118110. * Should the module support parabolic ray on top of direct ray
  118111. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  118112. * Very helpful when moving between floors / different heights
  118113. */
  118114. parabolicRayEnabled: boolean;
  118115. /**
  118116. * The distance from the user to the inspection point in the direction of the controller
  118117. * A higher number will allow the user to move further
  118118. * defaults to 5 (meters, in xr units)
  118119. */
  118120. parabolicCheckRadius: number;
  118121. /**
  118122. * How much rotation should be applied when rotating right and left
  118123. */
  118124. rotationAngle: number;
  118125. /**
  118126. * Is movement backwards enabled
  118127. */
  118128. backwardsMovementEnabled: boolean;
  118129. /**
  118130. * Distance to travel when moving backwards
  118131. */
  118132. backwardsTeleportationDistance: number;
  118133. /**
  118134. * Add a new mesh to the floor meshes array
  118135. * @param mesh the mesh to use as floor mesh
  118136. */
  118137. addFloorMesh(mesh: AbstractMesh): void;
  118138. /**
  118139. * Remove a mesh from the floor meshes array
  118140. * @param mesh the mesh to remove
  118141. */
  118142. removeFloorMesh(mesh: AbstractMesh): void;
  118143. /**
  118144. * Remove a mesh from the floor meshes array using its name
  118145. * @param name the mesh name to remove
  118146. */
  118147. removeFloorMeshByName(name: string): void;
  118148. private _tmpRay;
  118149. private _tmpVector;
  118150. private _floorMeshes;
  118151. private _controllers;
  118152. /**
  118153. * constructs a new anchor system
  118154. * @param _xrSessionManager an instance of WebXRSessionManager
  118155. * @param _options configuration object for this feature
  118156. */
  118157. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  118158. private _selectionFeature;
  118159. /**
  118160. * This function sets a selection feature that will be disabled when
  118161. * the forward ray is shown and will be reattached when hidden.
  118162. * This is used to remove the selection rays when moving.
  118163. * @param selectionFeature the feature to disable when forward movement is enabled
  118164. */
  118165. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  118166. attach(): boolean;
  118167. detach(): boolean;
  118168. dispose(): void;
  118169. protected _onXRFrame(_xrFrame: XRFrame): void;
  118170. private _currentTeleportationControllerId;
  118171. private _attachController;
  118172. private _teleportForward;
  118173. private _detachController;
  118174. private createDefaultTargetMesh;
  118175. private setTargetMeshVisibility;
  118176. private setTargetMeshPosition;
  118177. private _quadraticBezierCurve;
  118178. private _showParabolicPath;
  118179. }
  118180. }
  118181. declare module BABYLON {
  118182. /**
  118183. * Options for the default xr helper
  118184. */
  118185. export class WebXRDefaultExperienceOptions {
  118186. /**
  118187. * Floor meshes that will be used for teleporting
  118188. */
  118189. floorMeshes?: Array<AbstractMesh>;
  118190. /**
  118191. * Enable or disable default UI to enter XR
  118192. */
  118193. disableDefaultUI?: boolean;
  118194. /**
  118195. * optional configuration for the output canvas
  118196. */
  118197. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  118198. /**
  118199. * optional UI options. This can be used among other to change session mode and reference space type
  118200. */
  118201. uiOptions?: WebXREnterExitUIOptions;
  118202. /**
  118203. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  118204. */
  118205. inputOptions?: IWebXRInputOptions;
  118206. /**
  118207. * Should teleportation not initialize. defaults to false.
  118208. */
  118209. disableTeleportation?: boolean;
  118210. /**
  118211. * If set to true, the first frame will not be used to reset position
  118212. * The first frame is mainly used when copying transformation from the old camera
  118213. * Mainly used in AR
  118214. */
  118215. ignoreNativeCameraTransformation?: boolean;
  118216. /**
  118217. * When loading teleportation and pointer select, use stable versions instead of latest.
  118218. */
  118219. useStablePlugins?: boolean;
  118220. }
  118221. /**
  118222. * Default experience which provides a similar setup to the previous webVRExperience
  118223. */
  118224. export class WebXRDefaultExperience {
  118225. /**
  118226. * Base experience
  118227. */
  118228. baseExperience: WebXRExperienceHelper;
  118229. /**
  118230. * Input experience extension
  118231. */
  118232. input: WebXRInput;
  118233. /**
  118234. * Enables laser pointer and selection
  118235. */
  118236. pointerSelection: WebXRControllerPointerSelection;
  118237. /**
  118238. * Enables teleportation
  118239. */
  118240. teleportation: WebXRMotionControllerTeleportation;
  118241. /**
  118242. * Enables ui for entering/exiting xr
  118243. */
  118244. enterExitUI: WebXREnterExitUI;
  118245. /**
  118246. * Default target xr should render to
  118247. */
  118248. renderTarget: WebXRRenderTarget;
  118249. /**
  118250. * Creates the default xr experience
  118251. * @param scene scene
  118252. * @param options options for basic configuration
  118253. * @returns resulting WebXRDefaultExperience
  118254. */
  118255. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  118256. private constructor();
  118257. /**
  118258. * DIsposes of the experience helper
  118259. */
  118260. dispose(): void;
  118261. }
  118262. }
  118263. declare module BABYLON {
  118264. /**
  118265. * Options to modify the vr teleportation behavior.
  118266. */
  118267. export interface VRTeleportationOptions {
  118268. /**
  118269. * The name of the mesh which should be used as the teleportation floor. (default: null)
  118270. */
  118271. floorMeshName?: string;
  118272. /**
  118273. * A list of meshes to be used as the teleportation floor. (default: empty)
  118274. */
  118275. floorMeshes?: Mesh[];
  118276. /**
  118277. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  118278. */
  118279. teleportationMode?: number;
  118280. /**
  118281. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  118282. */
  118283. teleportationTime?: number;
  118284. /**
  118285. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  118286. */
  118287. teleportationSpeed?: number;
  118288. /**
  118289. * The easing function used in the animation or null for Linear. (default CircleEase)
  118290. */
  118291. easingFunction?: EasingFunction;
  118292. }
  118293. /**
  118294. * Options to modify the vr experience helper's behavior.
  118295. */
  118296. export interface VRExperienceHelperOptions extends WebVROptions {
  118297. /**
  118298. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  118299. */
  118300. createDeviceOrientationCamera?: boolean;
  118301. /**
  118302. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  118303. */
  118304. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  118305. /**
  118306. * Uses the main button on the controller to toggle the laser casted. (default: true)
  118307. */
  118308. laserToggle?: boolean;
  118309. /**
  118310. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  118311. */
  118312. floorMeshes?: Mesh[];
  118313. /**
  118314. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  118315. */
  118316. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  118317. /**
  118318. * Defines if WebXR should be used instead of WebVR (if available)
  118319. */
  118320. useXR?: boolean;
  118321. }
  118322. /**
  118323. * Event containing information after VR has been entered
  118324. */
  118325. export class OnAfterEnteringVRObservableEvent {
  118326. /**
  118327. * If entering vr was successful
  118328. */
  118329. success: boolean;
  118330. }
  118331. /**
  118332. * Helps to quickly add VR support to an existing scene.
  118333. * See http://doc.babylonjs.com/how_to/webvr_helper
  118334. */
  118335. export class VRExperienceHelper {
  118336. /** Options to modify the vr experience helper's behavior. */
  118337. webVROptions: VRExperienceHelperOptions;
  118338. private _scene;
  118339. private _position;
  118340. private _btnVR;
  118341. private _btnVRDisplayed;
  118342. private _webVRsupported;
  118343. private _webVRready;
  118344. private _webVRrequesting;
  118345. private _webVRpresenting;
  118346. private _hasEnteredVR;
  118347. private _fullscreenVRpresenting;
  118348. private _inputElement;
  118349. private _webVRCamera;
  118350. private _vrDeviceOrientationCamera;
  118351. private _deviceOrientationCamera;
  118352. private _existingCamera;
  118353. private _onKeyDown;
  118354. private _onVrDisplayPresentChange;
  118355. private _onVRDisplayChanged;
  118356. private _onVRRequestPresentStart;
  118357. private _onVRRequestPresentComplete;
  118358. /**
  118359. * 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)
  118360. */
  118361. enableGazeEvenWhenNoPointerLock: boolean;
  118362. /**
  118363. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  118364. */
  118365. exitVROnDoubleTap: boolean;
  118366. /**
  118367. * Observable raised right before entering VR.
  118368. */
  118369. onEnteringVRObservable: Observable<VRExperienceHelper>;
  118370. /**
  118371. * Observable raised when entering VR has completed.
  118372. */
  118373. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  118374. /**
  118375. * Observable raised when exiting VR.
  118376. */
  118377. onExitingVRObservable: Observable<VRExperienceHelper>;
  118378. /**
  118379. * Observable raised when controller mesh is loaded.
  118380. */
  118381. onControllerMeshLoadedObservable: Observable<WebVRController>;
  118382. /** Return this.onEnteringVRObservable
  118383. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  118384. */
  118385. get onEnteringVR(): Observable<VRExperienceHelper>;
  118386. /** Return this.onExitingVRObservable
  118387. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  118388. */
  118389. get onExitingVR(): Observable<VRExperienceHelper>;
  118390. /** Return this.onControllerMeshLoadedObservable
  118391. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  118392. */
  118393. get onControllerMeshLoaded(): Observable<WebVRController>;
  118394. private _rayLength;
  118395. private _useCustomVRButton;
  118396. private _teleportationRequested;
  118397. private _teleportActive;
  118398. private _floorMeshName;
  118399. private _floorMeshesCollection;
  118400. private _teleportationMode;
  118401. private _teleportationTime;
  118402. private _teleportationSpeed;
  118403. private _teleportationEasing;
  118404. private _rotationAllowed;
  118405. private _teleportBackwardsVector;
  118406. private _teleportationTarget;
  118407. private _isDefaultTeleportationTarget;
  118408. private _postProcessMove;
  118409. private _teleportationFillColor;
  118410. private _teleportationBorderColor;
  118411. private _rotationAngle;
  118412. private _haloCenter;
  118413. private _cameraGazer;
  118414. private _padSensibilityUp;
  118415. private _padSensibilityDown;
  118416. private _leftController;
  118417. private _rightController;
  118418. private _gazeColor;
  118419. private _laserColor;
  118420. private _pickedLaserColor;
  118421. private _pickedGazeColor;
  118422. /**
  118423. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  118424. */
  118425. onNewMeshSelected: Observable<AbstractMesh>;
  118426. /**
  118427. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  118428. * This observable will provide the mesh and the controller used to select the mesh
  118429. */
  118430. onMeshSelectedWithController: Observable<{
  118431. mesh: AbstractMesh;
  118432. controller: WebVRController;
  118433. }>;
  118434. /**
  118435. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  118436. */
  118437. onNewMeshPicked: Observable<PickingInfo>;
  118438. private _circleEase;
  118439. /**
  118440. * Observable raised before camera teleportation
  118441. */
  118442. onBeforeCameraTeleport: Observable<Vector3>;
  118443. /**
  118444. * Observable raised after camera teleportation
  118445. */
  118446. onAfterCameraTeleport: Observable<Vector3>;
  118447. /**
  118448. * Observable raised when current selected mesh gets unselected
  118449. */
  118450. onSelectedMeshUnselected: Observable<AbstractMesh>;
  118451. private _raySelectionPredicate;
  118452. /**
  118453. * To be optionaly changed by user to define custom ray selection
  118454. */
  118455. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  118456. /**
  118457. * To be optionaly changed by user to define custom selection logic (after ray selection)
  118458. */
  118459. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  118460. /**
  118461. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  118462. */
  118463. teleportationEnabled: boolean;
  118464. private _defaultHeight;
  118465. private _teleportationInitialized;
  118466. private _interactionsEnabled;
  118467. private _interactionsRequested;
  118468. private _displayGaze;
  118469. private _displayLaserPointer;
  118470. /**
  118471. * The mesh used to display where the user is going to teleport.
  118472. */
  118473. get teleportationTarget(): Mesh;
  118474. /**
  118475. * Sets the mesh to be used to display where the user is going to teleport.
  118476. */
  118477. set teleportationTarget(value: Mesh);
  118478. /**
  118479. * 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
  118480. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  118481. * See http://doc.babylonjs.com/resources/baking_transformations
  118482. */
  118483. get gazeTrackerMesh(): Mesh;
  118484. set gazeTrackerMesh(value: Mesh);
  118485. /**
  118486. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  118487. */
  118488. updateGazeTrackerScale: boolean;
  118489. /**
  118490. * If the gaze trackers color should be updated when selecting meshes
  118491. */
  118492. updateGazeTrackerColor: boolean;
  118493. /**
  118494. * If the controller laser color should be updated when selecting meshes
  118495. */
  118496. updateControllerLaserColor: boolean;
  118497. /**
  118498. * The gaze tracking mesh corresponding to the left controller
  118499. */
  118500. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  118501. /**
  118502. * The gaze tracking mesh corresponding to the right controller
  118503. */
  118504. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  118505. /**
  118506. * If the ray of the gaze should be displayed.
  118507. */
  118508. get displayGaze(): boolean;
  118509. /**
  118510. * Sets if the ray of the gaze should be displayed.
  118511. */
  118512. set displayGaze(value: boolean);
  118513. /**
  118514. * If the ray of the LaserPointer should be displayed.
  118515. */
  118516. get displayLaserPointer(): boolean;
  118517. /**
  118518. * Sets if the ray of the LaserPointer should be displayed.
  118519. */
  118520. set displayLaserPointer(value: boolean);
  118521. /**
  118522. * The deviceOrientationCamera used as the camera when not in VR.
  118523. */
  118524. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  118525. /**
  118526. * Based on the current WebVR support, returns the current VR camera used.
  118527. */
  118528. get currentVRCamera(): Nullable<Camera>;
  118529. /**
  118530. * The webVRCamera which is used when in VR.
  118531. */
  118532. get webVRCamera(): WebVRFreeCamera;
  118533. /**
  118534. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  118535. */
  118536. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  118537. /**
  118538. * The html button that is used to trigger entering into VR.
  118539. */
  118540. get vrButton(): Nullable<HTMLButtonElement>;
  118541. private get _teleportationRequestInitiated();
  118542. /**
  118543. * Defines whether or not Pointer lock should be requested when switching to
  118544. * full screen.
  118545. */
  118546. requestPointerLockOnFullScreen: boolean;
  118547. /**
  118548. * If asking to force XR, this will be populated with the default xr experience
  118549. */
  118550. xr: WebXRDefaultExperience;
  118551. /**
  118552. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  118553. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  118554. */
  118555. xrTestDone: boolean;
  118556. /**
  118557. * Instantiates a VRExperienceHelper.
  118558. * Helps to quickly add VR support to an existing scene.
  118559. * @param scene The scene the VRExperienceHelper belongs to.
  118560. * @param webVROptions Options to modify the vr experience helper's behavior.
  118561. */
  118562. constructor(scene: Scene,
  118563. /** Options to modify the vr experience helper's behavior. */
  118564. webVROptions?: VRExperienceHelperOptions);
  118565. private completeVRInit;
  118566. private _onDefaultMeshLoaded;
  118567. private _onResize;
  118568. private _onFullscreenChange;
  118569. /**
  118570. * Gets a value indicating if we are currently in VR mode.
  118571. */
  118572. get isInVRMode(): boolean;
  118573. private onVrDisplayPresentChange;
  118574. private onVRDisplayChanged;
  118575. private moveButtonToBottomRight;
  118576. private displayVRButton;
  118577. private updateButtonVisibility;
  118578. private _cachedAngularSensibility;
  118579. /**
  118580. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  118581. * Otherwise, will use the fullscreen API.
  118582. */
  118583. enterVR(): void;
  118584. /**
  118585. * Attempt to exit VR, or fullscreen.
  118586. */
  118587. exitVR(): void;
  118588. /**
  118589. * The position of the vr experience helper.
  118590. */
  118591. get position(): Vector3;
  118592. /**
  118593. * Sets the position of the vr experience helper.
  118594. */
  118595. set position(value: Vector3);
  118596. /**
  118597. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  118598. */
  118599. enableInteractions(): void;
  118600. private get _noControllerIsActive();
  118601. private beforeRender;
  118602. private _isTeleportationFloor;
  118603. /**
  118604. * Adds a floor mesh to be used for teleportation.
  118605. * @param floorMesh the mesh to be used for teleportation.
  118606. */
  118607. addFloorMesh(floorMesh: Mesh): void;
  118608. /**
  118609. * Removes a floor mesh from being used for teleportation.
  118610. * @param floorMesh the mesh to be removed.
  118611. */
  118612. removeFloorMesh(floorMesh: Mesh): void;
  118613. /**
  118614. * Enables interactions and teleportation using the VR controllers and gaze.
  118615. * @param vrTeleportationOptions options to modify teleportation behavior.
  118616. */
  118617. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  118618. private _onNewGamepadConnected;
  118619. private _tryEnableInteractionOnController;
  118620. private _onNewGamepadDisconnected;
  118621. private _enableInteractionOnController;
  118622. private _checkTeleportWithRay;
  118623. private _checkRotate;
  118624. private _checkTeleportBackwards;
  118625. private _enableTeleportationOnController;
  118626. private _createTeleportationCircles;
  118627. private _displayTeleportationTarget;
  118628. private _hideTeleportationTarget;
  118629. private _rotateCamera;
  118630. private _moveTeleportationSelectorTo;
  118631. private _workingVector;
  118632. private _workingQuaternion;
  118633. private _workingMatrix;
  118634. /**
  118635. * Time Constant Teleportation Mode
  118636. */
  118637. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  118638. /**
  118639. * Speed Constant Teleportation Mode
  118640. */
  118641. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  118642. /**
  118643. * Teleports the users feet to the desired location
  118644. * @param location The location where the user's feet should be placed
  118645. */
  118646. teleportCamera(location: Vector3): void;
  118647. private _convertNormalToDirectionOfRay;
  118648. private _castRayAndSelectObject;
  118649. private _notifySelectedMeshUnselected;
  118650. /**
  118651. * Permanently set new colors for the laser pointer
  118652. * @param color the new laser color
  118653. * @param pickedColor the new laser color when picked mesh detected
  118654. */
  118655. setLaserColor(color: Color3, pickedColor?: Color3): void;
  118656. /**
  118657. * Set lighting enabled / disabled on the laser pointer of both controllers
  118658. * @param enabled should the lighting be enabled on the laser pointer
  118659. */
  118660. setLaserLightingState(enabled?: boolean): void;
  118661. /**
  118662. * Permanently set new colors for the gaze pointer
  118663. * @param color the new gaze color
  118664. * @param pickedColor the new gaze color when picked mesh detected
  118665. */
  118666. setGazeColor(color: Color3, pickedColor?: Color3): void;
  118667. /**
  118668. * Sets the color of the laser ray from the vr controllers.
  118669. * @param color new color for the ray.
  118670. */
  118671. changeLaserColor(color: Color3): void;
  118672. /**
  118673. * Sets the color of the ray from the vr headsets gaze.
  118674. * @param color new color for the ray.
  118675. */
  118676. changeGazeColor(color: Color3): void;
  118677. /**
  118678. * Exits VR and disposes of the vr experience helper
  118679. */
  118680. dispose(): void;
  118681. /**
  118682. * Gets the name of the VRExperienceHelper class
  118683. * @returns "VRExperienceHelper"
  118684. */
  118685. getClassName(): string;
  118686. }
  118687. }
  118688. declare module BABYLON {
  118689. /**
  118690. * Contains an array of blocks representing the octree
  118691. */
  118692. export interface IOctreeContainer<T> {
  118693. /**
  118694. * Blocks within the octree
  118695. */
  118696. blocks: Array<OctreeBlock<T>>;
  118697. }
  118698. /**
  118699. * Class used to store a cell in an octree
  118700. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118701. */
  118702. export class OctreeBlock<T> {
  118703. /**
  118704. * Gets the content of the current block
  118705. */
  118706. entries: T[];
  118707. /**
  118708. * Gets the list of block children
  118709. */
  118710. blocks: Array<OctreeBlock<T>>;
  118711. private _depth;
  118712. private _maxDepth;
  118713. private _capacity;
  118714. private _minPoint;
  118715. private _maxPoint;
  118716. private _boundingVectors;
  118717. private _creationFunc;
  118718. /**
  118719. * Creates a new block
  118720. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  118721. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  118722. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  118723. * @param depth defines the current depth of this block in the octree
  118724. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  118725. * @param creationFunc defines a callback to call when an element is added to the block
  118726. */
  118727. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  118728. /**
  118729. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  118730. */
  118731. get capacity(): number;
  118732. /**
  118733. * Gets the minimum vector (in world space) of the block's bounding box
  118734. */
  118735. get minPoint(): Vector3;
  118736. /**
  118737. * Gets the maximum vector (in world space) of the block's bounding box
  118738. */
  118739. get maxPoint(): Vector3;
  118740. /**
  118741. * Add a new element to this block
  118742. * @param entry defines the element to add
  118743. */
  118744. addEntry(entry: T): void;
  118745. /**
  118746. * Remove an element from this block
  118747. * @param entry defines the element to remove
  118748. */
  118749. removeEntry(entry: T): void;
  118750. /**
  118751. * Add an array of elements to this block
  118752. * @param entries defines the array of elements to add
  118753. */
  118754. addEntries(entries: T[]): void;
  118755. /**
  118756. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  118757. * @param frustumPlanes defines the frustum planes to test
  118758. * @param selection defines the array to store current content if selection is positive
  118759. * @param allowDuplicate defines if the selection array can contains duplicated entries
  118760. */
  118761. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  118762. /**
  118763. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  118764. * @param sphereCenter defines the bounding sphere center
  118765. * @param sphereRadius defines the bounding sphere radius
  118766. * @param selection defines the array to store current content if selection is positive
  118767. * @param allowDuplicate defines if the selection array can contains duplicated entries
  118768. */
  118769. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  118770. /**
  118771. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  118772. * @param ray defines the ray to test with
  118773. * @param selection defines the array to store current content if selection is positive
  118774. */
  118775. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  118776. /**
  118777. * Subdivide the content into child blocks (this block will then be empty)
  118778. */
  118779. createInnerBlocks(): void;
  118780. /**
  118781. * @hidden
  118782. */
  118783. 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;
  118784. }
  118785. }
  118786. declare module BABYLON {
  118787. /**
  118788. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  118789. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118790. */
  118791. export class Octree<T> {
  118792. /** 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.) */
  118793. maxDepth: number;
  118794. /**
  118795. * Blocks within the octree containing objects
  118796. */
  118797. blocks: Array<OctreeBlock<T>>;
  118798. /**
  118799. * Content stored in the octree
  118800. */
  118801. dynamicContent: T[];
  118802. private _maxBlockCapacity;
  118803. private _selectionContent;
  118804. private _creationFunc;
  118805. /**
  118806. * Creates a octree
  118807. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118808. * @param creationFunc function to be used to instatiate the octree
  118809. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  118810. * @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.)
  118811. */
  118812. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  118813. /** 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.) */
  118814. maxDepth?: number);
  118815. /**
  118816. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  118817. * @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);
  118818. * @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);
  118819. * @param entries meshes to be added to the octree blocks
  118820. */
  118821. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  118822. /**
  118823. * Adds a mesh to the octree
  118824. * @param entry Mesh to add to the octree
  118825. */
  118826. addMesh(entry: T): void;
  118827. /**
  118828. * Remove an element from the octree
  118829. * @param entry defines the element to remove
  118830. */
  118831. removeMesh(entry: T): void;
  118832. /**
  118833. * Selects an array of meshes within the frustum
  118834. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  118835. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  118836. * @returns array of meshes within the frustum
  118837. */
  118838. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  118839. /**
  118840. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  118841. * @param sphereCenter defines the bounding sphere center
  118842. * @param sphereRadius defines the bounding sphere radius
  118843. * @param allowDuplicate defines if the selection array can contains duplicated entries
  118844. * @returns an array of objects that intersect the sphere
  118845. */
  118846. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  118847. /**
  118848. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  118849. * @param ray defines the ray to test with
  118850. * @returns array of intersected objects
  118851. */
  118852. intersectsRay(ray: Ray): SmartArray<T>;
  118853. /**
  118854. * Adds a mesh into the octree block if it intersects the block
  118855. */
  118856. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  118857. /**
  118858. * Adds a submesh into the octree block if it intersects the block
  118859. */
  118860. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  118861. }
  118862. }
  118863. declare module BABYLON {
  118864. interface Scene {
  118865. /**
  118866. * @hidden
  118867. * Backing Filed
  118868. */
  118869. _selectionOctree: Octree<AbstractMesh>;
  118870. /**
  118871. * Gets the octree used to boost mesh selection (picking)
  118872. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118873. */
  118874. selectionOctree: Octree<AbstractMesh>;
  118875. /**
  118876. * Creates or updates the octree used to boost selection (picking)
  118877. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118878. * @param maxCapacity defines the maximum capacity per leaf
  118879. * @param maxDepth defines the maximum depth of the octree
  118880. * @returns an octree of AbstractMesh
  118881. */
  118882. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  118883. }
  118884. interface AbstractMesh {
  118885. /**
  118886. * @hidden
  118887. * Backing Field
  118888. */
  118889. _submeshesOctree: Octree<SubMesh>;
  118890. /**
  118891. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  118892. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  118893. * @param maxCapacity defines the maximum size of each block (64 by default)
  118894. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  118895. * @returns the new octree
  118896. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  118897. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118898. */
  118899. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  118900. }
  118901. /**
  118902. * Defines the octree scene component responsible to manage any octrees
  118903. * in a given scene.
  118904. */
  118905. export class OctreeSceneComponent {
  118906. /**
  118907. * The component name help to identify the component in the list of scene components.
  118908. */
  118909. readonly name: string;
  118910. /**
  118911. * The scene the component belongs to.
  118912. */
  118913. scene: Scene;
  118914. /**
  118915. * Indicates if the meshes have been checked to make sure they are isEnabled()
  118916. */
  118917. readonly checksIsEnabled: boolean;
  118918. /**
  118919. * Creates a new instance of the component for the given scene
  118920. * @param scene Defines the scene to register the component in
  118921. */
  118922. constructor(scene: Scene);
  118923. /**
  118924. * Registers the component in a given scene
  118925. */
  118926. register(): void;
  118927. /**
  118928. * Return the list of active meshes
  118929. * @returns the list of active meshes
  118930. */
  118931. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  118932. /**
  118933. * Return the list of active sub meshes
  118934. * @param mesh The mesh to get the candidates sub meshes from
  118935. * @returns the list of active sub meshes
  118936. */
  118937. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  118938. private _tempRay;
  118939. /**
  118940. * Return the list of sub meshes intersecting with a given local ray
  118941. * @param mesh defines the mesh to find the submesh for
  118942. * @param localRay defines the ray in local space
  118943. * @returns the list of intersecting sub meshes
  118944. */
  118945. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  118946. /**
  118947. * Return the list of sub meshes colliding with a collider
  118948. * @param mesh defines the mesh to find the submesh for
  118949. * @param collider defines the collider to evaluate the collision against
  118950. * @returns the list of colliding sub meshes
  118951. */
  118952. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  118953. /**
  118954. * Rebuilds the elements related to this component in case of
  118955. * context lost for instance.
  118956. */
  118957. rebuild(): void;
  118958. /**
  118959. * Disposes the component and the associated ressources.
  118960. */
  118961. dispose(): void;
  118962. }
  118963. }
  118964. declare module BABYLON {
  118965. /**
  118966. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  118967. */
  118968. export class Gizmo implements IDisposable {
  118969. /** The utility layer the gizmo will be added to */
  118970. gizmoLayer: UtilityLayerRenderer;
  118971. /**
  118972. * The root mesh of the gizmo
  118973. */
  118974. _rootMesh: Mesh;
  118975. private _attachedMesh;
  118976. /**
  118977. * Ratio for the scale of the gizmo (Default: 1)
  118978. */
  118979. scaleRatio: number;
  118980. /**
  118981. * If a custom mesh has been set (Default: false)
  118982. */
  118983. protected _customMeshSet: boolean;
  118984. /**
  118985. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  118986. * * When set, interactions will be enabled
  118987. */
  118988. get attachedMesh(): Nullable<AbstractMesh>;
  118989. set attachedMesh(value: Nullable<AbstractMesh>);
  118990. /**
  118991. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  118992. * @param mesh The mesh to replace the default mesh of the gizmo
  118993. */
  118994. setCustomMesh(mesh: Mesh): void;
  118995. /**
  118996. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  118997. */
  118998. updateGizmoRotationToMatchAttachedMesh: boolean;
  118999. /**
  119000. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  119001. */
  119002. updateGizmoPositionToMatchAttachedMesh: boolean;
  119003. /**
  119004. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  119005. */
  119006. updateScale: boolean;
  119007. protected _interactionsEnabled: boolean;
  119008. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119009. private _beforeRenderObserver;
  119010. private _tempVector;
  119011. /**
  119012. * Creates a gizmo
  119013. * @param gizmoLayer The utility layer the gizmo will be added to
  119014. */
  119015. constructor(
  119016. /** The utility layer the gizmo will be added to */
  119017. gizmoLayer?: UtilityLayerRenderer);
  119018. /**
  119019. * Updates the gizmo to match the attached mesh's position/rotation
  119020. */
  119021. protected _update(): void;
  119022. /**
  119023. * Disposes of the gizmo
  119024. */
  119025. dispose(): void;
  119026. }
  119027. }
  119028. declare module BABYLON {
  119029. /**
  119030. * Single plane drag gizmo
  119031. */
  119032. export class PlaneDragGizmo extends Gizmo {
  119033. /**
  119034. * Drag behavior responsible for the gizmos dragging interactions
  119035. */
  119036. dragBehavior: PointerDragBehavior;
  119037. private _pointerObserver;
  119038. /**
  119039. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119040. */
  119041. snapDistance: number;
  119042. /**
  119043. * Event that fires each time the gizmo snaps to a new location.
  119044. * * snapDistance is the the change in distance
  119045. */
  119046. onSnapObservable: Observable<{
  119047. snapDistance: number;
  119048. }>;
  119049. private _plane;
  119050. private _coloredMaterial;
  119051. private _hoverMaterial;
  119052. private _isEnabled;
  119053. private _parent;
  119054. /** @hidden */
  119055. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  119056. /** @hidden */
  119057. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  119058. /**
  119059. * Creates a PlaneDragGizmo
  119060. * @param gizmoLayer The utility layer the gizmo will be added to
  119061. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  119062. * @param color The color of the gizmo
  119063. */
  119064. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  119065. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119066. /**
  119067. * If the gizmo is enabled
  119068. */
  119069. set isEnabled(value: boolean);
  119070. get isEnabled(): boolean;
  119071. /**
  119072. * Disposes of the gizmo
  119073. */
  119074. dispose(): void;
  119075. }
  119076. }
  119077. declare module BABYLON {
  119078. /**
  119079. * Gizmo that enables dragging a mesh along 3 axis
  119080. */
  119081. export class PositionGizmo extends Gizmo {
  119082. /**
  119083. * Internal gizmo used for interactions on the x axis
  119084. */
  119085. xGizmo: AxisDragGizmo;
  119086. /**
  119087. * Internal gizmo used for interactions on the y axis
  119088. */
  119089. yGizmo: AxisDragGizmo;
  119090. /**
  119091. * Internal gizmo used for interactions on the z axis
  119092. */
  119093. zGizmo: AxisDragGizmo;
  119094. /**
  119095. * Internal gizmo used for interactions on the yz plane
  119096. */
  119097. xPlaneGizmo: PlaneDragGizmo;
  119098. /**
  119099. * Internal gizmo used for interactions on the xz plane
  119100. */
  119101. yPlaneGizmo: PlaneDragGizmo;
  119102. /**
  119103. * Internal gizmo used for interactions on the xy plane
  119104. */
  119105. zPlaneGizmo: PlaneDragGizmo;
  119106. /**
  119107. * private variables
  119108. */
  119109. private _meshAttached;
  119110. private _updateGizmoRotationToMatchAttachedMesh;
  119111. private _snapDistance;
  119112. private _scaleRatio;
  119113. /** Fires an event when any of it's sub gizmos are dragged */
  119114. onDragStartObservable: Observable<unknown>;
  119115. /** Fires an event when any of it's sub gizmos are released from dragging */
  119116. onDragEndObservable: Observable<unknown>;
  119117. /**
  119118. * If set to true, planar drag is enabled
  119119. */
  119120. private _planarGizmoEnabled;
  119121. get attachedMesh(): Nullable<AbstractMesh>;
  119122. set attachedMesh(mesh: Nullable<AbstractMesh>);
  119123. /**
  119124. * Creates a PositionGizmo
  119125. * @param gizmoLayer The utility layer the gizmo will be added to
  119126. */
  119127. constructor(gizmoLayer?: UtilityLayerRenderer);
  119128. /**
  119129. * If the planar drag gizmo is enabled
  119130. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  119131. */
  119132. set planarGizmoEnabled(value: boolean);
  119133. get planarGizmoEnabled(): boolean;
  119134. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  119135. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  119136. /**
  119137. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119138. */
  119139. set snapDistance(value: number);
  119140. get snapDistance(): number;
  119141. /**
  119142. * Ratio for the scale of the gizmo (Default: 1)
  119143. */
  119144. set scaleRatio(value: number);
  119145. get scaleRatio(): number;
  119146. /**
  119147. * Disposes of the gizmo
  119148. */
  119149. dispose(): void;
  119150. /**
  119151. * CustomMeshes are not supported by this gizmo
  119152. * @param mesh The mesh to replace the default mesh of the gizmo
  119153. */
  119154. setCustomMesh(mesh: Mesh): void;
  119155. }
  119156. }
  119157. declare module BABYLON {
  119158. /**
  119159. * Single axis drag gizmo
  119160. */
  119161. export class AxisDragGizmo extends Gizmo {
  119162. /**
  119163. * Drag behavior responsible for the gizmos dragging interactions
  119164. */
  119165. dragBehavior: PointerDragBehavior;
  119166. private _pointerObserver;
  119167. /**
  119168. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119169. */
  119170. snapDistance: number;
  119171. /**
  119172. * Event that fires each time the gizmo snaps to a new location.
  119173. * * snapDistance is the the change in distance
  119174. */
  119175. onSnapObservable: Observable<{
  119176. snapDistance: number;
  119177. }>;
  119178. private _isEnabled;
  119179. private _parent;
  119180. private _arrow;
  119181. private _coloredMaterial;
  119182. private _hoverMaterial;
  119183. /** @hidden */
  119184. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  119185. /** @hidden */
  119186. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  119187. /**
  119188. * Creates an AxisDragGizmo
  119189. * @param gizmoLayer The utility layer the gizmo will be added to
  119190. * @param dragAxis The axis which the gizmo will be able to drag on
  119191. * @param color The color of the gizmo
  119192. */
  119193. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  119194. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119195. /**
  119196. * If the gizmo is enabled
  119197. */
  119198. set isEnabled(value: boolean);
  119199. get isEnabled(): boolean;
  119200. /**
  119201. * Disposes of the gizmo
  119202. */
  119203. dispose(): void;
  119204. }
  119205. }
  119206. declare module BABYLON.Debug {
  119207. /**
  119208. * The Axes viewer will show 3 axes in a specific point in space
  119209. */
  119210. export class AxesViewer {
  119211. private _xAxis;
  119212. private _yAxis;
  119213. private _zAxis;
  119214. private _scaleLinesFactor;
  119215. private _instanced;
  119216. /**
  119217. * Gets the hosting scene
  119218. */
  119219. scene: Scene;
  119220. /**
  119221. * Gets or sets a number used to scale line length
  119222. */
  119223. scaleLines: number;
  119224. /** Gets the node hierarchy used to render x-axis */
  119225. get xAxis(): TransformNode;
  119226. /** Gets the node hierarchy used to render y-axis */
  119227. get yAxis(): TransformNode;
  119228. /** Gets the node hierarchy used to render z-axis */
  119229. get zAxis(): TransformNode;
  119230. /**
  119231. * Creates a new AxesViewer
  119232. * @param scene defines the hosting scene
  119233. * @param scaleLines defines a number used to scale line length (1 by default)
  119234. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  119235. * @param xAxis defines the node hierarchy used to render the x-axis
  119236. * @param yAxis defines the node hierarchy used to render the y-axis
  119237. * @param zAxis defines the node hierarchy used to render the z-axis
  119238. */
  119239. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  119240. /**
  119241. * Force the viewer to update
  119242. * @param position defines the position of the viewer
  119243. * @param xaxis defines the x axis of the viewer
  119244. * @param yaxis defines the y axis of the viewer
  119245. * @param zaxis defines the z axis of the viewer
  119246. */
  119247. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  119248. /**
  119249. * Creates an instance of this axes viewer.
  119250. * @returns a new axes viewer with instanced meshes
  119251. */
  119252. createInstance(): AxesViewer;
  119253. /** Releases resources */
  119254. dispose(): void;
  119255. private static _SetRenderingGroupId;
  119256. }
  119257. }
  119258. declare module BABYLON.Debug {
  119259. /**
  119260. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  119261. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  119262. */
  119263. export class BoneAxesViewer extends AxesViewer {
  119264. /**
  119265. * Gets or sets the target mesh where to display the axes viewer
  119266. */
  119267. mesh: Nullable<Mesh>;
  119268. /**
  119269. * Gets or sets the target bone where to display the axes viewer
  119270. */
  119271. bone: Nullable<Bone>;
  119272. /** Gets current position */
  119273. pos: Vector3;
  119274. /** Gets direction of X axis */
  119275. xaxis: Vector3;
  119276. /** Gets direction of Y axis */
  119277. yaxis: Vector3;
  119278. /** Gets direction of Z axis */
  119279. zaxis: Vector3;
  119280. /**
  119281. * Creates a new BoneAxesViewer
  119282. * @param scene defines the hosting scene
  119283. * @param bone defines the target bone
  119284. * @param mesh defines the target mesh
  119285. * @param scaleLines defines a scaling factor for line length (1 by default)
  119286. */
  119287. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  119288. /**
  119289. * Force the viewer to update
  119290. */
  119291. update(): void;
  119292. /** Releases resources */
  119293. dispose(): void;
  119294. }
  119295. }
  119296. declare module BABYLON {
  119297. /**
  119298. * Interface used to define scene explorer extensibility option
  119299. */
  119300. export interface IExplorerExtensibilityOption {
  119301. /**
  119302. * Define the option label
  119303. */
  119304. label: string;
  119305. /**
  119306. * Defines the action to execute on click
  119307. */
  119308. action: (entity: any) => void;
  119309. }
  119310. /**
  119311. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  119312. */
  119313. export interface IExplorerExtensibilityGroup {
  119314. /**
  119315. * Defines a predicate to test if a given type mut be extended
  119316. */
  119317. predicate: (entity: any) => boolean;
  119318. /**
  119319. * Gets the list of options added to a type
  119320. */
  119321. entries: IExplorerExtensibilityOption[];
  119322. }
  119323. /**
  119324. * Interface used to define the options to use to create the Inspector
  119325. */
  119326. export interface IInspectorOptions {
  119327. /**
  119328. * Display in overlay mode (default: false)
  119329. */
  119330. overlay?: boolean;
  119331. /**
  119332. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  119333. */
  119334. globalRoot?: HTMLElement;
  119335. /**
  119336. * Display the Scene explorer
  119337. */
  119338. showExplorer?: boolean;
  119339. /**
  119340. * Display the property inspector
  119341. */
  119342. showInspector?: boolean;
  119343. /**
  119344. * Display in embed mode (both panes on the right)
  119345. */
  119346. embedMode?: boolean;
  119347. /**
  119348. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  119349. */
  119350. handleResize?: boolean;
  119351. /**
  119352. * Allow the panes to popup (default: true)
  119353. */
  119354. enablePopup?: boolean;
  119355. /**
  119356. * Allow the panes to be closed by users (default: true)
  119357. */
  119358. enableClose?: boolean;
  119359. /**
  119360. * Optional list of extensibility entries
  119361. */
  119362. explorerExtensibility?: IExplorerExtensibilityGroup[];
  119363. /**
  119364. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  119365. */
  119366. inspectorURL?: string;
  119367. /**
  119368. * Optional initial tab (default to DebugLayerTab.Properties)
  119369. */
  119370. initialTab?: DebugLayerTab;
  119371. }
  119372. interface Scene {
  119373. /**
  119374. * @hidden
  119375. * Backing field
  119376. */
  119377. _debugLayer: DebugLayer;
  119378. /**
  119379. * Gets the debug layer (aka Inspector) associated with the scene
  119380. * @see http://doc.babylonjs.com/features/playground_debuglayer
  119381. */
  119382. debugLayer: DebugLayer;
  119383. }
  119384. /**
  119385. * Enum of inspector action tab
  119386. */
  119387. export enum DebugLayerTab {
  119388. /**
  119389. * Properties tag (default)
  119390. */
  119391. Properties = 0,
  119392. /**
  119393. * Debug tab
  119394. */
  119395. Debug = 1,
  119396. /**
  119397. * Statistics tab
  119398. */
  119399. Statistics = 2,
  119400. /**
  119401. * Tools tab
  119402. */
  119403. Tools = 3,
  119404. /**
  119405. * Settings tab
  119406. */
  119407. Settings = 4
  119408. }
  119409. /**
  119410. * The debug layer (aka Inspector) is the go to tool in order to better understand
  119411. * what is happening in your scene
  119412. * @see http://doc.babylonjs.com/features/playground_debuglayer
  119413. */
  119414. export class DebugLayer {
  119415. /**
  119416. * Define the url to get the inspector script from.
  119417. * By default it uses the babylonjs CDN.
  119418. * @ignoreNaming
  119419. */
  119420. static InspectorURL: string;
  119421. private _scene;
  119422. private BJSINSPECTOR;
  119423. private _onPropertyChangedObservable?;
  119424. /**
  119425. * Observable triggered when a property is changed through the inspector.
  119426. */
  119427. get onPropertyChangedObservable(): any;
  119428. /**
  119429. * Instantiates a new debug layer.
  119430. * The debug layer (aka Inspector) is the go to tool in order to better understand
  119431. * what is happening in your scene
  119432. * @see http://doc.babylonjs.com/features/playground_debuglayer
  119433. * @param scene Defines the scene to inspect
  119434. */
  119435. constructor(scene: Scene);
  119436. /** Creates the inspector window. */
  119437. private _createInspector;
  119438. /**
  119439. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  119440. * @param entity defines the entity to select
  119441. * @param lineContainerTitle defines the specific block to highlight
  119442. */
  119443. select(entity: any, lineContainerTitle?: string): void;
  119444. /** Get the inspector from bundle or global */
  119445. private _getGlobalInspector;
  119446. /**
  119447. * Get if the inspector is visible or not.
  119448. * @returns true if visible otherwise, false
  119449. */
  119450. isVisible(): boolean;
  119451. /**
  119452. * Hide the inspector and close its window.
  119453. */
  119454. hide(): void;
  119455. /**
  119456. * Launch the debugLayer.
  119457. * @param config Define the configuration of the inspector
  119458. * @return a promise fulfilled when the debug layer is visible
  119459. */
  119460. show(config?: IInspectorOptions): Promise<DebugLayer>;
  119461. }
  119462. }
  119463. declare module BABYLON {
  119464. /**
  119465. * Class containing static functions to help procedurally build meshes
  119466. */
  119467. export class BoxBuilder {
  119468. /**
  119469. * Creates a box mesh
  119470. * * The parameter `size` sets the size (float) of each box side (default 1)
  119471. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  119472. * * 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)
  119473. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  119474. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119475. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119476. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119477. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  119478. * @param name defines the name of the mesh
  119479. * @param options defines the options used to create the mesh
  119480. * @param scene defines the hosting scene
  119481. * @returns the box mesh
  119482. */
  119483. static CreateBox(name: string, options: {
  119484. size?: number;
  119485. width?: number;
  119486. height?: number;
  119487. depth?: number;
  119488. faceUV?: Vector4[];
  119489. faceColors?: Color4[];
  119490. sideOrientation?: number;
  119491. frontUVs?: Vector4;
  119492. backUVs?: Vector4;
  119493. wrap?: boolean;
  119494. topBaseAt?: number;
  119495. bottomBaseAt?: number;
  119496. updatable?: boolean;
  119497. }, scene?: Nullable<Scene>): Mesh;
  119498. }
  119499. }
  119500. declare module BABYLON.Debug {
  119501. /**
  119502. * Used to show the physics impostor around the specific mesh
  119503. */
  119504. export class PhysicsViewer {
  119505. /** @hidden */
  119506. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  119507. /** @hidden */
  119508. protected _meshes: Array<Nullable<AbstractMesh>>;
  119509. /** @hidden */
  119510. protected _scene: Nullable<Scene>;
  119511. /** @hidden */
  119512. protected _numMeshes: number;
  119513. /** @hidden */
  119514. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  119515. private _renderFunction;
  119516. private _utilityLayer;
  119517. private _debugBoxMesh;
  119518. private _debugSphereMesh;
  119519. private _debugCylinderMesh;
  119520. private _debugMaterial;
  119521. private _debugMeshMeshes;
  119522. /**
  119523. * Creates a new PhysicsViewer
  119524. * @param scene defines the hosting scene
  119525. */
  119526. constructor(scene: Scene);
  119527. /** @hidden */
  119528. protected _updateDebugMeshes(): void;
  119529. /**
  119530. * Renders a specified physic impostor
  119531. * @param impostor defines the impostor to render
  119532. * @param targetMesh defines the mesh represented by the impostor
  119533. * @returns the new debug mesh used to render the impostor
  119534. */
  119535. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  119536. /**
  119537. * Hides a specified physic impostor
  119538. * @param impostor defines the impostor to hide
  119539. */
  119540. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  119541. private _getDebugMaterial;
  119542. private _getDebugBoxMesh;
  119543. private _getDebugSphereMesh;
  119544. private _getDebugCylinderMesh;
  119545. private _getDebugMeshMesh;
  119546. private _getDebugMesh;
  119547. /** Releases all resources */
  119548. dispose(): void;
  119549. }
  119550. }
  119551. declare module BABYLON {
  119552. /**
  119553. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  119554. * in order to better appreciate the issue one might have.
  119555. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  119556. */
  119557. export class RayHelper {
  119558. /**
  119559. * Defines the ray we are currently tryin to visualize.
  119560. */
  119561. ray: Nullable<Ray>;
  119562. private _renderPoints;
  119563. private _renderLine;
  119564. private _renderFunction;
  119565. private _scene;
  119566. private _updateToMeshFunction;
  119567. private _attachedToMesh;
  119568. private _meshSpaceDirection;
  119569. private _meshSpaceOrigin;
  119570. /**
  119571. * Helper function to create a colored helper in a scene in one line.
  119572. * @param ray Defines the ray we are currently tryin to visualize
  119573. * @param scene Defines the scene the ray is used in
  119574. * @param color Defines the color we want to see the ray in
  119575. * @returns The newly created ray helper.
  119576. */
  119577. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  119578. /**
  119579. * Instantiate a new ray helper.
  119580. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  119581. * in order to better appreciate the issue one might have.
  119582. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  119583. * @param ray Defines the ray we are currently tryin to visualize
  119584. */
  119585. constructor(ray: Ray);
  119586. /**
  119587. * Shows the ray we are willing to debug.
  119588. * @param scene Defines the scene the ray needs to be rendered in
  119589. * @param color Defines the color the ray needs to be rendered in
  119590. */
  119591. show(scene: Scene, color?: Color3): void;
  119592. /**
  119593. * Hides the ray we are debugging.
  119594. */
  119595. hide(): void;
  119596. private _render;
  119597. /**
  119598. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  119599. * @param mesh Defines the mesh we want the helper attached to
  119600. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  119601. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  119602. * @param length Defines the length of the ray
  119603. */
  119604. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  119605. /**
  119606. * Detach the ray helper from the mesh it has previously been attached to.
  119607. */
  119608. detachFromMesh(): void;
  119609. private _updateToMesh;
  119610. /**
  119611. * Dispose the helper and release its associated resources.
  119612. */
  119613. dispose(): void;
  119614. }
  119615. }
  119616. declare module BABYLON.Debug {
  119617. /**
  119618. * Class used to render a debug view of a given skeleton
  119619. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  119620. */
  119621. export class SkeletonViewer {
  119622. /** defines the skeleton to render */
  119623. skeleton: Skeleton;
  119624. /** defines the mesh attached to the skeleton */
  119625. mesh: AbstractMesh;
  119626. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  119627. autoUpdateBonesMatrices: boolean;
  119628. /** defines the rendering group id to use with the viewer */
  119629. renderingGroupId: number;
  119630. /** Gets or sets the color used to render the skeleton */
  119631. color: Color3;
  119632. private _scene;
  119633. private _debugLines;
  119634. private _debugMesh;
  119635. private _isEnabled;
  119636. private _renderFunction;
  119637. private _utilityLayer;
  119638. /**
  119639. * Returns the mesh used to render the bones
  119640. */
  119641. get debugMesh(): Nullable<LinesMesh>;
  119642. /**
  119643. * Creates a new SkeletonViewer
  119644. * @param skeleton defines the skeleton to render
  119645. * @param mesh defines the mesh attached to the skeleton
  119646. * @param scene defines the hosting scene
  119647. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  119648. * @param renderingGroupId defines the rendering group id to use with the viewer
  119649. */
  119650. constructor(
  119651. /** defines the skeleton to render */
  119652. skeleton: Skeleton,
  119653. /** defines the mesh attached to the skeleton */
  119654. mesh: AbstractMesh, scene: Scene,
  119655. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  119656. autoUpdateBonesMatrices?: boolean,
  119657. /** defines the rendering group id to use with the viewer */
  119658. renderingGroupId?: number);
  119659. /** Gets or sets a boolean indicating if the viewer is enabled */
  119660. set isEnabled(value: boolean);
  119661. get isEnabled(): boolean;
  119662. private _getBonePosition;
  119663. private _getLinesForBonesWithLength;
  119664. private _getLinesForBonesNoLength;
  119665. /** Update the viewer to sync with current skeleton state */
  119666. update(): void;
  119667. /** Release associated resources */
  119668. dispose(): void;
  119669. }
  119670. }
  119671. declare module BABYLON {
  119672. /**
  119673. * Options to create the null engine
  119674. */
  119675. export class NullEngineOptions {
  119676. /**
  119677. * Render width (Default: 512)
  119678. */
  119679. renderWidth: number;
  119680. /**
  119681. * Render height (Default: 256)
  119682. */
  119683. renderHeight: number;
  119684. /**
  119685. * Texture size (Default: 512)
  119686. */
  119687. textureSize: number;
  119688. /**
  119689. * If delta time between frames should be constant
  119690. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119691. */
  119692. deterministicLockstep: boolean;
  119693. /**
  119694. * Maximum about of steps between frames (Default: 4)
  119695. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119696. */
  119697. lockstepMaxSteps: number;
  119698. }
  119699. /**
  119700. * The null engine class provides support for headless version of babylon.js.
  119701. * This can be used in server side scenario or for testing purposes
  119702. */
  119703. export class NullEngine extends Engine {
  119704. private _options;
  119705. /**
  119706. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  119707. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119708. * @returns true if engine is in deterministic lock step mode
  119709. */
  119710. isDeterministicLockStep(): boolean;
  119711. /**
  119712. * Gets the max steps when engine is running in deterministic lock step
  119713. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119714. * @returns the max steps
  119715. */
  119716. getLockstepMaxSteps(): number;
  119717. /**
  119718. * Gets the current hardware scaling level.
  119719. * By default the hardware scaling level is computed from the window device ratio.
  119720. * 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.
  119721. * @returns a number indicating the current hardware scaling level
  119722. */
  119723. getHardwareScalingLevel(): number;
  119724. constructor(options?: NullEngineOptions);
  119725. /**
  119726. * Creates a vertex buffer
  119727. * @param vertices the data for the vertex buffer
  119728. * @returns the new WebGL static buffer
  119729. */
  119730. createVertexBuffer(vertices: FloatArray): DataBuffer;
  119731. /**
  119732. * Creates a new index buffer
  119733. * @param indices defines the content of the index buffer
  119734. * @param updatable defines if the index buffer must be updatable
  119735. * @returns a new webGL buffer
  119736. */
  119737. createIndexBuffer(indices: IndicesArray): DataBuffer;
  119738. /**
  119739. * Clear the current render buffer or the current render target (if any is set up)
  119740. * @param color defines the color to use
  119741. * @param backBuffer defines if the back buffer must be cleared
  119742. * @param depth defines if the depth buffer must be cleared
  119743. * @param stencil defines if the stencil buffer must be cleared
  119744. */
  119745. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  119746. /**
  119747. * Gets the current render width
  119748. * @param useScreen defines if screen size must be used (or the current render target if any)
  119749. * @returns a number defining the current render width
  119750. */
  119751. getRenderWidth(useScreen?: boolean): number;
  119752. /**
  119753. * Gets the current render height
  119754. * @param useScreen defines if screen size must be used (or the current render target if any)
  119755. * @returns a number defining the current render height
  119756. */
  119757. getRenderHeight(useScreen?: boolean): number;
  119758. /**
  119759. * Set the WebGL's viewport
  119760. * @param viewport defines the viewport element to be used
  119761. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  119762. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  119763. */
  119764. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  119765. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  119766. /**
  119767. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  119768. * @param pipelineContext defines the pipeline context to use
  119769. * @param uniformsNames defines the list of uniform names
  119770. * @returns an array of webGL uniform locations
  119771. */
  119772. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  119773. /**
  119774. * Gets the lsit of active attributes for a given webGL program
  119775. * @param pipelineContext defines the pipeline context to use
  119776. * @param attributesNames defines the list of attribute names to get
  119777. * @returns an array of indices indicating the offset of each attribute
  119778. */
  119779. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  119780. /**
  119781. * Binds an effect to the webGL context
  119782. * @param effect defines the effect to bind
  119783. */
  119784. bindSamplers(effect: Effect): void;
  119785. /**
  119786. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  119787. * @param effect defines the effect to activate
  119788. */
  119789. enableEffect(effect: Effect): void;
  119790. /**
  119791. * Set various states to the webGL context
  119792. * @param culling defines backface culling state
  119793. * @param zOffset defines the value to apply to zOffset (0 by default)
  119794. * @param force defines if states must be applied even if cache is up to date
  119795. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  119796. */
  119797. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  119798. /**
  119799. * Set the value of an uniform to an array of int32
  119800. * @param uniform defines the webGL uniform location where to store the value
  119801. * @param array defines the array of int32 to store
  119802. */
  119803. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  119804. /**
  119805. * Set the value of an uniform to an array of int32 (stored as vec2)
  119806. * @param uniform defines the webGL uniform location where to store the value
  119807. * @param array defines the array of int32 to store
  119808. */
  119809. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  119810. /**
  119811. * Set the value of an uniform to an array of int32 (stored as vec3)
  119812. * @param uniform defines the webGL uniform location where to store the value
  119813. * @param array defines the array of int32 to store
  119814. */
  119815. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  119816. /**
  119817. * Set the value of an uniform to an array of int32 (stored as vec4)
  119818. * @param uniform defines the webGL uniform location where to store the value
  119819. * @param array defines the array of int32 to store
  119820. */
  119821. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  119822. /**
  119823. * Set the value of an uniform to an array of float32
  119824. * @param uniform defines the webGL uniform location where to store the value
  119825. * @param array defines the array of float32 to store
  119826. */
  119827. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  119828. /**
  119829. * Set the value of an uniform to an array of float32 (stored as vec2)
  119830. * @param uniform defines the webGL uniform location where to store the value
  119831. * @param array defines the array of float32 to store
  119832. */
  119833. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  119834. /**
  119835. * Set the value of an uniform to an array of float32 (stored as vec3)
  119836. * @param uniform defines the webGL uniform location where to store the value
  119837. * @param array defines the array of float32 to store
  119838. */
  119839. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  119840. /**
  119841. * Set the value of an uniform to an array of float32 (stored as vec4)
  119842. * @param uniform defines the webGL uniform location where to store the value
  119843. * @param array defines the array of float32 to store
  119844. */
  119845. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  119846. /**
  119847. * Set the value of an uniform to an array of number
  119848. * @param uniform defines the webGL uniform location where to store the value
  119849. * @param array defines the array of number to store
  119850. */
  119851. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  119852. /**
  119853. * Set the value of an uniform to an array of number (stored as vec2)
  119854. * @param uniform defines the webGL uniform location where to store the value
  119855. * @param array defines the array of number to store
  119856. */
  119857. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  119858. /**
  119859. * Set the value of an uniform to an array of number (stored as vec3)
  119860. * @param uniform defines the webGL uniform location where to store the value
  119861. * @param array defines the array of number to store
  119862. */
  119863. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  119864. /**
  119865. * Set the value of an uniform to an array of number (stored as vec4)
  119866. * @param uniform defines the webGL uniform location where to store the value
  119867. * @param array defines the array of number to store
  119868. */
  119869. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  119870. /**
  119871. * Set the value of an uniform to an array of float32 (stored as matrices)
  119872. * @param uniform defines the webGL uniform location where to store the value
  119873. * @param matrices defines the array of float32 to store
  119874. */
  119875. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  119876. /**
  119877. * Set the value of an uniform to a matrix (3x3)
  119878. * @param uniform defines the webGL uniform location where to store the value
  119879. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  119880. */
  119881. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  119882. /**
  119883. * Set the value of an uniform to a matrix (2x2)
  119884. * @param uniform defines the webGL uniform location where to store the value
  119885. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  119886. */
  119887. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  119888. /**
  119889. * Set the value of an uniform to a number (float)
  119890. * @param uniform defines the webGL uniform location where to store the value
  119891. * @param value defines the float number to store
  119892. */
  119893. setFloat(uniform: WebGLUniformLocation, value: number): void;
  119894. /**
  119895. * Set the value of an uniform to a vec2
  119896. * @param uniform defines the webGL uniform location where to store the value
  119897. * @param x defines the 1st component of the value
  119898. * @param y defines the 2nd component of the value
  119899. */
  119900. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  119901. /**
  119902. * Set the value of an uniform to a vec3
  119903. * @param uniform defines the webGL uniform location where to store the value
  119904. * @param x defines the 1st component of the value
  119905. * @param y defines the 2nd component of the value
  119906. * @param z defines the 3rd component of the value
  119907. */
  119908. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  119909. /**
  119910. * Set the value of an uniform to a boolean
  119911. * @param uniform defines the webGL uniform location where to store the value
  119912. * @param bool defines the boolean to store
  119913. */
  119914. setBool(uniform: WebGLUniformLocation, bool: number): void;
  119915. /**
  119916. * Set the value of an uniform to a vec4
  119917. * @param uniform defines the webGL uniform location where to store the value
  119918. * @param x defines the 1st component of the value
  119919. * @param y defines the 2nd component of the value
  119920. * @param z defines the 3rd component of the value
  119921. * @param w defines the 4th component of the value
  119922. */
  119923. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  119924. /**
  119925. * Sets the current alpha mode
  119926. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  119927. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  119928. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  119929. */
  119930. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  119931. /**
  119932. * Bind webGl buffers directly to the webGL context
  119933. * @param vertexBuffers defines the vertex buffer to bind
  119934. * @param indexBuffer defines the index buffer to bind
  119935. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  119936. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  119937. * @param effect defines the effect associated with the vertex buffer
  119938. */
  119939. bindBuffers(vertexBuffers: {
  119940. [key: string]: VertexBuffer;
  119941. }, indexBuffer: DataBuffer, effect: Effect): void;
  119942. /**
  119943. * Force the entire cache to be cleared
  119944. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  119945. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  119946. */
  119947. wipeCaches(bruteForce?: boolean): void;
  119948. /**
  119949. * Send a draw order
  119950. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  119951. * @param indexStart defines the starting index
  119952. * @param indexCount defines the number of index to draw
  119953. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119954. */
  119955. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  119956. /**
  119957. * Draw a list of indexed primitives
  119958. * @param fillMode defines the primitive to use
  119959. * @param indexStart defines the starting index
  119960. * @param indexCount defines the number of index to draw
  119961. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119962. */
  119963. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  119964. /**
  119965. * Draw a list of unindexed primitives
  119966. * @param fillMode defines the primitive to use
  119967. * @param verticesStart defines the index of first vertex to draw
  119968. * @param verticesCount defines the count of vertices to draw
  119969. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119970. */
  119971. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  119972. /** @hidden */
  119973. _createTexture(): WebGLTexture;
  119974. /** @hidden */
  119975. _releaseTexture(texture: InternalTexture): void;
  119976. /**
  119977. * Usually called from Texture.ts.
  119978. * Passed information to create a WebGLTexture
  119979. * @param urlArg defines a value which contains one of the following:
  119980. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  119981. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  119982. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  119983. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  119984. * @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)
  119985. * @param scene needed for loading to the correct scene
  119986. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  119987. * @param onLoad optional callback to be called upon successful completion
  119988. * @param onError optional callback to be called upon failure
  119989. * @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
  119990. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  119991. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  119992. * @param forcedExtension defines the extension to use to pick the right loader
  119993. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  119994. * @returns a InternalTexture for assignment back into BABYLON.Texture
  119995. */
  119996. createTexture(urlArg: string, noMipmap: boolean, invertY: boolean, scene: Scene, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<ArrayBuffer | HTMLImageElement>, fallBack?: InternalTexture, format?: number): InternalTexture;
  119997. /**
  119998. * Creates a new render target texture
  119999. * @param size defines the size of the texture
  120000. * @param options defines the options used to create the texture
  120001. * @returns a new render target texture stored in an InternalTexture
  120002. */
  120003. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  120004. /**
  120005. * Update the sampling mode of a given texture
  120006. * @param samplingMode defines the required sampling mode
  120007. * @param texture defines the texture to update
  120008. */
  120009. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  120010. /**
  120011. * Binds the frame buffer to the specified texture.
  120012. * @param texture The texture to render to or null for the default canvas
  120013. * @param faceIndex The face of the texture to render to in case of cube texture
  120014. * @param requiredWidth The width of the target to render to
  120015. * @param requiredHeight The height of the target to render to
  120016. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  120017. * @param lodLevel defines le lod level to bind to the frame buffer
  120018. */
  120019. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  120020. /**
  120021. * Unbind the current render target texture from the webGL context
  120022. * @param texture defines the render target texture to unbind
  120023. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  120024. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  120025. */
  120026. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  120027. /**
  120028. * Creates a dynamic vertex buffer
  120029. * @param vertices the data for the dynamic vertex buffer
  120030. * @returns the new WebGL dynamic buffer
  120031. */
  120032. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  120033. /**
  120034. * Update the content of a dynamic texture
  120035. * @param texture defines the texture to update
  120036. * @param canvas defines the canvas containing the source
  120037. * @param invertY defines if data must be stored with Y axis inverted
  120038. * @param premulAlpha defines if alpha is stored as premultiplied
  120039. * @param format defines the format of the data
  120040. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  120041. */
  120042. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  120043. /**
  120044. * Gets a boolean indicating if all created effects are ready
  120045. * @returns true if all effects are ready
  120046. */
  120047. areAllEffectsReady(): boolean;
  120048. /**
  120049. * @hidden
  120050. * Get the current error code of the webGL context
  120051. * @returns the error code
  120052. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  120053. */
  120054. getError(): number;
  120055. /** @hidden */
  120056. _getUnpackAlignement(): number;
  120057. /** @hidden */
  120058. _unpackFlipY(value: boolean): void;
  120059. /**
  120060. * Update a dynamic index buffer
  120061. * @param indexBuffer defines the target index buffer
  120062. * @param indices defines the data to update
  120063. * @param offset defines the offset in the target index buffer where update should start
  120064. */
  120065. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  120066. /**
  120067. * Updates a dynamic vertex buffer.
  120068. * @param vertexBuffer the vertex buffer to update
  120069. * @param vertices the data used to update the vertex buffer
  120070. * @param byteOffset the byte offset of the data (optional)
  120071. * @param byteLength the byte length of the data (optional)
  120072. */
  120073. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  120074. /** @hidden */
  120075. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  120076. /** @hidden */
  120077. _bindTexture(channel: number, texture: InternalTexture): void;
  120078. protected _deleteBuffer(buffer: WebGLBuffer): void;
  120079. /**
  120080. * 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
  120081. */
  120082. releaseEffects(): void;
  120083. displayLoadingUI(): void;
  120084. hideLoadingUI(): void;
  120085. /** @hidden */
  120086. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120087. /** @hidden */
  120088. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120089. /** @hidden */
  120090. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120091. /** @hidden */
  120092. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  120093. }
  120094. }
  120095. declare module BABYLON {
  120096. /**
  120097. * @hidden
  120098. **/
  120099. export class _TimeToken {
  120100. _startTimeQuery: Nullable<WebGLQuery>;
  120101. _endTimeQuery: Nullable<WebGLQuery>;
  120102. _timeElapsedQuery: Nullable<WebGLQuery>;
  120103. _timeElapsedQueryEnded: boolean;
  120104. }
  120105. }
  120106. declare module BABYLON {
  120107. /** @hidden */
  120108. export class _OcclusionDataStorage {
  120109. /** @hidden */
  120110. occlusionInternalRetryCounter: number;
  120111. /** @hidden */
  120112. isOcclusionQueryInProgress: boolean;
  120113. /** @hidden */
  120114. isOccluded: boolean;
  120115. /** @hidden */
  120116. occlusionRetryCount: number;
  120117. /** @hidden */
  120118. occlusionType: number;
  120119. /** @hidden */
  120120. occlusionQueryAlgorithmType: number;
  120121. }
  120122. interface Engine {
  120123. /**
  120124. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  120125. * @return the new query
  120126. */
  120127. createQuery(): WebGLQuery;
  120128. /**
  120129. * Delete and release a webGL query
  120130. * @param query defines the query to delete
  120131. * @return the current engine
  120132. */
  120133. deleteQuery(query: WebGLQuery): Engine;
  120134. /**
  120135. * Check if a given query has resolved and got its value
  120136. * @param query defines the query to check
  120137. * @returns true if the query got its value
  120138. */
  120139. isQueryResultAvailable(query: WebGLQuery): boolean;
  120140. /**
  120141. * Gets the value of a given query
  120142. * @param query defines the query to check
  120143. * @returns the value of the query
  120144. */
  120145. getQueryResult(query: WebGLQuery): number;
  120146. /**
  120147. * Initiates an occlusion query
  120148. * @param algorithmType defines the algorithm to use
  120149. * @param query defines the query to use
  120150. * @returns the current engine
  120151. * @see http://doc.babylonjs.com/features/occlusionquery
  120152. */
  120153. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  120154. /**
  120155. * Ends an occlusion query
  120156. * @see http://doc.babylonjs.com/features/occlusionquery
  120157. * @param algorithmType defines the algorithm to use
  120158. * @returns the current engine
  120159. */
  120160. endOcclusionQuery(algorithmType: number): Engine;
  120161. /**
  120162. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  120163. * Please note that only one query can be issued at a time
  120164. * @returns a time token used to track the time span
  120165. */
  120166. startTimeQuery(): Nullable<_TimeToken>;
  120167. /**
  120168. * Ends a time query
  120169. * @param token defines the token used to measure the time span
  120170. * @returns the time spent (in ns)
  120171. */
  120172. endTimeQuery(token: _TimeToken): int;
  120173. /** @hidden */
  120174. _currentNonTimestampToken: Nullable<_TimeToken>;
  120175. /** @hidden */
  120176. _createTimeQuery(): WebGLQuery;
  120177. /** @hidden */
  120178. _deleteTimeQuery(query: WebGLQuery): void;
  120179. /** @hidden */
  120180. _getGlAlgorithmType(algorithmType: number): number;
  120181. /** @hidden */
  120182. _getTimeQueryResult(query: WebGLQuery): any;
  120183. /** @hidden */
  120184. _getTimeQueryAvailability(query: WebGLQuery): any;
  120185. }
  120186. interface AbstractMesh {
  120187. /**
  120188. * Backing filed
  120189. * @hidden
  120190. */
  120191. __occlusionDataStorage: _OcclusionDataStorage;
  120192. /**
  120193. * Access property
  120194. * @hidden
  120195. */
  120196. _occlusionDataStorage: _OcclusionDataStorage;
  120197. /**
  120198. * 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.
  120199. * The default value is -1 which means don't break the query and wait till the result
  120200. * @see http://doc.babylonjs.com/features/occlusionquery
  120201. */
  120202. occlusionRetryCount: number;
  120203. /**
  120204. * 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:
  120205. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  120206. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  120207. * * 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.
  120208. * @see http://doc.babylonjs.com/features/occlusionquery
  120209. */
  120210. occlusionType: number;
  120211. /**
  120212. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  120213. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  120214. * * 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.
  120215. * @see http://doc.babylonjs.com/features/occlusionquery
  120216. */
  120217. occlusionQueryAlgorithmType: number;
  120218. /**
  120219. * 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
  120220. * @see http://doc.babylonjs.com/features/occlusionquery
  120221. */
  120222. isOccluded: boolean;
  120223. /**
  120224. * Flag to check the progress status of the query
  120225. * @see http://doc.babylonjs.com/features/occlusionquery
  120226. */
  120227. isOcclusionQueryInProgress: boolean;
  120228. }
  120229. }
  120230. declare module BABYLON {
  120231. /** @hidden */
  120232. export var _forceTransformFeedbackToBundle: boolean;
  120233. interface Engine {
  120234. /**
  120235. * Creates a webGL transform feedback object
  120236. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  120237. * @returns the webGL transform feedback object
  120238. */
  120239. createTransformFeedback(): WebGLTransformFeedback;
  120240. /**
  120241. * Delete a webGL transform feedback object
  120242. * @param value defines the webGL transform feedback object to delete
  120243. */
  120244. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  120245. /**
  120246. * Bind a webGL transform feedback object to the webgl context
  120247. * @param value defines the webGL transform feedback object to bind
  120248. */
  120249. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  120250. /**
  120251. * Begins a transform feedback operation
  120252. * @param usePoints defines if points or triangles must be used
  120253. */
  120254. beginTransformFeedback(usePoints: boolean): void;
  120255. /**
  120256. * Ends a transform feedback operation
  120257. */
  120258. endTransformFeedback(): void;
  120259. /**
  120260. * Specify the varyings to use with transform feedback
  120261. * @param program defines the associated webGL program
  120262. * @param value defines the list of strings representing the varying names
  120263. */
  120264. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  120265. /**
  120266. * Bind a webGL buffer for a transform feedback operation
  120267. * @param value defines the webGL buffer to bind
  120268. */
  120269. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  120270. }
  120271. }
  120272. declare module BABYLON {
  120273. /**
  120274. * Creation options of the multi render target texture.
  120275. */
  120276. export interface IMultiRenderTargetOptions {
  120277. /**
  120278. * Define if the texture needs to create mip maps after render.
  120279. */
  120280. generateMipMaps?: boolean;
  120281. /**
  120282. * Define the types of all the draw buffers we want to create
  120283. */
  120284. types?: number[];
  120285. /**
  120286. * Define the sampling modes of all the draw buffers we want to create
  120287. */
  120288. samplingModes?: number[];
  120289. /**
  120290. * Define if a depth buffer is required
  120291. */
  120292. generateDepthBuffer?: boolean;
  120293. /**
  120294. * Define if a stencil buffer is required
  120295. */
  120296. generateStencilBuffer?: boolean;
  120297. /**
  120298. * Define if a depth texture is required instead of a depth buffer
  120299. */
  120300. generateDepthTexture?: boolean;
  120301. /**
  120302. * Define the number of desired draw buffers
  120303. */
  120304. textureCount?: number;
  120305. /**
  120306. * Define if aspect ratio should be adapted to the texture or stay the scene one
  120307. */
  120308. doNotChangeAspectRatio?: boolean;
  120309. /**
  120310. * Define the default type of the buffers we are creating
  120311. */
  120312. defaultType?: number;
  120313. }
  120314. /**
  120315. * A multi render target, like a render target provides the ability to render to a texture.
  120316. * Unlike the render target, it can render to several draw buffers in one draw.
  120317. * This is specially interesting in deferred rendering or for any effects requiring more than
  120318. * just one color from a single pass.
  120319. */
  120320. export class MultiRenderTarget extends RenderTargetTexture {
  120321. private _internalTextures;
  120322. private _textures;
  120323. private _multiRenderTargetOptions;
  120324. /**
  120325. * Get if draw buffers are currently supported by the used hardware and browser.
  120326. */
  120327. get isSupported(): boolean;
  120328. /**
  120329. * Get the list of textures generated by the multi render target.
  120330. */
  120331. get textures(): Texture[];
  120332. /**
  120333. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  120334. */
  120335. get depthTexture(): Texture;
  120336. /**
  120337. * Set the wrapping mode on U of all the textures we are rendering to.
  120338. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  120339. */
  120340. set wrapU(wrap: number);
  120341. /**
  120342. * Set the wrapping mode on V of all the textures we are rendering to.
  120343. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  120344. */
  120345. set wrapV(wrap: number);
  120346. /**
  120347. * Instantiate a new multi render target texture.
  120348. * A multi render target, like a render target provides the ability to render to a texture.
  120349. * Unlike the render target, it can render to several draw buffers in one draw.
  120350. * This is specially interesting in deferred rendering or for any effects requiring more than
  120351. * just one color from a single pass.
  120352. * @param name Define the name of the texture
  120353. * @param size Define the size of the buffers to render to
  120354. * @param count Define the number of target we are rendering into
  120355. * @param scene Define the scene the texture belongs to
  120356. * @param options Define the options used to create the multi render target
  120357. */
  120358. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  120359. /** @hidden */
  120360. _rebuild(): void;
  120361. private _createInternalTextures;
  120362. private _createTextures;
  120363. /**
  120364. * Define the number of samples used if MSAA is enabled.
  120365. */
  120366. get samples(): number;
  120367. set samples(value: number);
  120368. /**
  120369. * Resize all the textures in the multi render target.
  120370. * Be carrefull as it will recreate all the data in the new texture.
  120371. * @param size Define the new size
  120372. */
  120373. resize(size: any): void;
  120374. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  120375. /**
  120376. * Dispose the render targets and their associated resources
  120377. */
  120378. dispose(): void;
  120379. /**
  120380. * Release all the underlying texture used as draw buffers.
  120381. */
  120382. releaseInternalTextures(): void;
  120383. }
  120384. }
  120385. declare module BABYLON {
  120386. interface ThinEngine {
  120387. /**
  120388. * Unbind a list of render target textures from the webGL context
  120389. * This is used only when drawBuffer extension or webGL2 are active
  120390. * @param textures defines the render target textures to unbind
  120391. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  120392. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  120393. */
  120394. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  120395. /**
  120396. * Create a multi render target texture
  120397. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  120398. * @param size defines the size of the texture
  120399. * @param options defines the creation options
  120400. * @returns the cube texture as an InternalTexture
  120401. */
  120402. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  120403. /**
  120404. * Update the sample count for a given multiple render target texture
  120405. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  120406. * @param textures defines the textures to update
  120407. * @param samples defines the sample count to set
  120408. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  120409. */
  120410. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  120411. }
  120412. }
  120413. declare module BABYLON {
  120414. /**
  120415. * Class used to define an additional view for the engine
  120416. * @see https://doc.babylonjs.com/how_to/multi_canvases
  120417. */
  120418. export class EngineView {
  120419. /** Defines the canvas where to render the view */
  120420. target: HTMLCanvasElement;
  120421. /** Defines an optional camera used to render the view (will use active camera else) */
  120422. camera?: Camera;
  120423. }
  120424. interface Engine {
  120425. /**
  120426. * Gets or sets the HTML element to use for attaching events
  120427. */
  120428. inputElement: Nullable<HTMLElement>;
  120429. /**
  120430. * Gets the current engine view
  120431. * @see https://doc.babylonjs.com/how_to/multi_canvases
  120432. */
  120433. activeView: Nullable<EngineView>;
  120434. /** Gets or sets the list of views */
  120435. views: EngineView[];
  120436. /**
  120437. * Register a new child canvas
  120438. * @param canvas defines the canvas to register
  120439. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  120440. * @returns the associated view
  120441. */
  120442. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  120443. /**
  120444. * Remove a registered child canvas
  120445. * @param canvas defines the canvas to remove
  120446. * @returns the current engine
  120447. */
  120448. unRegisterView(canvas: HTMLCanvasElement): Engine;
  120449. }
  120450. }
  120451. declare module BABYLON {
  120452. /**
  120453. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  120454. */
  120455. export interface CubeMapInfo {
  120456. /**
  120457. * The pixel array for the front face.
  120458. * This is stored in format, left to right, up to down format.
  120459. */
  120460. front: Nullable<ArrayBufferView>;
  120461. /**
  120462. * The pixel array for the back face.
  120463. * This is stored in format, left to right, up to down format.
  120464. */
  120465. back: Nullable<ArrayBufferView>;
  120466. /**
  120467. * The pixel array for the left face.
  120468. * This is stored in format, left to right, up to down format.
  120469. */
  120470. left: Nullable<ArrayBufferView>;
  120471. /**
  120472. * The pixel array for the right face.
  120473. * This is stored in format, left to right, up to down format.
  120474. */
  120475. right: Nullable<ArrayBufferView>;
  120476. /**
  120477. * The pixel array for the up face.
  120478. * This is stored in format, left to right, up to down format.
  120479. */
  120480. up: Nullable<ArrayBufferView>;
  120481. /**
  120482. * The pixel array for the down face.
  120483. * This is stored in format, left to right, up to down format.
  120484. */
  120485. down: Nullable<ArrayBufferView>;
  120486. /**
  120487. * The size of the cubemap stored.
  120488. *
  120489. * Each faces will be size * size pixels.
  120490. */
  120491. size: number;
  120492. /**
  120493. * The format of the texture.
  120494. *
  120495. * RGBA, RGB.
  120496. */
  120497. format: number;
  120498. /**
  120499. * The type of the texture data.
  120500. *
  120501. * UNSIGNED_INT, FLOAT.
  120502. */
  120503. type: number;
  120504. /**
  120505. * Specifies whether the texture is in gamma space.
  120506. */
  120507. gammaSpace: boolean;
  120508. }
  120509. /**
  120510. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  120511. */
  120512. export class PanoramaToCubeMapTools {
  120513. private static FACE_FRONT;
  120514. private static FACE_BACK;
  120515. private static FACE_RIGHT;
  120516. private static FACE_LEFT;
  120517. private static FACE_DOWN;
  120518. private static FACE_UP;
  120519. /**
  120520. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  120521. *
  120522. * @param float32Array The source data.
  120523. * @param inputWidth The width of the input panorama.
  120524. * @param inputHeight The height of the input panorama.
  120525. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  120526. * @return The cubemap data
  120527. */
  120528. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  120529. private static CreateCubemapTexture;
  120530. private static CalcProjectionSpherical;
  120531. }
  120532. }
  120533. declare module BABYLON {
  120534. /**
  120535. * Helper class dealing with the extraction of spherical polynomial dataArray
  120536. * from a cube map.
  120537. */
  120538. export class CubeMapToSphericalPolynomialTools {
  120539. private static FileFaces;
  120540. /**
  120541. * Converts a texture to the according Spherical Polynomial data.
  120542. * This extracts the first 3 orders only as they are the only one used in the lighting.
  120543. *
  120544. * @param texture The texture to extract the information from.
  120545. * @return The Spherical Polynomial data.
  120546. */
  120547. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  120548. /**
  120549. * Converts a cubemap to the according Spherical Polynomial data.
  120550. * This extracts the first 3 orders only as they are the only one used in the lighting.
  120551. *
  120552. * @param cubeInfo The Cube map to extract the information from.
  120553. * @return The Spherical Polynomial data.
  120554. */
  120555. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  120556. }
  120557. }
  120558. declare module BABYLON {
  120559. interface BaseTexture {
  120560. /**
  120561. * Get the polynomial representation of the texture data.
  120562. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  120563. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  120564. */
  120565. sphericalPolynomial: Nullable<SphericalPolynomial>;
  120566. }
  120567. }
  120568. declare module BABYLON {
  120569. /** @hidden */
  120570. export var rgbdEncodePixelShader: {
  120571. name: string;
  120572. shader: string;
  120573. };
  120574. }
  120575. declare module BABYLON {
  120576. /** @hidden */
  120577. export var rgbdDecodePixelShader: {
  120578. name: string;
  120579. shader: string;
  120580. };
  120581. }
  120582. declare module BABYLON {
  120583. /**
  120584. * Raw texture data and descriptor sufficient for WebGL texture upload
  120585. */
  120586. export interface EnvironmentTextureInfo {
  120587. /**
  120588. * Version of the environment map
  120589. */
  120590. version: number;
  120591. /**
  120592. * Width of image
  120593. */
  120594. width: number;
  120595. /**
  120596. * Irradiance information stored in the file.
  120597. */
  120598. irradiance: any;
  120599. /**
  120600. * Specular information stored in the file.
  120601. */
  120602. specular: any;
  120603. }
  120604. /**
  120605. * Defines One Image in the file. It requires only the position in the file
  120606. * as well as the length.
  120607. */
  120608. interface BufferImageData {
  120609. /**
  120610. * Length of the image data.
  120611. */
  120612. length: number;
  120613. /**
  120614. * Position of the data from the null terminator delimiting the end of the JSON.
  120615. */
  120616. position: number;
  120617. }
  120618. /**
  120619. * Defines the specular data enclosed in the file.
  120620. * This corresponds to the version 1 of the data.
  120621. */
  120622. export interface EnvironmentTextureSpecularInfoV1 {
  120623. /**
  120624. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  120625. */
  120626. specularDataPosition?: number;
  120627. /**
  120628. * This contains all the images data needed to reconstruct the cubemap.
  120629. */
  120630. mipmaps: Array<BufferImageData>;
  120631. /**
  120632. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  120633. */
  120634. lodGenerationScale: number;
  120635. }
  120636. /**
  120637. * Sets of helpers addressing the serialization and deserialization of environment texture
  120638. * stored in a BabylonJS env file.
  120639. * Those files are usually stored as .env files.
  120640. */
  120641. export class EnvironmentTextureTools {
  120642. /**
  120643. * Magic number identifying the env file.
  120644. */
  120645. private static _MagicBytes;
  120646. /**
  120647. * Gets the environment info from an env file.
  120648. * @param data The array buffer containing the .env bytes.
  120649. * @returns the environment file info (the json header) if successfully parsed.
  120650. */
  120651. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  120652. /**
  120653. * Creates an environment texture from a loaded cube texture.
  120654. * @param texture defines the cube texture to convert in env file
  120655. * @return a promise containing the environment data if succesfull.
  120656. */
  120657. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  120658. /**
  120659. * Creates a JSON representation of the spherical data.
  120660. * @param texture defines the texture containing the polynomials
  120661. * @return the JSON representation of the spherical info
  120662. */
  120663. private static _CreateEnvTextureIrradiance;
  120664. /**
  120665. * Creates the ArrayBufferViews used for initializing environment texture image data.
  120666. * @param data the image data
  120667. * @param info parameters that determine what views will be created for accessing the underlying buffer
  120668. * @return the views described by info providing access to the underlying buffer
  120669. */
  120670. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  120671. /**
  120672. * Uploads the texture info contained in the env file to the GPU.
  120673. * @param texture defines the internal texture to upload to
  120674. * @param data defines the data to load
  120675. * @param info defines the texture info retrieved through the GetEnvInfo method
  120676. * @returns a promise
  120677. */
  120678. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  120679. private static _OnImageReadyAsync;
  120680. /**
  120681. * Uploads the levels of image data to the GPU.
  120682. * @param texture defines the internal texture to upload to
  120683. * @param imageData defines the array buffer views of image data [mipmap][face]
  120684. * @returns a promise
  120685. */
  120686. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  120687. /**
  120688. * Uploads spherical polynomials information to the texture.
  120689. * @param texture defines the texture we are trying to upload the information to
  120690. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  120691. */
  120692. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  120693. /** @hidden */
  120694. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  120695. }
  120696. }
  120697. declare module BABYLON {
  120698. /**
  120699. * Contains position and normal vectors for a vertex
  120700. */
  120701. export class PositionNormalVertex {
  120702. /** the position of the vertex (defaut: 0,0,0) */
  120703. position: Vector3;
  120704. /** the normal of the vertex (defaut: 0,1,0) */
  120705. normal: Vector3;
  120706. /**
  120707. * Creates a PositionNormalVertex
  120708. * @param position the position of the vertex (defaut: 0,0,0)
  120709. * @param normal the normal of the vertex (defaut: 0,1,0)
  120710. */
  120711. constructor(
  120712. /** the position of the vertex (defaut: 0,0,0) */
  120713. position?: Vector3,
  120714. /** the normal of the vertex (defaut: 0,1,0) */
  120715. normal?: Vector3);
  120716. /**
  120717. * Clones the PositionNormalVertex
  120718. * @returns the cloned PositionNormalVertex
  120719. */
  120720. clone(): PositionNormalVertex;
  120721. }
  120722. /**
  120723. * Contains position, normal and uv vectors for a vertex
  120724. */
  120725. export class PositionNormalTextureVertex {
  120726. /** the position of the vertex (defaut: 0,0,0) */
  120727. position: Vector3;
  120728. /** the normal of the vertex (defaut: 0,1,0) */
  120729. normal: Vector3;
  120730. /** the uv of the vertex (default: 0,0) */
  120731. uv: Vector2;
  120732. /**
  120733. * Creates a PositionNormalTextureVertex
  120734. * @param position the position of the vertex (defaut: 0,0,0)
  120735. * @param normal the normal of the vertex (defaut: 0,1,0)
  120736. * @param uv the uv of the vertex (default: 0,0)
  120737. */
  120738. constructor(
  120739. /** the position of the vertex (defaut: 0,0,0) */
  120740. position?: Vector3,
  120741. /** the normal of the vertex (defaut: 0,1,0) */
  120742. normal?: Vector3,
  120743. /** the uv of the vertex (default: 0,0) */
  120744. uv?: Vector2);
  120745. /**
  120746. * Clones the PositionNormalTextureVertex
  120747. * @returns the cloned PositionNormalTextureVertex
  120748. */
  120749. clone(): PositionNormalTextureVertex;
  120750. }
  120751. }
  120752. declare module BABYLON {
  120753. /** @hidden */
  120754. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  120755. private _genericAttributeLocation;
  120756. private _varyingLocationCount;
  120757. private _varyingLocationMap;
  120758. private _replacements;
  120759. private _textureCount;
  120760. private _uniforms;
  120761. lineProcessor(line: string): string;
  120762. attributeProcessor(attribute: string): string;
  120763. varyingProcessor(varying: string, isFragment: boolean): string;
  120764. uniformProcessor(uniform: string): string;
  120765. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  120766. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  120767. }
  120768. }
  120769. declare module BABYLON {
  120770. /**
  120771. * Container for accessors for natively-stored mesh data buffers.
  120772. */
  120773. class NativeDataBuffer extends DataBuffer {
  120774. /**
  120775. * Accessor value used to identify/retrieve a natively-stored index buffer.
  120776. */
  120777. nativeIndexBuffer?: any;
  120778. /**
  120779. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  120780. */
  120781. nativeVertexBuffer?: any;
  120782. }
  120783. /** @hidden */
  120784. class NativeTexture extends InternalTexture {
  120785. getInternalTexture(): InternalTexture;
  120786. getViewCount(): number;
  120787. }
  120788. /** @hidden */
  120789. export class NativeEngine extends Engine {
  120790. private readonly _native;
  120791. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  120792. private readonly INVALID_HANDLE;
  120793. getHardwareScalingLevel(): number;
  120794. constructor();
  120795. /**
  120796. * Can be used to override the current requestAnimationFrame requester.
  120797. * @hidden
  120798. */
  120799. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  120800. /**
  120801. * Override default engine behavior.
  120802. * @param color
  120803. * @param backBuffer
  120804. * @param depth
  120805. * @param stencil
  120806. */
  120807. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  120808. /**
  120809. * Gets host document
  120810. * @returns the host document object
  120811. */
  120812. getHostDocument(): Nullable<Document>;
  120813. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  120814. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  120815. createVertexBuffer(data: DataArray): NativeDataBuffer;
  120816. recordVertexArrayObject(vertexBuffers: {
  120817. [key: string]: VertexBuffer;
  120818. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  120819. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  120820. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  120821. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  120822. /**
  120823. * Draw a list of indexed primitives
  120824. * @param fillMode defines the primitive to use
  120825. * @param indexStart defines the starting index
  120826. * @param indexCount defines the number of index to draw
  120827. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120828. */
  120829. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  120830. /**
  120831. * Draw a list of unindexed primitives
  120832. * @param fillMode defines the primitive to use
  120833. * @param verticesStart defines the index of first vertex to draw
  120834. * @param verticesCount defines the count of vertices to draw
  120835. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120836. */
  120837. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  120838. createPipelineContext(): IPipelineContext;
  120839. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  120840. /** @hidden */
  120841. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  120842. /** @hidden */
  120843. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  120844. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  120845. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  120846. protected _setProgram(program: WebGLProgram): void;
  120847. _releaseEffect(effect: Effect): void;
  120848. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  120849. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  120850. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  120851. bindSamplers(effect: Effect): void;
  120852. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  120853. getRenderWidth(useScreen?: boolean): number;
  120854. getRenderHeight(useScreen?: boolean): number;
  120855. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  120856. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  120857. /**
  120858. * Set the z offset to apply to current rendering
  120859. * @param value defines the offset to apply
  120860. */
  120861. setZOffset(value: number): void;
  120862. /**
  120863. * Gets the current value of the zOffset
  120864. * @returns the current zOffset state
  120865. */
  120866. getZOffset(): number;
  120867. /**
  120868. * Enable or disable depth buffering
  120869. * @param enable defines the state to set
  120870. */
  120871. setDepthBuffer(enable: boolean): void;
  120872. /**
  120873. * Gets a boolean indicating if depth writing is enabled
  120874. * @returns the current depth writing state
  120875. */
  120876. getDepthWrite(): boolean;
  120877. /**
  120878. * Enable or disable depth writing
  120879. * @param enable defines the state to set
  120880. */
  120881. setDepthWrite(enable: boolean): void;
  120882. /**
  120883. * Enable or disable color writing
  120884. * @param enable defines the state to set
  120885. */
  120886. setColorWrite(enable: boolean): void;
  120887. /**
  120888. * Gets a boolean indicating if color writing is enabled
  120889. * @returns the current color writing state
  120890. */
  120891. getColorWrite(): boolean;
  120892. /**
  120893. * Sets alpha constants used by some alpha blending modes
  120894. * @param r defines the red component
  120895. * @param g defines the green component
  120896. * @param b defines the blue component
  120897. * @param a defines the alpha component
  120898. */
  120899. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  120900. /**
  120901. * Sets the current alpha mode
  120902. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  120903. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  120904. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  120905. */
  120906. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  120907. /**
  120908. * Gets the current alpha mode
  120909. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  120910. * @returns the current alpha mode
  120911. */
  120912. getAlphaMode(): number;
  120913. setInt(uniform: WebGLUniformLocation, int: number): void;
  120914. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  120915. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  120916. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  120917. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  120918. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  120919. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  120920. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  120921. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  120922. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  120923. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  120924. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  120925. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  120926. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  120927. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  120928. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  120929. setFloat(uniform: WebGLUniformLocation, value: number): void;
  120930. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  120931. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  120932. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  120933. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  120934. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  120935. wipeCaches(bruteForce?: boolean): void;
  120936. _createTexture(): WebGLTexture;
  120937. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  120938. /**
  120939. * Usually called from BABYLON.Texture.ts.
  120940. * Passed information to create a WebGLTexture
  120941. * @param urlArg defines a value which contains one of the following:
  120942. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  120943. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  120944. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  120945. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  120946. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  120947. * @param scene needed for loading to the correct scene
  120948. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  120949. * @param onLoad optional callback to be called upon successful completion
  120950. * @param onError optional callback to be called upon failure
  120951. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  120952. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  120953. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  120954. * @param forcedExtension defines the extension to use to pick the right loader
  120955. * @returns a InternalTexture for assignment back into BABYLON.Texture
  120956. */
  120957. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  120958. /**
  120959. * Creates a cube texture
  120960. * @param rootUrl defines the url where the files to load is located
  120961. * @param scene defines the current scene
  120962. * @param files defines the list of files to load (1 per face)
  120963. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  120964. * @param onLoad defines an optional callback raised when the texture is loaded
  120965. * @param onError defines an optional callback raised if there is an issue to load the texture
  120966. * @param format defines the format of the data
  120967. * @param forcedExtension defines the extension to use to pick the right loader
  120968. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  120969. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  120970. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  120971. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  120972. * @returns the cube texture as an InternalTexture
  120973. */
  120974. 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;
  120975. private _getSamplingFilter;
  120976. private static _GetNativeTextureFormat;
  120977. createRenderTargetTexture(size: number | {
  120978. width: number;
  120979. height: number;
  120980. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  120981. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  120982. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  120983. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  120984. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  120985. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  120986. /**
  120987. * Updates a dynamic vertex buffer.
  120988. * @param vertexBuffer the vertex buffer to update
  120989. * @param data the data used to update the vertex buffer
  120990. * @param byteOffset the byte offset of the data (optional)
  120991. * @param byteLength the byte length of the data (optional)
  120992. */
  120993. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  120994. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  120995. private _updateAnisotropicLevel;
  120996. private _getAddressMode;
  120997. /** @hidden */
  120998. _bindTexture(channel: number, texture: InternalTexture): void;
  120999. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  121000. releaseEffects(): void;
  121001. /** @hidden */
  121002. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121003. /** @hidden */
  121004. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121005. /** @hidden */
  121006. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121007. /** @hidden */
  121008. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  121009. }
  121010. }
  121011. declare module BABYLON {
  121012. /**
  121013. * Gather the list of clipboard event types as constants.
  121014. */
  121015. export class ClipboardEventTypes {
  121016. /**
  121017. * The clipboard event is fired when a copy command is active (pressed).
  121018. */
  121019. static readonly COPY: number;
  121020. /**
  121021. * The clipboard event is fired when a cut command is active (pressed).
  121022. */
  121023. static readonly CUT: number;
  121024. /**
  121025. * The clipboard event is fired when a paste command is active (pressed).
  121026. */
  121027. static readonly PASTE: number;
  121028. }
  121029. /**
  121030. * This class is used to store clipboard related info for the onClipboardObservable event.
  121031. */
  121032. export class ClipboardInfo {
  121033. /**
  121034. * Defines the type of event (BABYLON.ClipboardEventTypes)
  121035. */
  121036. type: number;
  121037. /**
  121038. * Defines the related dom event
  121039. */
  121040. event: ClipboardEvent;
  121041. /**
  121042. *Creates an instance of ClipboardInfo.
  121043. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  121044. * @param event Defines the related dom event
  121045. */
  121046. constructor(
  121047. /**
  121048. * Defines the type of event (BABYLON.ClipboardEventTypes)
  121049. */
  121050. type: number,
  121051. /**
  121052. * Defines the related dom event
  121053. */
  121054. event: ClipboardEvent);
  121055. /**
  121056. * Get the clipboard event's type from the keycode.
  121057. * @param keyCode Defines the keyCode for the current keyboard event.
  121058. * @return {number}
  121059. */
  121060. static GetTypeFromCharacter(keyCode: number): number;
  121061. }
  121062. }
  121063. declare module BABYLON {
  121064. /**
  121065. * Google Daydream controller
  121066. */
  121067. export class DaydreamController extends WebVRController {
  121068. /**
  121069. * Base Url for the controller model.
  121070. */
  121071. static MODEL_BASE_URL: string;
  121072. /**
  121073. * File name for the controller model.
  121074. */
  121075. static MODEL_FILENAME: string;
  121076. /**
  121077. * Gamepad Id prefix used to identify Daydream Controller.
  121078. */
  121079. static readonly GAMEPAD_ID_PREFIX: string;
  121080. /**
  121081. * Creates a new DaydreamController from a gamepad
  121082. * @param vrGamepad the gamepad that the controller should be created from
  121083. */
  121084. constructor(vrGamepad: any);
  121085. /**
  121086. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121087. * @param scene scene in which to add meshes
  121088. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121089. */
  121090. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121091. /**
  121092. * Called once for each button that changed state since the last frame
  121093. * @param buttonIdx Which button index changed
  121094. * @param state New state of the button
  121095. * @param changes Which properties on the state changed since last frame
  121096. */
  121097. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121098. }
  121099. }
  121100. declare module BABYLON {
  121101. /**
  121102. * Gear VR Controller
  121103. */
  121104. export class GearVRController extends WebVRController {
  121105. /**
  121106. * Base Url for the controller model.
  121107. */
  121108. static MODEL_BASE_URL: string;
  121109. /**
  121110. * File name for the controller model.
  121111. */
  121112. static MODEL_FILENAME: string;
  121113. /**
  121114. * Gamepad Id prefix used to identify this controller.
  121115. */
  121116. static readonly GAMEPAD_ID_PREFIX: string;
  121117. private readonly _buttonIndexToObservableNameMap;
  121118. /**
  121119. * Creates a new GearVRController from a gamepad
  121120. * @param vrGamepad the gamepad that the controller should be created from
  121121. */
  121122. constructor(vrGamepad: any);
  121123. /**
  121124. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121125. * @param scene scene in which to add meshes
  121126. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121127. */
  121128. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121129. /**
  121130. * Called once for each button that changed state since the last frame
  121131. * @param buttonIdx Which button index changed
  121132. * @param state New state of the button
  121133. * @param changes Which properties on the state changed since last frame
  121134. */
  121135. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121136. }
  121137. }
  121138. declare module BABYLON {
  121139. /**
  121140. * Generic Controller
  121141. */
  121142. export class GenericController extends WebVRController {
  121143. /**
  121144. * Base Url for the controller model.
  121145. */
  121146. static readonly MODEL_BASE_URL: string;
  121147. /**
  121148. * File name for the controller model.
  121149. */
  121150. static readonly MODEL_FILENAME: string;
  121151. /**
  121152. * Creates a new GenericController from a gamepad
  121153. * @param vrGamepad the gamepad that the controller should be created from
  121154. */
  121155. constructor(vrGamepad: any);
  121156. /**
  121157. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121158. * @param scene scene in which to add meshes
  121159. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121160. */
  121161. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121162. /**
  121163. * Called once for each button that changed state since the last frame
  121164. * @param buttonIdx Which button index changed
  121165. * @param state New state of the button
  121166. * @param changes Which properties on the state changed since last frame
  121167. */
  121168. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121169. }
  121170. }
  121171. declare module BABYLON {
  121172. /**
  121173. * Oculus Touch Controller
  121174. */
  121175. export class OculusTouchController extends WebVRController {
  121176. /**
  121177. * Base Url for the controller model.
  121178. */
  121179. static MODEL_BASE_URL: string;
  121180. /**
  121181. * File name for the left controller model.
  121182. */
  121183. static MODEL_LEFT_FILENAME: string;
  121184. /**
  121185. * File name for the right controller model.
  121186. */
  121187. static MODEL_RIGHT_FILENAME: string;
  121188. /**
  121189. * Base Url for the Quest controller model.
  121190. */
  121191. static QUEST_MODEL_BASE_URL: string;
  121192. /**
  121193. * @hidden
  121194. * If the controllers are running on a device that needs the updated Quest controller models
  121195. */
  121196. static _IsQuest: boolean;
  121197. /**
  121198. * Fired when the secondary trigger on this controller is modified
  121199. */
  121200. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  121201. /**
  121202. * Fired when the thumb rest on this controller is modified
  121203. */
  121204. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  121205. /**
  121206. * Creates a new OculusTouchController from a gamepad
  121207. * @param vrGamepad the gamepad that the controller should be created from
  121208. */
  121209. constructor(vrGamepad: any);
  121210. /**
  121211. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121212. * @param scene scene in which to add meshes
  121213. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121214. */
  121215. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121216. /**
  121217. * Fired when the A button on this controller is modified
  121218. */
  121219. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121220. /**
  121221. * Fired when the B button on this controller is modified
  121222. */
  121223. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121224. /**
  121225. * Fired when the X button on this controller is modified
  121226. */
  121227. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121228. /**
  121229. * Fired when the Y button on this controller is modified
  121230. */
  121231. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121232. /**
  121233. * Called once for each button that changed state since the last frame
  121234. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  121235. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  121236. * 2) secondary trigger (same)
  121237. * 3) A (right) X (left), touch, pressed = value
  121238. * 4) B / Y
  121239. * 5) thumb rest
  121240. * @param buttonIdx Which button index changed
  121241. * @param state New state of the button
  121242. * @param changes Which properties on the state changed since last frame
  121243. */
  121244. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121245. }
  121246. }
  121247. declare module BABYLON {
  121248. /**
  121249. * Vive Controller
  121250. */
  121251. export class ViveController extends WebVRController {
  121252. /**
  121253. * Base Url for the controller model.
  121254. */
  121255. static MODEL_BASE_URL: string;
  121256. /**
  121257. * File name for the controller model.
  121258. */
  121259. static MODEL_FILENAME: string;
  121260. /**
  121261. * Creates a new ViveController from a gamepad
  121262. * @param vrGamepad the gamepad that the controller should be created from
  121263. */
  121264. constructor(vrGamepad: any);
  121265. /**
  121266. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121267. * @param scene scene in which to add meshes
  121268. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121269. */
  121270. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121271. /**
  121272. * Fired when the left button on this controller is modified
  121273. */
  121274. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121275. /**
  121276. * Fired when the right button on this controller is modified
  121277. */
  121278. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121279. /**
  121280. * Fired when the menu button on this controller is modified
  121281. */
  121282. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121283. /**
  121284. * Called once for each button that changed state since the last frame
  121285. * Vive mapping:
  121286. * 0: touchpad
  121287. * 1: trigger
  121288. * 2: left AND right buttons
  121289. * 3: menu button
  121290. * @param buttonIdx Which button index changed
  121291. * @param state New state of the button
  121292. * @param changes Which properties on the state changed since last frame
  121293. */
  121294. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121295. }
  121296. }
  121297. declare module BABYLON {
  121298. /**
  121299. * Defines the WindowsMotionController object that the state of the windows motion controller
  121300. */
  121301. export class WindowsMotionController extends WebVRController {
  121302. /**
  121303. * The base url used to load the left and right controller models
  121304. */
  121305. static MODEL_BASE_URL: string;
  121306. /**
  121307. * The name of the left controller model file
  121308. */
  121309. static MODEL_LEFT_FILENAME: string;
  121310. /**
  121311. * The name of the right controller model file
  121312. */
  121313. static MODEL_RIGHT_FILENAME: string;
  121314. /**
  121315. * The controller name prefix for this controller type
  121316. */
  121317. static readonly GAMEPAD_ID_PREFIX: string;
  121318. /**
  121319. * The controller id pattern for this controller type
  121320. */
  121321. private static readonly GAMEPAD_ID_PATTERN;
  121322. private _loadedMeshInfo;
  121323. protected readonly _mapping: {
  121324. buttons: string[];
  121325. buttonMeshNames: {
  121326. 'trigger': string;
  121327. 'menu': string;
  121328. 'grip': string;
  121329. 'thumbstick': string;
  121330. 'trackpad': string;
  121331. };
  121332. buttonObservableNames: {
  121333. 'trigger': string;
  121334. 'menu': string;
  121335. 'grip': string;
  121336. 'thumbstick': string;
  121337. 'trackpad': string;
  121338. };
  121339. axisMeshNames: string[];
  121340. pointingPoseMeshName: string;
  121341. };
  121342. /**
  121343. * Fired when the trackpad on this controller is clicked
  121344. */
  121345. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  121346. /**
  121347. * Fired when the trackpad on this controller is modified
  121348. */
  121349. onTrackpadValuesChangedObservable: Observable<StickValues>;
  121350. /**
  121351. * The current x and y values of this controller's trackpad
  121352. */
  121353. trackpad: StickValues;
  121354. /**
  121355. * Creates a new WindowsMotionController from a gamepad
  121356. * @param vrGamepad the gamepad that the controller should be created from
  121357. */
  121358. constructor(vrGamepad: any);
  121359. /**
  121360. * Fired when the trigger on this controller is modified
  121361. */
  121362. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121363. /**
  121364. * Fired when the menu button on this controller is modified
  121365. */
  121366. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121367. /**
  121368. * Fired when the grip button on this controller is modified
  121369. */
  121370. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121371. /**
  121372. * Fired when the thumbstick button on this controller is modified
  121373. */
  121374. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121375. /**
  121376. * Fired when the touchpad button on this controller is modified
  121377. */
  121378. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121379. /**
  121380. * Fired when the touchpad values on this controller are modified
  121381. */
  121382. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  121383. protected _updateTrackpad(): void;
  121384. /**
  121385. * Called once per frame by the engine.
  121386. */
  121387. update(): void;
  121388. /**
  121389. * Called once for each button that changed state since the last frame
  121390. * @param buttonIdx Which button index changed
  121391. * @param state New state of the button
  121392. * @param changes Which properties on the state changed since last frame
  121393. */
  121394. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121395. /**
  121396. * Moves the buttons on the controller mesh based on their current state
  121397. * @param buttonName the name of the button to move
  121398. * @param buttonValue the value of the button which determines the buttons new position
  121399. */
  121400. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  121401. /**
  121402. * Moves the axis on the controller mesh based on its current state
  121403. * @param axis the index of the axis
  121404. * @param axisValue the value of the axis which determines the meshes new position
  121405. * @hidden
  121406. */
  121407. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  121408. /**
  121409. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121410. * @param scene scene in which to add meshes
  121411. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121412. */
  121413. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  121414. /**
  121415. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  121416. * can be transformed by button presses and axes values, based on this._mapping.
  121417. *
  121418. * @param scene scene in which the meshes exist
  121419. * @param meshes list of meshes that make up the controller model to process
  121420. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  121421. */
  121422. private processModel;
  121423. private createMeshInfo;
  121424. /**
  121425. * Gets the ray of the controller in the direction the controller is pointing
  121426. * @param length the length the resulting ray should be
  121427. * @returns a ray in the direction the controller is pointing
  121428. */
  121429. getForwardRay(length?: number): Ray;
  121430. /**
  121431. * Disposes of the controller
  121432. */
  121433. dispose(): void;
  121434. }
  121435. /**
  121436. * This class represents a new windows motion controller in XR.
  121437. */
  121438. export class XRWindowsMotionController extends WindowsMotionController {
  121439. /**
  121440. * Changing the original WIndowsMotionController mapping to fir the new mapping
  121441. */
  121442. protected readonly _mapping: {
  121443. buttons: string[];
  121444. buttonMeshNames: {
  121445. 'trigger': string;
  121446. 'menu': string;
  121447. 'grip': string;
  121448. 'thumbstick': string;
  121449. 'trackpad': string;
  121450. };
  121451. buttonObservableNames: {
  121452. 'trigger': string;
  121453. 'menu': string;
  121454. 'grip': string;
  121455. 'thumbstick': string;
  121456. 'trackpad': string;
  121457. };
  121458. axisMeshNames: string[];
  121459. pointingPoseMeshName: string;
  121460. };
  121461. /**
  121462. * Construct a new XR-Based windows motion controller
  121463. *
  121464. * @param gamepadInfo the gamepad object from the browser
  121465. */
  121466. constructor(gamepadInfo: any);
  121467. /**
  121468. * holds the thumbstick values (X,Y)
  121469. */
  121470. thumbstickValues: StickValues;
  121471. /**
  121472. * Fired when the thumbstick on this controller is clicked
  121473. */
  121474. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  121475. /**
  121476. * Fired when the thumbstick on this controller is modified
  121477. */
  121478. onThumbstickValuesChangedObservable: Observable<StickValues>;
  121479. /**
  121480. * Fired when the touchpad button on this controller is modified
  121481. */
  121482. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  121483. /**
  121484. * Fired when the touchpad values on this controller are modified
  121485. */
  121486. onTrackpadValuesChangedObservable: Observable<StickValues>;
  121487. /**
  121488. * Fired when the thumbstick button on this controller is modified
  121489. * here to prevent breaking changes
  121490. */
  121491. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121492. /**
  121493. * updating the thumbstick(!) and not the trackpad.
  121494. * This is named this way due to the difference between WebVR and XR and to avoid
  121495. * changing the parent class.
  121496. */
  121497. protected _updateTrackpad(): void;
  121498. /**
  121499. * Disposes the class with joy
  121500. */
  121501. dispose(): void;
  121502. }
  121503. }
  121504. declare module BABYLON {
  121505. /**
  121506. * Class containing static functions to help procedurally build meshes
  121507. */
  121508. export class PolyhedronBuilder {
  121509. /**
  121510. * Creates a polyhedron mesh
  121511. * * 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
  121512. * * The parameter `size` (positive float, default 1) sets the polygon size
  121513. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  121514. * * 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`
  121515. * * 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
  121516. * * 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)`)
  121517. * * 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
  121518. * * 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
  121519. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121520. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121521. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121522. * @param name defines the name of the mesh
  121523. * @param options defines the options used to create the mesh
  121524. * @param scene defines the hosting scene
  121525. * @returns the polyhedron mesh
  121526. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  121527. */
  121528. static CreatePolyhedron(name: string, options: {
  121529. type?: number;
  121530. size?: number;
  121531. sizeX?: number;
  121532. sizeY?: number;
  121533. sizeZ?: number;
  121534. custom?: any;
  121535. faceUV?: Vector4[];
  121536. faceColors?: Color4[];
  121537. flat?: boolean;
  121538. updatable?: boolean;
  121539. sideOrientation?: number;
  121540. frontUVs?: Vector4;
  121541. backUVs?: Vector4;
  121542. }, scene?: Nullable<Scene>): Mesh;
  121543. }
  121544. }
  121545. declare module BABYLON {
  121546. /**
  121547. * Gizmo that enables scaling a mesh along 3 axis
  121548. */
  121549. export class ScaleGizmo extends Gizmo {
  121550. /**
  121551. * Internal gizmo used for interactions on the x axis
  121552. */
  121553. xGizmo: AxisScaleGizmo;
  121554. /**
  121555. * Internal gizmo used for interactions on the y axis
  121556. */
  121557. yGizmo: AxisScaleGizmo;
  121558. /**
  121559. * Internal gizmo used for interactions on the z axis
  121560. */
  121561. zGizmo: AxisScaleGizmo;
  121562. /**
  121563. * Internal gizmo used to scale all axis equally
  121564. */
  121565. uniformScaleGizmo: AxisScaleGizmo;
  121566. private _meshAttached;
  121567. private _updateGizmoRotationToMatchAttachedMesh;
  121568. private _snapDistance;
  121569. private _scaleRatio;
  121570. private _uniformScalingMesh;
  121571. private _octahedron;
  121572. private _sensitivity;
  121573. /** Fires an event when any of it's sub gizmos are dragged */
  121574. onDragStartObservable: Observable<unknown>;
  121575. /** Fires an event when any of it's sub gizmos are released from dragging */
  121576. onDragEndObservable: Observable<unknown>;
  121577. get attachedMesh(): Nullable<AbstractMesh>;
  121578. set attachedMesh(mesh: Nullable<AbstractMesh>);
  121579. /**
  121580. * Creates a ScaleGizmo
  121581. * @param gizmoLayer The utility layer the gizmo will be added to
  121582. */
  121583. constructor(gizmoLayer?: UtilityLayerRenderer);
  121584. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  121585. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  121586. /**
  121587. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121588. */
  121589. set snapDistance(value: number);
  121590. get snapDistance(): number;
  121591. /**
  121592. * Ratio for the scale of the gizmo (Default: 1)
  121593. */
  121594. set scaleRatio(value: number);
  121595. get scaleRatio(): number;
  121596. /**
  121597. * Sensitivity factor for dragging (Default: 1)
  121598. */
  121599. set sensitivity(value: number);
  121600. get sensitivity(): number;
  121601. /**
  121602. * Disposes of the gizmo
  121603. */
  121604. dispose(): void;
  121605. }
  121606. }
  121607. declare module BABYLON {
  121608. /**
  121609. * Single axis scale gizmo
  121610. */
  121611. export class AxisScaleGizmo extends Gizmo {
  121612. /**
  121613. * Drag behavior responsible for the gizmos dragging interactions
  121614. */
  121615. dragBehavior: PointerDragBehavior;
  121616. private _pointerObserver;
  121617. /**
  121618. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121619. */
  121620. snapDistance: number;
  121621. /**
  121622. * Event that fires each time the gizmo snaps to a new location.
  121623. * * snapDistance is the the change in distance
  121624. */
  121625. onSnapObservable: Observable<{
  121626. snapDistance: number;
  121627. }>;
  121628. /**
  121629. * If the scaling operation should be done on all axis (default: false)
  121630. */
  121631. uniformScaling: boolean;
  121632. /**
  121633. * Custom sensitivity value for the drag strength
  121634. */
  121635. sensitivity: number;
  121636. private _isEnabled;
  121637. private _parent;
  121638. private _arrow;
  121639. private _coloredMaterial;
  121640. private _hoverMaterial;
  121641. /**
  121642. * Creates an AxisScaleGizmo
  121643. * @param gizmoLayer The utility layer the gizmo will be added to
  121644. * @param dragAxis The axis which the gizmo will be able to scale on
  121645. * @param color The color of the gizmo
  121646. */
  121647. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  121648. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121649. /**
  121650. * If the gizmo is enabled
  121651. */
  121652. set isEnabled(value: boolean);
  121653. get isEnabled(): boolean;
  121654. /**
  121655. * Disposes of the gizmo
  121656. */
  121657. dispose(): void;
  121658. /**
  121659. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  121660. * @param mesh The mesh to replace the default mesh of the gizmo
  121661. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  121662. */
  121663. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  121664. }
  121665. }
  121666. declare module BABYLON {
  121667. /**
  121668. * Bounding box gizmo
  121669. */
  121670. export class BoundingBoxGizmo extends Gizmo {
  121671. private _lineBoundingBox;
  121672. private _rotateSpheresParent;
  121673. private _scaleBoxesParent;
  121674. private _boundingDimensions;
  121675. private _renderObserver;
  121676. private _pointerObserver;
  121677. private _scaleDragSpeed;
  121678. private _tmpQuaternion;
  121679. private _tmpVector;
  121680. private _tmpRotationMatrix;
  121681. /**
  121682. * 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)
  121683. */
  121684. ignoreChildren: boolean;
  121685. /**
  121686. * 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)
  121687. */
  121688. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  121689. /**
  121690. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  121691. */
  121692. rotationSphereSize: number;
  121693. /**
  121694. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  121695. */
  121696. scaleBoxSize: number;
  121697. /**
  121698. * 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)
  121699. */
  121700. fixedDragMeshScreenSize: boolean;
  121701. /**
  121702. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  121703. */
  121704. fixedDragMeshScreenSizeDistanceFactor: number;
  121705. /**
  121706. * Fired when a rotation sphere or scale box is dragged
  121707. */
  121708. onDragStartObservable: Observable<{}>;
  121709. /**
  121710. * Fired when a scale box is dragged
  121711. */
  121712. onScaleBoxDragObservable: Observable<{}>;
  121713. /**
  121714. * Fired when a scale box drag is ended
  121715. */
  121716. onScaleBoxDragEndObservable: Observable<{}>;
  121717. /**
  121718. * Fired when a rotation sphere is dragged
  121719. */
  121720. onRotationSphereDragObservable: Observable<{}>;
  121721. /**
  121722. * Fired when a rotation sphere drag is ended
  121723. */
  121724. onRotationSphereDragEndObservable: Observable<{}>;
  121725. /**
  121726. * 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)
  121727. */
  121728. scalePivot: Nullable<Vector3>;
  121729. /**
  121730. * Mesh used as a pivot to rotate the attached mesh
  121731. */
  121732. private _anchorMesh;
  121733. private _existingMeshScale;
  121734. private _dragMesh;
  121735. private pointerDragBehavior;
  121736. private coloredMaterial;
  121737. private hoverColoredMaterial;
  121738. /**
  121739. * Sets the color of the bounding box gizmo
  121740. * @param color the color to set
  121741. */
  121742. setColor(color: Color3): void;
  121743. /**
  121744. * Creates an BoundingBoxGizmo
  121745. * @param gizmoLayer The utility layer the gizmo will be added to
  121746. * @param color The color of the gizmo
  121747. */
  121748. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  121749. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121750. private _selectNode;
  121751. /**
  121752. * Updates the bounding box information for the Gizmo
  121753. */
  121754. updateBoundingBox(): void;
  121755. private _updateRotationSpheres;
  121756. private _updateScaleBoxes;
  121757. /**
  121758. * Enables rotation on the specified axis and disables rotation on the others
  121759. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  121760. */
  121761. setEnabledRotationAxis(axis: string): void;
  121762. /**
  121763. * Enables/disables scaling
  121764. * @param enable if scaling should be enabled
  121765. */
  121766. setEnabledScaling(enable: boolean): void;
  121767. private _updateDummy;
  121768. /**
  121769. * Enables a pointer drag behavior on the bounding box of the gizmo
  121770. */
  121771. enableDragBehavior(): void;
  121772. /**
  121773. * Disposes of the gizmo
  121774. */
  121775. dispose(): void;
  121776. /**
  121777. * 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)
  121778. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  121779. * @returns the bounding box mesh with the passed in mesh as a child
  121780. */
  121781. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  121782. /**
  121783. * CustomMeshes are not supported by this gizmo
  121784. * @param mesh The mesh to replace the default mesh of the gizmo
  121785. */
  121786. setCustomMesh(mesh: Mesh): void;
  121787. }
  121788. }
  121789. declare module BABYLON {
  121790. /**
  121791. * Single plane rotation gizmo
  121792. */
  121793. export class PlaneRotationGizmo extends Gizmo {
  121794. /**
  121795. * Drag behavior responsible for the gizmos dragging interactions
  121796. */
  121797. dragBehavior: PointerDragBehavior;
  121798. private _pointerObserver;
  121799. /**
  121800. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  121801. */
  121802. snapDistance: number;
  121803. /**
  121804. * Event that fires each time the gizmo snaps to a new location.
  121805. * * snapDistance is the the change in distance
  121806. */
  121807. onSnapObservable: Observable<{
  121808. snapDistance: number;
  121809. }>;
  121810. private _isEnabled;
  121811. private _parent;
  121812. /**
  121813. * Creates a PlaneRotationGizmo
  121814. * @param gizmoLayer The utility layer the gizmo will be added to
  121815. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  121816. * @param color The color of the gizmo
  121817. * @param tessellation Amount of tessellation to be used when creating rotation circles
  121818. * @param useEulerRotation Use and update Euler angle instead of quaternion
  121819. */
  121820. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  121821. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121822. /**
  121823. * If the gizmo is enabled
  121824. */
  121825. set isEnabled(value: boolean);
  121826. get isEnabled(): boolean;
  121827. /**
  121828. * Disposes of the gizmo
  121829. */
  121830. dispose(): void;
  121831. }
  121832. }
  121833. declare module BABYLON {
  121834. /**
  121835. * Gizmo that enables rotating a mesh along 3 axis
  121836. */
  121837. export class RotationGizmo extends Gizmo {
  121838. /**
  121839. * Internal gizmo used for interactions on the x axis
  121840. */
  121841. xGizmo: PlaneRotationGizmo;
  121842. /**
  121843. * Internal gizmo used for interactions on the y axis
  121844. */
  121845. yGizmo: PlaneRotationGizmo;
  121846. /**
  121847. * Internal gizmo used for interactions on the z axis
  121848. */
  121849. zGizmo: PlaneRotationGizmo;
  121850. /** Fires an event when any of it's sub gizmos are dragged */
  121851. onDragStartObservable: Observable<unknown>;
  121852. /** Fires an event when any of it's sub gizmos are released from dragging */
  121853. onDragEndObservable: Observable<unknown>;
  121854. private _meshAttached;
  121855. get attachedMesh(): Nullable<AbstractMesh>;
  121856. set attachedMesh(mesh: Nullable<AbstractMesh>);
  121857. /**
  121858. * Creates a RotationGizmo
  121859. * @param gizmoLayer The utility layer the gizmo will be added to
  121860. * @param tessellation Amount of tessellation to be used when creating rotation circles
  121861. * @param useEulerRotation Use and update Euler angle instead of quaternion
  121862. */
  121863. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  121864. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  121865. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  121866. /**
  121867. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121868. */
  121869. set snapDistance(value: number);
  121870. get snapDistance(): number;
  121871. /**
  121872. * Ratio for the scale of the gizmo (Default: 1)
  121873. */
  121874. set scaleRatio(value: number);
  121875. get scaleRatio(): number;
  121876. /**
  121877. * Disposes of the gizmo
  121878. */
  121879. dispose(): void;
  121880. /**
  121881. * CustomMeshes are not supported by this gizmo
  121882. * @param mesh The mesh to replace the default mesh of the gizmo
  121883. */
  121884. setCustomMesh(mesh: Mesh): void;
  121885. }
  121886. }
  121887. declare module BABYLON {
  121888. /**
  121889. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  121890. */
  121891. export class GizmoManager implements IDisposable {
  121892. private scene;
  121893. /**
  121894. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  121895. */
  121896. gizmos: {
  121897. positionGizmo: Nullable<PositionGizmo>;
  121898. rotationGizmo: Nullable<RotationGizmo>;
  121899. scaleGizmo: Nullable<ScaleGizmo>;
  121900. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  121901. };
  121902. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  121903. clearGizmoOnEmptyPointerEvent: boolean;
  121904. /** Fires an event when the manager is attached to a mesh */
  121905. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  121906. private _gizmosEnabled;
  121907. private _pointerObserver;
  121908. private _attachedMesh;
  121909. private _boundingBoxColor;
  121910. private _defaultUtilityLayer;
  121911. private _defaultKeepDepthUtilityLayer;
  121912. /**
  121913. * When bounding box gizmo is enabled, this can be used to track drag/end events
  121914. */
  121915. boundingBoxDragBehavior: SixDofDragBehavior;
  121916. /**
  121917. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  121918. */
  121919. attachableMeshes: Nullable<Array<AbstractMesh>>;
  121920. /**
  121921. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  121922. */
  121923. usePointerToAttachGizmos: boolean;
  121924. /**
  121925. * Utility layer that the bounding box gizmo belongs to
  121926. */
  121927. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  121928. /**
  121929. * Utility layer that all gizmos besides bounding box belong to
  121930. */
  121931. get utilityLayer(): UtilityLayerRenderer;
  121932. /**
  121933. * Instatiates a gizmo manager
  121934. * @param scene the scene to overlay the gizmos on top of
  121935. */
  121936. constructor(scene: Scene);
  121937. /**
  121938. * Attaches a set of gizmos to the specified mesh
  121939. * @param mesh The mesh the gizmo's should be attached to
  121940. */
  121941. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  121942. /**
  121943. * If the position gizmo is enabled
  121944. */
  121945. set positionGizmoEnabled(value: boolean);
  121946. get positionGizmoEnabled(): boolean;
  121947. /**
  121948. * If the rotation gizmo is enabled
  121949. */
  121950. set rotationGizmoEnabled(value: boolean);
  121951. get rotationGizmoEnabled(): boolean;
  121952. /**
  121953. * If the scale gizmo is enabled
  121954. */
  121955. set scaleGizmoEnabled(value: boolean);
  121956. get scaleGizmoEnabled(): boolean;
  121957. /**
  121958. * If the boundingBox gizmo is enabled
  121959. */
  121960. set boundingBoxGizmoEnabled(value: boolean);
  121961. get boundingBoxGizmoEnabled(): boolean;
  121962. /**
  121963. * Disposes of the gizmo manager
  121964. */
  121965. dispose(): void;
  121966. }
  121967. }
  121968. declare module BABYLON {
  121969. /**
  121970. * A directional light is defined by a direction (what a surprise!).
  121971. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  121972. * 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.
  121973. * Documentation: https://doc.babylonjs.com/babylon101/lights
  121974. */
  121975. export class DirectionalLight extends ShadowLight {
  121976. private _shadowFrustumSize;
  121977. /**
  121978. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  121979. */
  121980. get shadowFrustumSize(): number;
  121981. /**
  121982. * Specifies a fix frustum size for the shadow generation.
  121983. */
  121984. set shadowFrustumSize(value: number);
  121985. private _shadowOrthoScale;
  121986. /**
  121987. * Gets the shadow projection scale against the optimal computed one.
  121988. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  121989. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  121990. */
  121991. get shadowOrthoScale(): number;
  121992. /**
  121993. * Sets the shadow projection scale against the optimal computed one.
  121994. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  121995. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  121996. */
  121997. set shadowOrthoScale(value: number);
  121998. /**
  121999. * Automatically compute the projection matrix to best fit (including all the casters)
  122000. * on each frame.
  122001. */
  122002. autoUpdateExtends: boolean;
  122003. /**
  122004. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  122005. * on each frame. autoUpdateExtends must be set to true for this to work
  122006. */
  122007. autoCalcShadowZBounds: boolean;
  122008. private _orthoLeft;
  122009. private _orthoRight;
  122010. private _orthoTop;
  122011. private _orthoBottom;
  122012. /**
  122013. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  122014. * The directional light is emitted from everywhere in the given direction.
  122015. * It can cast shadows.
  122016. * Documentation : https://doc.babylonjs.com/babylon101/lights
  122017. * @param name The friendly name of the light
  122018. * @param direction The direction of the light
  122019. * @param scene The scene the light belongs to
  122020. */
  122021. constructor(name: string, direction: Vector3, scene: Scene);
  122022. /**
  122023. * Returns the string "DirectionalLight".
  122024. * @return The class name
  122025. */
  122026. getClassName(): string;
  122027. /**
  122028. * Returns the integer 1.
  122029. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  122030. */
  122031. getTypeID(): number;
  122032. /**
  122033. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  122034. * Returns the DirectionalLight Shadow projection matrix.
  122035. */
  122036. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  122037. /**
  122038. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  122039. * Returns the DirectionalLight Shadow projection matrix.
  122040. */
  122041. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  122042. /**
  122043. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  122044. * Returns the DirectionalLight Shadow projection matrix.
  122045. */
  122046. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  122047. protected _buildUniformLayout(): void;
  122048. /**
  122049. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  122050. * @param effect The effect to update
  122051. * @param lightIndex The index of the light in the effect to update
  122052. * @returns The directional light
  122053. */
  122054. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  122055. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  122056. /**
  122057. * Gets the minZ used for shadow according to both the scene and the light.
  122058. *
  122059. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  122060. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  122061. * @param activeCamera The camera we are returning the min for
  122062. * @returns the depth min z
  122063. */
  122064. getDepthMinZ(activeCamera: Camera): number;
  122065. /**
  122066. * Gets the maxZ used for shadow according to both the scene and the light.
  122067. *
  122068. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  122069. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  122070. * @param activeCamera The camera we are returning the max for
  122071. * @returns the depth max z
  122072. */
  122073. getDepthMaxZ(activeCamera: Camera): number;
  122074. /**
  122075. * Prepares the list of defines specific to the light type.
  122076. * @param defines the list of defines
  122077. * @param lightIndex defines the index of the light for the effect
  122078. */
  122079. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  122080. }
  122081. }
  122082. declare module BABYLON {
  122083. /**
  122084. * Class containing static functions to help procedurally build meshes
  122085. */
  122086. export class HemisphereBuilder {
  122087. /**
  122088. * Creates a hemisphere mesh
  122089. * @param name defines the name of the mesh
  122090. * @param options defines the options used to create the mesh
  122091. * @param scene defines the hosting scene
  122092. * @returns the hemisphere mesh
  122093. */
  122094. static CreateHemisphere(name: string, options: {
  122095. segments?: number;
  122096. diameter?: number;
  122097. sideOrientation?: number;
  122098. }, scene: any): Mesh;
  122099. }
  122100. }
  122101. declare module BABYLON {
  122102. /**
  122103. * A spot light is defined by a position, a direction, an angle, and an exponent.
  122104. * These values define a cone of light starting from the position, emitting toward the direction.
  122105. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  122106. * and the exponent defines the speed of the decay of the light with distance (reach).
  122107. * Documentation: https://doc.babylonjs.com/babylon101/lights
  122108. */
  122109. export class SpotLight extends ShadowLight {
  122110. private _angle;
  122111. private _innerAngle;
  122112. private _cosHalfAngle;
  122113. private _lightAngleScale;
  122114. private _lightAngleOffset;
  122115. /**
  122116. * Gets the cone angle of the spot light in Radians.
  122117. */
  122118. get angle(): number;
  122119. /**
  122120. * Sets the cone angle of the spot light in Radians.
  122121. */
  122122. set angle(value: number);
  122123. /**
  122124. * Only used in gltf falloff mode, this defines the angle where
  122125. * the directional falloff will start before cutting at angle which could be seen
  122126. * as outer angle.
  122127. */
  122128. get innerAngle(): number;
  122129. /**
  122130. * Only used in gltf falloff mode, this defines the angle where
  122131. * the directional falloff will start before cutting at angle which could be seen
  122132. * as outer angle.
  122133. */
  122134. set innerAngle(value: number);
  122135. private _shadowAngleScale;
  122136. /**
  122137. * Allows scaling the angle of the light for shadow generation only.
  122138. */
  122139. get shadowAngleScale(): number;
  122140. /**
  122141. * Allows scaling the angle of the light for shadow generation only.
  122142. */
  122143. set shadowAngleScale(value: number);
  122144. /**
  122145. * The light decay speed with the distance from the emission spot.
  122146. */
  122147. exponent: number;
  122148. private _projectionTextureMatrix;
  122149. /**
  122150. * Allows reading the projecton texture
  122151. */
  122152. get projectionTextureMatrix(): Matrix;
  122153. protected _projectionTextureLightNear: number;
  122154. /**
  122155. * Gets the near clip of the Spotlight for texture projection.
  122156. */
  122157. get projectionTextureLightNear(): number;
  122158. /**
  122159. * Sets the near clip of the Spotlight for texture projection.
  122160. */
  122161. set projectionTextureLightNear(value: number);
  122162. protected _projectionTextureLightFar: number;
  122163. /**
  122164. * Gets the far clip of the Spotlight for texture projection.
  122165. */
  122166. get projectionTextureLightFar(): number;
  122167. /**
  122168. * Sets the far clip of the Spotlight for texture projection.
  122169. */
  122170. set projectionTextureLightFar(value: number);
  122171. protected _projectionTextureUpDirection: Vector3;
  122172. /**
  122173. * Gets the Up vector of the Spotlight for texture projection.
  122174. */
  122175. get projectionTextureUpDirection(): Vector3;
  122176. /**
  122177. * Sets the Up vector of the Spotlight for texture projection.
  122178. */
  122179. set projectionTextureUpDirection(value: Vector3);
  122180. private _projectionTexture;
  122181. /**
  122182. * Gets the projection texture of the light.
  122183. */
  122184. get projectionTexture(): Nullable<BaseTexture>;
  122185. /**
  122186. * Sets the projection texture of the light.
  122187. */
  122188. set projectionTexture(value: Nullable<BaseTexture>);
  122189. private _projectionTextureViewLightDirty;
  122190. private _projectionTextureProjectionLightDirty;
  122191. private _projectionTextureDirty;
  122192. private _projectionTextureViewTargetVector;
  122193. private _projectionTextureViewLightMatrix;
  122194. private _projectionTextureProjectionLightMatrix;
  122195. private _projectionTextureScalingMatrix;
  122196. /**
  122197. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  122198. * It can cast shadows.
  122199. * Documentation : https://doc.babylonjs.com/babylon101/lights
  122200. * @param name The light friendly name
  122201. * @param position The position of the spot light in the scene
  122202. * @param direction The direction of the light in the scene
  122203. * @param angle The cone angle of the light in Radians
  122204. * @param exponent The light decay speed with the distance from the emission spot
  122205. * @param scene The scene the lights belongs to
  122206. */
  122207. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  122208. /**
  122209. * Returns the string "SpotLight".
  122210. * @returns the class name
  122211. */
  122212. getClassName(): string;
  122213. /**
  122214. * Returns the integer 2.
  122215. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  122216. */
  122217. getTypeID(): number;
  122218. /**
  122219. * Overrides the direction setter to recompute the projection texture view light Matrix.
  122220. */
  122221. protected _setDirection(value: Vector3): void;
  122222. /**
  122223. * Overrides the position setter to recompute the projection texture view light Matrix.
  122224. */
  122225. protected _setPosition(value: Vector3): void;
  122226. /**
  122227. * 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.
  122228. * Returns the SpotLight.
  122229. */
  122230. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  122231. protected _computeProjectionTextureViewLightMatrix(): void;
  122232. protected _computeProjectionTextureProjectionLightMatrix(): void;
  122233. /**
  122234. * Main function for light texture projection matrix computing.
  122235. */
  122236. protected _computeProjectionTextureMatrix(): void;
  122237. protected _buildUniformLayout(): void;
  122238. private _computeAngleValues;
  122239. /**
  122240. * Sets the passed Effect "effect" with the Light textures.
  122241. * @param effect The effect to update
  122242. * @param lightIndex The index of the light in the effect to update
  122243. * @returns The light
  122244. */
  122245. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  122246. /**
  122247. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  122248. * @param effect The effect to update
  122249. * @param lightIndex The index of the light in the effect to update
  122250. * @returns The spot light
  122251. */
  122252. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  122253. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  122254. /**
  122255. * Disposes the light and the associated resources.
  122256. */
  122257. dispose(): void;
  122258. /**
  122259. * Prepares the list of defines specific to the light type.
  122260. * @param defines the list of defines
  122261. * @param lightIndex defines the index of the light for the effect
  122262. */
  122263. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  122264. }
  122265. }
  122266. declare module BABYLON {
  122267. /**
  122268. * Gizmo that enables viewing a light
  122269. */
  122270. export class LightGizmo extends Gizmo {
  122271. private _lightMesh;
  122272. private _material;
  122273. private _cachedPosition;
  122274. private _cachedForward;
  122275. private _attachedMeshParent;
  122276. /**
  122277. * Creates a LightGizmo
  122278. * @param gizmoLayer The utility layer the gizmo will be added to
  122279. */
  122280. constructor(gizmoLayer?: UtilityLayerRenderer);
  122281. private _light;
  122282. /**
  122283. * The light that the gizmo is attached to
  122284. */
  122285. set light(light: Nullable<Light>);
  122286. get light(): Nullable<Light>;
  122287. /**
  122288. * Gets the material used to render the light gizmo
  122289. */
  122290. get material(): StandardMaterial;
  122291. /**
  122292. * @hidden
  122293. * Updates the gizmo to match the attached mesh's position/rotation
  122294. */
  122295. protected _update(): void;
  122296. private static _Scale;
  122297. /**
  122298. * Creates the lines for a light mesh
  122299. */
  122300. private static _CreateLightLines;
  122301. /**
  122302. * Disposes of the light gizmo
  122303. */
  122304. dispose(): void;
  122305. private static _CreateHemisphericLightMesh;
  122306. private static _CreatePointLightMesh;
  122307. private static _CreateSpotLightMesh;
  122308. private static _CreateDirectionalLightMesh;
  122309. }
  122310. }
  122311. declare module BABYLON {
  122312. /** @hidden */
  122313. export var backgroundFragmentDeclaration: {
  122314. name: string;
  122315. shader: string;
  122316. };
  122317. }
  122318. declare module BABYLON {
  122319. /** @hidden */
  122320. export var backgroundUboDeclaration: {
  122321. name: string;
  122322. shader: string;
  122323. };
  122324. }
  122325. declare module BABYLON {
  122326. /** @hidden */
  122327. export var backgroundPixelShader: {
  122328. name: string;
  122329. shader: string;
  122330. };
  122331. }
  122332. declare module BABYLON {
  122333. /** @hidden */
  122334. export var backgroundVertexDeclaration: {
  122335. name: string;
  122336. shader: string;
  122337. };
  122338. }
  122339. declare module BABYLON {
  122340. /** @hidden */
  122341. export var backgroundVertexShader: {
  122342. name: string;
  122343. shader: string;
  122344. };
  122345. }
  122346. declare module BABYLON {
  122347. /**
  122348. * Background material used to create an efficient environement around your scene.
  122349. */
  122350. export class BackgroundMaterial extends PushMaterial {
  122351. /**
  122352. * Standard reflectance value at parallel view angle.
  122353. */
  122354. static StandardReflectance0: number;
  122355. /**
  122356. * Standard reflectance value at grazing angle.
  122357. */
  122358. static StandardReflectance90: number;
  122359. protected _primaryColor: Color3;
  122360. /**
  122361. * Key light Color (multiply against the environement texture)
  122362. */
  122363. primaryColor: Color3;
  122364. protected __perceptualColor: Nullable<Color3>;
  122365. /**
  122366. * Experimental Internal Use Only.
  122367. *
  122368. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  122369. * This acts as a helper to set the primary color to a more "human friendly" value.
  122370. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  122371. * output color as close as possible from the chosen value.
  122372. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  122373. * part of lighting setup.)
  122374. */
  122375. get _perceptualColor(): Nullable<Color3>;
  122376. set _perceptualColor(value: Nullable<Color3>);
  122377. protected _primaryColorShadowLevel: float;
  122378. /**
  122379. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  122380. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  122381. */
  122382. get primaryColorShadowLevel(): float;
  122383. set primaryColorShadowLevel(value: float);
  122384. protected _primaryColorHighlightLevel: float;
  122385. /**
  122386. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  122387. * The primary color is used at the level chosen to define what the white area would look.
  122388. */
  122389. get primaryColorHighlightLevel(): float;
  122390. set primaryColorHighlightLevel(value: float);
  122391. protected _reflectionTexture: Nullable<BaseTexture>;
  122392. /**
  122393. * Reflection Texture used in the material.
  122394. * Should be author in a specific way for the best result (refer to the documentation).
  122395. */
  122396. reflectionTexture: Nullable<BaseTexture>;
  122397. protected _reflectionBlur: float;
  122398. /**
  122399. * Reflection Texture level of blur.
  122400. *
  122401. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  122402. * texture twice.
  122403. */
  122404. reflectionBlur: float;
  122405. protected _diffuseTexture: Nullable<BaseTexture>;
  122406. /**
  122407. * Diffuse Texture used in the material.
  122408. * Should be author in a specific way for the best result (refer to the documentation).
  122409. */
  122410. diffuseTexture: Nullable<BaseTexture>;
  122411. protected _shadowLights: Nullable<IShadowLight[]>;
  122412. /**
  122413. * Specify the list of lights casting shadow on the material.
  122414. * All scene shadow lights will be included if null.
  122415. */
  122416. shadowLights: Nullable<IShadowLight[]>;
  122417. protected _shadowLevel: float;
  122418. /**
  122419. * Helps adjusting the shadow to a softer level if required.
  122420. * 0 means black shadows and 1 means no shadows.
  122421. */
  122422. shadowLevel: float;
  122423. protected _sceneCenter: Vector3;
  122424. /**
  122425. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  122426. * It is usually zero but might be interesting to modify according to your setup.
  122427. */
  122428. sceneCenter: Vector3;
  122429. protected _opacityFresnel: boolean;
  122430. /**
  122431. * This helps specifying that the material is falling off to the sky box at grazing angle.
  122432. * This helps ensuring a nice transition when the camera goes under the ground.
  122433. */
  122434. opacityFresnel: boolean;
  122435. protected _reflectionFresnel: boolean;
  122436. /**
  122437. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  122438. * This helps adding a mirror texture on the ground.
  122439. */
  122440. reflectionFresnel: boolean;
  122441. protected _reflectionFalloffDistance: number;
  122442. /**
  122443. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  122444. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  122445. */
  122446. reflectionFalloffDistance: number;
  122447. protected _reflectionAmount: number;
  122448. /**
  122449. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  122450. */
  122451. reflectionAmount: number;
  122452. protected _reflectionReflectance0: number;
  122453. /**
  122454. * This specifies the weight of the reflection at grazing angle.
  122455. */
  122456. reflectionReflectance0: number;
  122457. protected _reflectionReflectance90: number;
  122458. /**
  122459. * This specifies the weight of the reflection at a perpendicular point of view.
  122460. */
  122461. reflectionReflectance90: number;
  122462. /**
  122463. * Sets the reflection reflectance fresnel values according to the default standard
  122464. * empirically know to work well :-)
  122465. */
  122466. set reflectionStandardFresnelWeight(value: number);
  122467. protected _useRGBColor: boolean;
  122468. /**
  122469. * Helps to directly use the maps channels instead of their level.
  122470. */
  122471. useRGBColor: boolean;
  122472. protected _enableNoise: boolean;
  122473. /**
  122474. * This helps reducing the banding effect that could occur on the background.
  122475. */
  122476. enableNoise: boolean;
  122477. /**
  122478. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  122479. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  122480. * Recommended to be keep at 1.0 except for special cases.
  122481. */
  122482. get fovMultiplier(): number;
  122483. set fovMultiplier(value: number);
  122484. private _fovMultiplier;
  122485. /**
  122486. * Enable the FOV adjustment feature controlled by fovMultiplier.
  122487. */
  122488. useEquirectangularFOV: boolean;
  122489. private _maxSimultaneousLights;
  122490. /**
  122491. * Number of Simultaneous lights allowed on the material.
  122492. */
  122493. maxSimultaneousLights: int;
  122494. /**
  122495. * Default configuration related to image processing available in the Background Material.
  122496. */
  122497. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  122498. /**
  122499. * Keep track of the image processing observer to allow dispose and replace.
  122500. */
  122501. private _imageProcessingObserver;
  122502. /**
  122503. * Attaches a new image processing configuration to the PBR Material.
  122504. * @param configuration (if null the scene configuration will be use)
  122505. */
  122506. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  122507. /**
  122508. * Gets the image processing configuration used either in this material.
  122509. */
  122510. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  122511. /**
  122512. * Sets the Default image processing configuration used either in the this material.
  122513. *
  122514. * If sets to null, the scene one is in use.
  122515. */
  122516. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  122517. /**
  122518. * Gets wether the color curves effect is enabled.
  122519. */
  122520. get cameraColorCurvesEnabled(): boolean;
  122521. /**
  122522. * Sets wether the color curves effect is enabled.
  122523. */
  122524. set cameraColorCurvesEnabled(value: boolean);
  122525. /**
  122526. * Gets wether the color grading effect is enabled.
  122527. */
  122528. get cameraColorGradingEnabled(): boolean;
  122529. /**
  122530. * Gets wether the color grading effect is enabled.
  122531. */
  122532. set cameraColorGradingEnabled(value: boolean);
  122533. /**
  122534. * Gets wether tonemapping is enabled or not.
  122535. */
  122536. get cameraToneMappingEnabled(): boolean;
  122537. /**
  122538. * Sets wether tonemapping is enabled or not
  122539. */
  122540. set cameraToneMappingEnabled(value: boolean);
  122541. /**
  122542. * The camera exposure used on this material.
  122543. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  122544. * This corresponds to a photographic exposure.
  122545. */
  122546. get cameraExposure(): float;
  122547. /**
  122548. * The camera exposure used on this material.
  122549. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  122550. * This corresponds to a photographic exposure.
  122551. */
  122552. set cameraExposure(value: float);
  122553. /**
  122554. * Gets The camera contrast used on this material.
  122555. */
  122556. get cameraContrast(): float;
  122557. /**
  122558. * Sets The camera contrast used on this material.
  122559. */
  122560. set cameraContrast(value: float);
  122561. /**
  122562. * Gets the Color Grading 2D Lookup Texture.
  122563. */
  122564. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  122565. /**
  122566. * Sets the Color Grading 2D Lookup Texture.
  122567. */
  122568. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  122569. /**
  122570. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  122571. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  122572. * 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;
  122573. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  122574. */
  122575. get cameraColorCurves(): Nullable<ColorCurves>;
  122576. /**
  122577. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  122578. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  122579. * 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;
  122580. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  122581. */
  122582. set cameraColorCurves(value: Nullable<ColorCurves>);
  122583. /**
  122584. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  122585. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  122586. */
  122587. switchToBGR: boolean;
  122588. private _renderTargets;
  122589. private _reflectionControls;
  122590. private _white;
  122591. private _primaryShadowColor;
  122592. private _primaryHighlightColor;
  122593. /**
  122594. * Instantiates a Background Material in the given scene
  122595. * @param name The friendly name of the material
  122596. * @param scene The scene to add the material to
  122597. */
  122598. constructor(name: string, scene: Scene);
  122599. /**
  122600. * Gets a boolean indicating that current material needs to register RTT
  122601. */
  122602. get hasRenderTargetTextures(): boolean;
  122603. /**
  122604. * The entire material has been created in order to prevent overdraw.
  122605. * @returns false
  122606. */
  122607. needAlphaTesting(): boolean;
  122608. /**
  122609. * The entire material has been created in order to prevent overdraw.
  122610. * @returns true if blending is enable
  122611. */
  122612. needAlphaBlending(): boolean;
  122613. /**
  122614. * Checks wether the material is ready to be rendered for a given mesh.
  122615. * @param mesh The mesh to render
  122616. * @param subMesh The submesh to check against
  122617. * @param useInstances Specify wether or not the material is used with instances
  122618. * @returns true if all the dependencies are ready (Textures, Effects...)
  122619. */
  122620. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  122621. /**
  122622. * Compute the primary color according to the chosen perceptual color.
  122623. */
  122624. private _computePrimaryColorFromPerceptualColor;
  122625. /**
  122626. * Compute the highlights and shadow colors according to their chosen levels.
  122627. */
  122628. private _computePrimaryColors;
  122629. /**
  122630. * Build the uniform buffer used in the material.
  122631. */
  122632. buildUniformLayout(): void;
  122633. /**
  122634. * Unbind the material.
  122635. */
  122636. unbind(): void;
  122637. /**
  122638. * Bind only the world matrix to the material.
  122639. * @param world The world matrix to bind.
  122640. */
  122641. bindOnlyWorldMatrix(world: Matrix): void;
  122642. /**
  122643. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  122644. * @param world The world matrix to bind.
  122645. * @param subMesh The submesh to bind for.
  122646. */
  122647. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  122648. /**
  122649. * Checks to see if a texture is used in the material.
  122650. * @param texture - Base texture to use.
  122651. * @returns - Boolean specifying if a texture is used in the material.
  122652. */
  122653. hasTexture(texture: BaseTexture): boolean;
  122654. /**
  122655. * Dispose the material.
  122656. * @param forceDisposeEffect Force disposal of the associated effect.
  122657. * @param forceDisposeTextures Force disposal of the associated textures.
  122658. */
  122659. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  122660. /**
  122661. * Clones the material.
  122662. * @param name The cloned name.
  122663. * @returns The cloned material.
  122664. */
  122665. clone(name: string): BackgroundMaterial;
  122666. /**
  122667. * Serializes the current material to its JSON representation.
  122668. * @returns The JSON representation.
  122669. */
  122670. serialize(): any;
  122671. /**
  122672. * Gets the class name of the material
  122673. * @returns "BackgroundMaterial"
  122674. */
  122675. getClassName(): string;
  122676. /**
  122677. * Parse a JSON input to create back a background material.
  122678. * @param source The JSON data to parse
  122679. * @param scene The scene to create the parsed material in
  122680. * @param rootUrl The root url of the assets the material depends upon
  122681. * @returns the instantiated BackgroundMaterial.
  122682. */
  122683. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  122684. }
  122685. }
  122686. declare module BABYLON {
  122687. /**
  122688. * Represents the different options available during the creation of
  122689. * a Environment helper.
  122690. *
  122691. * This can control the default ground, skybox and image processing setup of your scene.
  122692. */
  122693. export interface IEnvironmentHelperOptions {
  122694. /**
  122695. * Specifies whether or not to create a ground.
  122696. * True by default.
  122697. */
  122698. createGround: boolean;
  122699. /**
  122700. * Specifies the ground size.
  122701. * 15 by default.
  122702. */
  122703. groundSize: number;
  122704. /**
  122705. * The texture used on the ground for the main color.
  122706. * Comes from the BabylonJS CDN by default.
  122707. *
  122708. * Remarks: Can be either a texture or a url.
  122709. */
  122710. groundTexture: string | BaseTexture;
  122711. /**
  122712. * The color mixed in the ground texture by default.
  122713. * BabylonJS clearColor by default.
  122714. */
  122715. groundColor: Color3;
  122716. /**
  122717. * Specifies the ground opacity.
  122718. * 1 by default.
  122719. */
  122720. groundOpacity: number;
  122721. /**
  122722. * Enables the ground to receive shadows.
  122723. * True by default.
  122724. */
  122725. enableGroundShadow: boolean;
  122726. /**
  122727. * Helps preventing the shadow to be fully black on the ground.
  122728. * 0.5 by default.
  122729. */
  122730. groundShadowLevel: number;
  122731. /**
  122732. * Creates a mirror texture attach to the ground.
  122733. * false by default.
  122734. */
  122735. enableGroundMirror: boolean;
  122736. /**
  122737. * Specifies the ground mirror size ratio.
  122738. * 0.3 by default as the default kernel is 64.
  122739. */
  122740. groundMirrorSizeRatio: number;
  122741. /**
  122742. * Specifies the ground mirror blur kernel size.
  122743. * 64 by default.
  122744. */
  122745. groundMirrorBlurKernel: number;
  122746. /**
  122747. * Specifies the ground mirror visibility amount.
  122748. * 1 by default
  122749. */
  122750. groundMirrorAmount: number;
  122751. /**
  122752. * Specifies the ground mirror reflectance weight.
  122753. * This uses the standard weight of the background material to setup the fresnel effect
  122754. * of the mirror.
  122755. * 1 by default.
  122756. */
  122757. groundMirrorFresnelWeight: number;
  122758. /**
  122759. * Specifies the ground mirror Falloff distance.
  122760. * This can helps reducing the size of the reflection.
  122761. * 0 by Default.
  122762. */
  122763. groundMirrorFallOffDistance: number;
  122764. /**
  122765. * Specifies the ground mirror texture type.
  122766. * Unsigned Int by Default.
  122767. */
  122768. groundMirrorTextureType: number;
  122769. /**
  122770. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  122771. * the shown objects.
  122772. */
  122773. groundYBias: number;
  122774. /**
  122775. * Specifies whether or not to create a skybox.
  122776. * True by default.
  122777. */
  122778. createSkybox: boolean;
  122779. /**
  122780. * Specifies the skybox size.
  122781. * 20 by default.
  122782. */
  122783. skyboxSize: number;
  122784. /**
  122785. * The texture used on the skybox for the main color.
  122786. * Comes from the BabylonJS CDN by default.
  122787. *
  122788. * Remarks: Can be either a texture or a url.
  122789. */
  122790. skyboxTexture: string | BaseTexture;
  122791. /**
  122792. * The color mixed in the skybox texture by default.
  122793. * BabylonJS clearColor by default.
  122794. */
  122795. skyboxColor: Color3;
  122796. /**
  122797. * The background rotation around the Y axis of the scene.
  122798. * This helps aligning the key lights of your scene with the background.
  122799. * 0 by default.
  122800. */
  122801. backgroundYRotation: number;
  122802. /**
  122803. * Compute automatically the size of the elements to best fit with the scene.
  122804. */
  122805. sizeAuto: boolean;
  122806. /**
  122807. * Default position of the rootMesh if autoSize is not true.
  122808. */
  122809. rootPosition: Vector3;
  122810. /**
  122811. * Sets up the image processing in the scene.
  122812. * true by default.
  122813. */
  122814. setupImageProcessing: boolean;
  122815. /**
  122816. * The texture used as your environment texture in the scene.
  122817. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  122818. *
  122819. * Remarks: Can be either a texture or a url.
  122820. */
  122821. environmentTexture: string | BaseTexture;
  122822. /**
  122823. * The value of the exposure to apply to the scene.
  122824. * 0.6 by default if setupImageProcessing is true.
  122825. */
  122826. cameraExposure: number;
  122827. /**
  122828. * The value of the contrast to apply to the scene.
  122829. * 1.6 by default if setupImageProcessing is true.
  122830. */
  122831. cameraContrast: number;
  122832. /**
  122833. * Specifies whether or not tonemapping should be enabled in the scene.
  122834. * true by default if setupImageProcessing is true.
  122835. */
  122836. toneMappingEnabled: boolean;
  122837. }
  122838. /**
  122839. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  122840. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  122841. * It also helps with the default setup of your imageProcessing configuration.
  122842. */
  122843. export class EnvironmentHelper {
  122844. /**
  122845. * Default ground texture URL.
  122846. */
  122847. private static _groundTextureCDNUrl;
  122848. /**
  122849. * Default skybox texture URL.
  122850. */
  122851. private static _skyboxTextureCDNUrl;
  122852. /**
  122853. * Default environment texture URL.
  122854. */
  122855. private static _environmentTextureCDNUrl;
  122856. /**
  122857. * Creates the default options for the helper.
  122858. */
  122859. private static _getDefaultOptions;
  122860. private _rootMesh;
  122861. /**
  122862. * Gets the root mesh created by the helper.
  122863. */
  122864. get rootMesh(): Mesh;
  122865. private _skybox;
  122866. /**
  122867. * Gets the skybox created by the helper.
  122868. */
  122869. get skybox(): Nullable<Mesh>;
  122870. private _skyboxTexture;
  122871. /**
  122872. * Gets the skybox texture created by the helper.
  122873. */
  122874. get skyboxTexture(): Nullable<BaseTexture>;
  122875. private _skyboxMaterial;
  122876. /**
  122877. * Gets the skybox material created by the helper.
  122878. */
  122879. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  122880. private _ground;
  122881. /**
  122882. * Gets the ground mesh created by the helper.
  122883. */
  122884. get ground(): Nullable<Mesh>;
  122885. private _groundTexture;
  122886. /**
  122887. * Gets the ground texture created by the helper.
  122888. */
  122889. get groundTexture(): Nullable<BaseTexture>;
  122890. private _groundMirror;
  122891. /**
  122892. * Gets the ground mirror created by the helper.
  122893. */
  122894. get groundMirror(): Nullable<MirrorTexture>;
  122895. /**
  122896. * Gets the ground mirror render list to helps pushing the meshes
  122897. * you wish in the ground reflection.
  122898. */
  122899. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  122900. private _groundMaterial;
  122901. /**
  122902. * Gets the ground material created by the helper.
  122903. */
  122904. get groundMaterial(): Nullable<BackgroundMaterial>;
  122905. /**
  122906. * Stores the creation options.
  122907. */
  122908. private readonly _scene;
  122909. private _options;
  122910. /**
  122911. * This observable will be notified with any error during the creation of the environment,
  122912. * mainly texture creation errors.
  122913. */
  122914. onErrorObservable: Observable<{
  122915. message?: string;
  122916. exception?: any;
  122917. }>;
  122918. /**
  122919. * constructor
  122920. * @param options Defines the options we want to customize the helper
  122921. * @param scene The scene to add the material to
  122922. */
  122923. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  122924. /**
  122925. * Updates the background according to the new options
  122926. * @param options
  122927. */
  122928. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  122929. /**
  122930. * Sets the primary color of all the available elements.
  122931. * @param color the main color to affect to the ground and the background
  122932. */
  122933. setMainColor(color: Color3): void;
  122934. /**
  122935. * Setup the image processing according to the specified options.
  122936. */
  122937. private _setupImageProcessing;
  122938. /**
  122939. * Setup the environment texture according to the specified options.
  122940. */
  122941. private _setupEnvironmentTexture;
  122942. /**
  122943. * Setup the background according to the specified options.
  122944. */
  122945. private _setupBackground;
  122946. /**
  122947. * Get the scene sizes according to the setup.
  122948. */
  122949. private _getSceneSize;
  122950. /**
  122951. * Setup the ground according to the specified options.
  122952. */
  122953. private _setupGround;
  122954. /**
  122955. * Setup the ground material according to the specified options.
  122956. */
  122957. private _setupGroundMaterial;
  122958. /**
  122959. * Setup the ground diffuse texture according to the specified options.
  122960. */
  122961. private _setupGroundDiffuseTexture;
  122962. /**
  122963. * Setup the ground mirror texture according to the specified options.
  122964. */
  122965. private _setupGroundMirrorTexture;
  122966. /**
  122967. * Setup the ground to receive the mirror texture.
  122968. */
  122969. private _setupMirrorInGroundMaterial;
  122970. /**
  122971. * Setup the skybox according to the specified options.
  122972. */
  122973. private _setupSkybox;
  122974. /**
  122975. * Setup the skybox material according to the specified options.
  122976. */
  122977. private _setupSkyboxMaterial;
  122978. /**
  122979. * Setup the skybox reflection texture according to the specified options.
  122980. */
  122981. private _setupSkyboxReflectionTexture;
  122982. private _errorHandler;
  122983. /**
  122984. * Dispose all the elements created by the Helper.
  122985. */
  122986. dispose(): void;
  122987. }
  122988. }
  122989. declare module BABYLON {
  122990. /**
  122991. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  122992. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  122993. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  122994. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  122995. */
  122996. export class PhotoDome extends TransformNode {
  122997. /**
  122998. * Define the image as a Monoscopic panoramic 360 image.
  122999. */
  123000. static readonly MODE_MONOSCOPIC: number;
  123001. /**
  123002. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  123003. */
  123004. static readonly MODE_TOPBOTTOM: number;
  123005. /**
  123006. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  123007. */
  123008. static readonly MODE_SIDEBYSIDE: number;
  123009. private _useDirectMapping;
  123010. /**
  123011. * The texture being displayed on the sphere
  123012. */
  123013. protected _photoTexture: Texture;
  123014. /**
  123015. * Gets or sets the texture being displayed on the sphere
  123016. */
  123017. get photoTexture(): Texture;
  123018. set photoTexture(value: Texture);
  123019. /**
  123020. * Observable raised when an error occured while loading the 360 image
  123021. */
  123022. onLoadErrorObservable: Observable<string>;
  123023. /**
  123024. * The skybox material
  123025. */
  123026. protected _material: BackgroundMaterial;
  123027. /**
  123028. * The surface used for the skybox
  123029. */
  123030. protected _mesh: Mesh;
  123031. /**
  123032. * Gets the mesh used for the skybox.
  123033. */
  123034. get mesh(): Mesh;
  123035. /**
  123036. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  123037. * Also see the options.resolution property.
  123038. */
  123039. get fovMultiplier(): number;
  123040. set fovMultiplier(value: number);
  123041. private _imageMode;
  123042. /**
  123043. * Gets or set the current video mode for the video. It can be:
  123044. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  123045. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  123046. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  123047. */
  123048. get imageMode(): number;
  123049. set imageMode(value: number);
  123050. /**
  123051. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  123052. * @param name Element's name, child elements will append suffixes for their own names.
  123053. * @param urlsOfPhoto defines the url of the photo to display
  123054. * @param options defines an object containing optional or exposed sub element properties
  123055. * @param onError defines a callback called when an error occured while loading the texture
  123056. */
  123057. constructor(name: string, urlOfPhoto: string, options: {
  123058. resolution?: number;
  123059. size?: number;
  123060. useDirectMapping?: boolean;
  123061. faceForward?: boolean;
  123062. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  123063. private _onBeforeCameraRenderObserver;
  123064. private _changeImageMode;
  123065. /**
  123066. * Releases resources associated with this node.
  123067. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  123068. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  123069. */
  123070. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  123071. }
  123072. }
  123073. declare module BABYLON {
  123074. /**
  123075. * Class used to host RGBD texture specific utilities
  123076. */
  123077. export class RGBDTextureTools {
  123078. /**
  123079. * Expand the RGBD Texture from RGBD to Half Float if possible.
  123080. * @param texture the texture to expand.
  123081. */
  123082. static ExpandRGBDTexture(texture: Texture): void;
  123083. }
  123084. }
  123085. declare module BABYLON {
  123086. /**
  123087. * Class used to host texture specific utilities
  123088. */
  123089. export class BRDFTextureTools {
  123090. /**
  123091. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  123092. * @param scene defines the hosting scene
  123093. * @returns the environment BRDF texture
  123094. */
  123095. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  123096. private static _environmentBRDFBase64Texture;
  123097. }
  123098. }
  123099. declare module BABYLON {
  123100. /**
  123101. * @hidden
  123102. */
  123103. export interface IMaterialClearCoatDefines {
  123104. CLEARCOAT: boolean;
  123105. CLEARCOAT_DEFAULTIOR: boolean;
  123106. CLEARCOAT_TEXTURE: boolean;
  123107. CLEARCOAT_TEXTUREDIRECTUV: number;
  123108. CLEARCOAT_BUMP: boolean;
  123109. CLEARCOAT_BUMPDIRECTUV: number;
  123110. CLEARCOAT_TINT: boolean;
  123111. CLEARCOAT_TINT_TEXTURE: boolean;
  123112. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  123113. /** @hidden */
  123114. _areTexturesDirty: boolean;
  123115. }
  123116. /**
  123117. * Define the code related to the clear coat parameters of the pbr material.
  123118. */
  123119. export class PBRClearCoatConfiguration {
  123120. /**
  123121. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  123122. * The default fits with a polyurethane material.
  123123. */
  123124. private static readonly _DefaultIndexOfRefraction;
  123125. private _isEnabled;
  123126. /**
  123127. * Defines if the clear coat is enabled in the material.
  123128. */
  123129. isEnabled: boolean;
  123130. /**
  123131. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  123132. */
  123133. intensity: number;
  123134. /**
  123135. * Defines the clear coat layer roughness.
  123136. */
  123137. roughness: number;
  123138. private _indexOfRefraction;
  123139. /**
  123140. * Defines the index of refraction of the clear coat.
  123141. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  123142. * The default fits with a polyurethane material.
  123143. * Changing the default value is more performance intensive.
  123144. */
  123145. indexOfRefraction: number;
  123146. private _texture;
  123147. /**
  123148. * Stores the clear coat values in a texture.
  123149. */
  123150. texture: Nullable<BaseTexture>;
  123151. private _bumpTexture;
  123152. /**
  123153. * Define the clear coat specific bump texture.
  123154. */
  123155. bumpTexture: Nullable<BaseTexture>;
  123156. private _isTintEnabled;
  123157. /**
  123158. * Defines if the clear coat tint is enabled in the material.
  123159. */
  123160. isTintEnabled: boolean;
  123161. /**
  123162. * Defines the clear coat tint of the material.
  123163. * This is only use if tint is enabled
  123164. */
  123165. tintColor: Color3;
  123166. /**
  123167. * Defines the distance at which the tint color should be found in the
  123168. * clear coat media.
  123169. * This is only use if tint is enabled
  123170. */
  123171. tintColorAtDistance: number;
  123172. /**
  123173. * Defines the clear coat layer thickness.
  123174. * This is only use if tint is enabled
  123175. */
  123176. tintThickness: number;
  123177. private _tintTexture;
  123178. /**
  123179. * Stores the clear tint values in a texture.
  123180. * rgb is tint
  123181. * a is a thickness factor
  123182. */
  123183. tintTexture: Nullable<BaseTexture>;
  123184. /** @hidden */
  123185. private _internalMarkAllSubMeshesAsTexturesDirty;
  123186. /** @hidden */
  123187. _markAllSubMeshesAsTexturesDirty(): void;
  123188. /**
  123189. * Instantiate a new istance of clear coat configuration.
  123190. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123191. */
  123192. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123193. /**
  123194. * Gets wehter the submesh is ready to be used or not.
  123195. * @param defines the list of "defines" to update.
  123196. * @param scene defines the scene the material belongs to.
  123197. * @param engine defines the engine the material belongs to.
  123198. * @param disableBumpMap defines wether the material disables bump or not.
  123199. * @returns - boolean indicating that the submesh is ready or not.
  123200. */
  123201. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  123202. /**
  123203. * Checks to see if a texture is used in the material.
  123204. * @param defines the list of "defines" to update.
  123205. * @param scene defines the scene to the material belongs to.
  123206. */
  123207. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  123208. /**
  123209. * Binds the material data.
  123210. * @param uniformBuffer defines the Uniform buffer to fill in.
  123211. * @param scene defines the scene the material belongs to.
  123212. * @param engine defines the engine the material belongs to.
  123213. * @param disableBumpMap defines wether the material disables bump or not.
  123214. * @param isFrozen defines wether the material is frozen or not.
  123215. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  123216. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  123217. */
  123218. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  123219. /**
  123220. * Checks to see if a texture is used in the material.
  123221. * @param texture - Base texture to use.
  123222. * @returns - Boolean specifying if a texture is used in the material.
  123223. */
  123224. hasTexture(texture: BaseTexture): boolean;
  123225. /**
  123226. * Returns an array of the actively used textures.
  123227. * @param activeTextures Array of BaseTextures
  123228. */
  123229. getActiveTextures(activeTextures: BaseTexture[]): void;
  123230. /**
  123231. * Returns the animatable textures.
  123232. * @param animatables Array of animatable textures.
  123233. */
  123234. getAnimatables(animatables: IAnimatable[]): void;
  123235. /**
  123236. * Disposes the resources of the material.
  123237. * @param forceDisposeTextures - Forces the disposal of all textures.
  123238. */
  123239. dispose(forceDisposeTextures?: boolean): void;
  123240. /**
  123241. * Get the current class name of the texture useful for serialization or dynamic coding.
  123242. * @returns "PBRClearCoatConfiguration"
  123243. */
  123244. getClassName(): string;
  123245. /**
  123246. * Add fallbacks to the effect fallbacks list.
  123247. * @param defines defines the Base texture to use.
  123248. * @param fallbacks defines the current fallback list.
  123249. * @param currentRank defines the current fallback rank.
  123250. * @returns the new fallback rank.
  123251. */
  123252. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123253. /**
  123254. * Add the required uniforms to the current list.
  123255. * @param uniforms defines the current uniform list.
  123256. */
  123257. static AddUniforms(uniforms: string[]): void;
  123258. /**
  123259. * Add the required samplers to the current list.
  123260. * @param samplers defines the current sampler list.
  123261. */
  123262. static AddSamplers(samplers: string[]): void;
  123263. /**
  123264. * Add the required uniforms to the current buffer.
  123265. * @param uniformBuffer defines the current uniform buffer.
  123266. */
  123267. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123268. /**
  123269. * Makes a duplicate of the current configuration into another one.
  123270. * @param clearCoatConfiguration define the config where to copy the info
  123271. */
  123272. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  123273. /**
  123274. * Serializes this clear coat configuration.
  123275. * @returns - An object with the serialized config.
  123276. */
  123277. serialize(): any;
  123278. /**
  123279. * Parses a anisotropy Configuration from a serialized object.
  123280. * @param source - Serialized object.
  123281. * @param scene Defines the scene we are parsing for
  123282. * @param rootUrl Defines the rootUrl to load from
  123283. */
  123284. parse(source: any, scene: Scene, rootUrl: string): void;
  123285. }
  123286. }
  123287. declare module BABYLON {
  123288. /**
  123289. * @hidden
  123290. */
  123291. export interface IMaterialAnisotropicDefines {
  123292. ANISOTROPIC: boolean;
  123293. ANISOTROPIC_TEXTURE: boolean;
  123294. ANISOTROPIC_TEXTUREDIRECTUV: number;
  123295. MAINUV1: boolean;
  123296. _areTexturesDirty: boolean;
  123297. _needUVs: boolean;
  123298. }
  123299. /**
  123300. * Define the code related to the anisotropic parameters of the pbr material.
  123301. */
  123302. export class PBRAnisotropicConfiguration {
  123303. private _isEnabled;
  123304. /**
  123305. * Defines if the anisotropy is enabled in the material.
  123306. */
  123307. isEnabled: boolean;
  123308. /**
  123309. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  123310. */
  123311. intensity: number;
  123312. /**
  123313. * Defines if the effect is along the tangents, bitangents or in between.
  123314. * By default, the effect is "strectching" the highlights along the tangents.
  123315. */
  123316. direction: Vector2;
  123317. private _texture;
  123318. /**
  123319. * Stores the anisotropy values in a texture.
  123320. * rg is direction (like normal from -1 to 1)
  123321. * b is a intensity
  123322. */
  123323. texture: Nullable<BaseTexture>;
  123324. /** @hidden */
  123325. private _internalMarkAllSubMeshesAsTexturesDirty;
  123326. /** @hidden */
  123327. _markAllSubMeshesAsTexturesDirty(): void;
  123328. /**
  123329. * Instantiate a new istance of anisotropy configuration.
  123330. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123331. */
  123332. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123333. /**
  123334. * Specifies that the submesh is ready to be used.
  123335. * @param defines the list of "defines" to update.
  123336. * @param scene defines the scene the material belongs to.
  123337. * @returns - boolean indicating that the submesh is ready or not.
  123338. */
  123339. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  123340. /**
  123341. * Checks to see if a texture is used in the material.
  123342. * @param defines the list of "defines" to update.
  123343. * @param mesh the mesh we are preparing the defines for.
  123344. * @param scene defines the scene the material belongs to.
  123345. */
  123346. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  123347. /**
  123348. * Binds the material data.
  123349. * @param uniformBuffer defines the Uniform buffer to fill in.
  123350. * @param scene defines the scene the material belongs to.
  123351. * @param isFrozen defines wether the material is frozen or not.
  123352. */
  123353. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  123354. /**
  123355. * Checks to see if a texture is used in the material.
  123356. * @param texture - Base texture to use.
  123357. * @returns - Boolean specifying if a texture is used in the material.
  123358. */
  123359. hasTexture(texture: BaseTexture): boolean;
  123360. /**
  123361. * Returns an array of the actively used textures.
  123362. * @param activeTextures Array of BaseTextures
  123363. */
  123364. getActiveTextures(activeTextures: BaseTexture[]): void;
  123365. /**
  123366. * Returns the animatable textures.
  123367. * @param animatables Array of animatable textures.
  123368. */
  123369. getAnimatables(animatables: IAnimatable[]): void;
  123370. /**
  123371. * Disposes the resources of the material.
  123372. * @param forceDisposeTextures - Forces the disposal of all textures.
  123373. */
  123374. dispose(forceDisposeTextures?: boolean): void;
  123375. /**
  123376. * Get the current class name of the texture useful for serialization or dynamic coding.
  123377. * @returns "PBRAnisotropicConfiguration"
  123378. */
  123379. getClassName(): string;
  123380. /**
  123381. * Add fallbacks to the effect fallbacks list.
  123382. * @param defines defines the Base texture to use.
  123383. * @param fallbacks defines the current fallback list.
  123384. * @param currentRank defines the current fallback rank.
  123385. * @returns the new fallback rank.
  123386. */
  123387. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123388. /**
  123389. * Add the required uniforms to the current list.
  123390. * @param uniforms defines the current uniform list.
  123391. */
  123392. static AddUniforms(uniforms: string[]): void;
  123393. /**
  123394. * Add the required uniforms to the current buffer.
  123395. * @param uniformBuffer defines the current uniform buffer.
  123396. */
  123397. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123398. /**
  123399. * Add the required samplers to the current list.
  123400. * @param samplers defines the current sampler list.
  123401. */
  123402. static AddSamplers(samplers: string[]): void;
  123403. /**
  123404. * Makes a duplicate of the current configuration into another one.
  123405. * @param anisotropicConfiguration define the config where to copy the info
  123406. */
  123407. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  123408. /**
  123409. * Serializes this anisotropy configuration.
  123410. * @returns - An object with the serialized config.
  123411. */
  123412. serialize(): any;
  123413. /**
  123414. * Parses a anisotropy Configuration from a serialized object.
  123415. * @param source - Serialized object.
  123416. * @param scene Defines the scene we are parsing for
  123417. * @param rootUrl Defines the rootUrl to load from
  123418. */
  123419. parse(source: any, scene: Scene, rootUrl: string): void;
  123420. }
  123421. }
  123422. declare module BABYLON {
  123423. /**
  123424. * @hidden
  123425. */
  123426. export interface IMaterialBRDFDefines {
  123427. BRDF_V_HEIGHT_CORRELATED: boolean;
  123428. MS_BRDF_ENERGY_CONSERVATION: boolean;
  123429. SPHERICAL_HARMONICS: boolean;
  123430. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  123431. /** @hidden */
  123432. _areMiscDirty: boolean;
  123433. }
  123434. /**
  123435. * Define the code related to the BRDF parameters of the pbr material.
  123436. */
  123437. export class PBRBRDFConfiguration {
  123438. /**
  123439. * Default value used for the energy conservation.
  123440. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  123441. */
  123442. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  123443. /**
  123444. * Default value used for the Smith Visibility Height Correlated mode.
  123445. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  123446. */
  123447. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  123448. /**
  123449. * Default value used for the IBL diffuse part.
  123450. * This can help switching back to the polynomials mode globally which is a tiny bit
  123451. * less GPU intensive at the drawback of a lower quality.
  123452. */
  123453. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  123454. /**
  123455. * Default value used for activating energy conservation for the specular workflow.
  123456. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  123457. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  123458. */
  123459. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  123460. private _useEnergyConservation;
  123461. /**
  123462. * Defines if the material uses energy conservation.
  123463. */
  123464. useEnergyConservation: boolean;
  123465. private _useSmithVisibilityHeightCorrelated;
  123466. /**
  123467. * LEGACY Mode set to false
  123468. * Defines if the material uses height smith correlated visibility term.
  123469. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  123470. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  123471. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  123472. * Not relying on height correlated will also disable energy conservation.
  123473. */
  123474. useSmithVisibilityHeightCorrelated: boolean;
  123475. private _useSphericalHarmonics;
  123476. /**
  123477. * LEGACY Mode set to false
  123478. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  123479. * diffuse part of the IBL.
  123480. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  123481. * to the ground truth.
  123482. */
  123483. useSphericalHarmonics: boolean;
  123484. private _useSpecularGlossinessInputEnergyConservation;
  123485. /**
  123486. * Defines if the material uses energy conservation, when the specular workflow is active.
  123487. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  123488. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  123489. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  123490. */
  123491. useSpecularGlossinessInputEnergyConservation: boolean;
  123492. /** @hidden */
  123493. private _internalMarkAllSubMeshesAsMiscDirty;
  123494. /** @hidden */
  123495. _markAllSubMeshesAsMiscDirty(): void;
  123496. /**
  123497. * Instantiate a new istance of clear coat configuration.
  123498. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  123499. */
  123500. constructor(markAllSubMeshesAsMiscDirty: () => void);
  123501. /**
  123502. * Checks to see if a texture is used in the material.
  123503. * @param defines the list of "defines" to update.
  123504. */
  123505. prepareDefines(defines: IMaterialBRDFDefines): void;
  123506. /**
  123507. * Get the current class name of the texture useful for serialization or dynamic coding.
  123508. * @returns "PBRClearCoatConfiguration"
  123509. */
  123510. getClassName(): string;
  123511. /**
  123512. * Makes a duplicate of the current configuration into another one.
  123513. * @param brdfConfiguration define the config where to copy the info
  123514. */
  123515. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  123516. /**
  123517. * Serializes this BRDF configuration.
  123518. * @returns - An object with the serialized config.
  123519. */
  123520. serialize(): any;
  123521. /**
  123522. * Parses a anisotropy Configuration from a serialized object.
  123523. * @param source - Serialized object.
  123524. * @param scene Defines the scene we are parsing for
  123525. * @param rootUrl Defines the rootUrl to load from
  123526. */
  123527. parse(source: any, scene: Scene, rootUrl: string): void;
  123528. }
  123529. }
  123530. declare module BABYLON {
  123531. /**
  123532. * @hidden
  123533. */
  123534. export interface IMaterialSheenDefines {
  123535. SHEEN: boolean;
  123536. SHEEN_TEXTURE: boolean;
  123537. SHEEN_TEXTUREDIRECTUV: number;
  123538. SHEEN_LINKWITHALBEDO: boolean;
  123539. /** @hidden */
  123540. _areTexturesDirty: boolean;
  123541. }
  123542. /**
  123543. * Define the code related to the Sheen parameters of the pbr material.
  123544. */
  123545. export class PBRSheenConfiguration {
  123546. private _isEnabled;
  123547. /**
  123548. * Defines if the material uses sheen.
  123549. */
  123550. isEnabled: boolean;
  123551. private _linkSheenWithAlbedo;
  123552. /**
  123553. * Defines if the sheen is linked to the sheen color.
  123554. */
  123555. linkSheenWithAlbedo: boolean;
  123556. /**
  123557. * Defines the sheen intensity.
  123558. */
  123559. intensity: number;
  123560. /**
  123561. * Defines the sheen color.
  123562. */
  123563. color: Color3;
  123564. private _texture;
  123565. /**
  123566. * Stores the sheen tint values in a texture.
  123567. * rgb is tint
  123568. * a is a intensity
  123569. */
  123570. texture: Nullable<BaseTexture>;
  123571. /** @hidden */
  123572. private _internalMarkAllSubMeshesAsTexturesDirty;
  123573. /** @hidden */
  123574. _markAllSubMeshesAsTexturesDirty(): void;
  123575. /**
  123576. * Instantiate a new istance of clear coat configuration.
  123577. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123578. */
  123579. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123580. /**
  123581. * Specifies that the submesh is ready to be used.
  123582. * @param defines the list of "defines" to update.
  123583. * @param scene defines the scene the material belongs to.
  123584. * @returns - boolean indicating that the submesh is ready or not.
  123585. */
  123586. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  123587. /**
  123588. * Checks to see if a texture is used in the material.
  123589. * @param defines the list of "defines" to update.
  123590. * @param scene defines the scene the material belongs to.
  123591. */
  123592. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  123593. /**
  123594. * Binds the material data.
  123595. * @param uniformBuffer defines the Uniform buffer to fill in.
  123596. * @param scene defines the scene the material belongs to.
  123597. * @param isFrozen defines wether the material is frozen or not.
  123598. */
  123599. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  123600. /**
  123601. * Checks to see if a texture is used in the material.
  123602. * @param texture - Base texture to use.
  123603. * @returns - Boolean specifying if a texture is used in the material.
  123604. */
  123605. hasTexture(texture: BaseTexture): boolean;
  123606. /**
  123607. * Returns an array of the actively used textures.
  123608. * @param activeTextures Array of BaseTextures
  123609. */
  123610. getActiveTextures(activeTextures: BaseTexture[]): void;
  123611. /**
  123612. * Returns the animatable textures.
  123613. * @param animatables Array of animatable textures.
  123614. */
  123615. getAnimatables(animatables: IAnimatable[]): void;
  123616. /**
  123617. * Disposes the resources of the material.
  123618. * @param forceDisposeTextures - Forces the disposal of all textures.
  123619. */
  123620. dispose(forceDisposeTextures?: boolean): void;
  123621. /**
  123622. * Get the current class name of the texture useful for serialization or dynamic coding.
  123623. * @returns "PBRSheenConfiguration"
  123624. */
  123625. getClassName(): string;
  123626. /**
  123627. * Add fallbacks to the effect fallbacks list.
  123628. * @param defines defines the Base texture to use.
  123629. * @param fallbacks defines the current fallback list.
  123630. * @param currentRank defines the current fallback rank.
  123631. * @returns the new fallback rank.
  123632. */
  123633. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123634. /**
  123635. * Add the required uniforms to the current list.
  123636. * @param uniforms defines the current uniform list.
  123637. */
  123638. static AddUniforms(uniforms: string[]): void;
  123639. /**
  123640. * Add the required uniforms to the current buffer.
  123641. * @param uniformBuffer defines the current uniform buffer.
  123642. */
  123643. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123644. /**
  123645. * Add the required samplers to the current list.
  123646. * @param samplers defines the current sampler list.
  123647. */
  123648. static AddSamplers(samplers: string[]): void;
  123649. /**
  123650. * Makes a duplicate of the current configuration into another one.
  123651. * @param sheenConfiguration define the config where to copy the info
  123652. */
  123653. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  123654. /**
  123655. * Serializes this BRDF configuration.
  123656. * @returns - An object with the serialized config.
  123657. */
  123658. serialize(): any;
  123659. /**
  123660. * Parses a anisotropy Configuration from a serialized object.
  123661. * @param source - Serialized object.
  123662. * @param scene Defines the scene we are parsing for
  123663. * @param rootUrl Defines the rootUrl to load from
  123664. */
  123665. parse(source: any, scene: Scene, rootUrl: string): void;
  123666. }
  123667. }
  123668. declare module BABYLON {
  123669. /**
  123670. * @hidden
  123671. */
  123672. export interface IMaterialSubSurfaceDefines {
  123673. SUBSURFACE: boolean;
  123674. SS_REFRACTION: boolean;
  123675. SS_TRANSLUCENCY: boolean;
  123676. SS_SCATERRING: boolean;
  123677. SS_THICKNESSANDMASK_TEXTURE: boolean;
  123678. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  123679. SS_REFRACTIONMAP_3D: boolean;
  123680. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  123681. SS_LODINREFRACTIONALPHA: boolean;
  123682. SS_GAMMAREFRACTION: boolean;
  123683. SS_RGBDREFRACTION: boolean;
  123684. SS_LINEARSPECULARREFRACTION: boolean;
  123685. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  123686. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  123687. /** @hidden */
  123688. _areTexturesDirty: boolean;
  123689. }
  123690. /**
  123691. * Define the code related to the sub surface parameters of the pbr material.
  123692. */
  123693. export class PBRSubSurfaceConfiguration {
  123694. private _isRefractionEnabled;
  123695. /**
  123696. * Defines if the refraction is enabled in the material.
  123697. */
  123698. isRefractionEnabled: boolean;
  123699. private _isTranslucencyEnabled;
  123700. /**
  123701. * Defines if the translucency is enabled in the material.
  123702. */
  123703. isTranslucencyEnabled: boolean;
  123704. private _isScatteringEnabled;
  123705. /**
  123706. * Defines the refraction intensity of the material.
  123707. * The refraction when enabled replaces the Diffuse part of the material.
  123708. * The intensity helps transitionning between diffuse and refraction.
  123709. */
  123710. refractionIntensity: number;
  123711. /**
  123712. * Defines the translucency intensity of the material.
  123713. * When translucency has been enabled, this defines how much of the "translucency"
  123714. * is addded to the diffuse part of the material.
  123715. */
  123716. translucencyIntensity: number;
  123717. /**
  123718. * Defines the scattering intensity of the material.
  123719. * When scattering has been enabled, this defines how much of the "scattered light"
  123720. * is addded to the diffuse part of the material.
  123721. */
  123722. scatteringIntensity: number;
  123723. private _thicknessTexture;
  123724. /**
  123725. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  123726. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  123727. * 0 would mean minimumThickness
  123728. * 1 would mean maximumThickness
  123729. * The other channels might be use as a mask to vary the different effects intensity.
  123730. */
  123731. thicknessTexture: Nullable<BaseTexture>;
  123732. private _refractionTexture;
  123733. /**
  123734. * Defines the texture to use for refraction.
  123735. */
  123736. refractionTexture: Nullable<BaseTexture>;
  123737. private _indexOfRefraction;
  123738. /**
  123739. * Defines the index of refraction used in the material.
  123740. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  123741. */
  123742. indexOfRefraction: number;
  123743. private _invertRefractionY;
  123744. /**
  123745. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  123746. */
  123747. invertRefractionY: boolean;
  123748. private _linkRefractionWithTransparency;
  123749. /**
  123750. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  123751. * Materials half opaque for instance using refraction could benefit from this control.
  123752. */
  123753. linkRefractionWithTransparency: boolean;
  123754. /**
  123755. * Defines the minimum thickness stored in the thickness map.
  123756. * If no thickness map is defined, this value will be used to simulate thickness.
  123757. */
  123758. minimumThickness: number;
  123759. /**
  123760. * Defines the maximum thickness stored in the thickness map.
  123761. */
  123762. maximumThickness: number;
  123763. /**
  123764. * Defines the volume tint of the material.
  123765. * This is used for both translucency and scattering.
  123766. */
  123767. tintColor: Color3;
  123768. /**
  123769. * Defines the distance at which the tint color should be found in the media.
  123770. * This is used for refraction only.
  123771. */
  123772. tintColorAtDistance: number;
  123773. /**
  123774. * Defines how far each channel transmit through the media.
  123775. * It is defined as a color to simplify it selection.
  123776. */
  123777. diffusionDistance: Color3;
  123778. private _useMaskFromThicknessTexture;
  123779. /**
  123780. * Stores the intensity of the different subsurface effects in the thickness texture.
  123781. * * the green channel is the translucency intensity.
  123782. * * the blue channel is the scattering intensity.
  123783. * * the alpha channel is the refraction intensity.
  123784. */
  123785. useMaskFromThicknessTexture: boolean;
  123786. /** @hidden */
  123787. private _internalMarkAllSubMeshesAsTexturesDirty;
  123788. /** @hidden */
  123789. _markAllSubMeshesAsTexturesDirty(): void;
  123790. /**
  123791. * Instantiate a new istance of sub surface configuration.
  123792. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123793. */
  123794. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123795. /**
  123796. * Gets wehter the submesh is ready to be used or not.
  123797. * @param defines the list of "defines" to update.
  123798. * @param scene defines the scene the material belongs to.
  123799. * @returns - boolean indicating that the submesh is ready or not.
  123800. */
  123801. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  123802. /**
  123803. * Checks to see if a texture is used in the material.
  123804. * @param defines the list of "defines" to update.
  123805. * @param scene defines the scene to the material belongs to.
  123806. */
  123807. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  123808. /**
  123809. * Binds the material data.
  123810. * @param uniformBuffer defines the Uniform buffer to fill in.
  123811. * @param scene defines the scene the material belongs to.
  123812. * @param engine defines the engine the material belongs to.
  123813. * @param isFrozen defines wether the material is frozen or not.
  123814. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  123815. */
  123816. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  123817. /**
  123818. * Unbinds the material from the mesh.
  123819. * @param activeEffect defines the effect that should be unbound from.
  123820. * @returns true if unbound, otherwise false
  123821. */
  123822. unbind(activeEffect: Effect): boolean;
  123823. /**
  123824. * Returns the texture used for refraction or null if none is used.
  123825. * @param scene defines the scene the material belongs to.
  123826. * @returns - Refraction texture if present. If no refraction texture and refraction
  123827. * is linked with transparency, returns environment texture. Otherwise, returns null.
  123828. */
  123829. private _getRefractionTexture;
  123830. /**
  123831. * Returns true if alpha blending should be disabled.
  123832. */
  123833. get disableAlphaBlending(): boolean;
  123834. /**
  123835. * Fills the list of render target textures.
  123836. * @param renderTargets the list of render targets to update
  123837. */
  123838. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  123839. /**
  123840. * Checks to see if a texture is used in the material.
  123841. * @param texture - Base texture to use.
  123842. * @returns - Boolean specifying if a texture is used in the material.
  123843. */
  123844. hasTexture(texture: BaseTexture): boolean;
  123845. /**
  123846. * Gets a boolean indicating that current material needs to register RTT
  123847. * @returns true if this uses a render target otherwise false.
  123848. */
  123849. hasRenderTargetTextures(): boolean;
  123850. /**
  123851. * Returns an array of the actively used textures.
  123852. * @param activeTextures Array of BaseTextures
  123853. */
  123854. getActiveTextures(activeTextures: BaseTexture[]): void;
  123855. /**
  123856. * Returns the animatable textures.
  123857. * @param animatables Array of animatable textures.
  123858. */
  123859. getAnimatables(animatables: IAnimatable[]): void;
  123860. /**
  123861. * Disposes the resources of the material.
  123862. * @param forceDisposeTextures - Forces the disposal of all textures.
  123863. */
  123864. dispose(forceDisposeTextures?: boolean): void;
  123865. /**
  123866. * Get the current class name of the texture useful for serialization or dynamic coding.
  123867. * @returns "PBRSubSurfaceConfiguration"
  123868. */
  123869. getClassName(): string;
  123870. /**
  123871. * Add fallbacks to the effect fallbacks list.
  123872. * @param defines defines the Base texture to use.
  123873. * @param fallbacks defines the current fallback list.
  123874. * @param currentRank defines the current fallback rank.
  123875. * @returns the new fallback rank.
  123876. */
  123877. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123878. /**
  123879. * Add the required uniforms to the current list.
  123880. * @param uniforms defines the current uniform list.
  123881. */
  123882. static AddUniforms(uniforms: string[]): void;
  123883. /**
  123884. * Add the required samplers to the current list.
  123885. * @param samplers defines the current sampler list.
  123886. */
  123887. static AddSamplers(samplers: string[]): void;
  123888. /**
  123889. * Add the required uniforms to the current buffer.
  123890. * @param uniformBuffer defines the current uniform buffer.
  123891. */
  123892. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123893. /**
  123894. * Makes a duplicate of the current configuration into another one.
  123895. * @param configuration define the config where to copy the info
  123896. */
  123897. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  123898. /**
  123899. * Serializes this Sub Surface configuration.
  123900. * @returns - An object with the serialized config.
  123901. */
  123902. serialize(): any;
  123903. /**
  123904. * Parses a anisotropy Configuration from a serialized object.
  123905. * @param source - Serialized object.
  123906. * @param scene Defines the scene we are parsing for
  123907. * @param rootUrl Defines the rootUrl to load from
  123908. */
  123909. parse(source: any, scene: Scene, rootUrl: string): void;
  123910. }
  123911. }
  123912. declare module BABYLON {
  123913. /** @hidden */
  123914. export var pbrFragmentDeclaration: {
  123915. name: string;
  123916. shader: string;
  123917. };
  123918. }
  123919. declare module BABYLON {
  123920. /** @hidden */
  123921. export var pbrUboDeclaration: {
  123922. name: string;
  123923. shader: string;
  123924. };
  123925. }
  123926. declare module BABYLON {
  123927. /** @hidden */
  123928. export var pbrFragmentExtraDeclaration: {
  123929. name: string;
  123930. shader: string;
  123931. };
  123932. }
  123933. declare module BABYLON {
  123934. /** @hidden */
  123935. export var pbrFragmentSamplersDeclaration: {
  123936. name: string;
  123937. shader: string;
  123938. };
  123939. }
  123940. declare module BABYLON {
  123941. /** @hidden */
  123942. export var pbrHelperFunctions: {
  123943. name: string;
  123944. shader: string;
  123945. };
  123946. }
  123947. declare module BABYLON {
  123948. /** @hidden */
  123949. export var harmonicsFunctions: {
  123950. name: string;
  123951. shader: string;
  123952. };
  123953. }
  123954. declare module BABYLON {
  123955. /** @hidden */
  123956. export var pbrDirectLightingSetupFunctions: {
  123957. name: string;
  123958. shader: string;
  123959. };
  123960. }
  123961. declare module BABYLON {
  123962. /** @hidden */
  123963. export var pbrDirectLightingFalloffFunctions: {
  123964. name: string;
  123965. shader: string;
  123966. };
  123967. }
  123968. declare module BABYLON {
  123969. /** @hidden */
  123970. export var pbrBRDFFunctions: {
  123971. name: string;
  123972. shader: string;
  123973. };
  123974. }
  123975. declare module BABYLON {
  123976. /** @hidden */
  123977. export var pbrDirectLightingFunctions: {
  123978. name: string;
  123979. shader: string;
  123980. };
  123981. }
  123982. declare module BABYLON {
  123983. /** @hidden */
  123984. export var pbrIBLFunctions: {
  123985. name: string;
  123986. shader: string;
  123987. };
  123988. }
  123989. declare module BABYLON {
  123990. /** @hidden */
  123991. export var pbrDebug: {
  123992. name: string;
  123993. shader: string;
  123994. };
  123995. }
  123996. declare module BABYLON {
  123997. /** @hidden */
  123998. export var pbrPixelShader: {
  123999. name: string;
  124000. shader: string;
  124001. };
  124002. }
  124003. declare module BABYLON {
  124004. /** @hidden */
  124005. export var pbrVertexDeclaration: {
  124006. name: string;
  124007. shader: string;
  124008. };
  124009. }
  124010. declare module BABYLON {
  124011. /** @hidden */
  124012. export var pbrVertexShader: {
  124013. name: string;
  124014. shader: string;
  124015. };
  124016. }
  124017. declare module BABYLON {
  124018. /**
  124019. * Manages the defines for the PBR Material.
  124020. * @hidden
  124021. */
  124022. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  124023. PBR: boolean;
  124024. MAINUV1: boolean;
  124025. MAINUV2: boolean;
  124026. UV1: boolean;
  124027. UV2: boolean;
  124028. ALBEDO: boolean;
  124029. ALBEDODIRECTUV: number;
  124030. VERTEXCOLOR: boolean;
  124031. AMBIENT: boolean;
  124032. AMBIENTDIRECTUV: number;
  124033. AMBIENTINGRAYSCALE: boolean;
  124034. OPACITY: boolean;
  124035. VERTEXALPHA: boolean;
  124036. OPACITYDIRECTUV: number;
  124037. OPACITYRGB: boolean;
  124038. ALPHATEST: boolean;
  124039. DEPTHPREPASS: boolean;
  124040. ALPHABLEND: boolean;
  124041. ALPHAFROMALBEDO: boolean;
  124042. ALPHATESTVALUE: string;
  124043. SPECULAROVERALPHA: boolean;
  124044. RADIANCEOVERALPHA: boolean;
  124045. ALPHAFRESNEL: boolean;
  124046. LINEARALPHAFRESNEL: boolean;
  124047. PREMULTIPLYALPHA: boolean;
  124048. EMISSIVE: boolean;
  124049. EMISSIVEDIRECTUV: number;
  124050. REFLECTIVITY: boolean;
  124051. REFLECTIVITYDIRECTUV: number;
  124052. SPECULARTERM: boolean;
  124053. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  124054. MICROSURFACEAUTOMATIC: boolean;
  124055. LODBASEDMICROSFURACE: boolean;
  124056. MICROSURFACEMAP: boolean;
  124057. MICROSURFACEMAPDIRECTUV: number;
  124058. METALLICWORKFLOW: boolean;
  124059. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  124060. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  124061. METALLNESSSTOREINMETALMAPBLUE: boolean;
  124062. AOSTOREINMETALMAPRED: boolean;
  124063. METALLICF0FACTORFROMMETALLICMAP: boolean;
  124064. ENVIRONMENTBRDF: boolean;
  124065. ENVIRONMENTBRDF_RGBD: boolean;
  124066. NORMAL: boolean;
  124067. TANGENT: boolean;
  124068. BUMP: boolean;
  124069. BUMPDIRECTUV: number;
  124070. OBJECTSPACE_NORMALMAP: boolean;
  124071. PARALLAX: boolean;
  124072. PARALLAXOCCLUSION: boolean;
  124073. NORMALXYSCALE: boolean;
  124074. LIGHTMAP: boolean;
  124075. LIGHTMAPDIRECTUV: number;
  124076. USELIGHTMAPASSHADOWMAP: boolean;
  124077. GAMMALIGHTMAP: boolean;
  124078. RGBDLIGHTMAP: boolean;
  124079. REFLECTION: boolean;
  124080. REFLECTIONMAP_3D: boolean;
  124081. REFLECTIONMAP_SPHERICAL: boolean;
  124082. REFLECTIONMAP_PLANAR: boolean;
  124083. REFLECTIONMAP_CUBIC: boolean;
  124084. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  124085. REFLECTIONMAP_PROJECTION: boolean;
  124086. REFLECTIONMAP_SKYBOX: boolean;
  124087. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  124088. REFLECTIONMAP_EXPLICIT: boolean;
  124089. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  124090. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  124091. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  124092. INVERTCUBICMAP: boolean;
  124093. USESPHERICALFROMREFLECTIONMAP: boolean;
  124094. USEIRRADIANCEMAP: boolean;
  124095. SPHERICAL_HARMONICS: boolean;
  124096. USESPHERICALINVERTEX: boolean;
  124097. REFLECTIONMAP_OPPOSITEZ: boolean;
  124098. LODINREFLECTIONALPHA: boolean;
  124099. GAMMAREFLECTION: boolean;
  124100. RGBDREFLECTION: boolean;
  124101. LINEARSPECULARREFLECTION: boolean;
  124102. RADIANCEOCCLUSION: boolean;
  124103. HORIZONOCCLUSION: boolean;
  124104. INSTANCES: boolean;
  124105. NUM_BONE_INFLUENCERS: number;
  124106. BonesPerMesh: number;
  124107. BONETEXTURE: boolean;
  124108. NONUNIFORMSCALING: boolean;
  124109. MORPHTARGETS: boolean;
  124110. MORPHTARGETS_NORMAL: boolean;
  124111. MORPHTARGETS_TANGENT: boolean;
  124112. MORPHTARGETS_UV: boolean;
  124113. NUM_MORPH_INFLUENCERS: number;
  124114. IMAGEPROCESSING: boolean;
  124115. VIGNETTE: boolean;
  124116. VIGNETTEBLENDMODEMULTIPLY: boolean;
  124117. VIGNETTEBLENDMODEOPAQUE: boolean;
  124118. TONEMAPPING: boolean;
  124119. TONEMAPPING_ACES: boolean;
  124120. CONTRAST: boolean;
  124121. COLORCURVES: boolean;
  124122. COLORGRADING: boolean;
  124123. COLORGRADING3D: boolean;
  124124. SAMPLER3DGREENDEPTH: boolean;
  124125. SAMPLER3DBGRMAP: boolean;
  124126. IMAGEPROCESSINGPOSTPROCESS: boolean;
  124127. EXPOSURE: boolean;
  124128. MULTIVIEW: boolean;
  124129. USEPHYSICALLIGHTFALLOFF: boolean;
  124130. USEGLTFLIGHTFALLOFF: boolean;
  124131. TWOSIDEDLIGHTING: boolean;
  124132. SHADOWFLOAT: boolean;
  124133. CLIPPLANE: boolean;
  124134. CLIPPLANE2: boolean;
  124135. CLIPPLANE3: boolean;
  124136. CLIPPLANE4: boolean;
  124137. CLIPPLANE5: boolean;
  124138. CLIPPLANE6: boolean;
  124139. POINTSIZE: boolean;
  124140. FOG: boolean;
  124141. LOGARITHMICDEPTH: boolean;
  124142. FORCENORMALFORWARD: boolean;
  124143. SPECULARAA: boolean;
  124144. CLEARCOAT: boolean;
  124145. CLEARCOAT_DEFAULTIOR: boolean;
  124146. CLEARCOAT_TEXTURE: boolean;
  124147. CLEARCOAT_TEXTUREDIRECTUV: number;
  124148. CLEARCOAT_BUMP: boolean;
  124149. CLEARCOAT_BUMPDIRECTUV: number;
  124150. CLEARCOAT_TINT: boolean;
  124151. CLEARCOAT_TINT_TEXTURE: boolean;
  124152. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  124153. ANISOTROPIC: boolean;
  124154. ANISOTROPIC_TEXTURE: boolean;
  124155. ANISOTROPIC_TEXTUREDIRECTUV: number;
  124156. BRDF_V_HEIGHT_CORRELATED: boolean;
  124157. MS_BRDF_ENERGY_CONSERVATION: boolean;
  124158. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  124159. SHEEN: boolean;
  124160. SHEEN_TEXTURE: boolean;
  124161. SHEEN_TEXTUREDIRECTUV: number;
  124162. SHEEN_LINKWITHALBEDO: boolean;
  124163. SUBSURFACE: boolean;
  124164. SS_REFRACTION: boolean;
  124165. SS_TRANSLUCENCY: boolean;
  124166. SS_SCATERRING: boolean;
  124167. SS_THICKNESSANDMASK_TEXTURE: boolean;
  124168. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  124169. SS_REFRACTIONMAP_3D: boolean;
  124170. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  124171. SS_LODINREFRACTIONALPHA: boolean;
  124172. SS_GAMMAREFRACTION: boolean;
  124173. SS_RGBDREFRACTION: boolean;
  124174. SS_LINEARSPECULARREFRACTION: boolean;
  124175. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  124176. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  124177. UNLIT: boolean;
  124178. DEBUGMODE: number;
  124179. /**
  124180. * Initializes the PBR Material defines.
  124181. */
  124182. constructor();
  124183. /**
  124184. * Resets the PBR Material defines.
  124185. */
  124186. reset(): void;
  124187. }
  124188. /**
  124189. * The Physically based material base class of BJS.
  124190. *
  124191. * This offers the main features of a standard PBR material.
  124192. * For more information, please refer to the documentation :
  124193. * https://doc.babylonjs.com/how_to/physically_based_rendering
  124194. */
  124195. export abstract class PBRBaseMaterial extends PushMaterial {
  124196. /**
  124197. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  124198. */
  124199. static readonly PBRMATERIAL_OPAQUE: number;
  124200. /**
  124201. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  124202. */
  124203. static readonly PBRMATERIAL_ALPHATEST: number;
  124204. /**
  124205. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124206. */
  124207. static readonly PBRMATERIAL_ALPHABLEND: number;
  124208. /**
  124209. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124210. * They are also discarded below the alpha cutoff threshold to improve performances.
  124211. */
  124212. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  124213. /**
  124214. * Defines the default value of how much AO map is occluding the analytical lights
  124215. * (point spot...).
  124216. */
  124217. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  124218. /**
  124219. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  124220. */
  124221. static readonly LIGHTFALLOFF_PHYSICAL: number;
  124222. /**
  124223. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  124224. * to enhance interoperability with other engines.
  124225. */
  124226. static readonly LIGHTFALLOFF_GLTF: number;
  124227. /**
  124228. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  124229. * to enhance interoperability with other materials.
  124230. */
  124231. static readonly LIGHTFALLOFF_STANDARD: number;
  124232. /**
  124233. * Intensity of the direct lights e.g. the four lights available in your scene.
  124234. * This impacts both the direct diffuse and specular highlights.
  124235. */
  124236. protected _directIntensity: number;
  124237. /**
  124238. * Intensity of the emissive part of the material.
  124239. * This helps controlling the emissive effect without modifying the emissive color.
  124240. */
  124241. protected _emissiveIntensity: number;
  124242. /**
  124243. * Intensity of the environment e.g. how much the environment will light the object
  124244. * either through harmonics for rough material or through the refelction for shiny ones.
  124245. */
  124246. protected _environmentIntensity: number;
  124247. /**
  124248. * This is a special control allowing the reduction of the specular highlights coming from the
  124249. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  124250. */
  124251. protected _specularIntensity: number;
  124252. /**
  124253. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  124254. */
  124255. private _lightingInfos;
  124256. /**
  124257. * Debug Control allowing disabling the bump map on this material.
  124258. */
  124259. protected _disableBumpMap: boolean;
  124260. /**
  124261. * AKA Diffuse Texture in standard nomenclature.
  124262. */
  124263. protected _albedoTexture: Nullable<BaseTexture>;
  124264. /**
  124265. * AKA Occlusion Texture in other nomenclature.
  124266. */
  124267. protected _ambientTexture: Nullable<BaseTexture>;
  124268. /**
  124269. * AKA Occlusion Texture Intensity in other nomenclature.
  124270. */
  124271. protected _ambientTextureStrength: number;
  124272. /**
  124273. * Defines how much the AO map is occluding the analytical lights (point spot...).
  124274. * 1 means it completely occludes it
  124275. * 0 mean it has no impact
  124276. */
  124277. protected _ambientTextureImpactOnAnalyticalLights: number;
  124278. /**
  124279. * Stores the alpha values in a texture.
  124280. */
  124281. protected _opacityTexture: Nullable<BaseTexture>;
  124282. /**
  124283. * Stores the reflection values in a texture.
  124284. */
  124285. protected _reflectionTexture: Nullable<BaseTexture>;
  124286. /**
  124287. * Stores the emissive values in a texture.
  124288. */
  124289. protected _emissiveTexture: Nullable<BaseTexture>;
  124290. /**
  124291. * AKA Specular texture in other nomenclature.
  124292. */
  124293. protected _reflectivityTexture: Nullable<BaseTexture>;
  124294. /**
  124295. * Used to switch from specular/glossiness to metallic/roughness workflow.
  124296. */
  124297. protected _metallicTexture: Nullable<BaseTexture>;
  124298. /**
  124299. * Specifies the metallic scalar of the metallic/roughness workflow.
  124300. * Can also be used to scale the metalness values of the metallic texture.
  124301. */
  124302. protected _metallic: Nullable<number>;
  124303. /**
  124304. * Specifies the roughness scalar of the metallic/roughness workflow.
  124305. * Can also be used to scale the roughness values of the metallic texture.
  124306. */
  124307. protected _roughness: Nullable<number>;
  124308. /**
  124309. * Specifies the an F0 factor to help configuring the material F0.
  124310. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  124311. * to 0.5 the previously hard coded value stays the same.
  124312. * Can also be used to scale the F0 values of the metallic texture.
  124313. */
  124314. protected _metallicF0Factor: number;
  124315. /**
  124316. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  124317. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  124318. * your expectation as it multiplies with the texture data.
  124319. */
  124320. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  124321. /**
  124322. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  124323. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  124324. */
  124325. protected _microSurfaceTexture: Nullable<BaseTexture>;
  124326. /**
  124327. * Stores surface normal data used to displace a mesh in a texture.
  124328. */
  124329. protected _bumpTexture: Nullable<BaseTexture>;
  124330. /**
  124331. * Stores the pre-calculated light information of a mesh in a texture.
  124332. */
  124333. protected _lightmapTexture: Nullable<BaseTexture>;
  124334. /**
  124335. * The color of a material in ambient lighting.
  124336. */
  124337. protected _ambientColor: Color3;
  124338. /**
  124339. * AKA Diffuse Color in other nomenclature.
  124340. */
  124341. protected _albedoColor: Color3;
  124342. /**
  124343. * AKA Specular Color in other nomenclature.
  124344. */
  124345. protected _reflectivityColor: Color3;
  124346. /**
  124347. * The color applied when light is reflected from a material.
  124348. */
  124349. protected _reflectionColor: Color3;
  124350. /**
  124351. * The color applied when light is emitted from a material.
  124352. */
  124353. protected _emissiveColor: Color3;
  124354. /**
  124355. * AKA Glossiness in other nomenclature.
  124356. */
  124357. protected _microSurface: number;
  124358. /**
  124359. * Specifies that the material will use the light map as a show map.
  124360. */
  124361. protected _useLightmapAsShadowmap: boolean;
  124362. /**
  124363. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  124364. * makes the reflect vector face the model (under horizon).
  124365. */
  124366. protected _useHorizonOcclusion: boolean;
  124367. /**
  124368. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  124369. * too much the area relying on ambient texture to define their ambient occlusion.
  124370. */
  124371. protected _useRadianceOcclusion: boolean;
  124372. /**
  124373. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  124374. */
  124375. protected _useAlphaFromAlbedoTexture: boolean;
  124376. /**
  124377. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  124378. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  124379. */
  124380. protected _useSpecularOverAlpha: boolean;
  124381. /**
  124382. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  124383. */
  124384. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  124385. /**
  124386. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  124387. */
  124388. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  124389. /**
  124390. * Specifies if the metallic texture contains the roughness information in its green channel.
  124391. */
  124392. protected _useRoughnessFromMetallicTextureGreen: boolean;
  124393. /**
  124394. * Specifies if the metallic texture contains the metallness information in its blue channel.
  124395. */
  124396. protected _useMetallnessFromMetallicTextureBlue: boolean;
  124397. /**
  124398. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  124399. */
  124400. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  124401. /**
  124402. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  124403. */
  124404. protected _useAmbientInGrayScale: boolean;
  124405. /**
  124406. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  124407. * The material will try to infer what glossiness each pixel should be.
  124408. */
  124409. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  124410. /**
  124411. * Defines the falloff type used in this material.
  124412. * It by default is Physical.
  124413. */
  124414. protected _lightFalloff: number;
  124415. /**
  124416. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  124417. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  124418. */
  124419. protected _useRadianceOverAlpha: boolean;
  124420. /**
  124421. * Allows using an object space normal map (instead of tangent space).
  124422. */
  124423. protected _useObjectSpaceNormalMap: boolean;
  124424. /**
  124425. * Allows using the bump map in parallax mode.
  124426. */
  124427. protected _useParallax: boolean;
  124428. /**
  124429. * Allows using the bump map in parallax occlusion mode.
  124430. */
  124431. protected _useParallaxOcclusion: boolean;
  124432. /**
  124433. * Controls the scale bias of the parallax mode.
  124434. */
  124435. protected _parallaxScaleBias: number;
  124436. /**
  124437. * If sets to true, disables all the lights affecting the material.
  124438. */
  124439. protected _disableLighting: boolean;
  124440. /**
  124441. * Number of Simultaneous lights allowed on the material.
  124442. */
  124443. protected _maxSimultaneousLights: number;
  124444. /**
  124445. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  124446. */
  124447. protected _invertNormalMapX: boolean;
  124448. /**
  124449. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  124450. */
  124451. protected _invertNormalMapY: boolean;
  124452. /**
  124453. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  124454. */
  124455. protected _twoSidedLighting: boolean;
  124456. /**
  124457. * Defines the alpha limits in alpha test mode.
  124458. */
  124459. protected _alphaCutOff: number;
  124460. /**
  124461. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  124462. */
  124463. protected _forceAlphaTest: boolean;
  124464. /**
  124465. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  124466. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  124467. */
  124468. protected _useAlphaFresnel: boolean;
  124469. /**
  124470. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  124471. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  124472. */
  124473. protected _useLinearAlphaFresnel: boolean;
  124474. /**
  124475. * The transparency mode of the material.
  124476. */
  124477. protected _transparencyMode: Nullable<number>;
  124478. /**
  124479. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  124480. * from cos thetav and roughness:
  124481. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  124482. */
  124483. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  124484. /**
  124485. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  124486. */
  124487. protected _forceIrradianceInFragment: boolean;
  124488. /**
  124489. * Force normal to face away from face.
  124490. */
  124491. protected _forceNormalForward: boolean;
  124492. /**
  124493. * Enables specular anti aliasing in the PBR shader.
  124494. * It will both interacts on the Geometry for analytical and IBL lighting.
  124495. * It also prefilter the roughness map based on the bump values.
  124496. */
  124497. protected _enableSpecularAntiAliasing: boolean;
  124498. /**
  124499. * Default configuration related to image processing available in the PBR Material.
  124500. */
  124501. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  124502. /**
  124503. * Keep track of the image processing observer to allow dispose and replace.
  124504. */
  124505. private _imageProcessingObserver;
  124506. /**
  124507. * Attaches a new image processing configuration to the PBR Material.
  124508. * @param configuration
  124509. */
  124510. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  124511. /**
  124512. * Stores the available render targets.
  124513. */
  124514. private _renderTargets;
  124515. /**
  124516. * Sets the global ambient color for the material used in lighting calculations.
  124517. */
  124518. private _globalAmbientColor;
  124519. /**
  124520. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  124521. */
  124522. private _useLogarithmicDepth;
  124523. /**
  124524. * If set to true, no lighting calculations will be applied.
  124525. */
  124526. private _unlit;
  124527. private _debugMode;
  124528. /**
  124529. * @hidden
  124530. * This is reserved for the inspector.
  124531. * Defines the material debug mode.
  124532. * It helps seeing only some components of the material while troubleshooting.
  124533. */
  124534. debugMode: number;
  124535. /**
  124536. * @hidden
  124537. * This is reserved for the inspector.
  124538. * Specify from where on screen the debug mode should start.
  124539. * The value goes from -1 (full screen) to 1 (not visible)
  124540. * It helps with side by side comparison against the final render
  124541. * This defaults to -1
  124542. */
  124543. private debugLimit;
  124544. /**
  124545. * @hidden
  124546. * This is reserved for the inspector.
  124547. * As the default viewing range might not be enough (if the ambient is really small for instance)
  124548. * You can use the factor to better multiply the final value.
  124549. */
  124550. private debugFactor;
  124551. /**
  124552. * Defines the clear coat layer parameters for the material.
  124553. */
  124554. readonly clearCoat: PBRClearCoatConfiguration;
  124555. /**
  124556. * Defines the anisotropic parameters for the material.
  124557. */
  124558. readonly anisotropy: PBRAnisotropicConfiguration;
  124559. /**
  124560. * Defines the BRDF parameters for the material.
  124561. */
  124562. readonly brdf: PBRBRDFConfiguration;
  124563. /**
  124564. * Defines the Sheen parameters for the material.
  124565. */
  124566. readonly sheen: PBRSheenConfiguration;
  124567. /**
  124568. * Defines the SubSurface parameters for the material.
  124569. */
  124570. readonly subSurface: PBRSubSurfaceConfiguration;
  124571. /**
  124572. * Custom callback helping to override the default shader used in the material.
  124573. */
  124574. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  124575. protected _rebuildInParallel: boolean;
  124576. /**
  124577. * Instantiates a new PBRMaterial instance.
  124578. *
  124579. * @param name The material name
  124580. * @param scene The scene the material will be use in.
  124581. */
  124582. constructor(name: string, scene: Scene);
  124583. /**
  124584. * Gets a boolean indicating that current material needs to register RTT
  124585. */
  124586. get hasRenderTargetTextures(): boolean;
  124587. /**
  124588. * Gets the name of the material class.
  124589. */
  124590. getClassName(): string;
  124591. /**
  124592. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  124593. */
  124594. get useLogarithmicDepth(): boolean;
  124595. /**
  124596. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  124597. */
  124598. set useLogarithmicDepth(value: boolean);
  124599. /**
  124600. * Gets the current transparency mode.
  124601. */
  124602. get transparencyMode(): Nullable<number>;
  124603. /**
  124604. * Sets the transparency mode of the material.
  124605. *
  124606. * | Value | Type | Description |
  124607. * | ----- | ----------------------------------- | ----------- |
  124608. * | 0 | OPAQUE | |
  124609. * | 1 | ALPHATEST | |
  124610. * | 2 | ALPHABLEND | |
  124611. * | 3 | ALPHATESTANDBLEND | |
  124612. *
  124613. */
  124614. set transparencyMode(value: Nullable<number>);
  124615. /**
  124616. * Returns true if alpha blending should be disabled.
  124617. */
  124618. private get _disableAlphaBlending();
  124619. /**
  124620. * Specifies whether or not this material should be rendered in alpha blend mode.
  124621. */
  124622. needAlphaBlending(): boolean;
  124623. /**
  124624. * Specifies if the mesh will require alpha blending.
  124625. * @param mesh - BJS mesh.
  124626. */
  124627. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  124628. /**
  124629. * Specifies whether or not this material should be rendered in alpha test mode.
  124630. */
  124631. needAlphaTesting(): boolean;
  124632. /**
  124633. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  124634. */
  124635. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  124636. /**
  124637. * Gets the texture used for the alpha test.
  124638. */
  124639. getAlphaTestTexture(): Nullable<BaseTexture>;
  124640. /**
  124641. * Specifies that the submesh is ready to be used.
  124642. * @param mesh - BJS mesh.
  124643. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  124644. * @param useInstances - Specifies that instances should be used.
  124645. * @returns - boolean indicating that the submesh is ready or not.
  124646. */
  124647. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  124648. /**
  124649. * Specifies if the material uses metallic roughness workflow.
  124650. * @returns boolean specifiying if the material uses metallic roughness workflow.
  124651. */
  124652. isMetallicWorkflow(): boolean;
  124653. private _prepareEffect;
  124654. private _prepareDefines;
  124655. /**
  124656. * Force shader compilation
  124657. */
  124658. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  124659. /**
  124660. * Initializes the uniform buffer layout for the shader.
  124661. */
  124662. buildUniformLayout(): void;
  124663. /**
  124664. * Unbinds the material from the mesh
  124665. */
  124666. unbind(): void;
  124667. /**
  124668. * Binds the submesh data.
  124669. * @param world - The world matrix.
  124670. * @param mesh - The BJS mesh.
  124671. * @param subMesh - A submesh of the BJS mesh.
  124672. */
  124673. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  124674. /**
  124675. * Returns the animatable textures.
  124676. * @returns - Array of animatable textures.
  124677. */
  124678. getAnimatables(): IAnimatable[];
  124679. /**
  124680. * Returns the texture used for reflections.
  124681. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  124682. */
  124683. private _getReflectionTexture;
  124684. /**
  124685. * Returns an array of the actively used textures.
  124686. * @returns - Array of BaseTextures
  124687. */
  124688. getActiveTextures(): BaseTexture[];
  124689. /**
  124690. * Checks to see if a texture is used in the material.
  124691. * @param texture - Base texture to use.
  124692. * @returns - Boolean specifying if a texture is used in the material.
  124693. */
  124694. hasTexture(texture: BaseTexture): boolean;
  124695. /**
  124696. * Disposes the resources of the material.
  124697. * @param forceDisposeEffect - Forces the disposal of effects.
  124698. * @param forceDisposeTextures - Forces the disposal of all textures.
  124699. */
  124700. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  124701. }
  124702. }
  124703. declare module BABYLON {
  124704. /**
  124705. * The Physically based material of BJS.
  124706. *
  124707. * This offers the main features of a standard PBR material.
  124708. * For more information, please refer to the documentation :
  124709. * https://doc.babylonjs.com/how_to/physically_based_rendering
  124710. */
  124711. export class PBRMaterial extends PBRBaseMaterial {
  124712. /**
  124713. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  124714. */
  124715. static readonly PBRMATERIAL_OPAQUE: number;
  124716. /**
  124717. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  124718. */
  124719. static readonly PBRMATERIAL_ALPHATEST: number;
  124720. /**
  124721. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124722. */
  124723. static readonly PBRMATERIAL_ALPHABLEND: number;
  124724. /**
  124725. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124726. * They are also discarded below the alpha cutoff threshold to improve performances.
  124727. */
  124728. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  124729. /**
  124730. * Defines the default value of how much AO map is occluding the analytical lights
  124731. * (point spot...).
  124732. */
  124733. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  124734. /**
  124735. * Intensity of the direct lights e.g. the four lights available in your scene.
  124736. * This impacts both the direct diffuse and specular highlights.
  124737. */
  124738. directIntensity: number;
  124739. /**
  124740. * Intensity of the emissive part of the material.
  124741. * This helps controlling the emissive effect without modifying the emissive color.
  124742. */
  124743. emissiveIntensity: number;
  124744. /**
  124745. * Intensity of the environment e.g. how much the environment will light the object
  124746. * either through harmonics for rough material or through the refelction for shiny ones.
  124747. */
  124748. environmentIntensity: number;
  124749. /**
  124750. * This is a special control allowing the reduction of the specular highlights coming from the
  124751. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  124752. */
  124753. specularIntensity: number;
  124754. /**
  124755. * Debug Control allowing disabling the bump map on this material.
  124756. */
  124757. disableBumpMap: boolean;
  124758. /**
  124759. * AKA Diffuse Texture in standard nomenclature.
  124760. */
  124761. albedoTexture: BaseTexture;
  124762. /**
  124763. * AKA Occlusion Texture in other nomenclature.
  124764. */
  124765. ambientTexture: BaseTexture;
  124766. /**
  124767. * AKA Occlusion Texture Intensity in other nomenclature.
  124768. */
  124769. ambientTextureStrength: number;
  124770. /**
  124771. * Defines how much the AO map is occluding the analytical lights (point spot...).
  124772. * 1 means it completely occludes it
  124773. * 0 mean it has no impact
  124774. */
  124775. ambientTextureImpactOnAnalyticalLights: number;
  124776. /**
  124777. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  124778. */
  124779. opacityTexture: BaseTexture;
  124780. /**
  124781. * Stores the reflection values in a texture.
  124782. */
  124783. reflectionTexture: Nullable<BaseTexture>;
  124784. /**
  124785. * Stores the emissive values in a texture.
  124786. */
  124787. emissiveTexture: BaseTexture;
  124788. /**
  124789. * AKA Specular texture in other nomenclature.
  124790. */
  124791. reflectivityTexture: BaseTexture;
  124792. /**
  124793. * Used to switch from specular/glossiness to metallic/roughness workflow.
  124794. */
  124795. metallicTexture: BaseTexture;
  124796. /**
  124797. * Specifies the metallic scalar of the metallic/roughness workflow.
  124798. * Can also be used to scale the metalness values of the metallic texture.
  124799. */
  124800. metallic: Nullable<number>;
  124801. /**
  124802. * Specifies the roughness scalar of the metallic/roughness workflow.
  124803. * Can also be used to scale the roughness values of the metallic texture.
  124804. */
  124805. roughness: Nullable<number>;
  124806. /**
  124807. * Specifies the an F0 factor to help configuring the material F0.
  124808. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  124809. * to 0.5 the previously hard coded value stays the same.
  124810. * Can also be used to scale the F0 values of the metallic texture.
  124811. */
  124812. metallicF0Factor: number;
  124813. /**
  124814. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  124815. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  124816. * your expectation as it multiplies with the texture data.
  124817. */
  124818. useMetallicF0FactorFromMetallicTexture: boolean;
  124819. /**
  124820. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  124821. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  124822. */
  124823. microSurfaceTexture: BaseTexture;
  124824. /**
  124825. * Stores surface normal data used to displace a mesh in a texture.
  124826. */
  124827. bumpTexture: BaseTexture;
  124828. /**
  124829. * Stores the pre-calculated light information of a mesh in a texture.
  124830. */
  124831. lightmapTexture: BaseTexture;
  124832. /**
  124833. * Stores the refracted light information in a texture.
  124834. */
  124835. get refractionTexture(): Nullable<BaseTexture>;
  124836. set refractionTexture(value: Nullable<BaseTexture>);
  124837. /**
  124838. * The color of a material in ambient lighting.
  124839. */
  124840. ambientColor: Color3;
  124841. /**
  124842. * AKA Diffuse Color in other nomenclature.
  124843. */
  124844. albedoColor: Color3;
  124845. /**
  124846. * AKA Specular Color in other nomenclature.
  124847. */
  124848. reflectivityColor: Color3;
  124849. /**
  124850. * The color reflected from the material.
  124851. */
  124852. reflectionColor: Color3;
  124853. /**
  124854. * The color emitted from the material.
  124855. */
  124856. emissiveColor: Color3;
  124857. /**
  124858. * AKA Glossiness in other nomenclature.
  124859. */
  124860. microSurface: number;
  124861. /**
  124862. * source material index of refraction (IOR)' / 'destination material IOR.
  124863. */
  124864. get indexOfRefraction(): number;
  124865. set indexOfRefraction(value: number);
  124866. /**
  124867. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  124868. */
  124869. get invertRefractionY(): boolean;
  124870. set invertRefractionY(value: boolean);
  124871. /**
  124872. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  124873. * Materials half opaque for instance using refraction could benefit from this control.
  124874. */
  124875. get linkRefractionWithTransparency(): boolean;
  124876. set linkRefractionWithTransparency(value: boolean);
  124877. /**
  124878. * If true, the light map contains occlusion information instead of lighting info.
  124879. */
  124880. useLightmapAsShadowmap: boolean;
  124881. /**
  124882. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  124883. */
  124884. useAlphaFromAlbedoTexture: boolean;
  124885. /**
  124886. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  124887. */
  124888. forceAlphaTest: boolean;
  124889. /**
  124890. * Defines the alpha limits in alpha test mode.
  124891. */
  124892. alphaCutOff: number;
  124893. /**
  124894. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  124895. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  124896. */
  124897. useSpecularOverAlpha: boolean;
  124898. /**
  124899. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  124900. */
  124901. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  124902. /**
  124903. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  124904. */
  124905. useRoughnessFromMetallicTextureAlpha: boolean;
  124906. /**
  124907. * Specifies if the metallic texture contains the roughness information in its green channel.
  124908. */
  124909. useRoughnessFromMetallicTextureGreen: boolean;
  124910. /**
  124911. * Specifies if the metallic texture contains the metallness information in its blue channel.
  124912. */
  124913. useMetallnessFromMetallicTextureBlue: boolean;
  124914. /**
  124915. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  124916. */
  124917. useAmbientOcclusionFromMetallicTextureRed: boolean;
  124918. /**
  124919. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  124920. */
  124921. useAmbientInGrayScale: boolean;
  124922. /**
  124923. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  124924. * The material will try to infer what glossiness each pixel should be.
  124925. */
  124926. useAutoMicroSurfaceFromReflectivityMap: boolean;
  124927. /**
  124928. * BJS is using an harcoded light falloff based on a manually sets up range.
  124929. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  124930. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  124931. */
  124932. get usePhysicalLightFalloff(): boolean;
  124933. /**
  124934. * BJS is using an harcoded light falloff based on a manually sets up range.
  124935. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  124936. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  124937. */
  124938. set usePhysicalLightFalloff(value: boolean);
  124939. /**
  124940. * In order to support the falloff compatibility with gltf, a special mode has been added
  124941. * to reproduce the gltf light falloff.
  124942. */
  124943. get useGLTFLightFalloff(): boolean;
  124944. /**
  124945. * In order to support the falloff compatibility with gltf, a special mode has been added
  124946. * to reproduce the gltf light falloff.
  124947. */
  124948. set useGLTFLightFalloff(value: boolean);
  124949. /**
  124950. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  124951. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  124952. */
  124953. useRadianceOverAlpha: boolean;
  124954. /**
  124955. * Allows using an object space normal map (instead of tangent space).
  124956. */
  124957. useObjectSpaceNormalMap: boolean;
  124958. /**
  124959. * Allows using the bump map in parallax mode.
  124960. */
  124961. useParallax: boolean;
  124962. /**
  124963. * Allows using the bump map in parallax occlusion mode.
  124964. */
  124965. useParallaxOcclusion: boolean;
  124966. /**
  124967. * Controls the scale bias of the parallax mode.
  124968. */
  124969. parallaxScaleBias: number;
  124970. /**
  124971. * If sets to true, disables all the lights affecting the material.
  124972. */
  124973. disableLighting: boolean;
  124974. /**
  124975. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  124976. */
  124977. forceIrradianceInFragment: boolean;
  124978. /**
  124979. * Number of Simultaneous lights allowed on the material.
  124980. */
  124981. maxSimultaneousLights: number;
  124982. /**
  124983. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  124984. */
  124985. invertNormalMapX: boolean;
  124986. /**
  124987. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  124988. */
  124989. invertNormalMapY: boolean;
  124990. /**
  124991. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  124992. */
  124993. twoSidedLighting: boolean;
  124994. /**
  124995. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  124996. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  124997. */
  124998. useAlphaFresnel: boolean;
  124999. /**
  125000. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  125001. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  125002. */
  125003. useLinearAlphaFresnel: boolean;
  125004. /**
  125005. * Let user defines the brdf lookup texture used for IBL.
  125006. * A default 8bit version is embedded but you could point at :
  125007. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  125008. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  125009. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  125010. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  125011. */
  125012. environmentBRDFTexture: Nullable<BaseTexture>;
  125013. /**
  125014. * Force normal to face away from face.
  125015. */
  125016. forceNormalForward: boolean;
  125017. /**
  125018. * Enables specular anti aliasing in the PBR shader.
  125019. * It will both interacts on the Geometry for analytical and IBL lighting.
  125020. * It also prefilter the roughness map based on the bump values.
  125021. */
  125022. enableSpecularAntiAliasing: boolean;
  125023. /**
  125024. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  125025. * makes the reflect vector face the model (under horizon).
  125026. */
  125027. useHorizonOcclusion: boolean;
  125028. /**
  125029. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  125030. * too much the area relying on ambient texture to define their ambient occlusion.
  125031. */
  125032. useRadianceOcclusion: boolean;
  125033. /**
  125034. * If set to true, no lighting calculations will be applied.
  125035. */
  125036. unlit: boolean;
  125037. /**
  125038. * Gets the image processing configuration used either in this material.
  125039. */
  125040. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  125041. /**
  125042. * Sets the Default image processing configuration used either in the this material.
  125043. *
  125044. * If sets to null, the scene one is in use.
  125045. */
  125046. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  125047. /**
  125048. * Gets wether the color curves effect is enabled.
  125049. */
  125050. get cameraColorCurvesEnabled(): boolean;
  125051. /**
  125052. * Sets wether the color curves effect is enabled.
  125053. */
  125054. set cameraColorCurvesEnabled(value: boolean);
  125055. /**
  125056. * Gets wether the color grading effect is enabled.
  125057. */
  125058. get cameraColorGradingEnabled(): boolean;
  125059. /**
  125060. * Gets wether the color grading effect is enabled.
  125061. */
  125062. set cameraColorGradingEnabled(value: boolean);
  125063. /**
  125064. * Gets wether tonemapping is enabled or not.
  125065. */
  125066. get cameraToneMappingEnabled(): boolean;
  125067. /**
  125068. * Sets wether tonemapping is enabled or not
  125069. */
  125070. set cameraToneMappingEnabled(value: boolean);
  125071. /**
  125072. * The camera exposure used on this material.
  125073. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  125074. * This corresponds to a photographic exposure.
  125075. */
  125076. get cameraExposure(): number;
  125077. /**
  125078. * The camera exposure used on this material.
  125079. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  125080. * This corresponds to a photographic exposure.
  125081. */
  125082. set cameraExposure(value: number);
  125083. /**
  125084. * Gets The camera contrast used on this material.
  125085. */
  125086. get cameraContrast(): number;
  125087. /**
  125088. * Sets The camera contrast used on this material.
  125089. */
  125090. set cameraContrast(value: number);
  125091. /**
  125092. * Gets the Color Grading 2D Lookup Texture.
  125093. */
  125094. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  125095. /**
  125096. * Sets the Color Grading 2D Lookup Texture.
  125097. */
  125098. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  125099. /**
  125100. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  125101. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  125102. * 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;
  125103. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  125104. */
  125105. get cameraColorCurves(): Nullable<ColorCurves>;
  125106. /**
  125107. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  125108. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  125109. * 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;
  125110. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  125111. */
  125112. set cameraColorCurves(value: Nullable<ColorCurves>);
  125113. /**
  125114. * Instantiates a new PBRMaterial instance.
  125115. *
  125116. * @param name The material name
  125117. * @param scene The scene the material will be use in.
  125118. */
  125119. constructor(name: string, scene: Scene);
  125120. /**
  125121. * Returns the name of this material class.
  125122. */
  125123. getClassName(): string;
  125124. /**
  125125. * Makes a duplicate of the current material.
  125126. * @param name - name to use for the new material.
  125127. */
  125128. clone(name: string): PBRMaterial;
  125129. /**
  125130. * Serializes this PBR Material.
  125131. * @returns - An object with the serialized material.
  125132. */
  125133. serialize(): any;
  125134. /**
  125135. * Parses a PBR Material from a serialized object.
  125136. * @param source - Serialized object.
  125137. * @param scene - BJS scene instance.
  125138. * @param rootUrl - url for the scene object
  125139. * @returns - PBRMaterial
  125140. */
  125141. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  125142. }
  125143. }
  125144. declare module BABYLON {
  125145. /**
  125146. * Direct draw surface info
  125147. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  125148. */
  125149. export interface DDSInfo {
  125150. /**
  125151. * Width of the texture
  125152. */
  125153. width: number;
  125154. /**
  125155. * Width of the texture
  125156. */
  125157. height: number;
  125158. /**
  125159. * Number of Mipmaps for the texture
  125160. * @see https://en.wikipedia.org/wiki/Mipmap
  125161. */
  125162. mipmapCount: number;
  125163. /**
  125164. * If the textures format is a known fourCC format
  125165. * @see https://www.fourcc.org/
  125166. */
  125167. isFourCC: boolean;
  125168. /**
  125169. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  125170. */
  125171. isRGB: boolean;
  125172. /**
  125173. * If the texture is a lumincance format
  125174. */
  125175. isLuminance: boolean;
  125176. /**
  125177. * If this is a cube texture
  125178. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  125179. */
  125180. isCube: boolean;
  125181. /**
  125182. * If the texture is a compressed format eg. FOURCC_DXT1
  125183. */
  125184. isCompressed: boolean;
  125185. /**
  125186. * The dxgiFormat of the texture
  125187. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  125188. */
  125189. dxgiFormat: number;
  125190. /**
  125191. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  125192. */
  125193. textureType: number;
  125194. /**
  125195. * Sphericle polynomial created for the dds texture
  125196. */
  125197. sphericalPolynomial?: SphericalPolynomial;
  125198. }
  125199. /**
  125200. * Class used to provide DDS decompression tools
  125201. */
  125202. export class DDSTools {
  125203. /**
  125204. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  125205. */
  125206. static StoreLODInAlphaChannel: boolean;
  125207. /**
  125208. * Gets DDS information from an array buffer
  125209. * @param data defines the array buffer view to read data from
  125210. * @returns the DDS information
  125211. */
  125212. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  125213. private static _FloatView;
  125214. private static _Int32View;
  125215. private static _ToHalfFloat;
  125216. private static _FromHalfFloat;
  125217. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  125218. private static _GetHalfFloatRGBAArrayBuffer;
  125219. private static _GetFloatRGBAArrayBuffer;
  125220. private static _GetFloatAsUIntRGBAArrayBuffer;
  125221. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  125222. private static _GetRGBAArrayBuffer;
  125223. private static _ExtractLongWordOrder;
  125224. private static _GetRGBArrayBuffer;
  125225. private static _GetLuminanceArrayBuffer;
  125226. /**
  125227. * Uploads DDS Levels to a Babylon Texture
  125228. * @hidden
  125229. */
  125230. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  125231. }
  125232. interface ThinEngine {
  125233. /**
  125234. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  125235. * @param rootUrl defines the url where the file to load is located
  125236. * @param scene defines the current scene
  125237. * @param lodScale defines scale to apply to the mip map selection
  125238. * @param lodOffset defines offset to apply to the mip map selection
  125239. * @param onLoad defines an optional callback raised when the texture is loaded
  125240. * @param onError defines an optional callback raised if there is an issue to load the texture
  125241. * @param format defines the format of the data
  125242. * @param forcedExtension defines the extension to use to pick the right loader
  125243. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  125244. * @returns the cube texture as an InternalTexture
  125245. */
  125246. 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;
  125247. }
  125248. }
  125249. declare module BABYLON {
  125250. /**
  125251. * Implementation of the DDS Texture Loader.
  125252. * @hidden
  125253. */
  125254. export class _DDSTextureLoader implements IInternalTextureLoader {
  125255. /**
  125256. * Defines wether the loader supports cascade loading the different faces.
  125257. */
  125258. readonly supportCascades: boolean;
  125259. /**
  125260. * This returns if the loader support the current file information.
  125261. * @param extension defines the file extension of the file being loaded
  125262. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125263. * @param fallback defines the fallback internal texture if any
  125264. * @param isBase64 defines whether the texture is encoded as a base64
  125265. * @param isBuffer defines whether the texture data are stored as a buffer
  125266. * @returns true if the loader can load the specified file
  125267. */
  125268. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  125269. /**
  125270. * Transform the url before loading if required.
  125271. * @param rootUrl the url of the texture
  125272. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125273. * @returns the transformed texture
  125274. */
  125275. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  125276. /**
  125277. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  125278. * @param rootUrl the url of the texture
  125279. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125280. * @returns the fallback texture
  125281. */
  125282. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  125283. /**
  125284. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  125285. * @param data contains the texture data
  125286. * @param texture defines the BabylonJS internal texture
  125287. * @param createPolynomials will be true if polynomials have been requested
  125288. * @param onLoad defines the callback to trigger once the texture is ready
  125289. * @param onError defines the callback to trigger in case of error
  125290. */
  125291. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125292. /**
  125293. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  125294. * @param data contains the texture data
  125295. * @param texture defines the BabylonJS internal texture
  125296. * @param callback defines the method to call once ready to upload
  125297. */
  125298. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  125299. }
  125300. }
  125301. declare module BABYLON {
  125302. /**
  125303. * Implementation of the ENV Texture Loader.
  125304. * @hidden
  125305. */
  125306. export class _ENVTextureLoader implements IInternalTextureLoader {
  125307. /**
  125308. * Defines wether the loader supports cascade loading the different faces.
  125309. */
  125310. readonly supportCascades: boolean;
  125311. /**
  125312. * This returns if the loader support the current file information.
  125313. * @param extension defines the file extension of the file being loaded
  125314. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125315. * @param fallback defines the fallback internal texture if any
  125316. * @param isBase64 defines whether the texture is encoded as a base64
  125317. * @param isBuffer defines whether the texture data are stored as a buffer
  125318. * @returns true if the loader can load the specified file
  125319. */
  125320. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  125321. /**
  125322. * Transform the url before loading if required.
  125323. * @param rootUrl the url of the texture
  125324. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125325. * @returns the transformed texture
  125326. */
  125327. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  125328. /**
  125329. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  125330. * @param rootUrl the url of the texture
  125331. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125332. * @returns the fallback texture
  125333. */
  125334. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  125335. /**
  125336. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  125337. * @param data contains the texture data
  125338. * @param texture defines the BabylonJS internal texture
  125339. * @param createPolynomials will be true if polynomials have been requested
  125340. * @param onLoad defines the callback to trigger once the texture is ready
  125341. * @param onError defines the callback to trigger in case of error
  125342. */
  125343. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125344. /**
  125345. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  125346. * @param data contains the texture data
  125347. * @param texture defines the BabylonJS internal texture
  125348. * @param callback defines the method to call once ready to upload
  125349. */
  125350. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  125351. }
  125352. }
  125353. declare module BABYLON {
  125354. /**
  125355. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  125356. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  125357. */
  125358. export class KhronosTextureContainer {
  125359. /** contents of the KTX container file */
  125360. data: ArrayBufferView;
  125361. private static HEADER_LEN;
  125362. private static COMPRESSED_2D;
  125363. private static COMPRESSED_3D;
  125364. private static TEX_2D;
  125365. private static TEX_3D;
  125366. /**
  125367. * Gets the openGL type
  125368. */
  125369. glType: number;
  125370. /**
  125371. * Gets the openGL type size
  125372. */
  125373. glTypeSize: number;
  125374. /**
  125375. * Gets the openGL format
  125376. */
  125377. glFormat: number;
  125378. /**
  125379. * Gets the openGL internal format
  125380. */
  125381. glInternalFormat: number;
  125382. /**
  125383. * Gets the base internal format
  125384. */
  125385. glBaseInternalFormat: number;
  125386. /**
  125387. * Gets image width in pixel
  125388. */
  125389. pixelWidth: number;
  125390. /**
  125391. * Gets image height in pixel
  125392. */
  125393. pixelHeight: number;
  125394. /**
  125395. * Gets image depth in pixels
  125396. */
  125397. pixelDepth: number;
  125398. /**
  125399. * Gets the number of array elements
  125400. */
  125401. numberOfArrayElements: number;
  125402. /**
  125403. * Gets the number of faces
  125404. */
  125405. numberOfFaces: number;
  125406. /**
  125407. * Gets the number of mipmap levels
  125408. */
  125409. numberOfMipmapLevels: number;
  125410. /**
  125411. * Gets the bytes of key value data
  125412. */
  125413. bytesOfKeyValueData: number;
  125414. /**
  125415. * Gets the load type
  125416. */
  125417. loadType: number;
  125418. /**
  125419. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  125420. */
  125421. isInvalid: boolean;
  125422. /**
  125423. * Creates a new KhronosTextureContainer
  125424. * @param data contents of the KTX container file
  125425. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  125426. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  125427. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  125428. */
  125429. constructor(
  125430. /** contents of the KTX container file */
  125431. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  125432. /**
  125433. * Uploads KTX content to a Babylon Texture.
  125434. * It is assumed that the texture has already been created & is currently bound
  125435. * @hidden
  125436. */
  125437. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  125438. private _upload2DCompressedLevels;
  125439. }
  125440. }
  125441. declare module BABYLON {
  125442. /**
  125443. * Implementation of the KTX Texture Loader.
  125444. * @hidden
  125445. */
  125446. export class _KTXTextureLoader implements IInternalTextureLoader {
  125447. /**
  125448. * Defines wether the loader supports cascade loading the different faces.
  125449. */
  125450. readonly supportCascades: boolean;
  125451. /**
  125452. * This returns if the loader support the current file information.
  125453. * @param extension defines the file extension of the file being loaded
  125454. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125455. * @param fallback defines the fallback internal texture if any
  125456. * @param isBase64 defines whether the texture is encoded as a base64
  125457. * @param isBuffer defines whether the texture data are stored as a buffer
  125458. * @returns true if the loader can load the specified file
  125459. */
  125460. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  125461. /**
  125462. * Transform the url before loading if required.
  125463. * @param rootUrl the url of the texture
  125464. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125465. * @returns the transformed texture
  125466. */
  125467. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  125468. /**
  125469. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  125470. * @param rootUrl the url of the texture
  125471. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125472. * @returns the fallback texture
  125473. */
  125474. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  125475. /**
  125476. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  125477. * @param data contains the texture data
  125478. * @param texture defines the BabylonJS internal texture
  125479. * @param createPolynomials will be true if polynomials have been requested
  125480. * @param onLoad defines the callback to trigger once the texture is ready
  125481. * @param onError defines the callback to trigger in case of error
  125482. */
  125483. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125484. /**
  125485. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  125486. * @param data contains the texture data
  125487. * @param texture defines the BabylonJS internal texture
  125488. * @param callback defines the method to call once ready to upload
  125489. */
  125490. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  125491. }
  125492. }
  125493. declare module BABYLON {
  125494. /** @hidden */
  125495. export var _forceSceneHelpersToBundle: boolean;
  125496. interface Scene {
  125497. /**
  125498. * Creates a default light for the scene.
  125499. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  125500. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  125501. */
  125502. createDefaultLight(replace?: boolean): void;
  125503. /**
  125504. * Creates a default camera for the scene.
  125505. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  125506. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  125507. * @param replace has default false, when true replaces the active camera in the scene
  125508. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  125509. */
  125510. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  125511. /**
  125512. * Creates a default camera and a default light.
  125513. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  125514. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  125515. * @param replace has the default false, when true replaces the active camera/light in the scene
  125516. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  125517. */
  125518. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  125519. /**
  125520. * Creates a new sky box
  125521. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  125522. * @param environmentTexture defines the texture to use as environment texture
  125523. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  125524. * @param scale defines the overall scale of the skybox
  125525. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  125526. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  125527. * @returns a new mesh holding the sky box
  125528. */
  125529. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  125530. /**
  125531. * Creates a new environment
  125532. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  125533. * @param options defines the options you can use to configure the environment
  125534. * @returns the new EnvironmentHelper
  125535. */
  125536. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  125537. /**
  125538. * Creates a new VREXperienceHelper
  125539. * @see http://doc.babylonjs.com/how_to/webvr_helper
  125540. * @param webVROptions defines the options used to create the new VREXperienceHelper
  125541. * @returns a new VREXperienceHelper
  125542. */
  125543. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  125544. /**
  125545. * Creates a new WebXRDefaultExperience
  125546. * @see http://doc.babylonjs.com/how_to/webxr
  125547. * @param options experience options
  125548. * @returns a promise for a new WebXRDefaultExperience
  125549. */
  125550. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  125551. }
  125552. }
  125553. declare module BABYLON {
  125554. /**
  125555. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  125556. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  125557. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  125558. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  125559. */
  125560. export class VideoDome extends TransformNode {
  125561. /**
  125562. * Define the video source as a Monoscopic panoramic 360 video.
  125563. */
  125564. static readonly MODE_MONOSCOPIC: number;
  125565. /**
  125566. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  125567. */
  125568. static readonly MODE_TOPBOTTOM: number;
  125569. /**
  125570. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  125571. */
  125572. static readonly MODE_SIDEBYSIDE: number;
  125573. private _halfDome;
  125574. private _useDirectMapping;
  125575. /**
  125576. * The video texture being displayed on the sphere
  125577. */
  125578. protected _videoTexture: VideoTexture;
  125579. /**
  125580. * Gets the video texture being displayed on the sphere
  125581. */
  125582. get videoTexture(): VideoTexture;
  125583. /**
  125584. * The skybox material
  125585. */
  125586. protected _material: BackgroundMaterial;
  125587. /**
  125588. * The surface used for the skybox
  125589. */
  125590. protected _mesh: Mesh;
  125591. /**
  125592. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  125593. */
  125594. private _halfDomeMask;
  125595. /**
  125596. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  125597. * Also see the options.resolution property.
  125598. */
  125599. get fovMultiplier(): number;
  125600. set fovMultiplier(value: number);
  125601. private _videoMode;
  125602. /**
  125603. * Gets or set the current video mode for the video. It can be:
  125604. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  125605. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  125606. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  125607. */
  125608. get videoMode(): number;
  125609. set videoMode(value: number);
  125610. /**
  125611. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  125612. *
  125613. */
  125614. get halfDome(): boolean;
  125615. /**
  125616. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  125617. */
  125618. set halfDome(enabled: boolean);
  125619. /**
  125620. * Oberserver used in Stereoscopic VR Mode.
  125621. */
  125622. private _onBeforeCameraRenderObserver;
  125623. /**
  125624. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  125625. * @param name Element's name, child elements will append suffixes for their own names.
  125626. * @param urlsOrVideo defines the url(s) or the video element to use
  125627. * @param options An object containing optional or exposed sub element properties
  125628. */
  125629. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  125630. resolution?: number;
  125631. clickToPlay?: boolean;
  125632. autoPlay?: boolean;
  125633. loop?: boolean;
  125634. size?: number;
  125635. poster?: string;
  125636. faceForward?: boolean;
  125637. useDirectMapping?: boolean;
  125638. halfDomeMode?: boolean;
  125639. }, scene: Scene);
  125640. private _changeVideoMode;
  125641. /**
  125642. * Releases resources associated with this node.
  125643. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  125644. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  125645. */
  125646. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  125647. }
  125648. }
  125649. declare module BABYLON {
  125650. /**
  125651. * This class can be used to get instrumentation data from a Babylon engine
  125652. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  125653. */
  125654. export class EngineInstrumentation implements IDisposable {
  125655. /**
  125656. * Define the instrumented engine.
  125657. */
  125658. engine: Engine;
  125659. private _captureGPUFrameTime;
  125660. private _gpuFrameTimeToken;
  125661. private _gpuFrameTime;
  125662. private _captureShaderCompilationTime;
  125663. private _shaderCompilationTime;
  125664. private _onBeginFrameObserver;
  125665. private _onEndFrameObserver;
  125666. private _onBeforeShaderCompilationObserver;
  125667. private _onAfterShaderCompilationObserver;
  125668. /**
  125669. * Gets the perf counter used for GPU frame time
  125670. */
  125671. get gpuFrameTimeCounter(): PerfCounter;
  125672. /**
  125673. * Gets the GPU frame time capture status
  125674. */
  125675. get captureGPUFrameTime(): boolean;
  125676. /**
  125677. * Enable or disable the GPU frame time capture
  125678. */
  125679. set captureGPUFrameTime(value: boolean);
  125680. /**
  125681. * Gets the perf counter used for shader compilation time
  125682. */
  125683. get shaderCompilationTimeCounter(): PerfCounter;
  125684. /**
  125685. * Gets the shader compilation time capture status
  125686. */
  125687. get captureShaderCompilationTime(): boolean;
  125688. /**
  125689. * Enable or disable the shader compilation time capture
  125690. */
  125691. set captureShaderCompilationTime(value: boolean);
  125692. /**
  125693. * Instantiates a new engine instrumentation.
  125694. * This class can be used to get instrumentation data from a Babylon engine
  125695. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  125696. * @param engine Defines the engine to instrument
  125697. */
  125698. constructor(
  125699. /**
  125700. * Define the instrumented engine.
  125701. */
  125702. engine: Engine);
  125703. /**
  125704. * Dispose and release associated resources.
  125705. */
  125706. dispose(): void;
  125707. }
  125708. }
  125709. declare module BABYLON {
  125710. /**
  125711. * This class can be used to get instrumentation data from a Babylon engine
  125712. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  125713. */
  125714. export class SceneInstrumentation implements IDisposable {
  125715. /**
  125716. * Defines the scene to instrument
  125717. */
  125718. scene: Scene;
  125719. private _captureActiveMeshesEvaluationTime;
  125720. private _activeMeshesEvaluationTime;
  125721. private _captureRenderTargetsRenderTime;
  125722. private _renderTargetsRenderTime;
  125723. private _captureFrameTime;
  125724. private _frameTime;
  125725. private _captureRenderTime;
  125726. private _renderTime;
  125727. private _captureInterFrameTime;
  125728. private _interFrameTime;
  125729. private _captureParticlesRenderTime;
  125730. private _particlesRenderTime;
  125731. private _captureSpritesRenderTime;
  125732. private _spritesRenderTime;
  125733. private _capturePhysicsTime;
  125734. private _physicsTime;
  125735. private _captureAnimationsTime;
  125736. private _animationsTime;
  125737. private _captureCameraRenderTime;
  125738. private _cameraRenderTime;
  125739. private _onBeforeActiveMeshesEvaluationObserver;
  125740. private _onAfterActiveMeshesEvaluationObserver;
  125741. private _onBeforeRenderTargetsRenderObserver;
  125742. private _onAfterRenderTargetsRenderObserver;
  125743. private _onAfterRenderObserver;
  125744. private _onBeforeDrawPhaseObserver;
  125745. private _onAfterDrawPhaseObserver;
  125746. private _onBeforeAnimationsObserver;
  125747. private _onBeforeParticlesRenderingObserver;
  125748. private _onAfterParticlesRenderingObserver;
  125749. private _onBeforeSpritesRenderingObserver;
  125750. private _onAfterSpritesRenderingObserver;
  125751. private _onBeforePhysicsObserver;
  125752. private _onAfterPhysicsObserver;
  125753. private _onAfterAnimationsObserver;
  125754. private _onBeforeCameraRenderObserver;
  125755. private _onAfterCameraRenderObserver;
  125756. /**
  125757. * Gets the perf counter used for active meshes evaluation time
  125758. */
  125759. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  125760. /**
  125761. * Gets the active meshes evaluation time capture status
  125762. */
  125763. get captureActiveMeshesEvaluationTime(): boolean;
  125764. /**
  125765. * Enable or disable the active meshes evaluation time capture
  125766. */
  125767. set captureActiveMeshesEvaluationTime(value: boolean);
  125768. /**
  125769. * Gets the perf counter used for render targets render time
  125770. */
  125771. get renderTargetsRenderTimeCounter(): PerfCounter;
  125772. /**
  125773. * Gets the render targets render time capture status
  125774. */
  125775. get captureRenderTargetsRenderTime(): boolean;
  125776. /**
  125777. * Enable or disable the render targets render time capture
  125778. */
  125779. set captureRenderTargetsRenderTime(value: boolean);
  125780. /**
  125781. * Gets the perf counter used for particles render time
  125782. */
  125783. get particlesRenderTimeCounter(): PerfCounter;
  125784. /**
  125785. * Gets the particles render time capture status
  125786. */
  125787. get captureParticlesRenderTime(): boolean;
  125788. /**
  125789. * Enable or disable the particles render time capture
  125790. */
  125791. set captureParticlesRenderTime(value: boolean);
  125792. /**
  125793. * Gets the perf counter used for sprites render time
  125794. */
  125795. get spritesRenderTimeCounter(): PerfCounter;
  125796. /**
  125797. * Gets the sprites render time capture status
  125798. */
  125799. get captureSpritesRenderTime(): boolean;
  125800. /**
  125801. * Enable or disable the sprites render time capture
  125802. */
  125803. set captureSpritesRenderTime(value: boolean);
  125804. /**
  125805. * Gets the perf counter used for physics time
  125806. */
  125807. get physicsTimeCounter(): PerfCounter;
  125808. /**
  125809. * Gets the physics time capture status
  125810. */
  125811. get capturePhysicsTime(): boolean;
  125812. /**
  125813. * Enable or disable the physics time capture
  125814. */
  125815. set capturePhysicsTime(value: boolean);
  125816. /**
  125817. * Gets the perf counter used for animations time
  125818. */
  125819. get animationsTimeCounter(): PerfCounter;
  125820. /**
  125821. * Gets the animations time capture status
  125822. */
  125823. get captureAnimationsTime(): boolean;
  125824. /**
  125825. * Enable or disable the animations time capture
  125826. */
  125827. set captureAnimationsTime(value: boolean);
  125828. /**
  125829. * Gets the perf counter used for frame time capture
  125830. */
  125831. get frameTimeCounter(): PerfCounter;
  125832. /**
  125833. * Gets the frame time capture status
  125834. */
  125835. get captureFrameTime(): boolean;
  125836. /**
  125837. * Enable or disable the frame time capture
  125838. */
  125839. set captureFrameTime(value: boolean);
  125840. /**
  125841. * Gets the perf counter used for inter-frames time capture
  125842. */
  125843. get interFrameTimeCounter(): PerfCounter;
  125844. /**
  125845. * Gets the inter-frames time capture status
  125846. */
  125847. get captureInterFrameTime(): boolean;
  125848. /**
  125849. * Enable or disable the inter-frames time capture
  125850. */
  125851. set captureInterFrameTime(value: boolean);
  125852. /**
  125853. * Gets the perf counter used for render time capture
  125854. */
  125855. get renderTimeCounter(): PerfCounter;
  125856. /**
  125857. * Gets the render time capture status
  125858. */
  125859. get captureRenderTime(): boolean;
  125860. /**
  125861. * Enable or disable the render time capture
  125862. */
  125863. set captureRenderTime(value: boolean);
  125864. /**
  125865. * Gets the perf counter used for camera render time capture
  125866. */
  125867. get cameraRenderTimeCounter(): PerfCounter;
  125868. /**
  125869. * Gets the camera render time capture status
  125870. */
  125871. get captureCameraRenderTime(): boolean;
  125872. /**
  125873. * Enable or disable the camera render time capture
  125874. */
  125875. set captureCameraRenderTime(value: boolean);
  125876. /**
  125877. * Gets the perf counter used for draw calls
  125878. */
  125879. get drawCallsCounter(): PerfCounter;
  125880. /**
  125881. * Instantiates a new scene instrumentation.
  125882. * This class can be used to get instrumentation data from a Babylon engine
  125883. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  125884. * @param scene Defines the scene to instrument
  125885. */
  125886. constructor(
  125887. /**
  125888. * Defines the scene to instrument
  125889. */
  125890. scene: Scene);
  125891. /**
  125892. * Dispose and release associated resources.
  125893. */
  125894. dispose(): void;
  125895. }
  125896. }
  125897. declare module BABYLON {
  125898. /** @hidden */
  125899. export var glowMapGenerationPixelShader: {
  125900. name: string;
  125901. shader: string;
  125902. };
  125903. }
  125904. declare module BABYLON {
  125905. /** @hidden */
  125906. export var glowMapGenerationVertexShader: {
  125907. name: string;
  125908. shader: string;
  125909. };
  125910. }
  125911. declare module BABYLON {
  125912. /**
  125913. * Effect layer options. This helps customizing the behaviour
  125914. * of the effect layer.
  125915. */
  125916. export interface IEffectLayerOptions {
  125917. /**
  125918. * Multiplication factor apply to the canvas size to compute the render target size
  125919. * used to generated the objects (the smaller the faster).
  125920. */
  125921. mainTextureRatio: number;
  125922. /**
  125923. * Enforces a fixed size texture to ensure effect stability across devices.
  125924. */
  125925. mainTextureFixedSize?: number;
  125926. /**
  125927. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  125928. */
  125929. alphaBlendingMode: number;
  125930. /**
  125931. * The camera attached to the layer.
  125932. */
  125933. camera: Nullable<Camera>;
  125934. /**
  125935. * The rendering group to draw the layer in.
  125936. */
  125937. renderingGroupId: number;
  125938. }
  125939. /**
  125940. * The effect layer Helps adding post process effect blended with the main pass.
  125941. *
  125942. * This can be for instance use to generate glow or higlight effects on the scene.
  125943. *
  125944. * The effect layer class can not be used directly and is intented to inherited from to be
  125945. * customized per effects.
  125946. */
  125947. export abstract class EffectLayer {
  125948. private _vertexBuffers;
  125949. private _indexBuffer;
  125950. private _cachedDefines;
  125951. private _effectLayerMapGenerationEffect;
  125952. private _effectLayerOptions;
  125953. private _mergeEffect;
  125954. protected _scene: Scene;
  125955. protected _engine: Engine;
  125956. protected _maxSize: number;
  125957. protected _mainTextureDesiredSize: ISize;
  125958. protected _mainTexture: RenderTargetTexture;
  125959. protected _shouldRender: boolean;
  125960. protected _postProcesses: PostProcess[];
  125961. protected _textures: BaseTexture[];
  125962. protected _emissiveTextureAndColor: {
  125963. texture: Nullable<BaseTexture>;
  125964. color: Color4;
  125965. };
  125966. /**
  125967. * The name of the layer
  125968. */
  125969. name: string;
  125970. /**
  125971. * The clear color of the texture used to generate the glow map.
  125972. */
  125973. neutralColor: Color4;
  125974. /**
  125975. * Specifies whether the highlight layer is enabled or not.
  125976. */
  125977. isEnabled: boolean;
  125978. /**
  125979. * Gets the camera attached to the layer.
  125980. */
  125981. get camera(): Nullable<Camera>;
  125982. /**
  125983. * Gets the rendering group id the layer should render in.
  125984. */
  125985. get renderingGroupId(): number;
  125986. set renderingGroupId(renderingGroupId: number);
  125987. /**
  125988. * An event triggered when the effect layer has been disposed.
  125989. */
  125990. onDisposeObservable: Observable<EffectLayer>;
  125991. /**
  125992. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  125993. */
  125994. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  125995. /**
  125996. * An event triggered when the generated texture is being merged in the scene.
  125997. */
  125998. onBeforeComposeObservable: Observable<EffectLayer>;
  125999. /**
  126000. * An event triggered when the mesh is rendered into the effect render target.
  126001. */
  126002. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  126003. /**
  126004. * An event triggered after the mesh has been rendered into the effect render target.
  126005. */
  126006. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  126007. /**
  126008. * An event triggered when the generated texture has been merged in the scene.
  126009. */
  126010. onAfterComposeObservable: Observable<EffectLayer>;
  126011. /**
  126012. * An event triggered when the efffect layer changes its size.
  126013. */
  126014. onSizeChangedObservable: Observable<EffectLayer>;
  126015. /** @hidden */
  126016. static _SceneComponentInitialization: (scene: Scene) => void;
  126017. /**
  126018. * Instantiates a new effect Layer and references it in the scene.
  126019. * @param name The name of the layer
  126020. * @param scene The scene to use the layer in
  126021. */
  126022. constructor(
  126023. /** The Friendly of the effect in the scene */
  126024. name: string, scene: Scene);
  126025. /**
  126026. * Get the effect name of the layer.
  126027. * @return The effect name
  126028. */
  126029. abstract getEffectName(): string;
  126030. /**
  126031. * Checks for the readiness of the element composing the layer.
  126032. * @param subMesh the mesh to check for
  126033. * @param useInstances specify whether or not to use instances to render the mesh
  126034. * @return true if ready otherwise, false
  126035. */
  126036. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126037. /**
  126038. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  126039. * @returns true if the effect requires stencil during the main canvas render pass.
  126040. */
  126041. abstract needStencil(): boolean;
  126042. /**
  126043. * Create the merge effect. This is the shader use to blit the information back
  126044. * to the main canvas at the end of the scene rendering.
  126045. * @returns The effect containing the shader used to merge the effect on the main canvas
  126046. */
  126047. protected abstract _createMergeEffect(): Effect;
  126048. /**
  126049. * Creates the render target textures and post processes used in the effect layer.
  126050. */
  126051. protected abstract _createTextureAndPostProcesses(): void;
  126052. /**
  126053. * Implementation specific of rendering the generating effect on the main canvas.
  126054. * @param effect The effect used to render through
  126055. */
  126056. protected abstract _internalRender(effect: Effect): void;
  126057. /**
  126058. * Sets the required values for both the emissive texture and and the main color.
  126059. */
  126060. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  126061. /**
  126062. * Free any resources and references associated to a mesh.
  126063. * Internal use
  126064. * @param mesh The mesh to free.
  126065. */
  126066. abstract _disposeMesh(mesh: Mesh): void;
  126067. /**
  126068. * Serializes this layer (Glow or Highlight for example)
  126069. * @returns a serialized layer object
  126070. */
  126071. abstract serialize?(): any;
  126072. /**
  126073. * Initializes the effect layer with the required options.
  126074. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  126075. */
  126076. protected _init(options: Partial<IEffectLayerOptions>): void;
  126077. /**
  126078. * Generates the index buffer of the full screen quad blending to the main canvas.
  126079. */
  126080. private _generateIndexBuffer;
  126081. /**
  126082. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  126083. */
  126084. private _generateVertexBuffer;
  126085. /**
  126086. * Sets the main texture desired size which is the closest power of two
  126087. * of the engine canvas size.
  126088. */
  126089. private _setMainTextureSize;
  126090. /**
  126091. * Creates the main texture for the effect layer.
  126092. */
  126093. protected _createMainTexture(): void;
  126094. /**
  126095. * Adds specific effects defines.
  126096. * @param defines The defines to add specifics to.
  126097. */
  126098. protected _addCustomEffectDefines(defines: string[]): void;
  126099. /**
  126100. * Checks for the readiness of the element composing the layer.
  126101. * @param subMesh the mesh to check for
  126102. * @param useInstances specify whether or not to use instances to render the mesh
  126103. * @param emissiveTexture the associated emissive texture used to generate the glow
  126104. * @return true if ready otherwise, false
  126105. */
  126106. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  126107. /**
  126108. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  126109. */
  126110. render(): void;
  126111. /**
  126112. * Determine if a given mesh will be used in the current effect.
  126113. * @param mesh mesh to test
  126114. * @returns true if the mesh will be used
  126115. */
  126116. hasMesh(mesh: AbstractMesh): boolean;
  126117. /**
  126118. * Returns true if the layer contains information to display, otherwise false.
  126119. * @returns true if the glow layer should be rendered
  126120. */
  126121. shouldRender(): boolean;
  126122. /**
  126123. * Returns true if the mesh should render, otherwise false.
  126124. * @param mesh The mesh to render
  126125. * @returns true if it should render otherwise false
  126126. */
  126127. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  126128. /**
  126129. * Returns true if the mesh can be rendered, otherwise false.
  126130. * @param mesh The mesh to render
  126131. * @param material The material used on the mesh
  126132. * @returns true if it can be rendered otherwise false
  126133. */
  126134. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  126135. /**
  126136. * Returns true if the mesh should render, otherwise false.
  126137. * @param mesh The mesh to render
  126138. * @returns true if it should render otherwise false
  126139. */
  126140. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  126141. /**
  126142. * Renders the submesh passed in parameter to the generation map.
  126143. */
  126144. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  126145. /**
  126146. * Defines whether the current material of the mesh should be use to render the effect.
  126147. * @param mesh defines the current mesh to render
  126148. */
  126149. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  126150. /**
  126151. * Rebuild the required buffers.
  126152. * @hidden Internal use only.
  126153. */
  126154. _rebuild(): void;
  126155. /**
  126156. * Dispose only the render target textures and post process.
  126157. */
  126158. private _disposeTextureAndPostProcesses;
  126159. /**
  126160. * Dispose the highlight layer and free resources.
  126161. */
  126162. dispose(): void;
  126163. /**
  126164. * Gets the class name of the effect layer
  126165. * @returns the string with the class name of the effect layer
  126166. */
  126167. getClassName(): string;
  126168. /**
  126169. * Creates an effect layer from parsed effect layer data
  126170. * @param parsedEffectLayer defines effect layer data
  126171. * @param scene defines the current scene
  126172. * @param rootUrl defines the root URL containing the effect layer information
  126173. * @returns a parsed effect Layer
  126174. */
  126175. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  126176. }
  126177. }
  126178. declare module BABYLON {
  126179. interface AbstractScene {
  126180. /**
  126181. * The list of effect layers (highlights/glow) added to the scene
  126182. * @see http://doc.babylonjs.com/how_to/highlight_layer
  126183. * @see http://doc.babylonjs.com/how_to/glow_layer
  126184. */
  126185. effectLayers: Array<EffectLayer>;
  126186. /**
  126187. * Removes the given effect layer from this scene.
  126188. * @param toRemove defines the effect layer to remove
  126189. * @returns the index of the removed effect layer
  126190. */
  126191. removeEffectLayer(toRemove: EffectLayer): number;
  126192. /**
  126193. * Adds the given effect layer to this scene
  126194. * @param newEffectLayer defines the effect layer to add
  126195. */
  126196. addEffectLayer(newEffectLayer: EffectLayer): void;
  126197. }
  126198. /**
  126199. * Defines the layer scene component responsible to manage any effect layers
  126200. * in a given scene.
  126201. */
  126202. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  126203. /**
  126204. * The component name helpfull to identify the component in the list of scene components.
  126205. */
  126206. readonly name: string;
  126207. /**
  126208. * The scene the component belongs to.
  126209. */
  126210. scene: Scene;
  126211. private _engine;
  126212. private _renderEffects;
  126213. private _needStencil;
  126214. private _previousStencilState;
  126215. /**
  126216. * Creates a new instance of the component for the given scene
  126217. * @param scene Defines the scene to register the component in
  126218. */
  126219. constructor(scene: Scene);
  126220. /**
  126221. * Registers the component in a given scene
  126222. */
  126223. register(): void;
  126224. /**
  126225. * Rebuilds the elements related to this component in case of
  126226. * context lost for instance.
  126227. */
  126228. rebuild(): void;
  126229. /**
  126230. * Serializes the component data to the specified json object
  126231. * @param serializationObject The object to serialize to
  126232. */
  126233. serialize(serializationObject: any): void;
  126234. /**
  126235. * Adds all the elements from the container to the scene
  126236. * @param container the container holding the elements
  126237. */
  126238. addFromContainer(container: AbstractScene): void;
  126239. /**
  126240. * Removes all the elements in the container from the scene
  126241. * @param container contains the elements to remove
  126242. * @param dispose if the removed element should be disposed (default: false)
  126243. */
  126244. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  126245. /**
  126246. * Disposes the component and the associated ressources.
  126247. */
  126248. dispose(): void;
  126249. private _isReadyForMesh;
  126250. private _renderMainTexture;
  126251. private _setStencil;
  126252. private _setStencilBack;
  126253. private _draw;
  126254. private _drawCamera;
  126255. private _drawRenderingGroup;
  126256. }
  126257. }
  126258. declare module BABYLON {
  126259. /** @hidden */
  126260. export var glowMapMergePixelShader: {
  126261. name: string;
  126262. shader: string;
  126263. };
  126264. }
  126265. declare module BABYLON {
  126266. /** @hidden */
  126267. export var glowMapMergeVertexShader: {
  126268. name: string;
  126269. shader: string;
  126270. };
  126271. }
  126272. declare module BABYLON {
  126273. interface AbstractScene {
  126274. /**
  126275. * Return a the first highlight layer of the scene with a given name.
  126276. * @param name The name of the highlight layer to look for.
  126277. * @return The highlight layer if found otherwise null.
  126278. */
  126279. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  126280. }
  126281. /**
  126282. * Glow layer options. This helps customizing the behaviour
  126283. * of the glow layer.
  126284. */
  126285. export interface IGlowLayerOptions {
  126286. /**
  126287. * Multiplication factor apply to the canvas size to compute the render target size
  126288. * used to generated the glowing objects (the smaller the faster).
  126289. */
  126290. mainTextureRatio: number;
  126291. /**
  126292. * Enforces a fixed size texture to ensure resize independant blur.
  126293. */
  126294. mainTextureFixedSize?: number;
  126295. /**
  126296. * How big is the kernel of the blur texture.
  126297. */
  126298. blurKernelSize: number;
  126299. /**
  126300. * The camera attached to the layer.
  126301. */
  126302. camera: Nullable<Camera>;
  126303. /**
  126304. * Enable MSAA by chosing the number of samples.
  126305. */
  126306. mainTextureSamples?: number;
  126307. /**
  126308. * The rendering group to draw the layer in.
  126309. */
  126310. renderingGroupId: number;
  126311. }
  126312. /**
  126313. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  126314. *
  126315. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  126316. *
  126317. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  126318. */
  126319. export class GlowLayer extends EffectLayer {
  126320. /**
  126321. * Effect Name of the layer.
  126322. */
  126323. static readonly EffectName: string;
  126324. /**
  126325. * The default blur kernel size used for the glow.
  126326. */
  126327. static DefaultBlurKernelSize: number;
  126328. /**
  126329. * The default texture size ratio used for the glow.
  126330. */
  126331. static DefaultTextureRatio: number;
  126332. /**
  126333. * Sets the kernel size of the blur.
  126334. */
  126335. set blurKernelSize(value: number);
  126336. /**
  126337. * Gets the kernel size of the blur.
  126338. */
  126339. get blurKernelSize(): number;
  126340. /**
  126341. * Sets the glow intensity.
  126342. */
  126343. set intensity(value: number);
  126344. /**
  126345. * Gets the glow intensity.
  126346. */
  126347. get intensity(): number;
  126348. private _options;
  126349. private _intensity;
  126350. private _horizontalBlurPostprocess1;
  126351. private _verticalBlurPostprocess1;
  126352. private _horizontalBlurPostprocess2;
  126353. private _verticalBlurPostprocess2;
  126354. private _blurTexture1;
  126355. private _blurTexture2;
  126356. private _postProcesses1;
  126357. private _postProcesses2;
  126358. private _includedOnlyMeshes;
  126359. private _excludedMeshes;
  126360. private _meshesUsingTheirOwnMaterials;
  126361. /**
  126362. * Callback used to let the user override the color selection on a per mesh basis
  126363. */
  126364. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  126365. /**
  126366. * Callback used to let the user override the texture selection on a per mesh basis
  126367. */
  126368. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  126369. /**
  126370. * Instantiates a new glow Layer and references it to the scene.
  126371. * @param name The name of the layer
  126372. * @param scene The scene to use the layer in
  126373. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  126374. */
  126375. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  126376. /**
  126377. * Get the effect name of the layer.
  126378. * @return The effect name
  126379. */
  126380. getEffectName(): string;
  126381. /**
  126382. * Create the merge effect. This is the shader use to blit the information back
  126383. * to the main canvas at the end of the scene rendering.
  126384. */
  126385. protected _createMergeEffect(): Effect;
  126386. /**
  126387. * Creates the render target textures and post processes used in the glow layer.
  126388. */
  126389. protected _createTextureAndPostProcesses(): void;
  126390. /**
  126391. * Checks for the readiness of the element composing the layer.
  126392. * @param subMesh the mesh to check for
  126393. * @param useInstances specify wether or not to use instances to render the mesh
  126394. * @param emissiveTexture the associated emissive texture used to generate the glow
  126395. * @return true if ready otherwise, false
  126396. */
  126397. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126398. /**
  126399. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  126400. */
  126401. needStencil(): boolean;
  126402. /**
  126403. * Returns true if the mesh can be rendered, otherwise false.
  126404. * @param mesh The mesh to render
  126405. * @param material The material used on the mesh
  126406. * @returns true if it can be rendered otherwise false
  126407. */
  126408. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  126409. /**
  126410. * Implementation specific of rendering the generating effect on the main canvas.
  126411. * @param effect The effect used to render through
  126412. */
  126413. protected _internalRender(effect: Effect): void;
  126414. /**
  126415. * Sets the required values for both the emissive texture and and the main color.
  126416. */
  126417. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  126418. /**
  126419. * Returns true if the mesh should render, otherwise false.
  126420. * @param mesh The mesh to render
  126421. * @returns true if it should render otherwise false
  126422. */
  126423. protected _shouldRenderMesh(mesh: Mesh): boolean;
  126424. /**
  126425. * Adds specific effects defines.
  126426. * @param defines The defines to add specifics to.
  126427. */
  126428. protected _addCustomEffectDefines(defines: string[]): void;
  126429. /**
  126430. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  126431. * @param mesh The mesh to exclude from the glow layer
  126432. */
  126433. addExcludedMesh(mesh: Mesh): void;
  126434. /**
  126435. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  126436. * @param mesh The mesh to remove
  126437. */
  126438. removeExcludedMesh(mesh: Mesh): void;
  126439. /**
  126440. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  126441. * @param mesh The mesh to include in the glow layer
  126442. */
  126443. addIncludedOnlyMesh(mesh: Mesh): void;
  126444. /**
  126445. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  126446. * @param mesh The mesh to remove
  126447. */
  126448. removeIncludedOnlyMesh(mesh: Mesh): void;
  126449. /**
  126450. * Determine if a given mesh will be used in the glow layer
  126451. * @param mesh The mesh to test
  126452. * @returns true if the mesh will be highlighted by the current glow layer
  126453. */
  126454. hasMesh(mesh: AbstractMesh): boolean;
  126455. /**
  126456. * Defines whether the current material of the mesh should be use to render the effect.
  126457. * @param mesh defines the current mesh to render
  126458. */
  126459. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  126460. /**
  126461. * Add a mesh to be rendered through its own material and not with emissive only.
  126462. * @param mesh The mesh for which we need to use its material
  126463. */
  126464. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  126465. /**
  126466. * Remove a mesh from being rendered through its own material and not with emissive only.
  126467. * @param mesh The mesh for which we need to not use its material
  126468. */
  126469. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  126470. /**
  126471. * Free any resources and references associated to a mesh.
  126472. * Internal use
  126473. * @param mesh The mesh to free.
  126474. * @hidden
  126475. */
  126476. _disposeMesh(mesh: Mesh): void;
  126477. /**
  126478. * Gets the class name of the effect layer
  126479. * @returns the string with the class name of the effect layer
  126480. */
  126481. getClassName(): string;
  126482. /**
  126483. * Serializes this glow layer
  126484. * @returns a serialized glow layer object
  126485. */
  126486. serialize(): any;
  126487. /**
  126488. * Creates a Glow Layer from parsed glow layer data
  126489. * @param parsedGlowLayer defines glow layer data
  126490. * @param scene defines the current scene
  126491. * @param rootUrl defines the root URL containing the glow layer information
  126492. * @returns a parsed Glow Layer
  126493. */
  126494. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  126495. }
  126496. }
  126497. declare module BABYLON {
  126498. /** @hidden */
  126499. export var glowBlurPostProcessPixelShader: {
  126500. name: string;
  126501. shader: string;
  126502. };
  126503. }
  126504. declare module BABYLON {
  126505. interface AbstractScene {
  126506. /**
  126507. * Return a the first highlight layer of the scene with a given name.
  126508. * @param name The name of the highlight layer to look for.
  126509. * @return The highlight layer if found otherwise null.
  126510. */
  126511. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  126512. }
  126513. /**
  126514. * Highlight layer options. This helps customizing the behaviour
  126515. * of the highlight layer.
  126516. */
  126517. export interface IHighlightLayerOptions {
  126518. /**
  126519. * Multiplication factor apply to the canvas size to compute the render target size
  126520. * used to generated the glowing objects (the smaller the faster).
  126521. */
  126522. mainTextureRatio: number;
  126523. /**
  126524. * Enforces a fixed size texture to ensure resize independant blur.
  126525. */
  126526. mainTextureFixedSize?: number;
  126527. /**
  126528. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  126529. * of the picture to blur (the smaller the faster).
  126530. */
  126531. blurTextureSizeRatio: number;
  126532. /**
  126533. * How big in texel of the blur texture is the vertical blur.
  126534. */
  126535. blurVerticalSize: number;
  126536. /**
  126537. * How big in texel of the blur texture is the horizontal blur.
  126538. */
  126539. blurHorizontalSize: number;
  126540. /**
  126541. * Alpha blending mode used to apply the blur. Default is combine.
  126542. */
  126543. alphaBlendingMode: number;
  126544. /**
  126545. * The camera attached to the layer.
  126546. */
  126547. camera: Nullable<Camera>;
  126548. /**
  126549. * Should we display highlight as a solid stroke?
  126550. */
  126551. isStroke?: boolean;
  126552. /**
  126553. * The rendering group to draw the layer in.
  126554. */
  126555. renderingGroupId: number;
  126556. }
  126557. /**
  126558. * The highlight layer Helps adding a glow effect around a mesh.
  126559. *
  126560. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  126561. * glowy meshes to your scene.
  126562. *
  126563. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  126564. */
  126565. export class HighlightLayer extends EffectLayer {
  126566. name: string;
  126567. /**
  126568. * Effect Name of the highlight layer.
  126569. */
  126570. static readonly EffectName: string;
  126571. /**
  126572. * The neutral color used during the preparation of the glow effect.
  126573. * This is black by default as the blend operation is a blend operation.
  126574. */
  126575. static NeutralColor: Color4;
  126576. /**
  126577. * Stencil value used for glowing meshes.
  126578. */
  126579. static GlowingMeshStencilReference: number;
  126580. /**
  126581. * Stencil value used for the other meshes in the scene.
  126582. */
  126583. static NormalMeshStencilReference: number;
  126584. /**
  126585. * Specifies whether or not the inner glow is ACTIVE in the layer.
  126586. */
  126587. innerGlow: boolean;
  126588. /**
  126589. * Specifies whether or not the outer glow is ACTIVE in the layer.
  126590. */
  126591. outerGlow: boolean;
  126592. /**
  126593. * Specifies the horizontal size of the blur.
  126594. */
  126595. set blurHorizontalSize(value: number);
  126596. /**
  126597. * Specifies the vertical size of the blur.
  126598. */
  126599. set blurVerticalSize(value: number);
  126600. /**
  126601. * Gets the horizontal size of the blur.
  126602. */
  126603. get blurHorizontalSize(): number;
  126604. /**
  126605. * Gets the vertical size of the blur.
  126606. */
  126607. get blurVerticalSize(): number;
  126608. /**
  126609. * An event triggered when the highlight layer is being blurred.
  126610. */
  126611. onBeforeBlurObservable: Observable<HighlightLayer>;
  126612. /**
  126613. * An event triggered when the highlight layer has been blurred.
  126614. */
  126615. onAfterBlurObservable: Observable<HighlightLayer>;
  126616. private _instanceGlowingMeshStencilReference;
  126617. private _options;
  126618. private _downSamplePostprocess;
  126619. private _horizontalBlurPostprocess;
  126620. private _verticalBlurPostprocess;
  126621. private _blurTexture;
  126622. private _meshes;
  126623. private _excludedMeshes;
  126624. /**
  126625. * Instantiates a new highlight Layer and references it to the scene..
  126626. * @param name The name of the layer
  126627. * @param scene The scene to use the layer in
  126628. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  126629. */
  126630. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  126631. /**
  126632. * Get the effect name of the layer.
  126633. * @return The effect name
  126634. */
  126635. getEffectName(): string;
  126636. /**
  126637. * Create the merge effect. This is the shader use to blit the information back
  126638. * to the main canvas at the end of the scene rendering.
  126639. */
  126640. protected _createMergeEffect(): Effect;
  126641. /**
  126642. * Creates the render target textures and post processes used in the highlight layer.
  126643. */
  126644. protected _createTextureAndPostProcesses(): void;
  126645. /**
  126646. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  126647. */
  126648. needStencil(): boolean;
  126649. /**
  126650. * Checks for the readiness of the element composing the layer.
  126651. * @param subMesh the mesh to check for
  126652. * @param useInstances specify wether or not to use instances to render the mesh
  126653. * @param emissiveTexture the associated emissive texture used to generate the glow
  126654. * @return true if ready otherwise, false
  126655. */
  126656. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126657. /**
  126658. * Implementation specific of rendering the generating effect on the main canvas.
  126659. * @param effect The effect used to render through
  126660. */
  126661. protected _internalRender(effect: Effect): void;
  126662. /**
  126663. * Returns true if the layer contains information to display, otherwise false.
  126664. */
  126665. shouldRender(): boolean;
  126666. /**
  126667. * Returns true if the mesh should render, otherwise false.
  126668. * @param mesh The mesh to render
  126669. * @returns true if it should render otherwise false
  126670. */
  126671. protected _shouldRenderMesh(mesh: Mesh): boolean;
  126672. /**
  126673. * Sets the required values for both the emissive texture and and the main color.
  126674. */
  126675. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  126676. /**
  126677. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  126678. * @param mesh The mesh to exclude from the highlight layer
  126679. */
  126680. addExcludedMesh(mesh: Mesh): void;
  126681. /**
  126682. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  126683. * @param mesh The mesh to highlight
  126684. */
  126685. removeExcludedMesh(mesh: Mesh): void;
  126686. /**
  126687. * Determine if a given mesh will be highlighted by the current HighlightLayer
  126688. * @param mesh mesh to test
  126689. * @returns true if the mesh will be highlighted by the current HighlightLayer
  126690. */
  126691. hasMesh(mesh: AbstractMesh): boolean;
  126692. /**
  126693. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  126694. * @param mesh The mesh to highlight
  126695. * @param color The color of the highlight
  126696. * @param glowEmissiveOnly Extract the glow from the emissive texture
  126697. */
  126698. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  126699. /**
  126700. * Remove a mesh from the highlight layer in order to make it stop glowing.
  126701. * @param mesh The mesh to highlight
  126702. */
  126703. removeMesh(mesh: Mesh): void;
  126704. /**
  126705. * Force the stencil to the normal expected value for none glowing parts
  126706. */
  126707. private _defaultStencilReference;
  126708. /**
  126709. * Free any resources and references associated to a mesh.
  126710. * Internal use
  126711. * @param mesh The mesh to free.
  126712. * @hidden
  126713. */
  126714. _disposeMesh(mesh: Mesh): void;
  126715. /**
  126716. * Dispose the highlight layer and free resources.
  126717. */
  126718. dispose(): void;
  126719. /**
  126720. * Gets the class name of the effect layer
  126721. * @returns the string with the class name of the effect layer
  126722. */
  126723. getClassName(): string;
  126724. /**
  126725. * Serializes this Highlight layer
  126726. * @returns a serialized Highlight layer object
  126727. */
  126728. serialize(): any;
  126729. /**
  126730. * Creates a Highlight layer from parsed Highlight layer data
  126731. * @param parsedHightlightLayer defines the Highlight layer data
  126732. * @param scene defines the current scene
  126733. * @param rootUrl defines the root URL containing the Highlight layer information
  126734. * @returns a parsed Highlight layer
  126735. */
  126736. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  126737. }
  126738. }
  126739. declare module BABYLON {
  126740. interface AbstractScene {
  126741. /**
  126742. * The list of layers (background and foreground) of the scene
  126743. */
  126744. layers: Array<Layer>;
  126745. }
  126746. /**
  126747. * Defines the layer scene component responsible to manage any layers
  126748. * in a given scene.
  126749. */
  126750. export class LayerSceneComponent implements ISceneComponent {
  126751. /**
  126752. * The component name helpfull to identify the component in the list of scene components.
  126753. */
  126754. readonly name: string;
  126755. /**
  126756. * The scene the component belongs to.
  126757. */
  126758. scene: Scene;
  126759. private _engine;
  126760. /**
  126761. * Creates a new instance of the component for the given scene
  126762. * @param scene Defines the scene to register the component in
  126763. */
  126764. constructor(scene: Scene);
  126765. /**
  126766. * Registers the component in a given scene
  126767. */
  126768. register(): void;
  126769. /**
  126770. * Rebuilds the elements related to this component in case of
  126771. * context lost for instance.
  126772. */
  126773. rebuild(): void;
  126774. /**
  126775. * Disposes the component and the associated ressources.
  126776. */
  126777. dispose(): void;
  126778. private _draw;
  126779. private _drawCameraPredicate;
  126780. private _drawCameraBackground;
  126781. private _drawCameraForeground;
  126782. private _drawRenderTargetPredicate;
  126783. private _drawRenderTargetBackground;
  126784. private _drawRenderTargetForeground;
  126785. /**
  126786. * Adds all the elements from the container to the scene
  126787. * @param container the container holding the elements
  126788. */
  126789. addFromContainer(container: AbstractScene): void;
  126790. /**
  126791. * Removes all the elements in the container from the scene
  126792. * @param container contains the elements to remove
  126793. * @param dispose if the removed element should be disposed (default: false)
  126794. */
  126795. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  126796. }
  126797. }
  126798. declare module BABYLON {
  126799. /** @hidden */
  126800. export var layerPixelShader: {
  126801. name: string;
  126802. shader: string;
  126803. };
  126804. }
  126805. declare module BABYLON {
  126806. /** @hidden */
  126807. export var layerVertexShader: {
  126808. name: string;
  126809. shader: string;
  126810. };
  126811. }
  126812. declare module BABYLON {
  126813. /**
  126814. * This represents a full screen 2d layer.
  126815. * This can be useful to display a picture in the background of your scene for instance.
  126816. * @see https://www.babylonjs-playground.com/#08A2BS#1
  126817. */
  126818. export class Layer {
  126819. /**
  126820. * Define the name of the layer.
  126821. */
  126822. name: string;
  126823. /**
  126824. * Define the texture the layer should display.
  126825. */
  126826. texture: Nullable<Texture>;
  126827. /**
  126828. * Is the layer in background or foreground.
  126829. */
  126830. isBackground: boolean;
  126831. /**
  126832. * Define the color of the layer (instead of texture).
  126833. */
  126834. color: Color4;
  126835. /**
  126836. * Define the scale of the layer in order to zoom in out of the texture.
  126837. */
  126838. scale: Vector2;
  126839. /**
  126840. * Define an offset for the layer in order to shift the texture.
  126841. */
  126842. offset: Vector2;
  126843. /**
  126844. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  126845. */
  126846. alphaBlendingMode: number;
  126847. /**
  126848. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  126849. * Alpha test will not mix with the background color in case of transparency.
  126850. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  126851. */
  126852. alphaTest: boolean;
  126853. /**
  126854. * Define a mask to restrict the layer to only some of the scene cameras.
  126855. */
  126856. layerMask: number;
  126857. /**
  126858. * Define the list of render target the layer is visible into.
  126859. */
  126860. renderTargetTextures: RenderTargetTexture[];
  126861. /**
  126862. * Define if the layer is only used in renderTarget or if it also
  126863. * renders in the main frame buffer of the canvas.
  126864. */
  126865. renderOnlyInRenderTargetTextures: boolean;
  126866. private _scene;
  126867. private _vertexBuffers;
  126868. private _indexBuffer;
  126869. private _effect;
  126870. private _previousDefines;
  126871. /**
  126872. * An event triggered when the layer is disposed.
  126873. */
  126874. onDisposeObservable: Observable<Layer>;
  126875. private _onDisposeObserver;
  126876. /**
  126877. * Back compatibility with callback before the onDisposeObservable existed.
  126878. * The set callback will be triggered when the layer has been disposed.
  126879. */
  126880. set onDispose(callback: () => void);
  126881. /**
  126882. * An event triggered before rendering the scene
  126883. */
  126884. onBeforeRenderObservable: Observable<Layer>;
  126885. private _onBeforeRenderObserver;
  126886. /**
  126887. * Back compatibility with callback before the onBeforeRenderObservable existed.
  126888. * The set callback will be triggered just before rendering the layer.
  126889. */
  126890. set onBeforeRender(callback: () => void);
  126891. /**
  126892. * An event triggered after rendering the scene
  126893. */
  126894. onAfterRenderObservable: Observable<Layer>;
  126895. private _onAfterRenderObserver;
  126896. /**
  126897. * Back compatibility with callback before the onAfterRenderObservable existed.
  126898. * The set callback will be triggered just after rendering the layer.
  126899. */
  126900. set onAfterRender(callback: () => void);
  126901. /**
  126902. * Instantiates a new layer.
  126903. * This represents a full screen 2d layer.
  126904. * This can be useful to display a picture in the background of your scene for instance.
  126905. * @see https://www.babylonjs-playground.com/#08A2BS#1
  126906. * @param name Define the name of the layer in the scene
  126907. * @param imgUrl Define the url of the texture to display in the layer
  126908. * @param scene Define the scene the layer belongs to
  126909. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  126910. * @param color Defines a color for the layer
  126911. */
  126912. constructor(
  126913. /**
  126914. * Define the name of the layer.
  126915. */
  126916. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  126917. private _createIndexBuffer;
  126918. /** @hidden */
  126919. _rebuild(): void;
  126920. /**
  126921. * Renders the layer in the scene.
  126922. */
  126923. render(): void;
  126924. /**
  126925. * Disposes and releases the associated ressources.
  126926. */
  126927. dispose(): void;
  126928. }
  126929. }
  126930. declare module BABYLON {
  126931. /** @hidden */
  126932. export var lensFlarePixelShader: {
  126933. name: string;
  126934. shader: string;
  126935. };
  126936. }
  126937. declare module BABYLON {
  126938. /** @hidden */
  126939. export var lensFlareVertexShader: {
  126940. name: string;
  126941. shader: string;
  126942. };
  126943. }
  126944. declare module BABYLON {
  126945. /**
  126946. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  126947. * It is usually composed of several `lensFlare`.
  126948. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  126949. */
  126950. export class LensFlareSystem {
  126951. /**
  126952. * Define the name of the lens flare system
  126953. */
  126954. name: string;
  126955. /**
  126956. * List of lens flares used in this system.
  126957. */
  126958. lensFlares: LensFlare[];
  126959. /**
  126960. * Define a limit from the border the lens flare can be visible.
  126961. */
  126962. borderLimit: number;
  126963. /**
  126964. * Define a viewport border we do not want to see the lens flare in.
  126965. */
  126966. viewportBorder: number;
  126967. /**
  126968. * Define a predicate which could limit the list of meshes able to occlude the effect.
  126969. */
  126970. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  126971. /**
  126972. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  126973. */
  126974. layerMask: number;
  126975. /**
  126976. * Define the id of the lens flare system in the scene.
  126977. * (equal to name by default)
  126978. */
  126979. id: string;
  126980. private _scene;
  126981. private _emitter;
  126982. private _vertexBuffers;
  126983. private _indexBuffer;
  126984. private _effect;
  126985. private _positionX;
  126986. private _positionY;
  126987. private _isEnabled;
  126988. /** @hidden */
  126989. static _SceneComponentInitialization: (scene: Scene) => void;
  126990. /**
  126991. * Instantiates a lens flare system.
  126992. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  126993. * It is usually composed of several `lensFlare`.
  126994. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  126995. * @param name Define the name of the lens flare system in the scene
  126996. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  126997. * @param scene Define the scene the lens flare system belongs to
  126998. */
  126999. constructor(
  127000. /**
  127001. * Define the name of the lens flare system
  127002. */
  127003. name: string, emitter: any, scene: Scene);
  127004. /**
  127005. * Define if the lens flare system is enabled.
  127006. */
  127007. get isEnabled(): boolean;
  127008. set isEnabled(value: boolean);
  127009. /**
  127010. * Get the scene the effects belongs to.
  127011. * @returns the scene holding the lens flare system
  127012. */
  127013. getScene(): Scene;
  127014. /**
  127015. * Get the emitter of the lens flare system.
  127016. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  127017. * @returns the emitter of the lens flare system
  127018. */
  127019. getEmitter(): any;
  127020. /**
  127021. * Set the emitter of the lens flare system.
  127022. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  127023. * @param newEmitter Define the new emitter of the system
  127024. */
  127025. setEmitter(newEmitter: any): void;
  127026. /**
  127027. * Get the lens flare system emitter position.
  127028. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  127029. * @returns the position
  127030. */
  127031. getEmitterPosition(): Vector3;
  127032. /**
  127033. * @hidden
  127034. */
  127035. computeEffectivePosition(globalViewport: Viewport): boolean;
  127036. /** @hidden */
  127037. _isVisible(): boolean;
  127038. /**
  127039. * @hidden
  127040. */
  127041. render(): boolean;
  127042. /**
  127043. * Dispose and release the lens flare with its associated resources.
  127044. */
  127045. dispose(): void;
  127046. /**
  127047. * Parse a lens flare system from a JSON repressentation
  127048. * @param parsedLensFlareSystem Define the JSON to parse
  127049. * @param scene Define the scene the parsed system should be instantiated in
  127050. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  127051. * @returns the parsed system
  127052. */
  127053. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  127054. /**
  127055. * Serialize the current Lens Flare System into a JSON representation.
  127056. * @returns the serialized JSON
  127057. */
  127058. serialize(): any;
  127059. }
  127060. }
  127061. declare module BABYLON {
  127062. /**
  127063. * This represents one of the lens effect in a `lensFlareSystem`.
  127064. * It controls one of the indiviual texture used in the effect.
  127065. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127066. */
  127067. export class LensFlare {
  127068. /**
  127069. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  127070. */
  127071. size: number;
  127072. /**
  127073. * 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.
  127074. */
  127075. position: number;
  127076. /**
  127077. * Define the lens color.
  127078. */
  127079. color: Color3;
  127080. /**
  127081. * Define the lens texture.
  127082. */
  127083. texture: Nullable<Texture>;
  127084. /**
  127085. * Define the alpha mode to render this particular lens.
  127086. */
  127087. alphaMode: number;
  127088. private _system;
  127089. /**
  127090. * Creates a new Lens Flare.
  127091. * This represents one of the lens effect in a `lensFlareSystem`.
  127092. * It controls one of the indiviual texture used in the effect.
  127093. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127094. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  127095. * @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.
  127096. * @param color Define the lens color
  127097. * @param imgUrl Define the lens texture url
  127098. * @param system Define the `lensFlareSystem` this flare is part of
  127099. * @returns The newly created Lens Flare
  127100. */
  127101. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  127102. /**
  127103. * Instantiates a new Lens Flare.
  127104. * This represents one of the lens effect in a `lensFlareSystem`.
  127105. * It controls one of the indiviual texture used in the effect.
  127106. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127107. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  127108. * @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.
  127109. * @param color Define the lens color
  127110. * @param imgUrl Define the lens texture url
  127111. * @param system Define the `lensFlareSystem` this flare is part of
  127112. */
  127113. constructor(
  127114. /**
  127115. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  127116. */
  127117. size: number,
  127118. /**
  127119. * Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  127120. */
  127121. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  127122. /**
  127123. * Dispose and release the lens flare with its associated resources.
  127124. */
  127125. dispose(): void;
  127126. }
  127127. }
  127128. declare module BABYLON {
  127129. interface AbstractScene {
  127130. /**
  127131. * The list of lens flare system added to the scene
  127132. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127133. */
  127134. lensFlareSystems: Array<LensFlareSystem>;
  127135. /**
  127136. * Removes the given lens flare system from this scene.
  127137. * @param toRemove The lens flare system to remove
  127138. * @returns The index of the removed lens flare system
  127139. */
  127140. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  127141. /**
  127142. * Adds the given lens flare system to this scene
  127143. * @param newLensFlareSystem The lens flare system to add
  127144. */
  127145. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  127146. /**
  127147. * Gets a lens flare system using its name
  127148. * @param name defines the name to look for
  127149. * @returns the lens flare system or null if not found
  127150. */
  127151. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  127152. /**
  127153. * Gets a lens flare system using its id
  127154. * @param id defines the id to look for
  127155. * @returns the lens flare system or null if not found
  127156. */
  127157. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  127158. }
  127159. /**
  127160. * Defines the lens flare scene component responsible to manage any lens flares
  127161. * in a given scene.
  127162. */
  127163. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  127164. /**
  127165. * The component name helpfull to identify the component in the list of scene components.
  127166. */
  127167. readonly name: string;
  127168. /**
  127169. * The scene the component belongs to.
  127170. */
  127171. scene: Scene;
  127172. /**
  127173. * Creates a new instance of the component for the given scene
  127174. * @param scene Defines the scene to register the component in
  127175. */
  127176. constructor(scene: Scene);
  127177. /**
  127178. * Registers the component in a given scene
  127179. */
  127180. register(): void;
  127181. /**
  127182. * Rebuilds the elements related to this component in case of
  127183. * context lost for instance.
  127184. */
  127185. rebuild(): void;
  127186. /**
  127187. * Adds all the elements from the container to the scene
  127188. * @param container the container holding the elements
  127189. */
  127190. addFromContainer(container: AbstractScene): void;
  127191. /**
  127192. * Removes all the elements in the container from the scene
  127193. * @param container contains the elements to remove
  127194. * @param dispose if the removed element should be disposed (default: false)
  127195. */
  127196. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  127197. /**
  127198. * Serializes the component data to the specified json object
  127199. * @param serializationObject The object to serialize to
  127200. */
  127201. serialize(serializationObject: any): void;
  127202. /**
  127203. * Disposes the component and the associated ressources.
  127204. */
  127205. dispose(): void;
  127206. private _draw;
  127207. }
  127208. }
  127209. declare module BABYLON {
  127210. /** @hidden */
  127211. export var depthPixelShader: {
  127212. name: string;
  127213. shader: string;
  127214. };
  127215. }
  127216. declare module BABYLON {
  127217. /** @hidden */
  127218. export var depthVertexShader: {
  127219. name: string;
  127220. shader: string;
  127221. };
  127222. }
  127223. declare module BABYLON {
  127224. /**
  127225. * This represents a depth renderer in Babylon.
  127226. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  127227. */
  127228. export class DepthRenderer {
  127229. private _scene;
  127230. private _depthMap;
  127231. private _effect;
  127232. private readonly _storeNonLinearDepth;
  127233. private readonly _clearColor;
  127234. /** Get if the depth renderer is using packed depth or not */
  127235. readonly isPacked: boolean;
  127236. private _cachedDefines;
  127237. private _camera;
  127238. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  127239. enabled: boolean;
  127240. /**
  127241. * Specifiess that the depth renderer will only be used within
  127242. * the camera it is created for.
  127243. * This can help forcing its rendering during the camera processing.
  127244. */
  127245. useOnlyInActiveCamera: boolean;
  127246. /** @hidden */
  127247. static _SceneComponentInitialization: (scene: Scene) => void;
  127248. /**
  127249. * Instantiates a depth renderer
  127250. * @param scene The scene the renderer belongs to
  127251. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  127252. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  127253. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  127254. */
  127255. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  127256. /**
  127257. * Creates the depth rendering effect and checks if the effect is ready.
  127258. * @param subMesh The submesh to be used to render the depth map of
  127259. * @param useInstances If multiple world instances should be used
  127260. * @returns if the depth renderer is ready to render the depth map
  127261. */
  127262. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  127263. /**
  127264. * Gets the texture which the depth map will be written to.
  127265. * @returns The depth map texture
  127266. */
  127267. getDepthMap(): RenderTargetTexture;
  127268. /**
  127269. * Disposes of the depth renderer.
  127270. */
  127271. dispose(): void;
  127272. }
  127273. }
  127274. declare module BABYLON {
  127275. /** @hidden */
  127276. export var minmaxReduxPixelShader: {
  127277. name: string;
  127278. shader: string;
  127279. };
  127280. }
  127281. declare module BABYLON {
  127282. /**
  127283. * This class computes a min/max reduction from a texture: it means it computes the minimum
  127284. * and maximum values from all values of the texture.
  127285. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  127286. * The source values are read from the red channel of the texture.
  127287. */
  127288. export class MinMaxReducer {
  127289. /**
  127290. * Observable triggered when the computation has been performed
  127291. */
  127292. onAfterReductionPerformed: Observable<{
  127293. min: number;
  127294. max: number;
  127295. }>;
  127296. protected _camera: Camera;
  127297. protected _sourceTexture: Nullable<RenderTargetTexture>;
  127298. protected _reductionSteps: Nullable<Array<PostProcess>>;
  127299. protected _postProcessManager: PostProcessManager;
  127300. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  127301. protected _forceFullscreenViewport: boolean;
  127302. /**
  127303. * Creates a min/max reducer
  127304. * @param camera The camera to use for the post processes
  127305. */
  127306. constructor(camera: Camera);
  127307. /**
  127308. * Gets the texture used to read the values from.
  127309. */
  127310. get sourceTexture(): Nullable<RenderTargetTexture>;
  127311. /**
  127312. * Sets the source texture to read the values from.
  127313. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  127314. * because in such textures '1' value must not be taken into account to compute the maximum
  127315. * as this value is used to clear the texture.
  127316. * Note that the computation is not activated by calling this function, you must call activate() for that!
  127317. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  127318. * @param depthRedux Indicates if the texture is a depth texture or not
  127319. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  127320. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  127321. */
  127322. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  127323. /**
  127324. * Defines the refresh rate of the computation.
  127325. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  127326. */
  127327. get refreshRate(): number;
  127328. set refreshRate(value: number);
  127329. protected _activated: boolean;
  127330. /**
  127331. * Gets the activation status of the reducer
  127332. */
  127333. get activated(): boolean;
  127334. /**
  127335. * Activates the reduction computation.
  127336. * When activated, the observers registered in onAfterReductionPerformed are
  127337. * called after the compuation is performed
  127338. */
  127339. activate(): void;
  127340. /**
  127341. * Deactivates the reduction computation.
  127342. */
  127343. deactivate(): void;
  127344. /**
  127345. * Disposes the min/max reducer
  127346. * @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.
  127347. */
  127348. dispose(disposeAll?: boolean): void;
  127349. }
  127350. }
  127351. declare module BABYLON {
  127352. /**
  127353. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  127354. */
  127355. export class DepthReducer extends MinMaxReducer {
  127356. private _depthRenderer;
  127357. private _depthRendererId;
  127358. /**
  127359. * Gets the depth renderer used for the computation.
  127360. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  127361. */
  127362. get depthRenderer(): Nullable<DepthRenderer>;
  127363. /**
  127364. * Creates a depth reducer
  127365. * @param camera The camera used to render the depth texture
  127366. */
  127367. constructor(camera: Camera);
  127368. /**
  127369. * Sets the depth renderer to use to generate the depth map
  127370. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  127371. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  127372. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  127373. */
  127374. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  127375. /** @hidden */
  127376. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  127377. /**
  127378. * Activates the reduction computation.
  127379. * When activated, the observers registered in onAfterReductionPerformed are
  127380. * called after the compuation is performed
  127381. */
  127382. activate(): void;
  127383. /**
  127384. * Deactivates the reduction computation.
  127385. */
  127386. deactivate(): void;
  127387. /**
  127388. * Disposes the depth reducer
  127389. * @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.
  127390. */
  127391. dispose(disposeAll?: boolean): void;
  127392. }
  127393. }
  127394. declare module BABYLON {
  127395. /**
  127396. * A CSM implementation allowing casting shadows on large scenes.
  127397. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  127398. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  127399. */
  127400. export class CascadedShadowGenerator extends ShadowGenerator {
  127401. private static readonly frustumCornersNDCSpace;
  127402. /**
  127403. * Name of the CSM class
  127404. */
  127405. static CLASSNAME: string;
  127406. /**
  127407. * Defines the default number of cascades used by the CSM.
  127408. */
  127409. static readonly DEFAULT_CASCADES_COUNT: number;
  127410. /**
  127411. * Defines the minimum number of cascades used by the CSM.
  127412. */
  127413. static readonly MIN_CASCADES_COUNT: number;
  127414. /**
  127415. * Defines the maximum number of cascades used by the CSM.
  127416. */
  127417. static readonly MAX_CASCADES_COUNT: number;
  127418. protected _validateFilter(filter: number): number;
  127419. /**
  127420. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  127421. */
  127422. penumbraDarkness: number;
  127423. private _numCascades;
  127424. /**
  127425. * Gets or set the number of cascades used by the CSM.
  127426. */
  127427. get numCascades(): number;
  127428. set numCascades(value: number);
  127429. /**
  127430. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  127431. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  127432. */
  127433. stabilizeCascades: boolean;
  127434. private _freezeShadowCastersBoundingInfo;
  127435. private _freezeShadowCastersBoundingInfoObservable;
  127436. /**
  127437. * Enables or disables the shadow casters bounding info computation.
  127438. * If your shadow casters don't move, you can disable this feature.
  127439. * If it is enabled, the bounding box computation is done every frame.
  127440. */
  127441. get freezeShadowCastersBoundingInfo(): boolean;
  127442. set freezeShadowCastersBoundingInfo(freeze: boolean);
  127443. private _scbiMin;
  127444. private _scbiMax;
  127445. protected _computeShadowCastersBoundingInfo(): void;
  127446. protected _shadowCastersBoundingInfo: BoundingInfo;
  127447. /**
  127448. * Gets or sets the shadow casters bounding info.
  127449. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  127450. * so that the system won't overwrite the bounds you provide
  127451. */
  127452. get shadowCastersBoundingInfo(): BoundingInfo;
  127453. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  127454. protected _breaksAreDirty: boolean;
  127455. protected _minDistance: number;
  127456. protected _maxDistance: number;
  127457. /**
  127458. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  127459. *
  127460. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  127461. * If you don't know these values, simply leave them to their defaults and don't call this function.
  127462. * @param min minimal distance for the breaks (default to 0.)
  127463. * @param max maximal distance for the breaks (default to 1.)
  127464. */
  127465. setMinMaxDistance(min: number, max: number): void;
  127466. /** Gets the minimal distance used in the cascade break computation */
  127467. get minDistance(): number;
  127468. /** Gets the maximal distance used in the cascade break computation */
  127469. get maxDistance(): number;
  127470. /**
  127471. * Gets the class name of that object
  127472. * @returns "CascadedShadowGenerator"
  127473. */
  127474. getClassName(): string;
  127475. private _cascadeMinExtents;
  127476. private _cascadeMaxExtents;
  127477. /**
  127478. * Gets a cascade minimum extents
  127479. * @param cascadeIndex index of the cascade
  127480. * @returns the minimum cascade extents
  127481. */
  127482. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  127483. /**
  127484. * Gets a cascade maximum extents
  127485. * @param cascadeIndex index of the cascade
  127486. * @returns the maximum cascade extents
  127487. */
  127488. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  127489. private _cascades;
  127490. private _currentLayer;
  127491. private _viewSpaceFrustumsZ;
  127492. private _viewMatrices;
  127493. private _projectionMatrices;
  127494. private _transformMatrices;
  127495. private _transformMatricesAsArray;
  127496. private _frustumLengths;
  127497. private _lightSizeUVCorrection;
  127498. private _depthCorrection;
  127499. private _frustumCornersWorldSpace;
  127500. private _frustumCenter;
  127501. private _shadowCameraPos;
  127502. private _shadowMaxZ;
  127503. /**
  127504. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  127505. * It defaults to camera.maxZ
  127506. */
  127507. get shadowMaxZ(): number;
  127508. /**
  127509. * Sets the shadow max z distance.
  127510. */
  127511. set shadowMaxZ(value: number);
  127512. protected _debug: boolean;
  127513. /**
  127514. * Gets or sets the debug flag.
  127515. * When enabled, the cascades are materialized by different colors on the screen.
  127516. */
  127517. get debug(): boolean;
  127518. set debug(dbg: boolean);
  127519. private _depthClamp;
  127520. /**
  127521. * Gets or sets the depth clamping value.
  127522. *
  127523. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  127524. * to account for the shadow casters far away.
  127525. *
  127526. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  127527. */
  127528. get depthClamp(): boolean;
  127529. set depthClamp(value: boolean);
  127530. private _cascadeBlendPercentage;
  127531. /**
  127532. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  127533. * It defaults to 0.1 (10% blending).
  127534. */
  127535. get cascadeBlendPercentage(): number;
  127536. set cascadeBlendPercentage(value: number);
  127537. private _lambda;
  127538. /**
  127539. * Gets or set the lambda parameter.
  127540. * This parameter is used to split the camera frustum and create the cascades.
  127541. * 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.
  127542. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  127543. */
  127544. get lambda(): number;
  127545. set lambda(value: number);
  127546. /**
  127547. * Gets the view matrix corresponding to a given cascade
  127548. * @param cascadeNum cascade to retrieve the view matrix from
  127549. * @returns the cascade view matrix
  127550. */
  127551. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  127552. /**
  127553. * Gets the projection matrix corresponding to a given cascade
  127554. * @param cascadeNum cascade to retrieve the projection matrix from
  127555. * @returns the cascade projection matrix
  127556. */
  127557. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  127558. /**
  127559. * Gets the transformation matrix corresponding to a given cascade
  127560. * @param cascadeNum cascade to retrieve the transformation matrix from
  127561. * @returns the cascade transformation matrix
  127562. */
  127563. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  127564. private _depthRenderer;
  127565. /**
  127566. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  127567. *
  127568. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  127569. *
  127570. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  127571. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  127572. * @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
  127573. */
  127574. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  127575. private _depthReducer;
  127576. private _autoCalcDepthBounds;
  127577. /**
  127578. * Gets or sets the autoCalcDepthBounds property.
  127579. *
  127580. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  127581. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  127582. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  127583. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  127584. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  127585. */
  127586. get autoCalcDepthBounds(): boolean;
  127587. set autoCalcDepthBounds(value: boolean);
  127588. /**
  127589. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  127590. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  127591. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  127592. * for setting the refresh rate on the renderer yourself!
  127593. */
  127594. get autoCalcDepthBoundsRefreshRate(): number;
  127595. set autoCalcDepthBoundsRefreshRate(value: number);
  127596. /**
  127597. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  127598. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  127599. * you change the camera near/far planes!
  127600. */
  127601. splitFrustum(): void;
  127602. private _splitFrustum;
  127603. private _computeMatrices;
  127604. private _computeFrustumInWorldSpace;
  127605. private _computeCascadeFrustum;
  127606. /** @hidden */
  127607. static _SceneComponentInitialization: (scene: Scene) => void;
  127608. /**
  127609. * Creates a Cascaded Shadow Generator object.
  127610. * A ShadowGenerator is the required tool to use the shadows.
  127611. * Each directional light casting shadows needs to use its own ShadowGenerator.
  127612. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  127613. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  127614. * @param light The directional light object generating the shadows.
  127615. * @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.
  127616. */
  127617. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  127618. protected _initializeGenerator(): void;
  127619. protected _createTargetRenderTexture(): void;
  127620. protected _initializeShadowMap(): void;
  127621. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  127622. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  127623. /**
  127624. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  127625. * @param defines Defines of the material we want to update
  127626. * @param lightIndex Index of the light in the enabled light list of the material
  127627. */
  127628. prepareDefines(defines: any, lightIndex: number): void;
  127629. /**
  127630. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  127631. * defined in the generator but impacting the effect).
  127632. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  127633. * @param effect The effect we are binfing the information for
  127634. */
  127635. bindShadowLight(lightIndex: string, effect: Effect): void;
  127636. /**
  127637. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  127638. * (eq to view projection * shadow projection matrices)
  127639. * @returns The transform matrix used to create the shadow map
  127640. */
  127641. getTransformMatrix(): Matrix;
  127642. /**
  127643. * Disposes the ShadowGenerator.
  127644. * Returns nothing.
  127645. */
  127646. dispose(): void;
  127647. /**
  127648. * Serializes the shadow generator setup to a json object.
  127649. * @returns The serialized JSON object
  127650. */
  127651. serialize(): any;
  127652. /**
  127653. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  127654. * @param parsedShadowGenerator The JSON object to parse
  127655. * @param scene The scene to create the shadow map for
  127656. * @returns The parsed shadow generator
  127657. */
  127658. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  127659. }
  127660. }
  127661. declare module BABYLON {
  127662. /**
  127663. * Defines the shadow generator component responsible to manage any shadow generators
  127664. * in a given scene.
  127665. */
  127666. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  127667. /**
  127668. * The component name helpfull to identify the component in the list of scene components.
  127669. */
  127670. readonly name: string;
  127671. /**
  127672. * The scene the component belongs to.
  127673. */
  127674. scene: Scene;
  127675. /**
  127676. * Creates a new instance of the component for the given scene
  127677. * @param scene Defines the scene to register the component in
  127678. */
  127679. constructor(scene: Scene);
  127680. /**
  127681. * Registers the component in a given scene
  127682. */
  127683. register(): void;
  127684. /**
  127685. * Rebuilds the elements related to this component in case of
  127686. * context lost for instance.
  127687. */
  127688. rebuild(): void;
  127689. /**
  127690. * Serializes the component data to the specified json object
  127691. * @param serializationObject The object to serialize to
  127692. */
  127693. serialize(serializationObject: any): void;
  127694. /**
  127695. * Adds all the elements from the container to the scene
  127696. * @param container the container holding the elements
  127697. */
  127698. addFromContainer(container: AbstractScene): void;
  127699. /**
  127700. * Removes all the elements in the container from the scene
  127701. * @param container contains the elements to remove
  127702. * @param dispose if the removed element should be disposed (default: false)
  127703. */
  127704. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  127705. /**
  127706. * Rebuilds the elements related to this component in case of
  127707. * context lost for instance.
  127708. */
  127709. dispose(): void;
  127710. private _gatherRenderTargets;
  127711. }
  127712. }
  127713. declare module BABYLON {
  127714. /**
  127715. * A point light is a light defined by an unique point in world space.
  127716. * The light is emitted in every direction from this point.
  127717. * A good example of a point light is a standard light bulb.
  127718. * Documentation: https://doc.babylonjs.com/babylon101/lights
  127719. */
  127720. export class PointLight extends ShadowLight {
  127721. private _shadowAngle;
  127722. /**
  127723. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127724. * This specifies what angle the shadow will use to be created.
  127725. *
  127726. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  127727. */
  127728. get shadowAngle(): number;
  127729. /**
  127730. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127731. * This specifies what angle the shadow will use to be created.
  127732. *
  127733. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  127734. */
  127735. set shadowAngle(value: number);
  127736. /**
  127737. * Gets the direction if it has been set.
  127738. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127739. */
  127740. get direction(): Vector3;
  127741. /**
  127742. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127743. */
  127744. set direction(value: Vector3);
  127745. /**
  127746. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  127747. * A PointLight emits the light in every direction.
  127748. * It can cast shadows.
  127749. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  127750. * ```javascript
  127751. * var pointLight = new PointLight("pl", camera.position, scene);
  127752. * ```
  127753. * Documentation : https://doc.babylonjs.com/babylon101/lights
  127754. * @param name The light friendly name
  127755. * @param position The position of the point light in the scene
  127756. * @param scene The scene the lights belongs to
  127757. */
  127758. constructor(name: string, position: Vector3, scene: Scene);
  127759. /**
  127760. * Returns the string "PointLight"
  127761. * @returns the class name
  127762. */
  127763. getClassName(): string;
  127764. /**
  127765. * Returns the integer 0.
  127766. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  127767. */
  127768. getTypeID(): number;
  127769. /**
  127770. * Specifies wether or not the shadowmap should be a cube texture.
  127771. * @returns true if the shadowmap needs to be a cube texture.
  127772. */
  127773. needCube(): boolean;
  127774. /**
  127775. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  127776. * @param faceIndex The index of the face we are computed the direction to generate shadow
  127777. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  127778. */
  127779. getShadowDirection(faceIndex?: number): Vector3;
  127780. /**
  127781. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  127782. * - fov = PI / 2
  127783. * - aspect ratio : 1.0
  127784. * - z-near and far equal to the active camera minZ and maxZ.
  127785. * Returns the PointLight.
  127786. */
  127787. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  127788. protected _buildUniformLayout(): void;
  127789. /**
  127790. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  127791. * @param effect The effect to update
  127792. * @param lightIndex The index of the light in the effect to update
  127793. * @returns The point light
  127794. */
  127795. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  127796. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  127797. /**
  127798. * Prepares the list of defines specific to the light type.
  127799. * @param defines the list of defines
  127800. * @param lightIndex defines the index of the light for the effect
  127801. */
  127802. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  127803. }
  127804. }
  127805. declare module BABYLON {
  127806. /**
  127807. * Header information of HDR texture files.
  127808. */
  127809. export interface HDRInfo {
  127810. /**
  127811. * The height of the texture in pixels.
  127812. */
  127813. height: number;
  127814. /**
  127815. * The width of the texture in pixels.
  127816. */
  127817. width: number;
  127818. /**
  127819. * The index of the beginning of the data in the binary file.
  127820. */
  127821. dataPosition: number;
  127822. }
  127823. /**
  127824. * This groups tools to convert HDR texture to native colors array.
  127825. */
  127826. export class HDRTools {
  127827. private static Ldexp;
  127828. private static Rgbe2float;
  127829. private static readStringLine;
  127830. /**
  127831. * Reads header information from an RGBE texture stored in a native array.
  127832. * More information on this format are available here:
  127833. * https://en.wikipedia.org/wiki/RGBE_image_format
  127834. *
  127835. * @param uint8array The binary file stored in native array.
  127836. * @return The header information.
  127837. */
  127838. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  127839. /**
  127840. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  127841. * This RGBE texture needs to store the information as a panorama.
  127842. *
  127843. * More information on this format are available here:
  127844. * https://en.wikipedia.org/wiki/RGBE_image_format
  127845. *
  127846. * @param buffer The binary file stored in an array buffer.
  127847. * @param size The expected size of the extracted cubemap.
  127848. * @return The Cube Map information.
  127849. */
  127850. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  127851. /**
  127852. * Returns the pixels data extracted from an RGBE texture.
  127853. * This pixels will be stored left to right up to down in the R G B order in one array.
  127854. *
  127855. * More information on this format are available here:
  127856. * https://en.wikipedia.org/wiki/RGBE_image_format
  127857. *
  127858. * @param uint8array The binary file stored in an array buffer.
  127859. * @param hdrInfo The header information of the file.
  127860. * @return The pixels data in RGB right to left up to down order.
  127861. */
  127862. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  127863. private static RGBE_ReadPixels_RLE;
  127864. }
  127865. }
  127866. declare module BABYLON {
  127867. /**
  127868. * This represents a texture coming from an HDR input.
  127869. *
  127870. * The only supported format is currently panorama picture stored in RGBE format.
  127871. * Example of such files can be found on HDRLib: http://hdrlib.com/
  127872. */
  127873. export class HDRCubeTexture extends BaseTexture {
  127874. private static _facesMapping;
  127875. private _generateHarmonics;
  127876. private _noMipmap;
  127877. private _textureMatrix;
  127878. private _size;
  127879. private _onLoad;
  127880. private _onError;
  127881. /**
  127882. * The texture URL.
  127883. */
  127884. url: string;
  127885. /**
  127886. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  127887. */
  127888. coordinatesMode: number;
  127889. protected _isBlocking: boolean;
  127890. /**
  127891. * Sets wether or not the texture is blocking during loading.
  127892. */
  127893. set isBlocking(value: boolean);
  127894. /**
  127895. * Gets wether or not the texture is blocking during loading.
  127896. */
  127897. get isBlocking(): boolean;
  127898. protected _rotationY: number;
  127899. /**
  127900. * Sets texture matrix rotation angle around Y axis in radians.
  127901. */
  127902. set rotationY(value: number);
  127903. /**
  127904. * Gets texture matrix rotation angle around Y axis radians.
  127905. */
  127906. get rotationY(): number;
  127907. /**
  127908. * Gets or sets the center of the bounding box associated with the cube texture
  127909. * It must define where the camera used to render the texture was set
  127910. */
  127911. boundingBoxPosition: Vector3;
  127912. private _boundingBoxSize;
  127913. /**
  127914. * Gets or sets the size of the bounding box associated with the cube texture
  127915. * When defined, the cubemap will switch to local mode
  127916. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  127917. * @example https://www.babylonjs-playground.com/#RNASML
  127918. */
  127919. set boundingBoxSize(value: Vector3);
  127920. get boundingBoxSize(): Vector3;
  127921. /**
  127922. * Instantiates an HDRTexture from the following parameters.
  127923. *
  127924. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  127925. * @param scene The scene the texture will be used in
  127926. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  127927. * @param noMipmap Forces to not generate the mipmap if true
  127928. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  127929. * @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)
  127930. * @param reserved Reserved flag for internal use.
  127931. */
  127932. 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>);
  127933. /**
  127934. * Get the current class name of the texture useful for serialization or dynamic coding.
  127935. * @returns "HDRCubeTexture"
  127936. */
  127937. getClassName(): string;
  127938. /**
  127939. * Occurs when the file is raw .hdr file.
  127940. */
  127941. private loadTexture;
  127942. clone(): HDRCubeTexture;
  127943. delayLoad(): void;
  127944. /**
  127945. * Get the texture reflection matrix used to rotate/transform the reflection.
  127946. * @returns the reflection matrix
  127947. */
  127948. getReflectionTextureMatrix(): Matrix;
  127949. /**
  127950. * Set the texture reflection matrix used to rotate/transform the reflection.
  127951. * @param value Define the reflection matrix to set
  127952. */
  127953. setReflectionTextureMatrix(value: Matrix): void;
  127954. /**
  127955. * Parses a JSON representation of an HDR Texture in order to create the texture
  127956. * @param parsedTexture Define the JSON representation
  127957. * @param scene Define the scene the texture should be created in
  127958. * @param rootUrl Define the root url in case we need to load relative dependencies
  127959. * @returns the newly created texture after parsing
  127960. */
  127961. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  127962. serialize(): any;
  127963. }
  127964. }
  127965. declare module BABYLON {
  127966. /**
  127967. * Class used to control physics engine
  127968. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  127969. */
  127970. export class PhysicsEngine implements IPhysicsEngine {
  127971. private _physicsPlugin;
  127972. /**
  127973. * Global value used to control the smallest number supported by the simulation
  127974. */
  127975. static Epsilon: number;
  127976. private _impostors;
  127977. private _joints;
  127978. private _subTimeStep;
  127979. /**
  127980. * Gets the gravity vector used by the simulation
  127981. */
  127982. gravity: Vector3;
  127983. /**
  127984. * Factory used to create the default physics plugin.
  127985. * @returns The default physics plugin
  127986. */
  127987. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  127988. /**
  127989. * Creates a new Physics Engine
  127990. * @param gravity defines the gravity vector used by the simulation
  127991. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  127992. */
  127993. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  127994. /**
  127995. * Sets the gravity vector used by the simulation
  127996. * @param gravity defines the gravity vector to use
  127997. */
  127998. setGravity(gravity: Vector3): void;
  127999. /**
  128000. * Set the time step of the physics engine.
  128001. * Default is 1/60.
  128002. * To slow it down, enter 1/600 for example.
  128003. * To speed it up, 1/30
  128004. * @param newTimeStep defines the new timestep to apply to this world.
  128005. */
  128006. setTimeStep(newTimeStep?: number): void;
  128007. /**
  128008. * Get the time step of the physics engine.
  128009. * @returns the current time step
  128010. */
  128011. getTimeStep(): number;
  128012. /**
  128013. * Set the sub time step of the physics engine.
  128014. * Default is 0 meaning there is no sub steps
  128015. * To increase physics resolution precision, set a small value (like 1 ms)
  128016. * @param subTimeStep defines the new sub timestep used for physics resolution.
  128017. */
  128018. setSubTimeStep(subTimeStep?: number): void;
  128019. /**
  128020. * Get the sub time step of the physics engine.
  128021. * @returns the current sub time step
  128022. */
  128023. getSubTimeStep(): number;
  128024. /**
  128025. * Release all resources
  128026. */
  128027. dispose(): void;
  128028. /**
  128029. * Gets the name of the current physics plugin
  128030. * @returns the name of the plugin
  128031. */
  128032. getPhysicsPluginName(): string;
  128033. /**
  128034. * Adding a new impostor for the impostor tracking.
  128035. * This will be done by the impostor itself.
  128036. * @param impostor the impostor to add
  128037. */
  128038. addImpostor(impostor: PhysicsImpostor): void;
  128039. /**
  128040. * Remove an impostor from the engine.
  128041. * This impostor and its mesh will not longer be updated by the physics engine.
  128042. * @param impostor the impostor to remove
  128043. */
  128044. removeImpostor(impostor: PhysicsImpostor): void;
  128045. /**
  128046. * Add a joint to the physics engine
  128047. * @param mainImpostor defines the main impostor to which the joint is added.
  128048. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  128049. * @param joint defines the joint that will connect both impostors.
  128050. */
  128051. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  128052. /**
  128053. * Removes a joint from the simulation
  128054. * @param mainImpostor defines the impostor used with the joint
  128055. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  128056. * @param joint defines the joint to remove
  128057. */
  128058. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  128059. /**
  128060. * Called by the scene. No need to call it.
  128061. * @param delta defines the timespam between frames
  128062. */
  128063. _step(delta: number): void;
  128064. /**
  128065. * Gets the current plugin used to run the simulation
  128066. * @returns current plugin
  128067. */
  128068. getPhysicsPlugin(): IPhysicsEnginePlugin;
  128069. /**
  128070. * Gets the list of physic impostors
  128071. * @returns an array of PhysicsImpostor
  128072. */
  128073. getImpostors(): Array<PhysicsImpostor>;
  128074. /**
  128075. * Gets the impostor for a physics enabled object
  128076. * @param object defines the object impersonated by the impostor
  128077. * @returns the PhysicsImpostor or null if not found
  128078. */
  128079. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  128080. /**
  128081. * Gets the impostor for a physics body object
  128082. * @param body defines physics body used by the impostor
  128083. * @returns the PhysicsImpostor or null if not found
  128084. */
  128085. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  128086. /**
  128087. * Does a raycast in the physics world
  128088. * @param from when should the ray start?
  128089. * @param to when should the ray end?
  128090. * @returns PhysicsRaycastResult
  128091. */
  128092. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128093. }
  128094. }
  128095. declare module BABYLON {
  128096. /** @hidden */
  128097. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  128098. private _useDeltaForWorldStep;
  128099. world: any;
  128100. name: string;
  128101. private _physicsMaterials;
  128102. private _fixedTimeStep;
  128103. private _cannonRaycastResult;
  128104. private _raycastResult;
  128105. private _physicsBodysToRemoveAfterStep;
  128106. BJSCANNON: any;
  128107. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  128108. setGravity(gravity: Vector3): void;
  128109. setTimeStep(timeStep: number): void;
  128110. getTimeStep(): number;
  128111. executeStep(delta: number): void;
  128112. private _removeMarkedPhysicsBodiesFromWorld;
  128113. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128114. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128115. generatePhysicsBody(impostor: PhysicsImpostor): void;
  128116. private _processChildMeshes;
  128117. removePhysicsBody(impostor: PhysicsImpostor): void;
  128118. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  128119. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  128120. private _addMaterial;
  128121. private _checkWithEpsilon;
  128122. private _createShape;
  128123. private _createHeightmap;
  128124. private _minus90X;
  128125. private _plus90X;
  128126. private _tmpPosition;
  128127. private _tmpDeltaPosition;
  128128. private _tmpUnityRotation;
  128129. private _updatePhysicsBodyTransformation;
  128130. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  128131. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  128132. isSupported(): boolean;
  128133. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128134. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128135. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128136. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128137. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  128138. getBodyMass(impostor: PhysicsImpostor): number;
  128139. getBodyFriction(impostor: PhysicsImpostor): number;
  128140. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  128141. getBodyRestitution(impostor: PhysicsImpostor): number;
  128142. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  128143. sleepBody(impostor: PhysicsImpostor): void;
  128144. wakeUpBody(impostor: PhysicsImpostor): void;
  128145. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  128146. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  128147. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  128148. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  128149. getRadius(impostor: PhysicsImpostor): number;
  128150. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  128151. dispose(): void;
  128152. private _extendNamespace;
  128153. /**
  128154. * Does a raycast in the physics world
  128155. * @param from when should the ray start?
  128156. * @param to when should the ray end?
  128157. * @returns PhysicsRaycastResult
  128158. */
  128159. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128160. }
  128161. }
  128162. declare module BABYLON {
  128163. /** @hidden */
  128164. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  128165. world: any;
  128166. name: string;
  128167. BJSOIMO: any;
  128168. private _raycastResult;
  128169. constructor(iterations?: number, oimoInjection?: any);
  128170. setGravity(gravity: Vector3): void;
  128171. setTimeStep(timeStep: number): void;
  128172. getTimeStep(): number;
  128173. private _tmpImpostorsArray;
  128174. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  128175. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128176. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128177. generatePhysicsBody(impostor: PhysicsImpostor): void;
  128178. private _tmpPositionVector;
  128179. removePhysicsBody(impostor: PhysicsImpostor): void;
  128180. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  128181. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  128182. isSupported(): boolean;
  128183. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  128184. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  128185. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128186. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128187. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128188. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128189. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  128190. getBodyMass(impostor: PhysicsImpostor): number;
  128191. getBodyFriction(impostor: PhysicsImpostor): number;
  128192. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  128193. getBodyRestitution(impostor: PhysicsImpostor): number;
  128194. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  128195. sleepBody(impostor: PhysicsImpostor): void;
  128196. wakeUpBody(impostor: PhysicsImpostor): void;
  128197. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  128198. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  128199. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  128200. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  128201. getRadius(impostor: PhysicsImpostor): number;
  128202. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  128203. dispose(): void;
  128204. /**
  128205. * Does a raycast in the physics world
  128206. * @param from when should the ray start?
  128207. * @param to when should the ray end?
  128208. * @returns PhysicsRaycastResult
  128209. */
  128210. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128211. }
  128212. }
  128213. declare module BABYLON {
  128214. /**
  128215. * Class containing static functions to help procedurally build meshes
  128216. */
  128217. export class RibbonBuilder {
  128218. /**
  128219. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  128220. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  128221. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  128222. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  128223. * * 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
  128224. * * 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
  128225. * * 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
  128226. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128227. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128228. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  128229. * * 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
  128230. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  128231. * * 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
  128232. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  128233. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128234. * @param name defines the name of the mesh
  128235. * @param options defines the options used to create the mesh
  128236. * @param scene defines the hosting scene
  128237. * @returns the ribbon mesh
  128238. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  128239. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128240. */
  128241. static CreateRibbon(name: string, options: {
  128242. pathArray: Vector3[][];
  128243. closeArray?: boolean;
  128244. closePath?: boolean;
  128245. offset?: number;
  128246. updatable?: boolean;
  128247. sideOrientation?: number;
  128248. frontUVs?: Vector4;
  128249. backUVs?: Vector4;
  128250. instance?: Mesh;
  128251. invertUV?: boolean;
  128252. uvs?: Vector2[];
  128253. colors?: Color4[];
  128254. }, scene?: Nullable<Scene>): Mesh;
  128255. }
  128256. }
  128257. declare module BABYLON {
  128258. /**
  128259. * Class containing static functions to help procedurally build meshes
  128260. */
  128261. export class ShapeBuilder {
  128262. /**
  128263. * 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.
  128264. * * 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.
  128265. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  128266. * * 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.
  128267. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  128268. * * 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
  128269. * * 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
  128270. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  128271. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128272. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128273. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  128274. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  128275. * @param name defines the name of the mesh
  128276. * @param options defines the options used to create the mesh
  128277. * @param scene defines the hosting scene
  128278. * @returns the extruded shape mesh
  128279. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128280. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  128281. */
  128282. static ExtrudeShape(name: string, options: {
  128283. shape: Vector3[];
  128284. path: Vector3[];
  128285. scale?: number;
  128286. rotation?: number;
  128287. cap?: number;
  128288. updatable?: boolean;
  128289. sideOrientation?: number;
  128290. frontUVs?: Vector4;
  128291. backUVs?: Vector4;
  128292. instance?: Mesh;
  128293. invertUV?: boolean;
  128294. }, scene?: Nullable<Scene>): Mesh;
  128295. /**
  128296. * Creates an custom extruded shape mesh.
  128297. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  128298. * * 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.
  128299. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  128300. * * 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
  128301. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  128302. * * 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
  128303. * * It must returns a float value that will be the scale value applied to the shape on each path point
  128304. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  128305. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  128306. * * 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
  128307. * * 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
  128308. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  128309. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128310. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128311. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  128312. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128313. * @param name defines the name of the mesh
  128314. * @param options defines the options used to create the mesh
  128315. * @param scene defines the hosting scene
  128316. * @returns the custom extruded shape mesh
  128317. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  128318. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128319. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  128320. */
  128321. static ExtrudeShapeCustom(name: string, options: {
  128322. shape: Vector3[];
  128323. path: Vector3[];
  128324. scaleFunction?: any;
  128325. rotationFunction?: any;
  128326. ribbonCloseArray?: boolean;
  128327. ribbonClosePath?: boolean;
  128328. cap?: number;
  128329. updatable?: boolean;
  128330. sideOrientation?: number;
  128331. frontUVs?: Vector4;
  128332. backUVs?: Vector4;
  128333. instance?: Mesh;
  128334. invertUV?: boolean;
  128335. }, scene?: Nullable<Scene>): Mesh;
  128336. private static _ExtrudeShapeGeneric;
  128337. }
  128338. }
  128339. declare module BABYLON {
  128340. /**
  128341. * AmmoJS Physics plugin
  128342. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  128343. * @see https://github.com/kripken/ammo.js/
  128344. */
  128345. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  128346. private _useDeltaForWorldStep;
  128347. /**
  128348. * Reference to the Ammo library
  128349. */
  128350. bjsAMMO: any;
  128351. /**
  128352. * Created ammoJS world which physics bodies are added to
  128353. */
  128354. world: any;
  128355. /**
  128356. * Name of the plugin
  128357. */
  128358. name: string;
  128359. private _timeStep;
  128360. private _fixedTimeStep;
  128361. private _maxSteps;
  128362. private _tmpQuaternion;
  128363. private _tmpAmmoTransform;
  128364. private _tmpAmmoQuaternion;
  128365. private _tmpAmmoConcreteContactResultCallback;
  128366. private _collisionConfiguration;
  128367. private _dispatcher;
  128368. private _overlappingPairCache;
  128369. private _solver;
  128370. private _softBodySolver;
  128371. private _tmpAmmoVectorA;
  128372. private _tmpAmmoVectorB;
  128373. private _tmpAmmoVectorC;
  128374. private _tmpAmmoVectorD;
  128375. private _tmpContactCallbackResult;
  128376. private _tmpAmmoVectorRCA;
  128377. private _tmpAmmoVectorRCB;
  128378. private _raycastResult;
  128379. private static readonly DISABLE_COLLISION_FLAG;
  128380. private static readonly KINEMATIC_FLAG;
  128381. private static readonly DISABLE_DEACTIVATION_FLAG;
  128382. /**
  128383. * Initializes the ammoJS plugin
  128384. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  128385. * @param ammoInjection can be used to inject your own ammo reference
  128386. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  128387. */
  128388. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  128389. /**
  128390. * Sets the gravity of the physics world (m/(s^2))
  128391. * @param gravity Gravity to set
  128392. */
  128393. setGravity(gravity: Vector3): void;
  128394. /**
  128395. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  128396. * @param timeStep timestep to use in seconds
  128397. */
  128398. setTimeStep(timeStep: number): void;
  128399. /**
  128400. * 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)
  128401. * @param fixedTimeStep fixedTimeStep to use in seconds
  128402. */
  128403. setFixedTimeStep(fixedTimeStep: number): void;
  128404. /**
  128405. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  128406. * @param maxSteps the maximum number of steps by the physics engine per frame
  128407. */
  128408. setMaxSteps(maxSteps: number): void;
  128409. /**
  128410. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  128411. * @returns the current timestep in seconds
  128412. */
  128413. getTimeStep(): number;
  128414. /**
  128415. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  128416. */
  128417. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  128418. private _isImpostorInContact;
  128419. private _isImpostorPairInContact;
  128420. private _stepSimulation;
  128421. /**
  128422. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  128423. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  128424. * After the step the babylon meshes are set to the position of the physics imposters
  128425. * @param delta amount of time to step forward
  128426. * @param impostors array of imposters to update before/after the step
  128427. */
  128428. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  128429. /**
  128430. * Update babylon mesh to match physics world object
  128431. * @param impostor imposter to match
  128432. */
  128433. private _afterSoftStep;
  128434. /**
  128435. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  128436. * @param impostor imposter to match
  128437. */
  128438. private _ropeStep;
  128439. /**
  128440. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  128441. * @param impostor imposter to match
  128442. */
  128443. private _softbodyOrClothStep;
  128444. private _tmpVector;
  128445. private _tmpMatrix;
  128446. /**
  128447. * Applies an impulse on the imposter
  128448. * @param impostor imposter to apply impulse to
  128449. * @param force amount of force to be applied to the imposter
  128450. * @param contactPoint the location to apply the impulse on the imposter
  128451. */
  128452. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128453. /**
  128454. * Applies a force on the imposter
  128455. * @param impostor imposter to apply force
  128456. * @param force amount of force to be applied to the imposter
  128457. * @param contactPoint the location to apply the force on the imposter
  128458. */
  128459. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128460. /**
  128461. * Creates a physics body using the plugin
  128462. * @param impostor the imposter to create the physics body on
  128463. */
  128464. generatePhysicsBody(impostor: PhysicsImpostor): void;
  128465. /**
  128466. * Removes the physics body from the imposter and disposes of the body's memory
  128467. * @param impostor imposter to remove the physics body from
  128468. */
  128469. removePhysicsBody(impostor: PhysicsImpostor): void;
  128470. /**
  128471. * Generates a joint
  128472. * @param impostorJoint the imposter joint to create the joint with
  128473. */
  128474. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  128475. /**
  128476. * Removes a joint
  128477. * @param impostorJoint the imposter joint to remove the joint from
  128478. */
  128479. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  128480. private _addMeshVerts;
  128481. /**
  128482. * Initialise the soft body vertices to match its object's (mesh) vertices
  128483. * Softbody vertices (nodes) are in world space and to match this
  128484. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  128485. * @param impostor to create the softbody for
  128486. */
  128487. private _softVertexData;
  128488. /**
  128489. * Create an impostor's soft body
  128490. * @param impostor to create the softbody for
  128491. */
  128492. private _createSoftbody;
  128493. /**
  128494. * Create cloth for an impostor
  128495. * @param impostor to create the softbody for
  128496. */
  128497. private _createCloth;
  128498. /**
  128499. * Create rope for an impostor
  128500. * @param impostor to create the softbody for
  128501. */
  128502. private _createRope;
  128503. /**
  128504. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  128505. * @param impostor to create the custom physics shape for
  128506. */
  128507. private _createCustom;
  128508. private _addHullVerts;
  128509. private _createShape;
  128510. /**
  128511. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  128512. * @param impostor imposter containing the physics body and babylon object
  128513. */
  128514. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  128515. /**
  128516. * Sets the babylon object's position/rotation from the physics body's position/rotation
  128517. * @param impostor imposter containing the physics body and babylon object
  128518. * @param newPosition new position
  128519. * @param newRotation new rotation
  128520. */
  128521. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  128522. /**
  128523. * If this plugin is supported
  128524. * @returns true if its supported
  128525. */
  128526. isSupported(): boolean;
  128527. /**
  128528. * Sets the linear velocity of the physics body
  128529. * @param impostor imposter to set the velocity on
  128530. * @param velocity velocity to set
  128531. */
  128532. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128533. /**
  128534. * Sets the angular velocity of the physics body
  128535. * @param impostor imposter to set the velocity on
  128536. * @param velocity velocity to set
  128537. */
  128538. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128539. /**
  128540. * gets the linear velocity
  128541. * @param impostor imposter to get linear velocity from
  128542. * @returns linear velocity
  128543. */
  128544. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128545. /**
  128546. * gets the angular velocity
  128547. * @param impostor imposter to get angular velocity from
  128548. * @returns angular velocity
  128549. */
  128550. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128551. /**
  128552. * Sets the mass of physics body
  128553. * @param impostor imposter to set the mass on
  128554. * @param mass mass to set
  128555. */
  128556. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  128557. /**
  128558. * Gets the mass of the physics body
  128559. * @param impostor imposter to get the mass from
  128560. * @returns mass
  128561. */
  128562. getBodyMass(impostor: PhysicsImpostor): number;
  128563. /**
  128564. * Gets friction of the impostor
  128565. * @param impostor impostor to get friction from
  128566. * @returns friction value
  128567. */
  128568. getBodyFriction(impostor: PhysicsImpostor): number;
  128569. /**
  128570. * Sets friction of the impostor
  128571. * @param impostor impostor to set friction on
  128572. * @param friction friction value
  128573. */
  128574. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  128575. /**
  128576. * Gets restitution of the impostor
  128577. * @param impostor impostor to get restitution from
  128578. * @returns restitution value
  128579. */
  128580. getBodyRestitution(impostor: PhysicsImpostor): number;
  128581. /**
  128582. * Sets resitution of the impostor
  128583. * @param impostor impostor to set resitution on
  128584. * @param restitution resitution value
  128585. */
  128586. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  128587. /**
  128588. * Gets pressure inside the impostor
  128589. * @param impostor impostor to get pressure from
  128590. * @returns pressure value
  128591. */
  128592. getBodyPressure(impostor: PhysicsImpostor): number;
  128593. /**
  128594. * Sets pressure inside a soft body impostor
  128595. * Cloth and rope must remain 0 pressure
  128596. * @param impostor impostor to set pressure on
  128597. * @param pressure pressure value
  128598. */
  128599. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  128600. /**
  128601. * Gets stiffness of the impostor
  128602. * @param impostor impostor to get stiffness from
  128603. * @returns pressure value
  128604. */
  128605. getBodyStiffness(impostor: PhysicsImpostor): number;
  128606. /**
  128607. * Sets stiffness of the impostor
  128608. * @param impostor impostor to set stiffness on
  128609. * @param stiffness stiffness value from 0 to 1
  128610. */
  128611. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  128612. /**
  128613. * Gets velocityIterations of the impostor
  128614. * @param impostor impostor to get velocity iterations from
  128615. * @returns velocityIterations value
  128616. */
  128617. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  128618. /**
  128619. * Sets velocityIterations of the impostor
  128620. * @param impostor impostor to set velocity iterations on
  128621. * @param velocityIterations velocityIterations value
  128622. */
  128623. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  128624. /**
  128625. * Gets positionIterations of the impostor
  128626. * @param impostor impostor to get position iterations from
  128627. * @returns positionIterations value
  128628. */
  128629. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  128630. /**
  128631. * Sets positionIterations of the impostor
  128632. * @param impostor impostor to set position on
  128633. * @param positionIterations positionIterations value
  128634. */
  128635. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  128636. /**
  128637. * Append an anchor to a cloth object
  128638. * @param impostor is the cloth impostor to add anchor to
  128639. * @param otherImpostor is the rigid impostor to anchor to
  128640. * @param width ratio across width from 0 to 1
  128641. * @param height ratio up height from 0 to 1
  128642. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  128643. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  128644. */
  128645. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  128646. /**
  128647. * Append an hook to a rope object
  128648. * @param impostor is the rope impostor to add hook to
  128649. * @param otherImpostor is the rigid impostor to hook to
  128650. * @param length ratio along the rope from 0 to 1
  128651. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  128652. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  128653. */
  128654. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  128655. /**
  128656. * Sleeps the physics body and stops it from being active
  128657. * @param impostor impostor to sleep
  128658. */
  128659. sleepBody(impostor: PhysicsImpostor): void;
  128660. /**
  128661. * Activates the physics body
  128662. * @param impostor impostor to activate
  128663. */
  128664. wakeUpBody(impostor: PhysicsImpostor): void;
  128665. /**
  128666. * Updates the distance parameters of the joint
  128667. * @param joint joint to update
  128668. * @param maxDistance maximum distance of the joint
  128669. * @param minDistance minimum distance of the joint
  128670. */
  128671. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  128672. /**
  128673. * Sets a motor on the joint
  128674. * @param joint joint to set motor on
  128675. * @param speed speed of the motor
  128676. * @param maxForce maximum force of the motor
  128677. * @param motorIndex index of the motor
  128678. */
  128679. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  128680. /**
  128681. * Sets the motors limit
  128682. * @param joint joint to set limit on
  128683. * @param upperLimit upper limit
  128684. * @param lowerLimit lower limit
  128685. */
  128686. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  128687. /**
  128688. * Syncs the position and rotation of a mesh with the impostor
  128689. * @param mesh mesh to sync
  128690. * @param impostor impostor to update the mesh with
  128691. */
  128692. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  128693. /**
  128694. * Gets the radius of the impostor
  128695. * @param impostor impostor to get radius from
  128696. * @returns the radius
  128697. */
  128698. getRadius(impostor: PhysicsImpostor): number;
  128699. /**
  128700. * Gets the box size of the impostor
  128701. * @param impostor impostor to get box size from
  128702. * @param result the resulting box size
  128703. */
  128704. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  128705. /**
  128706. * Disposes of the impostor
  128707. */
  128708. dispose(): void;
  128709. /**
  128710. * Does a raycast in the physics world
  128711. * @param from when should the ray start?
  128712. * @param to when should the ray end?
  128713. * @returns PhysicsRaycastResult
  128714. */
  128715. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128716. }
  128717. }
  128718. declare module BABYLON {
  128719. interface AbstractScene {
  128720. /**
  128721. * The list of reflection probes added to the scene
  128722. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  128723. */
  128724. reflectionProbes: Array<ReflectionProbe>;
  128725. /**
  128726. * Removes the given reflection probe from this scene.
  128727. * @param toRemove The reflection probe to remove
  128728. * @returns The index of the removed reflection probe
  128729. */
  128730. removeReflectionProbe(toRemove: ReflectionProbe): number;
  128731. /**
  128732. * Adds the given reflection probe to this scene.
  128733. * @param newReflectionProbe The reflection probe to add
  128734. */
  128735. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  128736. }
  128737. /**
  128738. * Class used to generate realtime reflection / refraction cube textures
  128739. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  128740. */
  128741. export class ReflectionProbe {
  128742. /** defines the name of the probe */
  128743. name: string;
  128744. private _scene;
  128745. private _renderTargetTexture;
  128746. private _projectionMatrix;
  128747. private _viewMatrix;
  128748. private _target;
  128749. private _add;
  128750. private _attachedMesh;
  128751. private _invertYAxis;
  128752. /** Gets or sets probe position (center of the cube map) */
  128753. position: Vector3;
  128754. /**
  128755. * Creates a new reflection probe
  128756. * @param name defines the name of the probe
  128757. * @param size defines the texture resolution (for each face)
  128758. * @param scene defines the hosting scene
  128759. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  128760. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  128761. */
  128762. constructor(
  128763. /** defines the name of the probe */
  128764. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  128765. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  128766. get samples(): number;
  128767. set samples(value: number);
  128768. /** Gets or sets the refresh rate to use (on every frame by default) */
  128769. get refreshRate(): number;
  128770. set refreshRate(value: number);
  128771. /**
  128772. * Gets the hosting scene
  128773. * @returns a Scene
  128774. */
  128775. getScene(): Scene;
  128776. /** Gets the internal CubeTexture used to render to */
  128777. get cubeTexture(): RenderTargetTexture;
  128778. /** Gets the list of meshes to render */
  128779. get renderList(): Nullable<AbstractMesh[]>;
  128780. /**
  128781. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  128782. * @param mesh defines the mesh to attach to
  128783. */
  128784. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  128785. /**
  128786. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  128787. * @param renderingGroupId The rendering group id corresponding to its index
  128788. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  128789. */
  128790. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  128791. /**
  128792. * Clean all associated resources
  128793. */
  128794. dispose(): void;
  128795. /**
  128796. * Converts the reflection probe information to a readable string for debug purpose.
  128797. * @param fullDetails Supports for multiple levels of logging within scene loading
  128798. * @returns the human readable reflection probe info
  128799. */
  128800. toString(fullDetails?: boolean): string;
  128801. /**
  128802. * Get the class name of the relfection probe.
  128803. * @returns "ReflectionProbe"
  128804. */
  128805. getClassName(): string;
  128806. /**
  128807. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  128808. * @returns The JSON representation of the texture
  128809. */
  128810. serialize(): any;
  128811. /**
  128812. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  128813. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  128814. * @param scene Define the scene the parsed reflection probe should be instantiated in
  128815. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  128816. * @returns The parsed reflection probe if successful
  128817. */
  128818. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  128819. }
  128820. }
  128821. declare module BABYLON {
  128822. /** @hidden */
  128823. export var _BabylonLoaderRegistered: boolean;
  128824. /**
  128825. * Helps setting up some configuration for the babylon file loader.
  128826. */
  128827. export class BabylonFileLoaderConfiguration {
  128828. /**
  128829. * The loader does not allow injecting custom physix engine into the plugins.
  128830. * Unfortunately in ES6, we need to manually inject them into the plugin.
  128831. * So you could set this variable to your engine import to make it work.
  128832. */
  128833. static LoaderInjectedPhysicsEngine: any;
  128834. }
  128835. }
  128836. declare module BABYLON {
  128837. /**
  128838. * The Physically based simple base material of BJS.
  128839. *
  128840. * This enables better naming and convention enforcements on top of the pbrMaterial.
  128841. * It is used as the base class for both the specGloss and metalRough conventions.
  128842. */
  128843. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  128844. /**
  128845. * Number of Simultaneous lights allowed on the material.
  128846. */
  128847. maxSimultaneousLights: number;
  128848. /**
  128849. * If sets to true, disables all the lights affecting the material.
  128850. */
  128851. disableLighting: boolean;
  128852. /**
  128853. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  128854. */
  128855. environmentTexture: BaseTexture;
  128856. /**
  128857. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  128858. */
  128859. invertNormalMapX: boolean;
  128860. /**
  128861. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  128862. */
  128863. invertNormalMapY: boolean;
  128864. /**
  128865. * Normal map used in the model.
  128866. */
  128867. normalTexture: BaseTexture;
  128868. /**
  128869. * Emissivie color used to self-illuminate the model.
  128870. */
  128871. emissiveColor: Color3;
  128872. /**
  128873. * Emissivie texture used to self-illuminate the model.
  128874. */
  128875. emissiveTexture: BaseTexture;
  128876. /**
  128877. * Occlusion Channel Strenght.
  128878. */
  128879. occlusionStrength: number;
  128880. /**
  128881. * Occlusion Texture of the material (adding extra occlusion effects).
  128882. */
  128883. occlusionTexture: BaseTexture;
  128884. /**
  128885. * Defines the alpha limits in alpha test mode.
  128886. */
  128887. alphaCutOff: number;
  128888. /**
  128889. * Gets the current double sided mode.
  128890. */
  128891. get doubleSided(): boolean;
  128892. /**
  128893. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  128894. */
  128895. set doubleSided(value: boolean);
  128896. /**
  128897. * Stores the pre-calculated light information of a mesh in a texture.
  128898. */
  128899. lightmapTexture: BaseTexture;
  128900. /**
  128901. * If true, the light map contains occlusion information instead of lighting info.
  128902. */
  128903. useLightmapAsShadowmap: boolean;
  128904. /**
  128905. * Instantiates a new PBRMaterial instance.
  128906. *
  128907. * @param name The material name
  128908. * @param scene The scene the material will be use in.
  128909. */
  128910. constructor(name: string, scene: Scene);
  128911. getClassName(): string;
  128912. }
  128913. }
  128914. declare module BABYLON {
  128915. /**
  128916. * The PBR material of BJS following the metal roughness convention.
  128917. *
  128918. * This fits to the PBR convention in the GLTF definition:
  128919. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  128920. */
  128921. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  128922. /**
  128923. * The base color has two different interpretations depending on the value of metalness.
  128924. * When the material is a metal, the base color is the specific measured reflectance value
  128925. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  128926. * of the material.
  128927. */
  128928. baseColor: Color3;
  128929. /**
  128930. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  128931. * well as opacity information in the alpha channel.
  128932. */
  128933. baseTexture: BaseTexture;
  128934. /**
  128935. * Specifies the metallic scalar value of the material.
  128936. * Can also be used to scale the metalness values of the metallic texture.
  128937. */
  128938. metallic: number;
  128939. /**
  128940. * Specifies the roughness scalar value of the material.
  128941. * Can also be used to scale the roughness values of the metallic texture.
  128942. */
  128943. roughness: number;
  128944. /**
  128945. * Texture containing both the metallic value in the B channel and the
  128946. * roughness value in the G channel to keep better precision.
  128947. */
  128948. metallicRoughnessTexture: BaseTexture;
  128949. /**
  128950. * Instantiates a new PBRMetalRoughnessMaterial instance.
  128951. *
  128952. * @param name The material name
  128953. * @param scene The scene the material will be use in.
  128954. */
  128955. constructor(name: string, scene: Scene);
  128956. /**
  128957. * Return the currrent class name of the material.
  128958. */
  128959. getClassName(): string;
  128960. /**
  128961. * Makes a duplicate of the current material.
  128962. * @param name - name to use for the new material.
  128963. */
  128964. clone(name: string): PBRMetallicRoughnessMaterial;
  128965. /**
  128966. * Serialize the material to a parsable JSON object.
  128967. */
  128968. serialize(): any;
  128969. /**
  128970. * Parses a JSON object correponding to the serialize function.
  128971. */
  128972. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  128973. }
  128974. }
  128975. declare module BABYLON {
  128976. /**
  128977. * The PBR material of BJS following the specular glossiness convention.
  128978. *
  128979. * This fits to the PBR convention in the GLTF definition:
  128980. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  128981. */
  128982. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  128983. /**
  128984. * Specifies the diffuse color of the material.
  128985. */
  128986. diffuseColor: Color3;
  128987. /**
  128988. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  128989. * channel.
  128990. */
  128991. diffuseTexture: BaseTexture;
  128992. /**
  128993. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  128994. */
  128995. specularColor: Color3;
  128996. /**
  128997. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  128998. */
  128999. glossiness: number;
  129000. /**
  129001. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  129002. */
  129003. specularGlossinessTexture: BaseTexture;
  129004. /**
  129005. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  129006. *
  129007. * @param name The material name
  129008. * @param scene The scene the material will be use in.
  129009. */
  129010. constructor(name: string, scene: Scene);
  129011. /**
  129012. * Return the currrent class name of the material.
  129013. */
  129014. getClassName(): string;
  129015. /**
  129016. * Makes a duplicate of the current material.
  129017. * @param name - name to use for the new material.
  129018. */
  129019. clone(name: string): PBRSpecularGlossinessMaterial;
  129020. /**
  129021. * Serialize the material to a parsable JSON object.
  129022. */
  129023. serialize(): any;
  129024. /**
  129025. * Parses a JSON object correponding to the serialize function.
  129026. */
  129027. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  129028. }
  129029. }
  129030. declare module BABYLON {
  129031. /**
  129032. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  129033. * It can help converting any input color in a desired output one. This can then be used to create effects
  129034. * from sepia, black and white to sixties or futuristic rendering...
  129035. *
  129036. * The only supported format is currently 3dl.
  129037. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  129038. */
  129039. export class ColorGradingTexture extends BaseTexture {
  129040. /**
  129041. * The current texture matrix. (will always be identity in color grading texture)
  129042. */
  129043. private _textureMatrix;
  129044. /**
  129045. * The texture URL.
  129046. */
  129047. url: string;
  129048. /**
  129049. * Empty line regex stored for GC.
  129050. */
  129051. private static _noneEmptyLineRegex;
  129052. private _engine;
  129053. /**
  129054. * Instantiates a ColorGradingTexture from the following parameters.
  129055. *
  129056. * @param url The location of the color gradind data (currently only supporting 3dl)
  129057. * @param scene The scene the texture will be used in
  129058. */
  129059. constructor(url: string, scene: Scene);
  129060. /**
  129061. * Returns the texture matrix used in most of the material.
  129062. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  129063. */
  129064. getTextureMatrix(): Matrix;
  129065. /**
  129066. * Occurs when the file being loaded is a .3dl LUT file.
  129067. */
  129068. private load3dlTexture;
  129069. /**
  129070. * Starts the loading process of the texture.
  129071. */
  129072. private loadTexture;
  129073. /**
  129074. * Clones the color gradind texture.
  129075. */
  129076. clone(): ColorGradingTexture;
  129077. /**
  129078. * Called during delayed load for textures.
  129079. */
  129080. delayLoad(): void;
  129081. /**
  129082. * Parses a color grading texture serialized by Babylon.
  129083. * @param parsedTexture The texture information being parsedTexture
  129084. * @param scene The scene to load the texture in
  129085. * @param rootUrl The root url of the data assets to load
  129086. * @return A color gradind texture
  129087. */
  129088. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  129089. /**
  129090. * Serializes the LUT texture to json format.
  129091. */
  129092. serialize(): any;
  129093. }
  129094. }
  129095. declare module BABYLON {
  129096. /**
  129097. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  129098. */
  129099. export class EquiRectangularCubeTexture extends BaseTexture {
  129100. /** The six faces of the cube. */
  129101. private static _FacesMapping;
  129102. private _noMipmap;
  129103. private _onLoad;
  129104. private _onError;
  129105. /** The size of the cubemap. */
  129106. private _size;
  129107. /** The buffer of the image. */
  129108. private _buffer;
  129109. /** The width of the input image. */
  129110. private _width;
  129111. /** The height of the input image. */
  129112. private _height;
  129113. /** The URL to the image. */
  129114. url: string;
  129115. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  129116. coordinatesMode: number;
  129117. /**
  129118. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  129119. * @param url The location of the image
  129120. * @param scene The scene the texture will be used in
  129121. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  129122. * @param noMipmap Forces to not generate the mipmap if true
  129123. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  129124. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  129125. * @param onLoad — defines a callback called when texture is loaded
  129126. * @param onError — defines a callback called if there is an error
  129127. */
  129128. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  129129. /**
  129130. * Load the image data, by putting the image on a canvas and extracting its buffer.
  129131. */
  129132. private loadImage;
  129133. /**
  129134. * Convert the image buffer into a cubemap and create a CubeTexture.
  129135. */
  129136. private loadTexture;
  129137. /**
  129138. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  129139. * @param buffer The ArrayBuffer that should be converted.
  129140. * @returns The buffer as Float32Array.
  129141. */
  129142. private getFloat32ArrayFromArrayBuffer;
  129143. /**
  129144. * Get the current class name of the texture useful for serialization or dynamic coding.
  129145. * @returns "EquiRectangularCubeTexture"
  129146. */
  129147. getClassName(): string;
  129148. /**
  129149. * Create a clone of the current EquiRectangularCubeTexture and return it.
  129150. * @returns A clone of the current EquiRectangularCubeTexture.
  129151. */
  129152. clone(): EquiRectangularCubeTexture;
  129153. }
  129154. }
  129155. declare module BABYLON {
  129156. /**
  129157. * Based on jsTGALoader - Javascript loader for TGA file
  129158. * By Vincent Thibault
  129159. * @see http://blog.robrowser.com/javascript-tga-loader.html
  129160. */
  129161. export class TGATools {
  129162. private static _TYPE_INDEXED;
  129163. private static _TYPE_RGB;
  129164. private static _TYPE_GREY;
  129165. private static _TYPE_RLE_INDEXED;
  129166. private static _TYPE_RLE_RGB;
  129167. private static _TYPE_RLE_GREY;
  129168. private static _ORIGIN_MASK;
  129169. private static _ORIGIN_SHIFT;
  129170. private static _ORIGIN_BL;
  129171. private static _ORIGIN_BR;
  129172. private static _ORIGIN_UL;
  129173. private static _ORIGIN_UR;
  129174. /**
  129175. * Gets the header of a TGA file
  129176. * @param data defines the TGA data
  129177. * @returns the header
  129178. */
  129179. static GetTGAHeader(data: Uint8Array): any;
  129180. /**
  129181. * Uploads TGA content to a Babylon Texture
  129182. * @hidden
  129183. */
  129184. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  129185. /** @hidden */
  129186. 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;
  129187. /** @hidden */
  129188. 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;
  129189. /** @hidden */
  129190. 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;
  129191. /** @hidden */
  129192. 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;
  129193. /** @hidden */
  129194. 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;
  129195. /** @hidden */
  129196. 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;
  129197. }
  129198. }
  129199. declare module BABYLON {
  129200. /**
  129201. * Implementation of the TGA Texture Loader.
  129202. * @hidden
  129203. */
  129204. export class _TGATextureLoader implements IInternalTextureLoader {
  129205. /**
  129206. * Defines wether the loader supports cascade loading the different faces.
  129207. */
  129208. readonly supportCascades: boolean;
  129209. /**
  129210. * This returns if the loader support the current file information.
  129211. * @param extension defines the file extension of the file being loaded
  129212. * @param textureFormatInUse defines the current compressed format in use iun the engine
  129213. * @param fallback defines the fallback internal texture if any
  129214. * @param isBase64 defines whether the texture is encoded as a base64
  129215. * @param isBuffer defines whether the texture data are stored as a buffer
  129216. * @returns true if the loader can load the specified file
  129217. */
  129218. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  129219. /**
  129220. * Transform the url before loading if required.
  129221. * @param rootUrl the url of the texture
  129222. * @param textureFormatInUse defines the current compressed format in use iun the engine
  129223. * @returns the transformed texture
  129224. */
  129225. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  129226. /**
  129227. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  129228. * @param rootUrl the url of the texture
  129229. * @param textureFormatInUse defines the current compressed format in use iun the engine
  129230. * @returns the fallback texture
  129231. */
  129232. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  129233. /**
  129234. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  129235. * @param data contains the texture data
  129236. * @param texture defines the BabylonJS internal texture
  129237. * @param createPolynomials will be true if polynomials have been requested
  129238. * @param onLoad defines the callback to trigger once the texture is ready
  129239. * @param onError defines the callback to trigger in case of error
  129240. */
  129241. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  129242. /**
  129243. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  129244. * @param data contains the texture data
  129245. * @param texture defines the BabylonJS internal texture
  129246. * @param callback defines the method to call once ready to upload
  129247. */
  129248. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  129249. }
  129250. }
  129251. declare module BABYLON {
  129252. /**
  129253. * Info about the .basis files
  129254. */
  129255. class BasisFileInfo {
  129256. /**
  129257. * If the file has alpha
  129258. */
  129259. hasAlpha: boolean;
  129260. /**
  129261. * Info about each image of the basis file
  129262. */
  129263. images: Array<{
  129264. levels: Array<{
  129265. width: number;
  129266. height: number;
  129267. transcodedPixels: ArrayBufferView;
  129268. }>;
  129269. }>;
  129270. }
  129271. /**
  129272. * Result of transcoding a basis file
  129273. */
  129274. class TranscodeResult {
  129275. /**
  129276. * Info about the .basis file
  129277. */
  129278. fileInfo: BasisFileInfo;
  129279. /**
  129280. * Format to use when loading the file
  129281. */
  129282. format: number;
  129283. }
  129284. /**
  129285. * Configuration options for the Basis transcoder
  129286. */
  129287. export class BasisTranscodeConfiguration {
  129288. /**
  129289. * Supported compression formats used to determine the supported output format of the transcoder
  129290. */
  129291. supportedCompressionFormats?: {
  129292. /**
  129293. * etc1 compression format
  129294. */
  129295. etc1?: boolean;
  129296. /**
  129297. * s3tc compression format
  129298. */
  129299. s3tc?: boolean;
  129300. /**
  129301. * pvrtc compression format
  129302. */
  129303. pvrtc?: boolean;
  129304. /**
  129305. * etc2 compression format
  129306. */
  129307. etc2?: boolean;
  129308. };
  129309. /**
  129310. * If mipmap levels should be loaded for transcoded images (Default: true)
  129311. */
  129312. loadMipmapLevels?: boolean;
  129313. /**
  129314. * Index of a single image to load (Default: all images)
  129315. */
  129316. loadSingleImage?: number;
  129317. }
  129318. /**
  129319. * Used to load .Basis files
  129320. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  129321. */
  129322. export class BasisTools {
  129323. private static _IgnoreSupportedFormats;
  129324. /**
  129325. * URL to use when loading the basis transcoder
  129326. */
  129327. static JSModuleURL: string;
  129328. /**
  129329. * URL to use when loading the wasm module for the transcoder
  129330. */
  129331. static WasmModuleURL: string;
  129332. /**
  129333. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  129334. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  129335. * @returns internal format corresponding to the Basis format
  129336. */
  129337. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  129338. private static _WorkerPromise;
  129339. private static _Worker;
  129340. private static _actionId;
  129341. private static _CreateWorkerAsync;
  129342. /**
  129343. * Transcodes a loaded image file to compressed pixel data
  129344. * @param data image data to transcode
  129345. * @param config configuration options for the transcoding
  129346. * @returns a promise resulting in the transcoded image
  129347. */
  129348. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  129349. /**
  129350. * Loads a texture from the transcode result
  129351. * @param texture texture load to
  129352. * @param transcodeResult the result of transcoding the basis file to load from
  129353. */
  129354. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  129355. }
  129356. }
  129357. declare module BABYLON {
  129358. /**
  129359. * Loader for .basis file format
  129360. */
  129361. export class _BasisTextureLoader implements IInternalTextureLoader {
  129362. /**
  129363. * Defines whether the loader supports cascade loading the different faces.
  129364. */
  129365. readonly supportCascades: boolean;
  129366. /**
  129367. * This returns if the loader support the current file information.
  129368. * @param extension defines the file extension of the file being loaded
  129369. * @param textureFormatInUse defines the current compressed format in use iun the engine
  129370. * @param fallback defines the fallback internal texture if any
  129371. * @param isBase64 defines whether the texture is encoded as a base64
  129372. * @param isBuffer defines whether the texture data are stored as a buffer
  129373. * @returns true if the loader can load the specified file
  129374. */
  129375. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  129376. /**
  129377. * Transform the url before loading if required.
  129378. * @param rootUrl the url of the texture
  129379. * @param textureFormatInUse defines the current compressed format in use iun the engine
  129380. * @returns the transformed texture
  129381. */
  129382. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  129383. /**
  129384. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  129385. * @param rootUrl the url of the texture
  129386. * @param textureFormatInUse defines the current compressed format in use iun the engine
  129387. * @returns the fallback texture
  129388. */
  129389. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  129390. /**
  129391. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  129392. * @param data contains the texture data
  129393. * @param texture defines the BabylonJS internal texture
  129394. * @param createPolynomials will be true if polynomials have been requested
  129395. * @param onLoad defines the callback to trigger once the texture is ready
  129396. * @param onError defines the callback to trigger in case of error
  129397. */
  129398. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  129399. /**
  129400. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  129401. * @param data contains the texture data
  129402. * @param texture defines the BabylonJS internal texture
  129403. * @param callback defines the method to call once ready to upload
  129404. */
  129405. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  129406. }
  129407. }
  129408. declare module BABYLON {
  129409. /**
  129410. * 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.
  129411. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  129412. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  129413. */
  129414. export class CustomProceduralTexture extends ProceduralTexture {
  129415. private _animate;
  129416. private _time;
  129417. private _config;
  129418. private _texturePath;
  129419. /**
  129420. * Instantiates a new Custom Procedural Texture.
  129421. * 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.
  129422. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  129423. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  129424. * @param name Define the name of the texture
  129425. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  129426. * @param size Define the size of the texture to create
  129427. * @param scene Define the scene the texture belongs to
  129428. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  129429. * @param generateMipMaps Define if the texture should creates mip maps or not
  129430. */
  129431. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  129432. private _loadJson;
  129433. /**
  129434. * Is the texture ready to be used ? (rendered at least once)
  129435. * @returns true if ready, otherwise, false.
  129436. */
  129437. isReady(): boolean;
  129438. /**
  129439. * Render the texture to its associated render target.
  129440. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  129441. */
  129442. render(useCameraPostProcess?: boolean): void;
  129443. /**
  129444. * Update the list of dependant textures samplers in the shader.
  129445. */
  129446. updateTextures(): void;
  129447. /**
  129448. * Update the uniform values of the procedural texture in the shader.
  129449. */
  129450. updateShaderUniforms(): void;
  129451. /**
  129452. * Define if the texture animates or not.
  129453. */
  129454. get animate(): boolean;
  129455. set animate(value: boolean);
  129456. }
  129457. }
  129458. declare module BABYLON {
  129459. /** @hidden */
  129460. export var noisePixelShader: {
  129461. name: string;
  129462. shader: string;
  129463. };
  129464. }
  129465. declare module BABYLON {
  129466. /**
  129467. * Class used to generate noise procedural textures
  129468. */
  129469. export class NoiseProceduralTexture extends ProceduralTexture {
  129470. private _time;
  129471. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  129472. brightness: number;
  129473. /** Defines the number of octaves to process */
  129474. octaves: number;
  129475. /** Defines the level of persistence (0.8 by default) */
  129476. persistence: number;
  129477. /** Gets or sets animation speed factor (default is 1) */
  129478. animationSpeedFactor: number;
  129479. /**
  129480. * Creates a new NoiseProceduralTexture
  129481. * @param name defines the name fo the texture
  129482. * @param size defines the size of the texture (default is 256)
  129483. * @param scene defines the hosting scene
  129484. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  129485. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  129486. */
  129487. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  129488. private _updateShaderUniforms;
  129489. protected _getDefines(): string;
  129490. /** Generate the current state of the procedural texture */
  129491. render(useCameraPostProcess?: boolean): void;
  129492. /**
  129493. * Serializes this noise procedural texture
  129494. * @returns a serialized noise procedural texture object
  129495. */
  129496. serialize(): any;
  129497. /**
  129498. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  129499. * @param parsedTexture defines parsed texture data
  129500. * @param scene defines the current scene
  129501. * @param rootUrl defines the root URL containing noise procedural texture information
  129502. * @returns a parsed NoiseProceduralTexture
  129503. */
  129504. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  129505. }
  129506. }
  129507. declare module BABYLON {
  129508. /**
  129509. * Raw cube texture where the raw buffers are passed in
  129510. */
  129511. export class RawCubeTexture extends CubeTexture {
  129512. /**
  129513. * Creates a cube texture where the raw buffers are passed in.
  129514. * @param scene defines the scene the texture is attached to
  129515. * @param data defines the array of data to use to create each face
  129516. * @param size defines the size of the textures
  129517. * @param format defines the format of the data
  129518. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  129519. * @param generateMipMaps defines if the engine should generate the mip levels
  129520. * @param invertY defines if data must be stored with Y axis inverted
  129521. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  129522. * @param compression defines the compression used (null by default)
  129523. */
  129524. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  129525. /**
  129526. * Updates the raw cube texture.
  129527. * @param data defines the data to store
  129528. * @param format defines the data format
  129529. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  129530. * @param invertY defines if data must be stored with Y axis inverted
  129531. * @param compression defines the compression used (null by default)
  129532. * @param level defines which level of the texture to update
  129533. */
  129534. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  129535. /**
  129536. * Updates a raw cube texture with RGBD encoded data.
  129537. * @param data defines the array of data [mipmap][face] to use to create each face
  129538. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  129539. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  129540. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  129541. * @returns a promsie that resolves when the operation is complete
  129542. */
  129543. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  129544. /**
  129545. * Clones the raw cube texture.
  129546. * @return a new cube texture
  129547. */
  129548. clone(): CubeTexture;
  129549. /** @hidden */
  129550. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  129551. }
  129552. }
  129553. declare module BABYLON {
  129554. /**
  129555. * Class used to store 3D textures containing user data
  129556. */
  129557. export class RawTexture3D extends Texture {
  129558. /** Gets or sets the texture format to use */
  129559. format: number;
  129560. private _engine;
  129561. /**
  129562. * Create a new RawTexture3D
  129563. * @param data defines the data of the texture
  129564. * @param width defines the width of the texture
  129565. * @param height defines the height of the texture
  129566. * @param depth defines the depth of the texture
  129567. * @param format defines the texture format to use
  129568. * @param scene defines the hosting scene
  129569. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  129570. * @param invertY defines if texture must be stored with Y axis inverted
  129571. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  129572. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  129573. */
  129574. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  129575. /** Gets or sets the texture format to use */
  129576. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  129577. /**
  129578. * Update the texture with new data
  129579. * @param data defines the data to store in the texture
  129580. */
  129581. update(data: ArrayBufferView): void;
  129582. }
  129583. }
  129584. declare module BABYLON {
  129585. /**
  129586. * Class used to store 2D array textures containing user data
  129587. */
  129588. export class RawTexture2DArray extends Texture {
  129589. /** Gets or sets the texture format to use */
  129590. format: number;
  129591. private _engine;
  129592. /**
  129593. * Create a new RawTexture2DArray
  129594. * @param data defines the data of the texture
  129595. * @param width defines the width of the texture
  129596. * @param height defines the height of the texture
  129597. * @param depth defines the number of layers of the texture
  129598. * @param format defines the texture format to use
  129599. * @param scene defines the hosting scene
  129600. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  129601. * @param invertY defines if texture must be stored with Y axis inverted
  129602. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  129603. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  129604. */
  129605. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  129606. /** Gets or sets the texture format to use */
  129607. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  129608. /**
  129609. * Update the texture with new data
  129610. * @param data defines the data to store in the texture
  129611. */
  129612. update(data: ArrayBufferView): void;
  129613. }
  129614. }
  129615. declare module BABYLON {
  129616. /**
  129617. * Creates a refraction texture used by refraction channel of the standard material.
  129618. * It is like a mirror but to see through a material.
  129619. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129620. */
  129621. export class RefractionTexture extends RenderTargetTexture {
  129622. /**
  129623. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  129624. * 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.
  129625. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129626. */
  129627. refractionPlane: Plane;
  129628. /**
  129629. * Define how deep under the surface we should see.
  129630. */
  129631. depth: number;
  129632. /**
  129633. * Creates a refraction texture used by refraction channel of the standard material.
  129634. * It is like a mirror but to see through a material.
  129635. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129636. * @param name Define the texture name
  129637. * @param size Define the size of the underlying texture
  129638. * @param scene Define the scene the refraction belongs to
  129639. * @param generateMipMaps Define if we need to generate mips level for the refraction
  129640. */
  129641. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  129642. /**
  129643. * Clone the refraction texture.
  129644. * @returns the cloned texture
  129645. */
  129646. clone(): RefractionTexture;
  129647. /**
  129648. * Serialize the texture to a JSON representation you could use in Parse later on
  129649. * @returns the serialized JSON representation
  129650. */
  129651. serialize(): any;
  129652. }
  129653. }
  129654. declare module BABYLON {
  129655. /**
  129656. * Defines the options related to the creation of an HtmlElementTexture
  129657. */
  129658. export interface IHtmlElementTextureOptions {
  129659. /**
  129660. * Defines wether mip maps should be created or not.
  129661. */
  129662. generateMipMaps?: boolean;
  129663. /**
  129664. * Defines the sampling mode of the texture.
  129665. */
  129666. samplingMode?: number;
  129667. /**
  129668. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  129669. */
  129670. engine: Nullable<ThinEngine>;
  129671. /**
  129672. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  129673. */
  129674. scene: Nullable<Scene>;
  129675. }
  129676. /**
  129677. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  129678. * To be as efficient as possible depending on your constraints nothing aside the first upload
  129679. * is automatically managed.
  129680. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  129681. * in your application.
  129682. *
  129683. * As the update is not automatic, you need to call them manually.
  129684. */
  129685. export class HtmlElementTexture extends BaseTexture {
  129686. /**
  129687. * The texture URL.
  129688. */
  129689. element: HTMLVideoElement | HTMLCanvasElement;
  129690. private static readonly DefaultOptions;
  129691. private _textureMatrix;
  129692. private _engine;
  129693. private _isVideo;
  129694. private _generateMipMaps;
  129695. private _samplingMode;
  129696. /**
  129697. * Instantiates a HtmlElementTexture from the following parameters.
  129698. *
  129699. * @param name Defines the name of the texture
  129700. * @param element Defines the video or canvas the texture is filled with
  129701. * @param options Defines the other none mandatory texture creation options
  129702. */
  129703. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  129704. private _createInternalTexture;
  129705. /**
  129706. * Returns the texture matrix used in most of the material.
  129707. */
  129708. getTextureMatrix(): Matrix;
  129709. /**
  129710. * Updates the content of the texture.
  129711. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  129712. */
  129713. update(invertY?: Nullable<boolean>): void;
  129714. }
  129715. }
  129716. declare module BABYLON {
  129717. /**
  129718. * Defines the basic options interface of a TexturePacker Frame
  129719. */
  129720. export interface ITexturePackerFrame {
  129721. /**
  129722. * The frame ID
  129723. */
  129724. id: number;
  129725. /**
  129726. * The frames Scale
  129727. */
  129728. scale: Vector2;
  129729. /**
  129730. * The Frames offset
  129731. */
  129732. offset: Vector2;
  129733. }
  129734. /**
  129735. * This is a support class for frame Data on texture packer sets.
  129736. */
  129737. export class TexturePackerFrame implements ITexturePackerFrame {
  129738. /**
  129739. * The frame ID
  129740. */
  129741. id: number;
  129742. /**
  129743. * The frames Scale
  129744. */
  129745. scale: Vector2;
  129746. /**
  129747. * The Frames offset
  129748. */
  129749. offset: Vector2;
  129750. /**
  129751. * Initializes a texture package frame.
  129752. * @param id The numerical frame identifier
  129753. * @param scale Scalar Vector2 for UV frame
  129754. * @param offset Vector2 for the frame position in UV units.
  129755. * @returns TexturePackerFrame
  129756. */
  129757. constructor(id: number, scale: Vector2, offset: Vector2);
  129758. }
  129759. }
  129760. declare module BABYLON {
  129761. /**
  129762. * Defines the basic options interface of a TexturePacker
  129763. */
  129764. export interface ITexturePackerOptions {
  129765. /**
  129766. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  129767. */
  129768. map?: string[];
  129769. /**
  129770. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  129771. */
  129772. uvsIn?: string;
  129773. /**
  129774. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  129775. */
  129776. uvsOut?: string;
  129777. /**
  129778. * number representing the layout style. Defaults to LAYOUT_STRIP
  129779. */
  129780. layout?: number;
  129781. /**
  129782. * number of columns if using custom column count layout(2). This defaults to 4.
  129783. */
  129784. colnum?: number;
  129785. /**
  129786. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  129787. */
  129788. updateInputMeshes?: boolean;
  129789. /**
  129790. * boolean flag to dispose all the source textures. Defaults to true.
  129791. */
  129792. disposeSources?: boolean;
  129793. /**
  129794. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  129795. */
  129796. fillBlanks?: boolean;
  129797. /**
  129798. * string value representing the context fill style color. Defaults to 'black'.
  129799. */
  129800. customFillColor?: string;
  129801. /**
  129802. * Width and Height Value of each Frame in the TexturePacker Sets
  129803. */
  129804. frameSize?: number;
  129805. /**
  129806. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  129807. */
  129808. paddingRatio?: number;
  129809. /**
  129810. * Number that declares the fill method for the padding gutter.
  129811. */
  129812. paddingMode?: number;
  129813. /**
  129814. * If in SUBUV_COLOR padding mode what color to use.
  129815. */
  129816. paddingColor?: Color3 | Color4;
  129817. }
  129818. /**
  129819. * Defines the basic interface of a TexturePacker JSON File
  129820. */
  129821. export interface ITexturePackerJSON {
  129822. /**
  129823. * The frame ID
  129824. */
  129825. name: string;
  129826. /**
  129827. * The base64 channel data
  129828. */
  129829. sets: any;
  129830. /**
  129831. * The options of the Packer
  129832. */
  129833. options: ITexturePackerOptions;
  129834. /**
  129835. * The frame data of the Packer
  129836. */
  129837. frames: Array<number>;
  129838. }
  129839. /**
  129840. * This is a support class that generates a series of packed texture sets.
  129841. * @see https://doc.babylonjs.com/babylon101/materials
  129842. */
  129843. export class TexturePacker {
  129844. /** Packer Layout Constant 0 */
  129845. static readonly LAYOUT_STRIP: number;
  129846. /** Packer Layout Constant 1 */
  129847. static readonly LAYOUT_POWER2: number;
  129848. /** Packer Layout Constant 2 */
  129849. static readonly LAYOUT_COLNUM: number;
  129850. /** Packer Layout Constant 0 */
  129851. static readonly SUBUV_WRAP: number;
  129852. /** Packer Layout Constant 1 */
  129853. static readonly SUBUV_EXTEND: number;
  129854. /** Packer Layout Constant 2 */
  129855. static readonly SUBUV_COLOR: number;
  129856. /** The Name of the Texture Package */
  129857. name: string;
  129858. /** The scene scope of the TexturePacker */
  129859. scene: Scene;
  129860. /** The Meshes to target */
  129861. meshes: AbstractMesh[];
  129862. /** Arguments passed with the Constructor */
  129863. options: ITexturePackerOptions;
  129864. /** The promise that is started upon initialization */
  129865. promise: Nullable<Promise<TexturePacker | string>>;
  129866. /** The Container object for the channel sets that are generated */
  129867. sets: object;
  129868. /** The Container array for the frames that are generated */
  129869. frames: TexturePackerFrame[];
  129870. /** The expected number of textures the system is parsing. */
  129871. private _expecting;
  129872. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  129873. private _paddingValue;
  129874. /**
  129875. * Initializes a texture package series from an array of meshes or a single mesh.
  129876. * @param name The name of the package
  129877. * @param meshes The target meshes to compose the package from
  129878. * @param options The arguments that texture packer should follow while building.
  129879. * @param scene The scene which the textures are scoped to.
  129880. * @returns TexturePacker
  129881. */
  129882. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  129883. /**
  129884. * Starts the package process
  129885. * @param resolve The promises resolution function
  129886. * @returns TexturePacker
  129887. */
  129888. private _createFrames;
  129889. /**
  129890. * Calculates the Size of the Channel Sets
  129891. * @returns Vector2
  129892. */
  129893. private _calculateSize;
  129894. /**
  129895. * Calculates the UV data for the frames.
  129896. * @param baseSize the base frameSize
  129897. * @param padding the base frame padding
  129898. * @param dtSize size of the Dynamic Texture for that channel
  129899. * @param dtUnits is 1/dtSize
  129900. * @param update flag to update the input meshes
  129901. */
  129902. private _calculateMeshUVFrames;
  129903. /**
  129904. * Calculates the frames Offset.
  129905. * @param index of the frame
  129906. * @returns Vector2
  129907. */
  129908. private _getFrameOffset;
  129909. /**
  129910. * Updates a Mesh to the frame data
  129911. * @param mesh that is the target
  129912. * @param frameID or the frame index
  129913. */
  129914. private _updateMeshUV;
  129915. /**
  129916. * Updates a Meshes materials to use the texture packer channels
  129917. * @param m is the mesh to target
  129918. * @param force all channels on the packer to be set.
  129919. */
  129920. private _updateTextureReferences;
  129921. /**
  129922. * Public method to set a Mesh to a frame
  129923. * @param m that is the target
  129924. * @param frameID or the frame index
  129925. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  129926. */
  129927. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  129928. /**
  129929. * Starts the async promise to compile the texture packer.
  129930. * @returns Promise<void>
  129931. */
  129932. processAsync(): Promise<void>;
  129933. /**
  129934. * Disposes all textures associated with this packer
  129935. */
  129936. dispose(): void;
  129937. /**
  129938. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  129939. * @param imageType is the image type to use.
  129940. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  129941. */
  129942. download(imageType?: string, quality?: number): void;
  129943. /**
  129944. * Public method to load a texturePacker JSON file.
  129945. * @param data of the JSON file in string format.
  129946. */
  129947. updateFromJSON(data: string): void;
  129948. }
  129949. }
  129950. declare module BABYLON {
  129951. /**
  129952. * Enum used to define the target of a block
  129953. */
  129954. export enum NodeMaterialBlockTargets {
  129955. /** Vertex shader */
  129956. Vertex = 1,
  129957. /** Fragment shader */
  129958. Fragment = 2,
  129959. /** Neutral */
  129960. Neutral = 4,
  129961. /** Vertex and Fragment */
  129962. VertexAndFragment = 3
  129963. }
  129964. }
  129965. declare module BABYLON {
  129966. /**
  129967. * Defines the kind of connection point for node based material
  129968. */
  129969. export enum NodeMaterialBlockConnectionPointTypes {
  129970. /** Float */
  129971. Float = 1,
  129972. /** Int */
  129973. Int = 2,
  129974. /** Vector2 */
  129975. Vector2 = 4,
  129976. /** Vector3 */
  129977. Vector3 = 8,
  129978. /** Vector4 */
  129979. Vector4 = 16,
  129980. /** Color3 */
  129981. Color3 = 32,
  129982. /** Color4 */
  129983. Color4 = 64,
  129984. /** Matrix */
  129985. Matrix = 128,
  129986. /** Detect type based on connection */
  129987. AutoDetect = 1024,
  129988. /** Output type that will be defined by input type */
  129989. BasedOnInput = 2048
  129990. }
  129991. }
  129992. declare module BABYLON {
  129993. /**
  129994. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  129995. */
  129996. export enum NodeMaterialBlockConnectionPointMode {
  129997. /** Value is an uniform */
  129998. Uniform = 0,
  129999. /** Value is a mesh attribute */
  130000. Attribute = 1,
  130001. /** Value is a varying between vertex and fragment shaders */
  130002. Varying = 2,
  130003. /** Mode is undefined */
  130004. Undefined = 3
  130005. }
  130006. }
  130007. declare module BABYLON {
  130008. /**
  130009. * Enum used to define system values e.g. values automatically provided by the system
  130010. */
  130011. export enum NodeMaterialSystemValues {
  130012. /** World */
  130013. World = 1,
  130014. /** View */
  130015. View = 2,
  130016. /** Projection */
  130017. Projection = 3,
  130018. /** ViewProjection */
  130019. ViewProjection = 4,
  130020. /** WorldView */
  130021. WorldView = 5,
  130022. /** WorldViewProjection */
  130023. WorldViewProjection = 6,
  130024. /** CameraPosition */
  130025. CameraPosition = 7,
  130026. /** Fog Color */
  130027. FogColor = 8,
  130028. /** Delta time */
  130029. DeltaTime = 9
  130030. }
  130031. }
  130032. declare module BABYLON {
  130033. /**
  130034. * Root class for all node material optimizers
  130035. */
  130036. export class NodeMaterialOptimizer {
  130037. /**
  130038. * Function used to optimize a NodeMaterial graph
  130039. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  130040. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  130041. */
  130042. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  130043. }
  130044. }
  130045. declare module BABYLON {
  130046. /**
  130047. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  130048. */
  130049. export class TransformBlock extends NodeMaterialBlock {
  130050. /**
  130051. * Defines the value to use to complement W value to transform it to a Vector4
  130052. */
  130053. complementW: number;
  130054. /**
  130055. * Defines the value to use to complement z value to transform it to a Vector4
  130056. */
  130057. complementZ: number;
  130058. /**
  130059. * Creates a new TransformBlock
  130060. * @param name defines the block name
  130061. */
  130062. constructor(name: string);
  130063. /**
  130064. * Gets the current class name
  130065. * @returns the class name
  130066. */
  130067. getClassName(): string;
  130068. /**
  130069. * Gets the vector input
  130070. */
  130071. get vector(): NodeMaterialConnectionPoint;
  130072. /**
  130073. * Gets the output component
  130074. */
  130075. get output(): NodeMaterialConnectionPoint;
  130076. /**
  130077. * Gets the matrix transform input
  130078. */
  130079. get transform(): NodeMaterialConnectionPoint;
  130080. protected _buildBlock(state: NodeMaterialBuildState): this;
  130081. serialize(): any;
  130082. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130083. protected _dumpPropertiesCode(): string;
  130084. }
  130085. }
  130086. declare module BABYLON {
  130087. /**
  130088. * Block used to output the vertex position
  130089. */
  130090. export class VertexOutputBlock extends NodeMaterialBlock {
  130091. /**
  130092. * Creates a new VertexOutputBlock
  130093. * @param name defines the block name
  130094. */
  130095. constructor(name: string);
  130096. /**
  130097. * Gets the current class name
  130098. * @returns the class name
  130099. */
  130100. getClassName(): string;
  130101. /**
  130102. * Gets the vector input component
  130103. */
  130104. get vector(): NodeMaterialConnectionPoint;
  130105. protected _buildBlock(state: NodeMaterialBuildState): this;
  130106. }
  130107. }
  130108. declare module BABYLON {
  130109. /**
  130110. * Block used to output the final color
  130111. */
  130112. export class FragmentOutputBlock extends NodeMaterialBlock {
  130113. /**
  130114. * Create a new FragmentOutputBlock
  130115. * @param name defines the block name
  130116. */
  130117. constructor(name: string);
  130118. /**
  130119. * Gets the current class name
  130120. * @returns the class name
  130121. */
  130122. getClassName(): string;
  130123. /**
  130124. * Gets the rgba input component
  130125. */
  130126. get rgba(): NodeMaterialConnectionPoint;
  130127. /**
  130128. * Gets the rgb input component
  130129. */
  130130. get rgb(): NodeMaterialConnectionPoint;
  130131. /**
  130132. * Gets the a input component
  130133. */
  130134. get a(): NodeMaterialConnectionPoint;
  130135. protected _buildBlock(state: NodeMaterialBuildState): this;
  130136. }
  130137. }
  130138. declare module BABYLON {
  130139. /**
  130140. * Block used to read a reflection texture from a sampler
  130141. */
  130142. export class ReflectionTextureBlock extends NodeMaterialBlock {
  130143. private _define3DName;
  130144. private _defineCubicName;
  130145. private _defineExplicitName;
  130146. private _defineProjectionName;
  130147. private _defineLocalCubicName;
  130148. private _defineSphericalName;
  130149. private _definePlanarName;
  130150. private _defineEquirectangularName;
  130151. private _defineMirroredEquirectangularFixedName;
  130152. private _defineEquirectangularFixedName;
  130153. private _defineSkyboxName;
  130154. private _cubeSamplerName;
  130155. private _2DSamplerName;
  130156. private _positionUVWName;
  130157. private _directionWName;
  130158. private _reflectionCoordsName;
  130159. private _reflection2DCoordsName;
  130160. private _reflectionColorName;
  130161. private _reflectionMatrixName;
  130162. /**
  130163. * Gets or sets the texture associated with the node
  130164. */
  130165. texture: Nullable<BaseTexture>;
  130166. /**
  130167. * Create a new TextureBlock
  130168. * @param name defines the block name
  130169. */
  130170. constructor(name: string);
  130171. /**
  130172. * Gets the current class name
  130173. * @returns the class name
  130174. */
  130175. getClassName(): string;
  130176. /**
  130177. * Gets the world position input component
  130178. */
  130179. get position(): NodeMaterialConnectionPoint;
  130180. /**
  130181. * Gets the world position input component
  130182. */
  130183. get worldPosition(): NodeMaterialConnectionPoint;
  130184. /**
  130185. * Gets the world normal input component
  130186. */
  130187. get worldNormal(): NodeMaterialConnectionPoint;
  130188. /**
  130189. * Gets the world input component
  130190. */
  130191. get world(): NodeMaterialConnectionPoint;
  130192. /**
  130193. * Gets the camera (or eye) position component
  130194. */
  130195. get cameraPosition(): NodeMaterialConnectionPoint;
  130196. /**
  130197. * Gets the view input component
  130198. */
  130199. get view(): NodeMaterialConnectionPoint;
  130200. /**
  130201. * Gets the rgb output component
  130202. */
  130203. get rgb(): NodeMaterialConnectionPoint;
  130204. /**
  130205. * Gets the r output component
  130206. */
  130207. get r(): NodeMaterialConnectionPoint;
  130208. /**
  130209. * Gets the g output component
  130210. */
  130211. get g(): NodeMaterialConnectionPoint;
  130212. /**
  130213. * Gets the b output component
  130214. */
  130215. get b(): NodeMaterialConnectionPoint;
  130216. autoConfigure(material: NodeMaterial): void;
  130217. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130218. isReady(): boolean;
  130219. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130220. private _injectVertexCode;
  130221. private _writeOutput;
  130222. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  130223. protected _dumpPropertiesCode(): string;
  130224. serialize(): any;
  130225. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130226. }
  130227. }
  130228. declare module BABYLON {
  130229. /**
  130230. * Interface used to configure the node material editor
  130231. */
  130232. export interface INodeMaterialEditorOptions {
  130233. /** Define the URl to load node editor script */
  130234. editorURL?: string;
  130235. }
  130236. /** @hidden */
  130237. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  130238. NORMAL: boolean;
  130239. TANGENT: boolean;
  130240. UV1: boolean;
  130241. /** BONES */
  130242. NUM_BONE_INFLUENCERS: number;
  130243. BonesPerMesh: number;
  130244. BONETEXTURE: boolean;
  130245. /** MORPH TARGETS */
  130246. MORPHTARGETS: boolean;
  130247. MORPHTARGETS_NORMAL: boolean;
  130248. MORPHTARGETS_TANGENT: boolean;
  130249. MORPHTARGETS_UV: boolean;
  130250. NUM_MORPH_INFLUENCERS: number;
  130251. /** IMAGE PROCESSING */
  130252. IMAGEPROCESSING: boolean;
  130253. VIGNETTE: boolean;
  130254. VIGNETTEBLENDMODEMULTIPLY: boolean;
  130255. VIGNETTEBLENDMODEOPAQUE: boolean;
  130256. TONEMAPPING: boolean;
  130257. TONEMAPPING_ACES: boolean;
  130258. CONTRAST: boolean;
  130259. EXPOSURE: boolean;
  130260. COLORCURVES: boolean;
  130261. COLORGRADING: boolean;
  130262. COLORGRADING3D: boolean;
  130263. SAMPLER3DGREENDEPTH: boolean;
  130264. SAMPLER3DBGRMAP: boolean;
  130265. IMAGEPROCESSINGPOSTPROCESS: boolean;
  130266. /** MISC. */
  130267. BUMPDIRECTUV: number;
  130268. constructor();
  130269. setValue(name: string, value: boolean): void;
  130270. }
  130271. /**
  130272. * Class used to configure NodeMaterial
  130273. */
  130274. export interface INodeMaterialOptions {
  130275. /**
  130276. * Defines if blocks should emit comments
  130277. */
  130278. emitComments: boolean;
  130279. }
  130280. /**
  130281. * Class used to create a node based material built by assembling shader blocks
  130282. */
  130283. export class NodeMaterial extends PushMaterial {
  130284. private static _BuildIdGenerator;
  130285. private _options;
  130286. private _vertexCompilationState;
  130287. private _fragmentCompilationState;
  130288. private _sharedData;
  130289. private _buildId;
  130290. private _buildWasSuccessful;
  130291. private _cachedWorldViewMatrix;
  130292. private _cachedWorldViewProjectionMatrix;
  130293. private _optimizers;
  130294. private _animationFrame;
  130295. /** Define the Url to load node editor script */
  130296. static EditorURL: string;
  130297. /** Define the Url to load snippets */
  130298. static SnippetUrl: string;
  130299. private BJSNODEMATERIALEDITOR;
  130300. /** Get the inspector from bundle or global */
  130301. private _getGlobalNodeMaterialEditor;
  130302. /**
  130303. * Gets or sets data used by visual editor
  130304. * @see https://nme.babylonjs.com
  130305. */
  130306. editorData: any;
  130307. /**
  130308. * 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)
  130309. */
  130310. ignoreAlpha: boolean;
  130311. /**
  130312. * Defines the maximum number of lights that can be used in the material
  130313. */
  130314. maxSimultaneousLights: number;
  130315. /**
  130316. * Observable raised when the material is built
  130317. */
  130318. onBuildObservable: Observable<NodeMaterial>;
  130319. /**
  130320. * Gets or sets the root nodes of the material vertex shader
  130321. */
  130322. _vertexOutputNodes: NodeMaterialBlock[];
  130323. /**
  130324. * Gets or sets the root nodes of the material fragment (pixel) shader
  130325. */
  130326. _fragmentOutputNodes: NodeMaterialBlock[];
  130327. /** Gets or sets options to control the node material overall behavior */
  130328. get options(): INodeMaterialOptions;
  130329. set options(options: INodeMaterialOptions);
  130330. /**
  130331. * Default configuration related to image processing available in the standard Material.
  130332. */
  130333. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  130334. /**
  130335. * Gets the image processing configuration used either in this material.
  130336. */
  130337. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  130338. /**
  130339. * Sets the Default image processing configuration used either in the this material.
  130340. *
  130341. * If sets to null, the scene one is in use.
  130342. */
  130343. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  130344. /**
  130345. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  130346. */
  130347. attachedBlocks: NodeMaterialBlock[];
  130348. /**
  130349. * Create a new node based material
  130350. * @param name defines the material name
  130351. * @param scene defines the hosting scene
  130352. * @param options defines creation option
  130353. */
  130354. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  130355. /**
  130356. * Gets the current class name of the material e.g. "NodeMaterial"
  130357. * @returns the class name
  130358. */
  130359. getClassName(): string;
  130360. /**
  130361. * Keep track of the image processing observer to allow dispose and replace.
  130362. */
  130363. private _imageProcessingObserver;
  130364. /**
  130365. * Attaches a new image processing configuration to the Standard Material.
  130366. * @param configuration
  130367. */
  130368. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  130369. /**
  130370. * Get a block by its name
  130371. * @param name defines the name of the block to retrieve
  130372. * @returns the required block or null if not found
  130373. */
  130374. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  130375. /**
  130376. * Get a block by its name
  130377. * @param predicate defines the predicate used to find the good candidate
  130378. * @returns the required block or null if not found
  130379. */
  130380. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  130381. /**
  130382. * Get an input block by its name
  130383. * @param predicate defines the predicate used to find the good candidate
  130384. * @returns the required input block or null if not found
  130385. */
  130386. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  130387. /**
  130388. * Gets the list of input blocks attached to this material
  130389. * @returns an array of InputBlocks
  130390. */
  130391. getInputBlocks(): InputBlock[];
  130392. /**
  130393. * Adds a new optimizer to the list of optimizers
  130394. * @param optimizer defines the optimizers to add
  130395. * @returns the current material
  130396. */
  130397. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  130398. /**
  130399. * Remove an optimizer from the list of optimizers
  130400. * @param optimizer defines the optimizers to remove
  130401. * @returns the current material
  130402. */
  130403. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  130404. /**
  130405. * Add a new block to the list of output nodes
  130406. * @param node defines the node to add
  130407. * @returns the current material
  130408. */
  130409. addOutputNode(node: NodeMaterialBlock): this;
  130410. /**
  130411. * Remove a block from the list of root nodes
  130412. * @param node defines the node to remove
  130413. * @returns the current material
  130414. */
  130415. removeOutputNode(node: NodeMaterialBlock): this;
  130416. private _addVertexOutputNode;
  130417. private _removeVertexOutputNode;
  130418. private _addFragmentOutputNode;
  130419. private _removeFragmentOutputNode;
  130420. /**
  130421. * Specifies if the material will require alpha blending
  130422. * @returns a boolean specifying if alpha blending is needed
  130423. */
  130424. needAlphaBlending(): boolean;
  130425. /**
  130426. * Specifies if this material should be rendered in alpha test mode
  130427. * @returns a boolean specifying if an alpha test is needed.
  130428. */
  130429. needAlphaTesting(): boolean;
  130430. private _initializeBlock;
  130431. private _resetDualBlocks;
  130432. /**
  130433. * Remove a block from the current node material
  130434. * @param block defines the block to remove
  130435. */
  130436. removeBlock(block: NodeMaterialBlock): void;
  130437. /**
  130438. * Build the material and generates the inner effect
  130439. * @param verbose defines if the build should log activity
  130440. */
  130441. build(verbose?: boolean): void;
  130442. /**
  130443. * Runs an otpimization phase to try to improve the shader code
  130444. */
  130445. optimize(): void;
  130446. private _prepareDefinesForAttributes;
  130447. /**
  130448. * Get if the submesh is ready to be used and all its information available.
  130449. * Child classes can use it to update shaders
  130450. * @param mesh defines the mesh to check
  130451. * @param subMesh defines which submesh to check
  130452. * @param useInstances specifies that instances should be used
  130453. * @returns a boolean indicating that the submesh is ready or not
  130454. */
  130455. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  130456. /**
  130457. * Get a string representing the shaders built by the current node graph
  130458. */
  130459. get compiledShaders(): string;
  130460. /**
  130461. * Binds the world matrix to the material
  130462. * @param world defines the world transformation matrix
  130463. */
  130464. bindOnlyWorldMatrix(world: Matrix): void;
  130465. /**
  130466. * Binds the submesh to this material by preparing the effect and shader to draw
  130467. * @param world defines the world transformation matrix
  130468. * @param mesh defines the mesh containing the submesh
  130469. * @param subMesh defines the submesh to bind the material to
  130470. */
  130471. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  130472. /**
  130473. * Gets the active textures from the material
  130474. * @returns an array of textures
  130475. */
  130476. getActiveTextures(): BaseTexture[];
  130477. /**
  130478. * Gets the list of texture blocks
  130479. * @returns an array of texture blocks
  130480. */
  130481. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  130482. /**
  130483. * Specifies if the material uses a texture
  130484. * @param texture defines the texture to check against the material
  130485. * @returns a boolean specifying if the material uses the texture
  130486. */
  130487. hasTexture(texture: BaseTexture): boolean;
  130488. /**
  130489. * Disposes the material
  130490. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  130491. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  130492. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  130493. */
  130494. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  130495. /** Creates the node editor window. */
  130496. private _createNodeEditor;
  130497. /**
  130498. * Launch the node material editor
  130499. * @param config Define the configuration of the editor
  130500. * @return a promise fulfilled when the node editor is visible
  130501. */
  130502. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  130503. /**
  130504. * Clear the current material
  130505. */
  130506. clear(): void;
  130507. /**
  130508. * Clear the current material and set it to a default state
  130509. */
  130510. setToDefault(): void;
  130511. /**
  130512. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  130513. * @param url defines the url to load from
  130514. * @returns a promise that will fullfil when the material is fully loaded
  130515. */
  130516. loadAsync(url: string): Promise<void>;
  130517. private _gatherBlocks;
  130518. /**
  130519. * Generate a string containing the code declaration required to create an equivalent of this material
  130520. * @returns a string
  130521. */
  130522. generateCode(): string;
  130523. /**
  130524. * Serializes this material in a JSON representation
  130525. * @returns the serialized material object
  130526. */
  130527. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  130528. private _restoreConnections;
  130529. /**
  130530. * Clear the current graph and load a new one from a serialization object
  130531. * @param source defines the JSON representation of the material
  130532. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130533. */
  130534. loadFromSerialization(source: any, rootUrl?: string): void;
  130535. /**
  130536. * Creates a node material from parsed material data
  130537. * @param source defines the JSON representation of the material
  130538. * @param scene defines the hosting scene
  130539. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130540. * @returns a new node material
  130541. */
  130542. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  130543. /**
  130544. * Creates a node material from a snippet saved in a remote file
  130545. * @param name defines the name of the material to create
  130546. * @param url defines the url to load from
  130547. * @param scene defines the hosting scene
  130548. * @returns a promise that will resolve to the new node material
  130549. */
  130550. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  130551. /**
  130552. * Creates a node material from a snippet saved by the node material editor
  130553. * @param snippetId defines the snippet to load
  130554. * @param scene defines the hosting scene
  130555. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130556. * @returns a promise that will resolve to the new node material
  130557. */
  130558. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  130559. /**
  130560. * Creates a new node material set to default basic configuration
  130561. * @param name defines the name of the material
  130562. * @param scene defines the hosting scene
  130563. * @returns a new NodeMaterial
  130564. */
  130565. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  130566. }
  130567. }
  130568. declare module BABYLON {
  130569. /**
  130570. * Block used to read a texture from a sampler
  130571. */
  130572. export class TextureBlock extends NodeMaterialBlock {
  130573. private _defineName;
  130574. private _linearDefineName;
  130575. private _tempTextureRead;
  130576. private _samplerName;
  130577. private _transformedUVName;
  130578. private _textureTransformName;
  130579. private _textureInfoName;
  130580. private _mainUVName;
  130581. private _mainUVDefineName;
  130582. /**
  130583. * Gets or sets the texture associated with the node
  130584. */
  130585. texture: Nullable<Texture>;
  130586. /**
  130587. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  130588. */
  130589. convertToGammaSpace: boolean;
  130590. /**
  130591. * Create a new TextureBlock
  130592. * @param name defines the block name
  130593. */
  130594. constructor(name: string);
  130595. /**
  130596. * Gets the current class name
  130597. * @returns the class name
  130598. */
  130599. getClassName(): string;
  130600. /**
  130601. * Gets the uv input component
  130602. */
  130603. get uv(): NodeMaterialConnectionPoint;
  130604. /**
  130605. * Gets the rgba output component
  130606. */
  130607. get rgba(): NodeMaterialConnectionPoint;
  130608. /**
  130609. * Gets the rgb output component
  130610. */
  130611. get rgb(): NodeMaterialConnectionPoint;
  130612. /**
  130613. * Gets the r output component
  130614. */
  130615. get r(): NodeMaterialConnectionPoint;
  130616. /**
  130617. * Gets the g output component
  130618. */
  130619. get g(): NodeMaterialConnectionPoint;
  130620. /**
  130621. * Gets the b output component
  130622. */
  130623. get b(): NodeMaterialConnectionPoint;
  130624. /**
  130625. * Gets the a output component
  130626. */
  130627. get a(): NodeMaterialConnectionPoint;
  130628. get target(): NodeMaterialBlockTargets;
  130629. autoConfigure(material: NodeMaterial): void;
  130630. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  130631. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130632. isReady(): boolean;
  130633. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130634. private get _isMixed();
  130635. private _injectVertexCode;
  130636. private _writeTextureRead;
  130637. private _writeOutput;
  130638. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  130639. protected _dumpPropertiesCode(): string;
  130640. serialize(): any;
  130641. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130642. }
  130643. }
  130644. declare module BABYLON {
  130645. /**
  130646. * Class used to store shared data between 2 NodeMaterialBuildState
  130647. */
  130648. export class NodeMaterialBuildStateSharedData {
  130649. /**
  130650. * Gets the list of emitted varyings
  130651. */
  130652. temps: string[];
  130653. /**
  130654. * Gets the list of emitted varyings
  130655. */
  130656. varyings: string[];
  130657. /**
  130658. * Gets the varying declaration string
  130659. */
  130660. varyingDeclaration: string;
  130661. /**
  130662. * Input blocks
  130663. */
  130664. inputBlocks: InputBlock[];
  130665. /**
  130666. * Input blocks
  130667. */
  130668. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  130669. /**
  130670. * Bindable blocks (Blocks that need to set data to the effect)
  130671. */
  130672. bindableBlocks: NodeMaterialBlock[];
  130673. /**
  130674. * List of blocks that can provide a compilation fallback
  130675. */
  130676. blocksWithFallbacks: NodeMaterialBlock[];
  130677. /**
  130678. * List of blocks that can provide a define update
  130679. */
  130680. blocksWithDefines: NodeMaterialBlock[];
  130681. /**
  130682. * List of blocks that can provide a repeatable content
  130683. */
  130684. repeatableContentBlocks: NodeMaterialBlock[];
  130685. /**
  130686. * List of blocks that can provide a dynamic list of uniforms
  130687. */
  130688. dynamicUniformBlocks: NodeMaterialBlock[];
  130689. /**
  130690. * List of blocks that can block the isReady function for the material
  130691. */
  130692. blockingBlocks: NodeMaterialBlock[];
  130693. /**
  130694. * Gets the list of animated inputs
  130695. */
  130696. animatedInputs: InputBlock[];
  130697. /**
  130698. * Build Id used to avoid multiple recompilations
  130699. */
  130700. buildId: number;
  130701. /** List of emitted variables */
  130702. variableNames: {
  130703. [key: string]: number;
  130704. };
  130705. /** List of emitted defines */
  130706. defineNames: {
  130707. [key: string]: number;
  130708. };
  130709. /** Should emit comments? */
  130710. emitComments: boolean;
  130711. /** Emit build activity */
  130712. verbose: boolean;
  130713. /** Gets or sets the hosting scene */
  130714. scene: Scene;
  130715. /**
  130716. * Gets the compilation hints emitted at compilation time
  130717. */
  130718. hints: {
  130719. needWorldViewMatrix: boolean;
  130720. needWorldViewProjectionMatrix: boolean;
  130721. needAlphaBlending: boolean;
  130722. needAlphaTesting: boolean;
  130723. };
  130724. /**
  130725. * List of compilation checks
  130726. */
  130727. checks: {
  130728. emitVertex: boolean;
  130729. emitFragment: boolean;
  130730. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  130731. };
  130732. /** Creates a new shared data */
  130733. constructor();
  130734. /**
  130735. * Emits console errors and exceptions if there is a failing check
  130736. */
  130737. emitErrors(): void;
  130738. }
  130739. }
  130740. declare module BABYLON {
  130741. /**
  130742. * Class used to store node based material build state
  130743. */
  130744. export class NodeMaterialBuildState {
  130745. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  130746. supportUniformBuffers: boolean;
  130747. /**
  130748. * Gets the list of emitted attributes
  130749. */
  130750. attributes: string[];
  130751. /**
  130752. * Gets the list of emitted uniforms
  130753. */
  130754. uniforms: string[];
  130755. /**
  130756. * Gets the list of emitted constants
  130757. */
  130758. constants: string[];
  130759. /**
  130760. * Gets the list of emitted samplers
  130761. */
  130762. samplers: string[];
  130763. /**
  130764. * Gets the list of emitted functions
  130765. */
  130766. functions: {
  130767. [key: string]: string;
  130768. };
  130769. /**
  130770. * Gets the list of emitted extensions
  130771. */
  130772. extensions: {
  130773. [key: string]: string;
  130774. };
  130775. /**
  130776. * Gets the target of the compilation state
  130777. */
  130778. target: NodeMaterialBlockTargets;
  130779. /**
  130780. * Gets the list of emitted counters
  130781. */
  130782. counters: {
  130783. [key: string]: number;
  130784. };
  130785. /**
  130786. * Shared data between multiple NodeMaterialBuildState instances
  130787. */
  130788. sharedData: NodeMaterialBuildStateSharedData;
  130789. /** @hidden */
  130790. _vertexState: NodeMaterialBuildState;
  130791. /** @hidden */
  130792. _attributeDeclaration: string;
  130793. /** @hidden */
  130794. _uniformDeclaration: string;
  130795. /** @hidden */
  130796. _constantDeclaration: string;
  130797. /** @hidden */
  130798. _samplerDeclaration: string;
  130799. /** @hidden */
  130800. _varyingTransfer: string;
  130801. private _repeatableContentAnchorIndex;
  130802. /** @hidden */
  130803. _builtCompilationString: string;
  130804. /**
  130805. * Gets the emitted compilation strings
  130806. */
  130807. compilationString: string;
  130808. /**
  130809. * Finalize the compilation strings
  130810. * @param state defines the current compilation state
  130811. */
  130812. finalize(state: NodeMaterialBuildState): void;
  130813. /** @hidden */
  130814. get _repeatableContentAnchor(): string;
  130815. /** @hidden */
  130816. _getFreeVariableName(prefix: string): string;
  130817. /** @hidden */
  130818. _getFreeDefineName(prefix: string): string;
  130819. /** @hidden */
  130820. _excludeVariableName(name: string): void;
  130821. /** @hidden */
  130822. _emit2DSampler(name: string): void;
  130823. /** @hidden */
  130824. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  130825. /** @hidden */
  130826. _emitExtension(name: string, extension: string): void;
  130827. /** @hidden */
  130828. _emitFunction(name: string, code: string, comments: string): void;
  130829. /** @hidden */
  130830. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  130831. replaceStrings?: {
  130832. search: RegExp;
  130833. replace: string;
  130834. }[];
  130835. repeatKey?: string;
  130836. }): string;
  130837. /** @hidden */
  130838. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  130839. repeatKey?: string;
  130840. removeAttributes?: boolean;
  130841. removeUniforms?: boolean;
  130842. removeVaryings?: boolean;
  130843. removeIfDef?: boolean;
  130844. replaceStrings?: {
  130845. search: RegExp;
  130846. replace: string;
  130847. }[];
  130848. }, storeKey?: string): void;
  130849. /** @hidden */
  130850. _registerTempVariable(name: string): boolean;
  130851. /** @hidden */
  130852. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  130853. /** @hidden */
  130854. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  130855. /** @hidden */
  130856. _emitFloat(value: number): string;
  130857. }
  130858. }
  130859. declare module BABYLON {
  130860. /**
  130861. * Defines a block that can be used inside a node based material
  130862. */
  130863. export class NodeMaterialBlock {
  130864. private _buildId;
  130865. private _buildTarget;
  130866. private _target;
  130867. private _isFinalMerger;
  130868. private _isInput;
  130869. protected _isUnique: boolean;
  130870. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  130871. inputsAreExclusive: boolean;
  130872. /** @hidden */
  130873. _codeVariableName: string;
  130874. /** @hidden */
  130875. _inputs: NodeMaterialConnectionPoint[];
  130876. /** @hidden */
  130877. _outputs: NodeMaterialConnectionPoint[];
  130878. /** @hidden */
  130879. _preparationId: number;
  130880. /**
  130881. * Gets or sets the name of the block
  130882. */
  130883. name: string;
  130884. /**
  130885. * Gets or sets the unique id of the node
  130886. */
  130887. uniqueId: number;
  130888. /**
  130889. * Gets or sets the comments associated with this block
  130890. */
  130891. comments: string;
  130892. /**
  130893. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  130894. */
  130895. get isUnique(): boolean;
  130896. /**
  130897. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  130898. */
  130899. get isFinalMerger(): boolean;
  130900. /**
  130901. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  130902. */
  130903. get isInput(): boolean;
  130904. /**
  130905. * Gets or sets the build Id
  130906. */
  130907. get buildId(): number;
  130908. set buildId(value: number);
  130909. /**
  130910. * Gets or sets the target of the block
  130911. */
  130912. get target(): NodeMaterialBlockTargets;
  130913. set target(value: NodeMaterialBlockTargets);
  130914. /**
  130915. * Gets the list of input points
  130916. */
  130917. get inputs(): NodeMaterialConnectionPoint[];
  130918. /** Gets the list of output points */
  130919. get outputs(): NodeMaterialConnectionPoint[];
  130920. /**
  130921. * Find an input by its name
  130922. * @param name defines the name of the input to look for
  130923. * @returns the input or null if not found
  130924. */
  130925. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  130926. /**
  130927. * Find an output by its name
  130928. * @param name defines the name of the outputto look for
  130929. * @returns the output or null if not found
  130930. */
  130931. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  130932. /**
  130933. * Creates a new NodeMaterialBlock
  130934. * @param name defines the block name
  130935. * @param target defines the target of that block (Vertex by default)
  130936. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  130937. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  130938. */
  130939. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  130940. /**
  130941. * Initialize the block and prepare the context for build
  130942. * @param state defines the state that will be used for the build
  130943. */
  130944. initialize(state: NodeMaterialBuildState): void;
  130945. /**
  130946. * Bind data to effect. Will only be called for blocks with isBindable === true
  130947. * @param effect defines the effect to bind data to
  130948. * @param nodeMaterial defines the hosting NodeMaterial
  130949. * @param mesh defines the mesh that will be rendered
  130950. */
  130951. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130952. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  130953. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  130954. protected _writeFloat(value: number): string;
  130955. /**
  130956. * Gets the current class name e.g. "NodeMaterialBlock"
  130957. * @returns the class name
  130958. */
  130959. getClassName(): string;
  130960. /**
  130961. * Register a new input. Must be called inside a block constructor
  130962. * @param name defines the connection point name
  130963. * @param type defines the connection point type
  130964. * @param isOptional defines a boolean indicating that this input can be omitted
  130965. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  130966. * @returns the current block
  130967. */
  130968. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  130969. /**
  130970. * Register a new output. Must be called inside a block constructor
  130971. * @param name defines the connection point name
  130972. * @param type defines the connection point type
  130973. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  130974. * @returns the current block
  130975. */
  130976. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  130977. /**
  130978. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  130979. * @param forOutput defines an optional connection point to check compatibility with
  130980. * @returns the first available input or null
  130981. */
  130982. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  130983. /**
  130984. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  130985. * @param forBlock defines an optional block to check compatibility with
  130986. * @returns the first available input or null
  130987. */
  130988. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  130989. /**
  130990. * Gets the sibling of the given output
  130991. * @param current defines the current output
  130992. * @returns the next output in the list or null
  130993. */
  130994. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  130995. /**
  130996. * Connect current block with another block
  130997. * @param other defines the block to connect with
  130998. * @param options define the various options to help pick the right connections
  130999. * @returns the current block
  131000. */
  131001. connectTo(other: NodeMaterialBlock, options?: {
  131002. input?: string;
  131003. output?: string;
  131004. outputSwizzle?: string;
  131005. }): this | undefined;
  131006. protected _buildBlock(state: NodeMaterialBuildState): void;
  131007. /**
  131008. * Add uniforms, samplers and uniform buffers at compilation time
  131009. * @param state defines the state to update
  131010. * @param nodeMaterial defines the node material requesting the update
  131011. * @param defines defines the material defines to update
  131012. * @param uniformBuffers defines the list of uniform buffer names
  131013. */
  131014. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  131015. /**
  131016. * Add potential fallbacks if shader compilation fails
  131017. * @param mesh defines the mesh to be rendered
  131018. * @param fallbacks defines the current prioritized list of fallbacks
  131019. */
  131020. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  131021. /**
  131022. * Initialize defines for shader compilation
  131023. * @param mesh defines the mesh to be rendered
  131024. * @param nodeMaterial defines the node material requesting the update
  131025. * @param defines defines the material defines to update
  131026. * @param useInstances specifies that instances should be used
  131027. */
  131028. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  131029. /**
  131030. * Update defines for shader compilation
  131031. * @param mesh defines the mesh to be rendered
  131032. * @param nodeMaterial defines the node material requesting the update
  131033. * @param defines defines the material defines to update
  131034. * @param useInstances specifies that instances should be used
  131035. */
  131036. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  131037. /**
  131038. * Lets the block try to connect some inputs automatically
  131039. * @param material defines the hosting NodeMaterial
  131040. */
  131041. autoConfigure(material: NodeMaterial): void;
  131042. /**
  131043. * Function called when a block is declared as repeatable content generator
  131044. * @param vertexShaderState defines the current compilation state for the vertex shader
  131045. * @param fragmentShaderState defines the current compilation state for the fragment shader
  131046. * @param mesh defines the mesh to be rendered
  131047. * @param defines defines the material defines to update
  131048. */
  131049. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  131050. /**
  131051. * Checks if the block is ready
  131052. * @param mesh defines the mesh to be rendered
  131053. * @param nodeMaterial defines the node material requesting the update
  131054. * @param defines defines the material defines to update
  131055. * @param useInstances specifies that instances should be used
  131056. * @returns true if the block is ready
  131057. */
  131058. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  131059. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  131060. private _processBuild;
  131061. /**
  131062. * Compile the current node and generate the shader code
  131063. * @param state defines the current compilation state (uniforms, samplers, current string)
  131064. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  131065. * @returns true if already built
  131066. */
  131067. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  131068. protected _inputRename(name: string): string;
  131069. protected _outputRename(name: string): string;
  131070. protected _dumpPropertiesCode(): string;
  131071. /** @hidden */
  131072. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  131073. /** @hidden */
  131074. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  131075. /**
  131076. * Clone the current block to a new identical block
  131077. * @param scene defines the hosting scene
  131078. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  131079. * @returns a copy of the current block
  131080. */
  131081. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  131082. /**
  131083. * Serializes this block in a JSON representation
  131084. * @returns the serialized block object
  131085. */
  131086. serialize(): any;
  131087. /** @hidden */
  131088. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131089. /**
  131090. * Release resources
  131091. */
  131092. dispose(): void;
  131093. }
  131094. }
  131095. declare module BABYLON {
  131096. /**
  131097. * Enum defining the type of animations supported by InputBlock
  131098. */
  131099. export enum AnimatedInputBlockTypes {
  131100. /** No animation */
  131101. None = 0,
  131102. /** Time based animation. Will only work for floats */
  131103. Time = 1
  131104. }
  131105. }
  131106. declare module BABYLON {
  131107. /**
  131108. * Block used to expose an input value
  131109. */
  131110. export class InputBlock extends NodeMaterialBlock {
  131111. private _mode;
  131112. private _associatedVariableName;
  131113. private _storedValue;
  131114. private _valueCallback;
  131115. private _type;
  131116. private _animationType;
  131117. /** Gets or set a value used to limit the range of float values */
  131118. min: number;
  131119. /** Gets or set a value used to limit the range of float values */
  131120. max: number;
  131121. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  131122. isBoolean: boolean;
  131123. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  131124. matrixMode: number;
  131125. /** @hidden */
  131126. _systemValue: Nullable<NodeMaterialSystemValues>;
  131127. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  131128. visibleInInspector: boolean;
  131129. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  131130. isConstant: boolean;
  131131. /** Gets or sets the group to use to display this block in the Inspector */
  131132. groupInInspector: string;
  131133. /**
  131134. * Gets or sets the connection point type (default is float)
  131135. */
  131136. get type(): NodeMaterialBlockConnectionPointTypes;
  131137. /**
  131138. * Creates a new InputBlock
  131139. * @param name defines the block name
  131140. * @param target defines the target of that block (Vertex by default)
  131141. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  131142. */
  131143. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  131144. /**
  131145. * Gets the output component
  131146. */
  131147. get output(): NodeMaterialConnectionPoint;
  131148. /**
  131149. * Set the source of this connection point to a vertex attribute
  131150. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  131151. * @returns the current connection point
  131152. */
  131153. setAsAttribute(attributeName?: string): InputBlock;
  131154. /**
  131155. * Set the source of this connection point to a system value
  131156. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  131157. * @returns the current connection point
  131158. */
  131159. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  131160. /**
  131161. * Gets or sets the value of that point.
  131162. * Please note that this value will be ignored if valueCallback is defined
  131163. */
  131164. get value(): any;
  131165. set value(value: any);
  131166. /**
  131167. * Gets or sets a callback used to get the value of that point.
  131168. * Please note that setting this value will force the connection point to ignore the value property
  131169. */
  131170. get valueCallback(): () => any;
  131171. set valueCallback(value: () => any);
  131172. /**
  131173. * Gets or sets the associated variable name in the shader
  131174. */
  131175. get associatedVariableName(): string;
  131176. set associatedVariableName(value: string);
  131177. /** Gets or sets the type of animation applied to the input */
  131178. get animationType(): AnimatedInputBlockTypes;
  131179. set animationType(value: AnimatedInputBlockTypes);
  131180. /**
  131181. * Gets a boolean indicating that this connection point not defined yet
  131182. */
  131183. get isUndefined(): boolean;
  131184. /**
  131185. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  131186. * In this case the connection point name must be the name of the uniform to use.
  131187. * Can only be set on inputs
  131188. */
  131189. get isUniform(): boolean;
  131190. set isUniform(value: boolean);
  131191. /**
  131192. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  131193. * In this case the connection point name must be the name of the attribute to use
  131194. * Can only be set on inputs
  131195. */
  131196. get isAttribute(): boolean;
  131197. set isAttribute(value: boolean);
  131198. /**
  131199. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  131200. * Can only be set on exit points
  131201. */
  131202. get isVarying(): boolean;
  131203. set isVarying(value: boolean);
  131204. /**
  131205. * Gets a boolean indicating that the current connection point is a system value
  131206. */
  131207. get isSystemValue(): boolean;
  131208. /**
  131209. * Gets or sets the current well known value or null if not defined as a system value
  131210. */
  131211. get systemValue(): Nullable<NodeMaterialSystemValues>;
  131212. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  131213. /**
  131214. * Gets the current class name
  131215. * @returns the class name
  131216. */
  131217. getClassName(): string;
  131218. /**
  131219. * Animate the input if animationType !== None
  131220. * @param scene defines the rendering scene
  131221. */
  131222. animate(scene: Scene): void;
  131223. private _emitDefine;
  131224. initialize(state: NodeMaterialBuildState): void;
  131225. /**
  131226. * Set the input block to its default value (based on its type)
  131227. */
  131228. setDefaultValue(): void;
  131229. private _emitConstant;
  131230. private _emit;
  131231. /** @hidden */
  131232. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  131233. /** @hidden */
  131234. _transmit(effect: Effect, scene: Scene): void;
  131235. protected _buildBlock(state: NodeMaterialBuildState): void;
  131236. protected _dumpPropertiesCode(): string;
  131237. serialize(): any;
  131238. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131239. }
  131240. }
  131241. declare module BABYLON {
  131242. /**
  131243. * Enum used to define the compatibility state between two connection points
  131244. */
  131245. export enum NodeMaterialConnectionPointCompatibilityStates {
  131246. /** Points are compatibles */
  131247. Compatible = 0,
  131248. /** Points are incompatible because of their types */
  131249. TypeIncompatible = 1,
  131250. /** Points are incompatible because of their targets (vertex vs fragment) */
  131251. TargetIncompatible = 2
  131252. }
  131253. /**
  131254. * Defines the direction of a connection point
  131255. */
  131256. export enum NodeMaterialConnectionPointDirection {
  131257. /** Input */
  131258. Input = 0,
  131259. /** Output */
  131260. Output = 1
  131261. }
  131262. /**
  131263. * Defines a connection point for a block
  131264. */
  131265. export class NodeMaterialConnectionPoint {
  131266. /** @hidden */
  131267. _ownerBlock: NodeMaterialBlock;
  131268. /** @hidden */
  131269. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  131270. private _endpoints;
  131271. private _associatedVariableName;
  131272. private _direction;
  131273. /** @hidden */
  131274. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  131275. /** @hidden */
  131276. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  131277. private _type;
  131278. /** @hidden */
  131279. _enforceAssociatedVariableName: boolean;
  131280. /** Gets the direction of the point */
  131281. get direction(): NodeMaterialConnectionPointDirection;
  131282. /**
  131283. * Gets or sets the additional types supported by this connection point
  131284. */
  131285. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  131286. /**
  131287. * Gets or sets the additional types excluded by this connection point
  131288. */
  131289. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  131290. /**
  131291. * Observable triggered when this point is connected
  131292. */
  131293. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  131294. /**
  131295. * Gets or sets the associated variable name in the shader
  131296. */
  131297. get associatedVariableName(): string;
  131298. set associatedVariableName(value: string);
  131299. /** Get the inner type (ie AutoDetect for isntance instead of the inferred one) */
  131300. get innerType(): NodeMaterialBlockConnectionPointTypes;
  131301. /**
  131302. * Gets or sets the connection point type (default is float)
  131303. */
  131304. get type(): NodeMaterialBlockConnectionPointTypes;
  131305. set type(value: NodeMaterialBlockConnectionPointTypes);
  131306. /**
  131307. * Gets or sets the connection point name
  131308. */
  131309. name: string;
  131310. /**
  131311. * Gets or sets a boolean indicating that this connection point can be omitted
  131312. */
  131313. isOptional: boolean;
  131314. /**
  131315. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  131316. */
  131317. define: string;
  131318. /** @hidden */
  131319. _prioritizeVertex: boolean;
  131320. private _target;
  131321. /** Gets or sets the target of that connection point */
  131322. get target(): NodeMaterialBlockTargets;
  131323. set target(value: NodeMaterialBlockTargets);
  131324. /**
  131325. * Gets a boolean indicating that the current point is connected
  131326. */
  131327. get isConnected(): boolean;
  131328. /**
  131329. * Gets a boolean indicating that the current point is connected to an input block
  131330. */
  131331. get isConnectedToInputBlock(): boolean;
  131332. /**
  131333. * Gets a the connected input block (if any)
  131334. */
  131335. get connectInputBlock(): Nullable<InputBlock>;
  131336. /** Get the other side of the connection (if any) */
  131337. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  131338. /** Get the block that owns this connection point */
  131339. get ownerBlock(): NodeMaterialBlock;
  131340. /** Get the block connected on the other side of this connection (if any) */
  131341. get sourceBlock(): Nullable<NodeMaterialBlock>;
  131342. /** Get the block connected on the endpoints of this connection (if any) */
  131343. get connectedBlocks(): Array<NodeMaterialBlock>;
  131344. /** Gets the list of connected endpoints */
  131345. get endpoints(): NodeMaterialConnectionPoint[];
  131346. /** Gets a boolean indicating if that output point is connected to at least one input */
  131347. get hasEndpoints(): boolean;
  131348. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  131349. get isConnectedInVertexShader(): boolean;
  131350. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  131351. get isConnectedInFragmentShader(): boolean;
  131352. /**
  131353. * Creates a new connection point
  131354. * @param name defines the connection point name
  131355. * @param ownerBlock defines the block hosting this connection point
  131356. * @param direction defines the direction of the connection point
  131357. */
  131358. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  131359. /**
  131360. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  131361. * @returns the class name
  131362. */
  131363. getClassName(): string;
  131364. /**
  131365. * Gets a boolean indicating if the current point can be connected to another point
  131366. * @param connectionPoint defines the other connection point
  131367. * @returns a boolean
  131368. */
  131369. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  131370. /**
  131371. * Gets a number indicating if the current point can be connected to another point
  131372. * @param connectionPoint defines the other connection point
  131373. * @returns a number defining the compatibility state
  131374. */
  131375. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  131376. /**
  131377. * Connect this point to another connection point
  131378. * @param connectionPoint defines the other connection point
  131379. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  131380. * @returns the current connection point
  131381. */
  131382. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  131383. /**
  131384. * Disconnect this point from one of his endpoint
  131385. * @param endpoint defines the other connection point
  131386. * @returns the current connection point
  131387. */
  131388. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  131389. /**
  131390. * Serializes this point in a JSON representation
  131391. * @returns the serialized point object
  131392. */
  131393. serialize(): any;
  131394. /**
  131395. * Release resources
  131396. */
  131397. dispose(): void;
  131398. }
  131399. }
  131400. declare module BABYLON {
  131401. /**
  131402. * Block used to add support for vertex skinning (bones)
  131403. */
  131404. export class BonesBlock extends NodeMaterialBlock {
  131405. /**
  131406. * Creates a new BonesBlock
  131407. * @param name defines the block name
  131408. */
  131409. constructor(name: string);
  131410. /**
  131411. * Initialize the block and prepare the context for build
  131412. * @param state defines the state that will be used for the build
  131413. */
  131414. initialize(state: NodeMaterialBuildState): void;
  131415. /**
  131416. * Gets the current class name
  131417. * @returns the class name
  131418. */
  131419. getClassName(): string;
  131420. /**
  131421. * Gets the matrix indices input component
  131422. */
  131423. get matricesIndices(): NodeMaterialConnectionPoint;
  131424. /**
  131425. * Gets the matrix weights input component
  131426. */
  131427. get matricesWeights(): NodeMaterialConnectionPoint;
  131428. /**
  131429. * Gets the extra matrix indices input component
  131430. */
  131431. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  131432. /**
  131433. * Gets the extra matrix weights input component
  131434. */
  131435. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  131436. /**
  131437. * Gets the world input component
  131438. */
  131439. get world(): NodeMaterialConnectionPoint;
  131440. /**
  131441. * Gets the output component
  131442. */
  131443. get output(): NodeMaterialConnectionPoint;
  131444. autoConfigure(material: NodeMaterial): void;
  131445. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  131446. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131447. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131448. protected _buildBlock(state: NodeMaterialBuildState): this;
  131449. }
  131450. }
  131451. declare module BABYLON {
  131452. /**
  131453. * Block used to add support for instances
  131454. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  131455. */
  131456. export class InstancesBlock extends NodeMaterialBlock {
  131457. /**
  131458. * Creates a new InstancesBlock
  131459. * @param name defines the block name
  131460. */
  131461. constructor(name: string);
  131462. /**
  131463. * Gets the current class name
  131464. * @returns the class name
  131465. */
  131466. getClassName(): string;
  131467. /**
  131468. * Gets the first world row input component
  131469. */
  131470. get world0(): NodeMaterialConnectionPoint;
  131471. /**
  131472. * Gets the second world row input component
  131473. */
  131474. get world1(): NodeMaterialConnectionPoint;
  131475. /**
  131476. * Gets the third world row input component
  131477. */
  131478. get world2(): NodeMaterialConnectionPoint;
  131479. /**
  131480. * Gets the forth world row input component
  131481. */
  131482. get world3(): NodeMaterialConnectionPoint;
  131483. /**
  131484. * Gets the world input component
  131485. */
  131486. get world(): NodeMaterialConnectionPoint;
  131487. /**
  131488. * Gets the output component
  131489. */
  131490. get output(): NodeMaterialConnectionPoint;
  131491. /**
  131492. * Gets the isntanceID component
  131493. */
  131494. get instanceID(): NodeMaterialConnectionPoint;
  131495. autoConfigure(material: NodeMaterial): void;
  131496. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  131497. protected _buildBlock(state: NodeMaterialBuildState): this;
  131498. }
  131499. }
  131500. declare module BABYLON {
  131501. /**
  131502. * Block used to add morph targets support to vertex shader
  131503. */
  131504. export class MorphTargetsBlock extends NodeMaterialBlock {
  131505. private _repeatableContentAnchor;
  131506. /**
  131507. * Create a new MorphTargetsBlock
  131508. * @param name defines the block name
  131509. */
  131510. constructor(name: string);
  131511. /**
  131512. * Gets the current class name
  131513. * @returns the class name
  131514. */
  131515. getClassName(): string;
  131516. /**
  131517. * Gets the position input component
  131518. */
  131519. get position(): NodeMaterialConnectionPoint;
  131520. /**
  131521. * Gets the normal input component
  131522. */
  131523. get normal(): NodeMaterialConnectionPoint;
  131524. /**
  131525. * Gets the tangent input component
  131526. */
  131527. get tangent(): NodeMaterialConnectionPoint;
  131528. /**
  131529. * Gets the tangent input component
  131530. */
  131531. get uv(): NodeMaterialConnectionPoint;
  131532. /**
  131533. * Gets the position output component
  131534. */
  131535. get positionOutput(): NodeMaterialConnectionPoint;
  131536. /**
  131537. * Gets the normal output component
  131538. */
  131539. get normalOutput(): NodeMaterialConnectionPoint;
  131540. /**
  131541. * Gets the tangent output component
  131542. */
  131543. get tangentOutput(): NodeMaterialConnectionPoint;
  131544. /**
  131545. * Gets the tangent output component
  131546. */
  131547. get uvOutput(): NodeMaterialConnectionPoint;
  131548. initialize(state: NodeMaterialBuildState): void;
  131549. autoConfigure(material: NodeMaterial): void;
  131550. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131551. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131552. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  131553. protected _buildBlock(state: NodeMaterialBuildState): this;
  131554. }
  131555. }
  131556. declare module BABYLON {
  131557. /**
  131558. * Block used to get data information from a light
  131559. */
  131560. export class LightInformationBlock extends NodeMaterialBlock {
  131561. private _lightDataUniformName;
  131562. private _lightColorUniformName;
  131563. private _lightTypeDefineName;
  131564. /**
  131565. * Gets or sets the light associated with this block
  131566. */
  131567. light: Nullable<Light>;
  131568. /**
  131569. * Creates a new LightInformationBlock
  131570. * @param name defines the block name
  131571. */
  131572. constructor(name: string);
  131573. /**
  131574. * Gets the current class name
  131575. * @returns the class name
  131576. */
  131577. getClassName(): string;
  131578. /**
  131579. * Gets the world position input component
  131580. */
  131581. get worldPosition(): NodeMaterialConnectionPoint;
  131582. /**
  131583. * Gets the direction output component
  131584. */
  131585. get direction(): NodeMaterialConnectionPoint;
  131586. /**
  131587. * Gets the direction output component
  131588. */
  131589. get color(): NodeMaterialConnectionPoint;
  131590. /**
  131591. * Gets the direction output component
  131592. */
  131593. get intensity(): NodeMaterialConnectionPoint;
  131594. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131595. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131596. protected _buildBlock(state: NodeMaterialBuildState): this;
  131597. serialize(): any;
  131598. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131599. }
  131600. }
  131601. declare module BABYLON {
  131602. /**
  131603. * Block used to add image processing support to fragment shader
  131604. */
  131605. export class ImageProcessingBlock extends NodeMaterialBlock {
  131606. /**
  131607. * Create a new ImageProcessingBlock
  131608. * @param name defines the block name
  131609. */
  131610. constructor(name: string);
  131611. /**
  131612. * Gets the current class name
  131613. * @returns the class name
  131614. */
  131615. getClassName(): string;
  131616. /**
  131617. * Gets the color input component
  131618. */
  131619. get color(): NodeMaterialConnectionPoint;
  131620. /**
  131621. * Gets the output component
  131622. */
  131623. get output(): NodeMaterialConnectionPoint;
  131624. /**
  131625. * Initialize the block and prepare the context for build
  131626. * @param state defines the state that will be used for the build
  131627. */
  131628. initialize(state: NodeMaterialBuildState): void;
  131629. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  131630. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131631. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131632. protected _buildBlock(state: NodeMaterialBuildState): this;
  131633. }
  131634. }
  131635. declare module BABYLON {
  131636. /**
  131637. * Block used to pertub normals based on a normal map
  131638. */
  131639. export class PerturbNormalBlock extends NodeMaterialBlock {
  131640. private _tangentSpaceParameterName;
  131641. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  131642. invertX: boolean;
  131643. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  131644. invertY: boolean;
  131645. /**
  131646. * Create a new PerturbNormalBlock
  131647. * @param name defines the block name
  131648. */
  131649. constructor(name: string);
  131650. /**
  131651. * Gets the current class name
  131652. * @returns the class name
  131653. */
  131654. getClassName(): string;
  131655. /**
  131656. * Gets the world position input component
  131657. */
  131658. get worldPosition(): NodeMaterialConnectionPoint;
  131659. /**
  131660. * Gets the world normal input component
  131661. */
  131662. get worldNormal(): NodeMaterialConnectionPoint;
  131663. /**
  131664. * Gets the world tangent input component
  131665. */
  131666. get worldTangent(): NodeMaterialConnectionPoint;
  131667. /**
  131668. * Gets the uv input component
  131669. */
  131670. get uv(): NodeMaterialConnectionPoint;
  131671. /**
  131672. * Gets the normal map color input component
  131673. */
  131674. get normalMapColor(): NodeMaterialConnectionPoint;
  131675. /**
  131676. * Gets the strength input component
  131677. */
  131678. get strength(): NodeMaterialConnectionPoint;
  131679. /**
  131680. * Gets the output component
  131681. */
  131682. get output(): NodeMaterialConnectionPoint;
  131683. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131684. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131685. autoConfigure(material: NodeMaterial): void;
  131686. protected _buildBlock(state: NodeMaterialBuildState): this;
  131687. protected _dumpPropertiesCode(): string;
  131688. serialize(): any;
  131689. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131690. }
  131691. }
  131692. declare module BABYLON {
  131693. /**
  131694. * Block used to discard a pixel if a value is smaller than a cutoff
  131695. */
  131696. export class DiscardBlock extends NodeMaterialBlock {
  131697. /**
  131698. * Create a new DiscardBlock
  131699. * @param name defines the block name
  131700. */
  131701. constructor(name: string);
  131702. /**
  131703. * Gets the current class name
  131704. * @returns the class name
  131705. */
  131706. getClassName(): string;
  131707. /**
  131708. * Gets the color input component
  131709. */
  131710. get value(): NodeMaterialConnectionPoint;
  131711. /**
  131712. * Gets the cutoff input component
  131713. */
  131714. get cutoff(): NodeMaterialConnectionPoint;
  131715. protected _buildBlock(state: NodeMaterialBuildState): this;
  131716. }
  131717. }
  131718. declare module BABYLON {
  131719. /**
  131720. * Block used to test if the fragment shader is front facing
  131721. */
  131722. export class FrontFacingBlock extends NodeMaterialBlock {
  131723. /**
  131724. * Creates a new FrontFacingBlock
  131725. * @param name defines the block name
  131726. */
  131727. constructor(name: string);
  131728. /**
  131729. * Gets the current class name
  131730. * @returns the class name
  131731. */
  131732. getClassName(): string;
  131733. /**
  131734. * Gets the output component
  131735. */
  131736. get output(): NodeMaterialConnectionPoint;
  131737. protected _buildBlock(state: NodeMaterialBuildState): this;
  131738. }
  131739. }
  131740. declare module BABYLON {
  131741. /**
  131742. * Block used to get the derivative value on x and y of a given input
  131743. */
  131744. export class DerivativeBlock extends NodeMaterialBlock {
  131745. /**
  131746. * Create a new DerivativeBlock
  131747. * @param name defines the block name
  131748. */
  131749. constructor(name: string);
  131750. /**
  131751. * Gets the current class name
  131752. * @returns the class name
  131753. */
  131754. getClassName(): string;
  131755. /**
  131756. * Gets the input component
  131757. */
  131758. get input(): NodeMaterialConnectionPoint;
  131759. /**
  131760. * Gets the derivative output on x
  131761. */
  131762. get dx(): NodeMaterialConnectionPoint;
  131763. /**
  131764. * Gets the derivative output on y
  131765. */
  131766. get dy(): NodeMaterialConnectionPoint;
  131767. protected _buildBlock(state: NodeMaterialBuildState): this;
  131768. }
  131769. }
  131770. declare module BABYLON {
  131771. /**
  131772. * Block used to add support for scene fog
  131773. */
  131774. export class FogBlock extends NodeMaterialBlock {
  131775. private _fogDistanceName;
  131776. private _fogParameters;
  131777. /**
  131778. * Create a new FogBlock
  131779. * @param name defines the block name
  131780. */
  131781. constructor(name: string);
  131782. /**
  131783. * Gets the current class name
  131784. * @returns the class name
  131785. */
  131786. getClassName(): string;
  131787. /**
  131788. * Gets the world position input component
  131789. */
  131790. get worldPosition(): NodeMaterialConnectionPoint;
  131791. /**
  131792. * Gets the view input component
  131793. */
  131794. get view(): NodeMaterialConnectionPoint;
  131795. /**
  131796. * Gets the color input component
  131797. */
  131798. get input(): NodeMaterialConnectionPoint;
  131799. /**
  131800. * Gets the fog color input component
  131801. */
  131802. get fogColor(): NodeMaterialConnectionPoint;
  131803. /**
  131804. * Gets the output component
  131805. */
  131806. get output(): NodeMaterialConnectionPoint;
  131807. autoConfigure(material: NodeMaterial): void;
  131808. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131809. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131810. protected _buildBlock(state: NodeMaterialBuildState): this;
  131811. }
  131812. }
  131813. declare module BABYLON {
  131814. /**
  131815. * Block used to add light in the fragment shader
  131816. */
  131817. export class LightBlock extends NodeMaterialBlock {
  131818. private _lightId;
  131819. /**
  131820. * Gets or sets the light associated with this block
  131821. */
  131822. light: Nullable<Light>;
  131823. /**
  131824. * Create a new LightBlock
  131825. * @param name defines the block name
  131826. */
  131827. constructor(name: string);
  131828. /**
  131829. * Gets the current class name
  131830. * @returns the class name
  131831. */
  131832. getClassName(): string;
  131833. /**
  131834. * Gets the world position input component
  131835. */
  131836. get worldPosition(): NodeMaterialConnectionPoint;
  131837. /**
  131838. * Gets the world normal input component
  131839. */
  131840. get worldNormal(): NodeMaterialConnectionPoint;
  131841. /**
  131842. * Gets the camera (or eye) position component
  131843. */
  131844. get cameraPosition(): NodeMaterialConnectionPoint;
  131845. /**
  131846. * Gets the glossiness component
  131847. */
  131848. get glossiness(): NodeMaterialConnectionPoint;
  131849. /**
  131850. * Gets the glossinness power component
  131851. */
  131852. get glossPower(): NodeMaterialConnectionPoint;
  131853. /**
  131854. * Gets the diffuse color component
  131855. */
  131856. get diffuseColor(): NodeMaterialConnectionPoint;
  131857. /**
  131858. * Gets the specular color component
  131859. */
  131860. get specularColor(): NodeMaterialConnectionPoint;
  131861. /**
  131862. * Gets the diffuse output component
  131863. */
  131864. get diffuseOutput(): NodeMaterialConnectionPoint;
  131865. /**
  131866. * Gets the specular output component
  131867. */
  131868. get specularOutput(): NodeMaterialConnectionPoint;
  131869. /**
  131870. * Gets the shadow output component
  131871. */
  131872. get shadow(): NodeMaterialConnectionPoint;
  131873. autoConfigure(material: NodeMaterial): void;
  131874. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131875. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  131876. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131877. private _injectVertexCode;
  131878. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  131879. serialize(): any;
  131880. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131881. }
  131882. }
  131883. declare module BABYLON {
  131884. /**
  131885. * Block used to multiply 2 values
  131886. */
  131887. export class MultiplyBlock extends NodeMaterialBlock {
  131888. /**
  131889. * Creates a new MultiplyBlock
  131890. * @param name defines the block name
  131891. */
  131892. constructor(name: string);
  131893. /**
  131894. * Gets the current class name
  131895. * @returns the class name
  131896. */
  131897. getClassName(): string;
  131898. /**
  131899. * Gets the left operand input component
  131900. */
  131901. get left(): NodeMaterialConnectionPoint;
  131902. /**
  131903. * Gets the right operand input component
  131904. */
  131905. get right(): NodeMaterialConnectionPoint;
  131906. /**
  131907. * Gets the output component
  131908. */
  131909. get output(): NodeMaterialConnectionPoint;
  131910. protected _buildBlock(state: NodeMaterialBuildState): this;
  131911. }
  131912. }
  131913. declare module BABYLON {
  131914. /**
  131915. * Block used to add 2 vectors
  131916. */
  131917. export class AddBlock extends NodeMaterialBlock {
  131918. /**
  131919. * Creates a new AddBlock
  131920. * @param name defines the block name
  131921. */
  131922. constructor(name: string);
  131923. /**
  131924. * Gets the current class name
  131925. * @returns the class name
  131926. */
  131927. getClassName(): string;
  131928. /**
  131929. * Gets the left operand input component
  131930. */
  131931. get left(): NodeMaterialConnectionPoint;
  131932. /**
  131933. * Gets the right operand input component
  131934. */
  131935. get right(): NodeMaterialConnectionPoint;
  131936. /**
  131937. * Gets the output component
  131938. */
  131939. get output(): NodeMaterialConnectionPoint;
  131940. protected _buildBlock(state: NodeMaterialBuildState): this;
  131941. }
  131942. }
  131943. declare module BABYLON {
  131944. /**
  131945. * Block used to scale a vector by a float
  131946. */
  131947. export class ScaleBlock extends NodeMaterialBlock {
  131948. /**
  131949. * Creates a new ScaleBlock
  131950. * @param name defines the block name
  131951. */
  131952. constructor(name: string);
  131953. /**
  131954. * Gets the current class name
  131955. * @returns the class name
  131956. */
  131957. getClassName(): string;
  131958. /**
  131959. * Gets the input component
  131960. */
  131961. get input(): NodeMaterialConnectionPoint;
  131962. /**
  131963. * Gets the factor input component
  131964. */
  131965. get factor(): NodeMaterialConnectionPoint;
  131966. /**
  131967. * Gets the output component
  131968. */
  131969. get output(): NodeMaterialConnectionPoint;
  131970. protected _buildBlock(state: NodeMaterialBuildState): this;
  131971. }
  131972. }
  131973. declare module BABYLON {
  131974. /**
  131975. * Block used to clamp a float
  131976. */
  131977. export class ClampBlock extends NodeMaterialBlock {
  131978. /** Gets or sets the minimum range */
  131979. minimum: number;
  131980. /** Gets or sets the maximum range */
  131981. maximum: number;
  131982. /**
  131983. * Creates a new ClampBlock
  131984. * @param name defines the block name
  131985. */
  131986. constructor(name: string);
  131987. /**
  131988. * Gets the current class name
  131989. * @returns the class name
  131990. */
  131991. getClassName(): string;
  131992. /**
  131993. * Gets the value input component
  131994. */
  131995. get value(): NodeMaterialConnectionPoint;
  131996. /**
  131997. * Gets the output component
  131998. */
  131999. get output(): NodeMaterialConnectionPoint;
  132000. protected _buildBlock(state: NodeMaterialBuildState): this;
  132001. protected _dumpPropertiesCode(): string;
  132002. serialize(): any;
  132003. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132004. }
  132005. }
  132006. declare module BABYLON {
  132007. /**
  132008. * Block used to apply a cross product between 2 vectors
  132009. */
  132010. export class CrossBlock extends NodeMaterialBlock {
  132011. /**
  132012. * Creates a new CrossBlock
  132013. * @param name defines the block name
  132014. */
  132015. constructor(name: string);
  132016. /**
  132017. * Gets the current class name
  132018. * @returns the class name
  132019. */
  132020. getClassName(): string;
  132021. /**
  132022. * Gets the left operand input component
  132023. */
  132024. get left(): NodeMaterialConnectionPoint;
  132025. /**
  132026. * Gets the right operand input component
  132027. */
  132028. get right(): NodeMaterialConnectionPoint;
  132029. /**
  132030. * Gets the output component
  132031. */
  132032. get output(): NodeMaterialConnectionPoint;
  132033. protected _buildBlock(state: NodeMaterialBuildState): this;
  132034. }
  132035. }
  132036. declare module BABYLON {
  132037. /**
  132038. * Block used to apply a dot product between 2 vectors
  132039. */
  132040. export class DotBlock extends NodeMaterialBlock {
  132041. /**
  132042. * Creates a new DotBlock
  132043. * @param name defines the block name
  132044. */
  132045. constructor(name: string);
  132046. /**
  132047. * Gets the current class name
  132048. * @returns the class name
  132049. */
  132050. getClassName(): string;
  132051. /**
  132052. * Gets the left operand input component
  132053. */
  132054. get left(): NodeMaterialConnectionPoint;
  132055. /**
  132056. * Gets the right operand input component
  132057. */
  132058. get right(): NodeMaterialConnectionPoint;
  132059. /**
  132060. * Gets the output component
  132061. */
  132062. get output(): NodeMaterialConnectionPoint;
  132063. protected _buildBlock(state: NodeMaterialBuildState): this;
  132064. }
  132065. }
  132066. declare module BABYLON {
  132067. /**
  132068. * Block used to remap a float from a range to a new one
  132069. */
  132070. export class RemapBlock extends NodeMaterialBlock {
  132071. /**
  132072. * Gets or sets the source range
  132073. */
  132074. sourceRange: Vector2;
  132075. /**
  132076. * Gets or sets the target range
  132077. */
  132078. targetRange: Vector2;
  132079. /**
  132080. * Creates a new RemapBlock
  132081. * @param name defines the block name
  132082. */
  132083. constructor(name: string);
  132084. /**
  132085. * Gets the current class name
  132086. * @returns the class name
  132087. */
  132088. getClassName(): string;
  132089. /**
  132090. * Gets the input component
  132091. */
  132092. get input(): NodeMaterialConnectionPoint;
  132093. /**
  132094. * Gets the source min input component
  132095. */
  132096. get sourceMin(): NodeMaterialConnectionPoint;
  132097. /**
  132098. * Gets the source max input component
  132099. */
  132100. get sourceMax(): NodeMaterialConnectionPoint;
  132101. /**
  132102. * Gets the target min input component
  132103. */
  132104. get targetMin(): NodeMaterialConnectionPoint;
  132105. /**
  132106. * Gets the target max input component
  132107. */
  132108. get targetMax(): NodeMaterialConnectionPoint;
  132109. /**
  132110. * Gets the output component
  132111. */
  132112. get output(): NodeMaterialConnectionPoint;
  132113. protected _buildBlock(state: NodeMaterialBuildState): this;
  132114. protected _dumpPropertiesCode(): string;
  132115. serialize(): any;
  132116. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132117. }
  132118. }
  132119. declare module BABYLON {
  132120. /**
  132121. * Block used to normalize a vector
  132122. */
  132123. export class NormalizeBlock extends NodeMaterialBlock {
  132124. /**
  132125. * Creates a new NormalizeBlock
  132126. * @param name defines the block name
  132127. */
  132128. constructor(name: string);
  132129. /**
  132130. * Gets the current class name
  132131. * @returns the class name
  132132. */
  132133. getClassName(): string;
  132134. /**
  132135. * Gets the input component
  132136. */
  132137. get input(): NodeMaterialConnectionPoint;
  132138. /**
  132139. * Gets the output component
  132140. */
  132141. get output(): NodeMaterialConnectionPoint;
  132142. protected _buildBlock(state: NodeMaterialBuildState): this;
  132143. }
  132144. }
  132145. declare module BABYLON {
  132146. /**
  132147. * Operations supported by the Trigonometry block
  132148. */
  132149. export enum TrigonometryBlockOperations {
  132150. /** Cos */
  132151. Cos = 0,
  132152. /** Sin */
  132153. Sin = 1,
  132154. /** Abs */
  132155. Abs = 2,
  132156. /** Exp */
  132157. Exp = 3,
  132158. /** Exp2 */
  132159. Exp2 = 4,
  132160. /** Round */
  132161. Round = 5,
  132162. /** Floor */
  132163. Floor = 6,
  132164. /** Ceiling */
  132165. Ceiling = 7,
  132166. /** Square root */
  132167. Sqrt = 8,
  132168. /** Log */
  132169. Log = 9,
  132170. /** Tangent */
  132171. Tan = 10,
  132172. /** Arc tangent */
  132173. ArcTan = 11,
  132174. /** Arc cosinus */
  132175. ArcCos = 12,
  132176. /** Arc sinus */
  132177. ArcSin = 13,
  132178. /** Fraction */
  132179. Fract = 14,
  132180. /** Sign */
  132181. Sign = 15,
  132182. /** To radians (from degrees) */
  132183. Radians = 16,
  132184. /** To degrees (from radians) */
  132185. Degrees = 17
  132186. }
  132187. /**
  132188. * Block used to apply trigonometry operation to floats
  132189. */
  132190. export class TrigonometryBlock extends NodeMaterialBlock {
  132191. /**
  132192. * Gets or sets the operation applied by the block
  132193. */
  132194. operation: TrigonometryBlockOperations;
  132195. /**
  132196. * Creates a new TrigonometryBlock
  132197. * @param name defines the block name
  132198. */
  132199. constructor(name: string);
  132200. /**
  132201. * Gets the current class name
  132202. * @returns the class name
  132203. */
  132204. getClassName(): string;
  132205. /**
  132206. * Gets the input component
  132207. */
  132208. get input(): NodeMaterialConnectionPoint;
  132209. /**
  132210. * Gets the output component
  132211. */
  132212. get output(): NodeMaterialConnectionPoint;
  132213. protected _buildBlock(state: NodeMaterialBuildState): this;
  132214. serialize(): any;
  132215. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132216. protected _dumpPropertiesCode(): string;
  132217. }
  132218. }
  132219. declare module BABYLON {
  132220. /**
  132221. * Block used to create a Color3/4 out of individual inputs (one for each component)
  132222. */
  132223. export class ColorMergerBlock extends NodeMaterialBlock {
  132224. /**
  132225. * Create a new ColorMergerBlock
  132226. * @param name defines the block name
  132227. */
  132228. constructor(name: string);
  132229. /**
  132230. * Gets the current class name
  132231. * @returns the class name
  132232. */
  132233. getClassName(): string;
  132234. /**
  132235. * Gets the rgb component (input)
  132236. */
  132237. get rgbIn(): NodeMaterialConnectionPoint;
  132238. /**
  132239. * Gets the r component (input)
  132240. */
  132241. get r(): NodeMaterialConnectionPoint;
  132242. /**
  132243. * Gets the g component (input)
  132244. */
  132245. get g(): NodeMaterialConnectionPoint;
  132246. /**
  132247. * Gets the b component (input)
  132248. */
  132249. get b(): NodeMaterialConnectionPoint;
  132250. /**
  132251. * Gets the a component (input)
  132252. */
  132253. get a(): NodeMaterialConnectionPoint;
  132254. /**
  132255. * Gets the rgba component (output)
  132256. */
  132257. get rgba(): NodeMaterialConnectionPoint;
  132258. /**
  132259. * Gets the rgb component (output)
  132260. */
  132261. get rgbOut(): NodeMaterialConnectionPoint;
  132262. /**
  132263. * Gets the rgb component (output)
  132264. * @deprecated Please use rgbOut instead.
  132265. */
  132266. get rgb(): NodeMaterialConnectionPoint;
  132267. protected _buildBlock(state: NodeMaterialBuildState): this;
  132268. }
  132269. }
  132270. declare module BABYLON {
  132271. /**
  132272. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  132273. */
  132274. export class VectorMergerBlock extends NodeMaterialBlock {
  132275. /**
  132276. * Create a new VectorMergerBlock
  132277. * @param name defines the block name
  132278. */
  132279. constructor(name: string);
  132280. /**
  132281. * Gets the current class name
  132282. * @returns the class name
  132283. */
  132284. getClassName(): string;
  132285. /**
  132286. * Gets the xyz component (input)
  132287. */
  132288. get xyzIn(): NodeMaterialConnectionPoint;
  132289. /**
  132290. * Gets the xy component (input)
  132291. */
  132292. get xyIn(): NodeMaterialConnectionPoint;
  132293. /**
  132294. * Gets the x component (input)
  132295. */
  132296. get x(): NodeMaterialConnectionPoint;
  132297. /**
  132298. * Gets the y component (input)
  132299. */
  132300. get y(): NodeMaterialConnectionPoint;
  132301. /**
  132302. * Gets the z component (input)
  132303. */
  132304. get z(): NodeMaterialConnectionPoint;
  132305. /**
  132306. * Gets the w component (input)
  132307. */
  132308. get w(): NodeMaterialConnectionPoint;
  132309. /**
  132310. * Gets the xyzw component (output)
  132311. */
  132312. get xyzw(): NodeMaterialConnectionPoint;
  132313. /**
  132314. * Gets the xyz component (output)
  132315. */
  132316. get xyzOut(): NodeMaterialConnectionPoint;
  132317. /**
  132318. * Gets the xy component (output)
  132319. */
  132320. get xyOut(): NodeMaterialConnectionPoint;
  132321. /**
  132322. * Gets the xy component (output)
  132323. * @deprecated Please use xyOut instead.
  132324. */
  132325. get xy(): NodeMaterialConnectionPoint;
  132326. /**
  132327. * Gets the xyz component (output)
  132328. * @deprecated Please use xyzOut instead.
  132329. */
  132330. get xyz(): NodeMaterialConnectionPoint;
  132331. protected _buildBlock(state: NodeMaterialBuildState): this;
  132332. }
  132333. }
  132334. declare module BABYLON {
  132335. /**
  132336. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  132337. */
  132338. export class ColorSplitterBlock extends NodeMaterialBlock {
  132339. /**
  132340. * Create a new ColorSplitterBlock
  132341. * @param name defines the block name
  132342. */
  132343. constructor(name: string);
  132344. /**
  132345. * Gets the current class name
  132346. * @returns the class name
  132347. */
  132348. getClassName(): string;
  132349. /**
  132350. * Gets the rgba component (input)
  132351. */
  132352. get rgba(): NodeMaterialConnectionPoint;
  132353. /**
  132354. * Gets the rgb component (input)
  132355. */
  132356. get rgbIn(): NodeMaterialConnectionPoint;
  132357. /**
  132358. * Gets the rgb component (output)
  132359. */
  132360. get rgbOut(): NodeMaterialConnectionPoint;
  132361. /**
  132362. * Gets the r component (output)
  132363. */
  132364. get r(): NodeMaterialConnectionPoint;
  132365. /**
  132366. * Gets the g component (output)
  132367. */
  132368. get g(): NodeMaterialConnectionPoint;
  132369. /**
  132370. * Gets the b component (output)
  132371. */
  132372. get b(): NodeMaterialConnectionPoint;
  132373. /**
  132374. * Gets the a component (output)
  132375. */
  132376. get a(): NodeMaterialConnectionPoint;
  132377. protected _inputRename(name: string): string;
  132378. protected _outputRename(name: string): string;
  132379. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  132380. }
  132381. }
  132382. declare module BABYLON {
  132383. /**
  132384. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  132385. */
  132386. export class VectorSplitterBlock extends NodeMaterialBlock {
  132387. /**
  132388. * Create a new VectorSplitterBlock
  132389. * @param name defines the block name
  132390. */
  132391. constructor(name: string);
  132392. /**
  132393. * Gets the current class name
  132394. * @returns the class name
  132395. */
  132396. getClassName(): string;
  132397. /**
  132398. * Gets the xyzw component (input)
  132399. */
  132400. get xyzw(): NodeMaterialConnectionPoint;
  132401. /**
  132402. * Gets the xyz component (input)
  132403. */
  132404. get xyzIn(): NodeMaterialConnectionPoint;
  132405. /**
  132406. * Gets the xy component (input)
  132407. */
  132408. get xyIn(): NodeMaterialConnectionPoint;
  132409. /**
  132410. * Gets the xyz component (output)
  132411. */
  132412. get xyzOut(): NodeMaterialConnectionPoint;
  132413. /**
  132414. * Gets the xy component (output)
  132415. */
  132416. get xyOut(): NodeMaterialConnectionPoint;
  132417. /**
  132418. * Gets the x component (output)
  132419. */
  132420. get x(): NodeMaterialConnectionPoint;
  132421. /**
  132422. * Gets the y component (output)
  132423. */
  132424. get y(): NodeMaterialConnectionPoint;
  132425. /**
  132426. * Gets the z component (output)
  132427. */
  132428. get z(): NodeMaterialConnectionPoint;
  132429. /**
  132430. * Gets the w component (output)
  132431. */
  132432. get w(): NodeMaterialConnectionPoint;
  132433. protected _inputRename(name: string): string;
  132434. protected _outputRename(name: string): string;
  132435. protected _buildBlock(state: NodeMaterialBuildState): this;
  132436. }
  132437. }
  132438. declare module BABYLON {
  132439. /**
  132440. * Block used to lerp between 2 values
  132441. */
  132442. export class LerpBlock extends NodeMaterialBlock {
  132443. /**
  132444. * Creates a new LerpBlock
  132445. * @param name defines the block name
  132446. */
  132447. constructor(name: string);
  132448. /**
  132449. * Gets the current class name
  132450. * @returns the class name
  132451. */
  132452. getClassName(): string;
  132453. /**
  132454. * Gets the left operand input component
  132455. */
  132456. get left(): NodeMaterialConnectionPoint;
  132457. /**
  132458. * Gets the right operand input component
  132459. */
  132460. get right(): NodeMaterialConnectionPoint;
  132461. /**
  132462. * Gets the gradient operand input component
  132463. */
  132464. get gradient(): NodeMaterialConnectionPoint;
  132465. /**
  132466. * Gets the output component
  132467. */
  132468. get output(): NodeMaterialConnectionPoint;
  132469. protected _buildBlock(state: NodeMaterialBuildState): this;
  132470. }
  132471. }
  132472. declare module BABYLON {
  132473. /**
  132474. * Block used to divide 2 vectors
  132475. */
  132476. export class DivideBlock extends NodeMaterialBlock {
  132477. /**
  132478. * Creates a new DivideBlock
  132479. * @param name defines the block name
  132480. */
  132481. constructor(name: string);
  132482. /**
  132483. * Gets the current class name
  132484. * @returns the class name
  132485. */
  132486. getClassName(): string;
  132487. /**
  132488. * Gets the left operand input component
  132489. */
  132490. get left(): NodeMaterialConnectionPoint;
  132491. /**
  132492. * Gets the right operand input component
  132493. */
  132494. get right(): NodeMaterialConnectionPoint;
  132495. /**
  132496. * Gets the output component
  132497. */
  132498. get output(): NodeMaterialConnectionPoint;
  132499. protected _buildBlock(state: NodeMaterialBuildState): this;
  132500. }
  132501. }
  132502. declare module BABYLON {
  132503. /**
  132504. * Block used to subtract 2 vectors
  132505. */
  132506. export class SubtractBlock extends NodeMaterialBlock {
  132507. /**
  132508. * Creates a new SubtractBlock
  132509. * @param name defines the block name
  132510. */
  132511. constructor(name: string);
  132512. /**
  132513. * Gets the current class name
  132514. * @returns the class name
  132515. */
  132516. getClassName(): string;
  132517. /**
  132518. * Gets the left operand input component
  132519. */
  132520. get left(): NodeMaterialConnectionPoint;
  132521. /**
  132522. * Gets the right operand input component
  132523. */
  132524. get right(): NodeMaterialConnectionPoint;
  132525. /**
  132526. * Gets the output component
  132527. */
  132528. get output(): NodeMaterialConnectionPoint;
  132529. protected _buildBlock(state: NodeMaterialBuildState): this;
  132530. }
  132531. }
  132532. declare module BABYLON {
  132533. /**
  132534. * Block used to step a value
  132535. */
  132536. export class StepBlock extends NodeMaterialBlock {
  132537. /**
  132538. * Creates a new StepBlock
  132539. * @param name defines the block name
  132540. */
  132541. constructor(name: string);
  132542. /**
  132543. * Gets the current class name
  132544. * @returns the class name
  132545. */
  132546. getClassName(): string;
  132547. /**
  132548. * Gets the value operand input component
  132549. */
  132550. get value(): NodeMaterialConnectionPoint;
  132551. /**
  132552. * Gets the edge operand input component
  132553. */
  132554. get edge(): NodeMaterialConnectionPoint;
  132555. /**
  132556. * Gets the output component
  132557. */
  132558. get output(): NodeMaterialConnectionPoint;
  132559. protected _buildBlock(state: NodeMaterialBuildState): this;
  132560. }
  132561. }
  132562. declare module BABYLON {
  132563. /**
  132564. * Block used to get the opposite (1 - x) of a value
  132565. */
  132566. export class OneMinusBlock extends NodeMaterialBlock {
  132567. /**
  132568. * Creates a new OneMinusBlock
  132569. * @param name defines the block name
  132570. */
  132571. constructor(name: string);
  132572. /**
  132573. * Gets the current class name
  132574. * @returns the class name
  132575. */
  132576. getClassName(): string;
  132577. /**
  132578. * Gets the input component
  132579. */
  132580. get input(): NodeMaterialConnectionPoint;
  132581. /**
  132582. * Gets the output component
  132583. */
  132584. get output(): NodeMaterialConnectionPoint;
  132585. protected _buildBlock(state: NodeMaterialBuildState): this;
  132586. }
  132587. }
  132588. declare module BABYLON {
  132589. /**
  132590. * Block used to get the view direction
  132591. */
  132592. export class ViewDirectionBlock extends NodeMaterialBlock {
  132593. /**
  132594. * Creates a new ViewDirectionBlock
  132595. * @param name defines the block name
  132596. */
  132597. constructor(name: string);
  132598. /**
  132599. * Gets the current class name
  132600. * @returns the class name
  132601. */
  132602. getClassName(): string;
  132603. /**
  132604. * Gets the world position component
  132605. */
  132606. get worldPosition(): NodeMaterialConnectionPoint;
  132607. /**
  132608. * Gets the camera position component
  132609. */
  132610. get cameraPosition(): NodeMaterialConnectionPoint;
  132611. /**
  132612. * Gets the output component
  132613. */
  132614. get output(): NodeMaterialConnectionPoint;
  132615. autoConfigure(material: NodeMaterial): void;
  132616. protected _buildBlock(state: NodeMaterialBuildState): this;
  132617. }
  132618. }
  132619. declare module BABYLON {
  132620. /**
  132621. * Block used to compute fresnel value
  132622. */
  132623. export class FresnelBlock extends NodeMaterialBlock {
  132624. /**
  132625. * Create a new FresnelBlock
  132626. * @param name defines the block name
  132627. */
  132628. constructor(name: string);
  132629. /**
  132630. * Gets the current class name
  132631. * @returns the class name
  132632. */
  132633. getClassName(): string;
  132634. /**
  132635. * Gets the world normal input component
  132636. */
  132637. get worldNormal(): NodeMaterialConnectionPoint;
  132638. /**
  132639. * Gets the view direction input component
  132640. */
  132641. get viewDirection(): NodeMaterialConnectionPoint;
  132642. /**
  132643. * Gets the bias input component
  132644. */
  132645. get bias(): NodeMaterialConnectionPoint;
  132646. /**
  132647. * Gets the camera (or eye) position component
  132648. */
  132649. get power(): NodeMaterialConnectionPoint;
  132650. /**
  132651. * Gets the fresnel output component
  132652. */
  132653. get fresnel(): NodeMaterialConnectionPoint;
  132654. autoConfigure(material: NodeMaterial): void;
  132655. protected _buildBlock(state: NodeMaterialBuildState): this;
  132656. }
  132657. }
  132658. declare module BABYLON {
  132659. /**
  132660. * Block used to get the max of 2 values
  132661. */
  132662. export class MaxBlock extends NodeMaterialBlock {
  132663. /**
  132664. * Creates a new MaxBlock
  132665. * @param name defines the block name
  132666. */
  132667. constructor(name: string);
  132668. /**
  132669. * Gets the current class name
  132670. * @returns the class name
  132671. */
  132672. getClassName(): string;
  132673. /**
  132674. * Gets the left operand input component
  132675. */
  132676. get left(): NodeMaterialConnectionPoint;
  132677. /**
  132678. * Gets the right operand input component
  132679. */
  132680. get right(): NodeMaterialConnectionPoint;
  132681. /**
  132682. * Gets the output component
  132683. */
  132684. get output(): NodeMaterialConnectionPoint;
  132685. protected _buildBlock(state: NodeMaterialBuildState): this;
  132686. }
  132687. }
  132688. declare module BABYLON {
  132689. /**
  132690. * Block used to get the min of 2 values
  132691. */
  132692. export class MinBlock extends NodeMaterialBlock {
  132693. /**
  132694. * Creates a new MinBlock
  132695. * @param name defines the block name
  132696. */
  132697. constructor(name: string);
  132698. /**
  132699. * Gets the current class name
  132700. * @returns the class name
  132701. */
  132702. getClassName(): string;
  132703. /**
  132704. * Gets the left operand input component
  132705. */
  132706. get left(): NodeMaterialConnectionPoint;
  132707. /**
  132708. * Gets the right operand input component
  132709. */
  132710. get right(): NodeMaterialConnectionPoint;
  132711. /**
  132712. * Gets the output component
  132713. */
  132714. get output(): NodeMaterialConnectionPoint;
  132715. protected _buildBlock(state: NodeMaterialBuildState): this;
  132716. }
  132717. }
  132718. declare module BABYLON {
  132719. /**
  132720. * Block used to get the distance between 2 values
  132721. */
  132722. export class DistanceBlock extends NodeMaterialBlock {
  132723. /**
  132724. * Creates a new DistanceBlock
  132725. * @param name defines the block name
  132726. */
  132727. constructor(name: string);
  132728. /**
  132729. * Gets the current class name
  132730. * @returns the class name
  132731. */
  132732. getClassName(): string;
  132733. /**
  132734. * Gets the left operand input component
  132735. */
  132736. get left(): NodeMaterialConnectionPoint;
  132737. /**
  132738. * Gets the right operand input component
  132739. */
  132740. get right(): NodeMaterialConnectionPoint;
  132741. /**
  132742. * Gets the output component
  132743. */
  132744. get output(): NodeMaterialConnectionPoint;
  132745. protected _buildBlock(state: NodeMaterialBuildState): this;
  132746. }
  132747. }
  132748. declare module BABYLON {
  132749. /**
  132750. * Block used to get the length of a vector
  132751. */
  132752. export class LengthBlock extends NodeMaterialBlock {
  132753. /**
  132754. * Creates a new LengthBlock
  132755. * @param name defines the block name
  132756. */
  132757. constructor(name: string);
  132758. /**
  132759. * Gets the current class name
  132760. * @returns the class name
  132761. */
  132762. getClassName(): string;
  132763. /**
  132764. * Gets the value input component
  132765. */
  132766. get value(): NodeMaterialConnectionPoint;
  132767. /**
  132768. * Gets the output component
  132769. */
  132770. get output(): NodeMaterialConnectionPoint;
  132771. protected _buildBlock(state: NodeMaterialBuildState): this;
  132772. }
  132773. }
  132774. declare module BABYLON {
  132775. /**
  132776. * Block used to get negative version of a value (i.e. x * -1)
  132777. */
  132778. export class NegateBlock extends NodeMaterialBlock {
  132779. /**
  132780. * Creates a new NegateBlock
  132781. * @param name defines the block name
  132782. */
  132783. constructor(name: string);
  132784. /**
  132785. * Gets the current class name
  132786. * @returns the class name
  132787. */
  132788. getClassName(): string;
  132789. /**
  132790. * Gets the value input component
  132791. */
  132792. get value(): NodeMaterialConnectionPoint;
  132793. /**
  132794. * Gets the output component
  132795. */
  132796. get output(): NodeMaterialConnectionPoint;
  132797. protected _buildBlock(state: NodeMaterialBuildState): this;
  132798. }
  132799. }
  132800. declare module BABYLON {
  132801. /**
  132802. * Block used to get the value of the first parameter raised to the power of the second
  132803. */
  132804. export class PowBlock extends NodeMaterialBlock {
  132805. /**
  132806. * Creates a new PowBlock
  132807. * @param name defines the block name
  132808. */
  132809. constructor(name: string);
  132810. /**
  132811. * Gets the current class name
  132812. * @returns the class name
  132813. */
  132814. getClassName(): string;
  132815. /**
  132816. * Gets the value operand input component
  132817. */
  132818. get value(): NodeMaterialConnectionPoint;
  132819. /**
  132820. * Gets the power operand input component
  132821. */
  132822. get power(): NodeMaterialConnectionPoint;
  132823. /**
  132824. * Gets the output component
  132825. */
  132826. get output(): NodeMaterialConnectionPoint;
  132827. protected _buildBlock(state: NodeMaterialBuildState): this;
  132828. }
  132829. }
  132830. declare module BABYLON {
  132831. /**
  132832. * Block used to get a random number
  132833. */
  132834. export class RandomNumberBlock extends NodeMaterialBlock {
  132835. /**
  132836. * Creates a new RandomNumberBlock
  132837. * @param name defines the block name
  132838. */
  132839. constructor(name: string);
  132840. /**
  132841. * Gets the current class name
  132842. * @returns the class name
  132843. */
  132844. getClassName(): string;
  132845. /**
  132846. * Gets the seed input component
  132847. */
  132848. get seed(): NodeMaterialConnectionPoint;
  132849. /**
  132850. * Gets the output component
  132851. */
  132852. get output(): NodeMaterialConnectionPoint;
  132853. protected _buildBlock(state: NodeMaterialBuildState): this;
  132854. }
  132855. }
  132856. declare module BABYLON {
  132857. /**
  132858. * Block used to compute arc tangent of 2 values
  132859. */
  132860. export class ArcTan2Block extends NodeMaterialBlock {
  132861. /**
  132862. * Creates a new ArcTan2Block
  132863. * @param name defines the block name
  132864. */
  132865. constructor(name: string);
  132866. /**
  132867. * Gets the current class name
  132868. * @returns the class name
  132869. */
  132870. getClassName(): string;
  132871. /**
  132872. * Gets the x operand input component
  132873. */
  132874. get x(): NodeMaterialConnectionPoint;
  132875. /**
  132876. * Gets the y operand input component
  132877. */
  132878. get y(): NodeMaterialConnectionPoint;
  132879. /**
  132880. * Gets the output component
  132881. */
  132882. get output(): NodeMaterialConnectionPoint;
  132883. protected _buildBlock(state: NodeMaterialBuildState): this;
  132884. }
  132885. }
  132886. declare module BABYLON {
  132887. /**
  132888. * Block used to smooth step a value
  132889. */
  132890. export class SmoothStepBlock extends NodeMaterialBlock {
  132891. /**
  132892. * Creates a new SmoothStepBlock
  132893. * @param name defines the block name
  132894. */
  132895. constructor(name: string);
  132896. /**
  132897. * Gets the current class name
  132898. * @returns the class name
  132899. */
  132900. getClassName(): string;
  132901. /**
  132902. * Gets the value operand input component
  132903. */
  132904. get value(): NodeMaterialConnectionPoint;
  132905. /**
  132906. * Gets the first edge operand input component
  132907. */
  132908. get edge0(): NodeMaterialConnectionPoint;
  132909. /**
  132910. * Gets the second edge operand input component
  132911. */
  132912. get edge1(): NodeMaterialConnectionPoint;
  132913. /**
  132914. * Gets the output component
  132915. */
  132916. get output(): NodeMaterialConnectionPoint;
  132917. protected _buildBlock(state: NodeMaterialBuildState): this;
  132918. }
  132919. }
  132920. declare module BABYLON {
  132921. /**
  132922. * Block used to get the reciprocal (1 / x) of a value
  132923. */
  132924. export class ReciprocalBlock extends NodeMaterialBlock {
  132925. /**
  132926. * Creates a new ReciprocalBlock
  132927. * @param name defines the block name
  132928. */
  132929. constructor(name: string);
  132930. /**
  132931. * Gets the current class name
  132932. * @returns the class name
  132933. */
  132934. getClassName(): string;
  132935. /**
  132936. * Gets the input component
  132937. */
  132938. get input(): NodeMaterialConnectionPoint;
  132939. /**
  132940. * Gets the output component
  132941. */
  132942. get output(): NodeMaterialConnectionPoint;
  132943. protected _buildBlock(state: NodeMaterialBuildState): this;
  132944. }
  132945. }
  132946. declare module BABYLON {
  132947. /**
  132948. * Block used to replace a color by another one
  132949. */
  132950. export class ReplaceColorBlock extends NodeMaterialBlock {
  132951. /**
  132952. * Creates a new ReplaceColorBlock
  132953. * @param name defines the block name
  132954. */
  132955. constructor(name: string);
  132956. /**
  132957. * Gets the current class name
  132958. * @returns the class name
  132959. */
  132960. getClassName(): string;
  132961. /**
  132962. * Gets the value input component
  132963. */
  132964. get value(): NodeMaterialConnectionPoint;
  132965. /**
  132966. * Gets the reference input component
  132967. */
  132968. get reference(): NodeMaterialConnectionPoint;
  132969. /**
  132970. * Gets the distance input component
  132971. */
  132972. get distance(): NodeMaterialConnectionPoint;
  132973. /**
  132974. * Gets the replacement input component
  132975. */
  132976. get replacement(): NodeMaterialConnectionPoint;
  132977. /**
  132978. * Gets the output component
  132979. */
  132980. get output(): NodeMaterialConnectionPoint;
  132981. protected _buildBlock(state: NodeMaterialBuildState): this;
  132982. }
  132983. }
  132984. declare module BABYLON {
  132985. /**
  132986. * Block used to posterize a value
  132987. * @see https://en.wikipedia.org/wiki/Posterization
  132988. */
  132989. export class PosterizeBlock extends NodeMaterialBlock {
  132990. /**
  132991. * Creates a new PosterizeBlock
  132992. * @param name defines the block name
  132993. */
  132994. constructor(name: string);
  132995. /**
  132996. * Gets the current class name
  132997. * @returns the class name
  132998. */
  132999. getClassName(): string;
  133000. /**
  133001. * Gets the value input component
  133002. */
  133003. get value(): NodeMaterialConnectionPoint;
  133004. /**
  133005. * Gets the steps input component
  133006. */
  133007. get steps(): NodeMaterialConnectionPoint;
  133008. /**
  133009. * Gets the output component
  133010. */
  133011. get output(): NodeMaterialConnectionPoint;
  133012. protected _buildBlock(state: NodeMaterialBuildState): this;
  133013. }
  133014. }
  133015. declare module BABYLON {
  133016. /**
  133017. * Operations supported by the Wave block
  133018. */
  133019. export enum WaveBlockKind {
  133020. /** SawTooth */
  133021. SawTooth = 0,
  133022. /** Square */
  133023. Square = 1,
  133024. /** Triangle */
  133025. Triangle = 2
  133026. }
  133027. /**
  133028. * Block used to apply wave operation to floats
  133029. */
  133030. export class WaveBlock extends NodeMaterialBlock {
  133031. /**
  133032. * Gets or sets the kibnd of wave to be applied by the block
  133033. */
  133034. kind: WaveBlockKind;
  133035. /**
  133036. * Creates a new WaveBlock
  133037. * @param name defines the block name
  133038. */
  133039. constructor(name: string);
  133040. /**
  133041. * Gets the current class name
  133042. * @returns the class name
  133043. */
  133044. getClassName(): string;
  133045. /**
  133046. * Gets the input component
  133047. */
  133048. get input(): NodeMaterialConnectionPoint;
  133049. /**
  133050. * Gets the output component
  133051. */
  133052. get output(): NodeMaterialConnectionPoint;
  133053. protected _buildBlock(state: NodeMaterialBuildState): this;
  133054. serialize(): any;
  133055. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133056. }
  133057. }
  133058. declare module BABYLON {
  133059. /**
  133060. * Class used to store a color step for the GradientBlock
  133061. */
  133062. export class GradientBlockColorStep {
  133063. /**
  133064. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  133065. */
  133066. step: number;
  133067. /**
  133068. * Gets or sets the color associated with this step
  133069. */
  133070. color: Color3;
  133071. /**
  133072. * Creates a new GradientBlockColorStep
  133073. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  133074. * @param color defines the color associated with this step
  133075. */
  133076. constructor(
  133077. /**
  133078. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  133079. */
  133080. step: number,
  133081. /**
  133082. * Gets or sets the color associated with this step
  133083. */
  133084. color: Color3);
  133085. }
  133086. /**
  133087. * Block used to return a color from a gradient based on an input value between 0 and 1
  133088. */
  133089. export class GradientBlock extends NodeMaterialBlock {
  133090. /**
  133091. * Gets or sets the list of color steps
  133092. */
  133093. colorSteps: GradientBlockColorStep[];
  133094. /**
  133095. * Creates a new GradientBlock
  133096. * @param name defines the block name
  133097. */
  133098. constructor(name: string);
  133099. /**
  133100. * Gets the current class name
  133101. * @returns the class name
  133102. */
  133103. getClassName(): string;
  133104. /**
  133105. * Gets the gradient input component
  133106. */
  133107. get gradient(): NodeMaterialConnectionPoint;
  133108. /**
  133109. * Gets the output component
  133110. */
  133111. get output(): NodeMaterialConnectionPoint;
  133112. private _writeColorConstant;
  133113. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133114. serialize(): any;
  133115. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133116. protected _dumpPropertiesCode(): string;
  133117. }
  133118. }
  133119. declare module BABYLON {
  133120. /**
  133121. * Block used to normalize lerp between 2 values
  133122. */
  133123. export class NLerpBlock extends NodeMaterialBlock {
  133124. /**
  133125. * Creates a new NLerpBlock
  133126. * @param name defines the block name
  133127. */
  133128. constructor(name: string);
  133129. /**
  133130. * Gets the current class name
  133131. * @returns the class name
  133132. */
  133133. getClassName(): string;
  133134. /**
  133135. * Gets the left operand input component
  133136. */
  133137. get left(): NodeMaterialConnectionPoint;
  133138. /**
  133139. * Gets the right operand input component
  133140. */
  133141. get right(): NodeMaterialConnectionPoint;
  133142. /**
  133143. * Gets the gradient operand input component
  133144. */
  133145. get gradient(): NodeMaterialConnectionPoint;
  133146. /**
  133147. * Gets the output component
  133148. */
  133149. get output(): NodeMaterialConnectionPoint;
  133150. protected _buildBlock(state: NodeMaterialBuildState): this;
  133151. }
  133152. }
  133153. declare module BABYLON {
  133154. /**
  133155. * block used to Generate a Worley Noise 3D Noise Pattern
  133156. */
  133157. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  133158. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  133159. manhattanDistance: boolean;
  133160. /**
  133161. * Creates a new WorleyNoise3DBlock
  133162. * @param name defines the block name
  133163. */
  133164. constructor(name: string);
  133165. /**
  133166. * Gets the current class name
  133167. * @returns the class name
  133168. */
  133169. getClassName(): string;
  133170. /**
  133171. * Gets the seed input component
  133172. */
  133173. get seed(): NodeMaterialConnectionPoint;
  133174. /**
  133175. * Gets the jitter input component
  133176. */
  133177. get jitter(): NodeMaterialConnectionPoint;
  133178. /**
  133179. * Gets the output component
  133180. */
  133181. get output(): NodeMaterialConnectionPoint;
  133182. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133183. /**
  133184. * Exposes the properties to the UI?
  133185. */
  133186. protected _dumpPropertiesCode(): string;
  133187. /**
  133188. * Exposes the properties to the Seralize?
  133189. */
  133190. serialize(): any;
  133191. /**
  133192. * Exposes the properties to the deseralize?
  133193. */
  133194. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133195. }
  133196. }
  133197. declare module BABYLON {
  133198. /**
  133199. * block used to Generate a Simplex Perlin 3d Noise Pattern
  133200. */
  133201. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  133202. /**
  133203. * Creates a new SimplexPerlin3DBlock
  133204. * @param name defines the block name
  133205. */
  133206. constructor(name: string);
  133207. /**
  133208. * Gets the current class name
  133209. * @returns the class name
  133210. */
  133211. getClassName(): string;
  133212. /**
  133213. * Gets the seed operand input component
  133214. */
  133215. get seed(): NodeMaterialConnectionPoint;
  133216. /**
  133217. * Gets the output component
  133218. */
  133219. get output(): NodeMaterialConnectionPoint;
  133220. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133221. }
  133222. }
  133223. declare module BABYLON {
  133224. /**
  133225. * Block used to blend normals
  133226. */
  133227. export class NormalBlendBlock extends NodeMaterialBlock {
  133228. /**
  133229. * Creates a new NormalBlendBlock
  133230. * @param name defines the block name
  133231. */
  133232. constructor(name: string);
  133233. /**
  133234. * Gets the current class name
  133235. * @returns the class name
  133236. */
  133237. getClassName(): string;
  133238. /**
  133239. * Gets the first input component
  133240. */
  133241. get normalMap0(): NodeMaterialConnectionPoint;
  133242. /**
  133243. * Gets the second input component
  133244. */
  133245. get normalMap1(): NodeMaterialConnectionPoint;
  133246. /**
  133247. * Gets the output component
  133248. */
  133249. get output(): NodeMaterialConnectionPoint;
  133250. protected _buildBlock(state: NodeMaterialBuildState): this;
  133251. }
  133252. }
  133253. declare module BABYLON {
  133254. /**
  133255. * Block used to rotate a 2d vector by a given angle
  133256. */
  133257. export class Rotate2dBlock extends NodeMaterialBlock {
  133258. /**
  133259. * Creates a new Rotate2dBlock
  133260. * @param name defines the block name
  133261. */
  133262. constructor(name: string);
  133263. /**
  133264. * Gets the current class name
  133265. * @returns the class name
  133266. */
  133267. getClassName(): string;
  133268. /**
  133269. * Gets the input vector
  133270. */
  133271. get input(): NodeMaterialConnectionPoint;
  133272. /**
  133273. * Gets the input angle
  133274. */
  133275. get angle(): NodeMaterialConnectionPoint;
  133276. /**
  133277. * Gets the output component
  133278. */
  133279. get output(): NodeMaterialConnectionPoint;
  133280. autoConfigure(material: NodeMaterial): void;
  133281. protected _buildBlock(state: NodeMaterialBuildState): this;
  133282. }
  133283. }
  133284. declare module BABYLON {
  133285. /**
  133286. * Block used to get the reflected vector from a direction and a normal
  133287. */
  133288. export class ReflectBlock extends NodeMaterialBlock {
  133289. /**
  133290. * Creates a new ReflectBlock
  133291. * @param name defines the block name
  133292. */
  133293. constructor(name: string);
  133294. /**
  133295. * Gets the current class name
  133296. * @returns the class name
  133297. */
  133298. getClassName(): string;
  133299. /**
  133300. * Gets the incident component
  133301. */
  133302. get incident(): NodeMaterialConnectionPoint;
  133303. /**
  133304. * Gets the normal component
  133305. */
  133306. get normal(): NodeMaterialConnectionPoint;
  133307. /**
  133308. * Gets the output component
  133309. */
  133310. get output(): NodeMaterialConnectionPoint;
  133311. protected _buildBlock(state: NodeMaterialBuildState): this;
  133312. }
  133313. }
  133314. declare module BABYLON {
  133315. /**
  133316. * Block used to get the refracted vector from a direction and a normal
  133317. */
  133318. export class RefractBlock extends NodeMaterialBlock {
  133319. /**
  133320. * Creates a new RefractBlock
  133321. * @param name defines the block name
  133322. */
  133323. constructor(name: string);
  133324. /**
  133325. * Gets the current class name
  133326. * @returns the class name
  133327. */
  133328. getClassName(): string;
  133329. /**
  133330. * Gets the incident component
  133331. */
  133332. get incident(): NodeMaterialConnectionPoint;
  133333. /**
  133334. * Gets the normal component
  133335. */
  133336. get normal(): NodeMaterialConnectionPoint;
  133337. /**
  133338. * Gets the index of refraction component
  133339. */
  133340. get ior(): NodeMaterialConnectionPoint;
  133341. /**
  133342. * Gets the output component
  133343. */
  133344. get output(): NodeMaterialConnectionPoint;
  133345. protected _buildBlock(state: NodeMaterialBuildState): this;
  133346. }
  133347. }
  133348. declare module BABYLON {
  133349. /**
  133350. * Block used to desaturate a color
  133351. */
  133352. export class DesaturateBlock extends NodeMaterialBlock {
  133353. /**
  133354. * Creates a new DesaturateBlock
  133355. * @param name defines the block name
  133356. */
  133357. constructor(name: string);
  133358. /**
  133359. * Gets the current class name
  133360. * @returns the class name
  133361. */
  133362. getClassName(): string;
  133363. /**
  133364. * Gets the color operand input component
  133365. */
  133366. get color(): NodeMaterialConnectionPoint;
  133367. /**
  133368. * Gets the level operand input component
  133369. */
  133370. get level(): NodeMaterialConnectionPoint;
  133371. /**
  133372. * Gets the output component
  133373. */
  133374. get output(): NodeMaterialConnectionPoint;
  133375. protected _buildBlock(state: NodeMaterialBuildState): this;
  133376. }
  133377. }
  133378. declare module BABYLON {
  133379. /**
  133380. * Effect Render Options
  133381. */
  133382. export interface IEffectRendererOptions {
  133383. /**
  133384. * Defines the vertices positions.
  133385. */
  133386. positions?: number[];
  133387. /**
  133388. * Defines the indices.
  133389. */
  133390. indices?: number[];
  133391. }
  133392. /**
  133393. * Helper class to render one or more effects
  133394. */
  133395. export class EffectRenderer {
  133396. private engine;
  133397. private static _DefaultOptions;
  133398. private _vertexBuffers;
  133399. private _indexBuffer;
  133400. private _ringBufferIndex;
  133401. private _ringScreenBuffer;
  133402. private _fullscreenViewport;
  133403. private _getNextFrameBuffer;
  133404. /**
  133405. * Creates an effect renderer
  133406. * @param engine the engine to use for rendering
  133407. * @param options defines the options of the effect renderer
  133408. */
  133409. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  133410. /**
  133411. * Sets the current viewport in normalized coordinates 0-1
  133412. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  133413. */
  133414. setViewport(viewport?: Viewport): void;
  133415. /**
  133416. * Binds the embedded attributes buffer to the effect.
  133417. * @param effect Defines the effect to bind the attributes for
  133418. */
  133419. bindBuffers(effect: Effect): void;
  133420. /**
  133421. * Sets the current effect wrapper to use during draw.
  133422. * The effect needs to be ready before calling this api.
  133423. * This also sets the default full screen position attribute.
  133424. * @param effectWrapper Defines the effect to draw with
  133425. */
  133426. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  133427. /**
  133428. * Draws a full screen quad.
  133429. */
  133430. draw(): void;
  133431. /**
  133432. * renders one or more effects to a specified texture
  133433. * @param effectWrappers list of effects to renderer
  133434. * @param outputTexture texture to draw to, if null it will render to the screen
  133435. */
  133436. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  133437. /**
  133438. * Disposes of the effect renderer
  133439. */
  133440. dispose(): void;
  133441. }
  133442. /**
  133443. * Options to create an EffectWrapper
  133444. */
  133445. interface EffectWrapperCreationOptions {
  133446. /**
  133447. * Engine to use to create the effect
  133448. */
  133449. engine: ThinEngine;
  133450. /**
  133451. * Fragment shader for the effect
  133452. */
  133453. fragmentShader: string;
  133454. /**
  133455. * Vertex shader for the effect
  133456. */
  133457. vertexShader?: string;
  133458. /**
  133459. * Attributes to use in the shader
  133460. */
  133461. attributeNames?: Array<string>;
  133462. /**
  133463. * Uniforms to use in the shader
  133464. */
  133465. uniformNames?: Array<string>;
  133466. /**
  133467. * Texture sampler names to use in the shader
  133468. */
  133469. samplerNames?: Array<string>;
  133470. /**
  133471. * The friendly name of the effect displayed in Spector.
  133472. */
  133473. name?: string;
  133474. }
  133475. /**
  133476. * Wraps an effect to be used for rendering
  133477. */
  133478. export class EffectWrapper {
  133479. /**
  133480. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  133481. */
  133482. onApplyObservable: Observable<{}>;
  133483. /**
  133484. * The underlying effect
  133485. */
  133486. effect: Effect;
  133487. /**
  133488. * Creates an effect to be renderer
  133489. * @param creationOptions options to create the effect
  133490. */
  133491. constructor(creationOptions: EffectWrapperCreationOptions);
  133492. /**
  133493. * Disposes of the effect wrapper
  133494. */
  133495. dispose(): void;
  133496. }
  133497. }
  133498. declare module BABYLON {
  133499. /**
  133500. * Helper class to push actions to a pool of workers.
  133501. */
  133502. export class WorkerPool implements IDisposable {
  133503. private _workerInfos;
  133504. private _pendingActions;
  133505. /**
  133506. * Constructor
  133507. * @param workers Array of workers to use for actions
  133508. */
  133509. constructor(workers: Array<Worker>);
  133510. /**
  133511. * Terminates all workers and clears any pending actions.
  133512. */
  133513. dispose(): void;
  133514. /**
  133515. * Pushes an action to the worker pool. If all the workers are active, the action will be
  133516. * pended until a worker has completed its action.
  133517. * @param action The action to perform. Call onComplete when the action is complete.
  133518. */
  133519. push(action: (worker: Worker, onComplete: () => void) => void): void;
  133520. private _execute;
  133521. }
  133522. }
  133523. declare module BABYLON {
  133524. /**
  133525. * Configuration for Draco compression
  133526. */
  133527. export interface IDracoCompressionConfiguration {
  133528. /**
  133529. * Configuration for the decoder.
  133530. */
  133531. decoder: {
  133532. /**
  133533. * The url to the WebAssembly module.
  133534. */
  133535. wasmUrl?: string;
  133536. /**
  133537. * The url to the WebAssembly binary.
  133538. */
  133539. wasmBinaryUrl?: string;
  133540. /**
  133541. * The url to the fallback JavaScript module.
  133542. */
  133543. fallbackUrl?: string;
  133544. };
  133545. }
  133546. /**
  133547. * Draco compression (https://google.github.io/draco/)
  133548. *
  133549. * This class wraps the Draco module.
  133550. *
  133551. * **Encoder**
  133552. *
  133553. * The encoder is not currently implemented.
  133554. *
  133555. * **Decoder**
  133556. *
  133557. * 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.
  133558. *
  133559. * To update the configuration, use the following code:
  133560. * ```javascript
  133561. * DracoCompression.Configuration = {
  133562. * decoder: {
  133563. * wasmUrl: "<url to the WebAssembly library>",
  133564. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  133565. * fallbackUrl: "<url to the fallback JavaScript library>",
  133566. * }
  133567. * };
  133568. * ```
  133569. *
  133570. * 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.
  133571. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  133572. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  133573. *
  133574. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  133575. * ```javascript
  133576. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  133577. * ```
  133578. *
  133579. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  133580. */
  133581. export class DracoCompression implements IDisposable {
  133582. private _workerPoolPromise?;
  133583. private _decoderModulePromise?;
  133584. /**
  133585. * The configuration. Defaults to the following urls:
  133586. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  133587. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  133588. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  133589. */
  133590. static Configuration: IDracoCompressionConfiguration;
  133591. /**
  133592. * Returns true if the decoder configuration is available.
  133593. */
  133594. static get DecoderAvailable(): boolean;
  133595. /**
  133596. * Default number of workers to create when creating the draco compression object.
  133597. */
  133598. static DefaultNumWorkers: number;
  133599. private static GetDefaultNumWorkers;
  133600. private static _Default;
  133601. /**
  133602. * Default instance for the draco compression object.
  133603. */
  133604. static get Default(): DracoCompression;
  133605. /**
  133606. * Constructor
  133607. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  133608. */
  133609. constructor(numWorkers?: number);
  133610. /**
  133611. * Stop all async operations and release resources.
  133612. */
  133613. dispose(): void;
  133614. /**
  133615. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  133616. * @returns a promise that resolves when ready
  133617. */
  133618. whenReadyAsync(): Promise<void>;
  133619. /**
  133620. * Decode Draco compressed mesh data to vertex data.
  133621. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  133622. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  133623. * @returns A promise that resolves with the decoded vertex data
  133624. */
  133625. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  133626. [kind: string]: number;
  133627. }): Promise<VertexData>;
  133628. }
  133629. }
  133630. declare module BABYLON {
  133631. /**
  133632. * Class for building Constructive Solid Geometry
  133633. */
  133634. export class CSG {
  133635. private polygons;
  133636. /**
  133637. * The world matrix
  133638. */
  133639. matrix: Matrix;
  133640. /**
  133641. * Stores the position
  133642. */
  133643. position: Vector3;
  133644. /**
  133645. * Stores the rotation
  133646. */
  133647. rotation: Vector3;
  133648. /**
  133649. * Stores the rotation quaternion
  133650. */
  133651. rotationQuaternion: Nullable<Quaternion>;
  133652. /**
  133653. * Stores the scaling vector
  133654. */
  133655. scaling: Vector3;
  133656. /**
  133657. * Convert the Mesh to CSG
  133658. * @param mesh The Mesh to convert to CSG
  133659. * @returns A new CSG from the Mesh
  133660. */
  133661. static FromMesh(mesh: Mesh): CSG;
  133662. /**
  133663. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  133664. * @param polygons Polygons used to construct a CSG solid
  133665. */
  133666. private static FromPolygons;
  133667. /**
  133668. * Clones, or makes a deep copy, of the CSG
  133669. * @returns A new CSG
  133670. */
  133671. clone(): CSG;
  133672. /**
  133673. * Unions this CSG with another CSG
  133674. * @param csg The CSG to union against this CSG
  133675. * @returns The unioned CSG
  133676. */
  133677. union(csg: CSG): CSG;
  133678. /**
  133679. * Unions this CSG with another CSG in place
  133680. * @param csg The CSG to union against this CSG
  133681. */
  133682. unionInPlace(csg: CSG): void;
  133683. /**
  133684. * Subtracts this CSG with another CSG
  133685. * @param csg The CSG to subtract against this CSG
  133686. * @returns A new CSG
  133687. */
  133688. subtract(csg: CSG): CSG;
  133689. /**
  133690. * Subtracts this CSG with another CSG in place
  133691. * @param csg The CSG to subtact against this CSG
  133692. */
  133693. subtractInPlace(csg: CSG): void;
  133694. /**
  133695. * Intersect this CSG with another CSG
  133696. * @param csg The CSG to intersect against this CSG
  133697. * @returns A new CSG
  133698. */
  133699. intersect(csg: CSG): CSG;
  133700. /**
  133701. * Intersects this CSG with another CSG in place
  133702. * @param csg The CSG to intersect against this CSG
  133703. */
  133704. intersectInPlace(csg: CSG): void;
  133705. /**
  133706. * Return a new CSG solid with solid and empty space switched. This solid is
  133707. * not modified.
  133708. * @returns A new CSG solid with solid and empty space switched
  133709. */
  133710. inverse(): CSG;
  133711. /**
  133712. * Inverses the CSG in place
  133713. */
  133714. inverseInPlace(): void;
  133715. /**
  133716. * This is used to keep meshes transformations so they can be restored
  133717. * when we build back a Babylon Mesh
  133718. * NB : All CSG operations are performed in world coordinates
  133719. * @param csg The CSG to copy the transform attributes from
  133720. * @returns This CSG
  133721. */
  133722. copyTransformAttributes(csg: CSG): CSG;
  133723. /**
  133724. * Build Raw mesh from CSG
  133725. * Coordinates here are in world space
  133726. * @param name The name of the mesh geometry
  133727. * @param scene The Scene
  133728. * @param keepSubMeshes Specifies if the submeshes should be kept
  133729. * @returns A new Mesh
  133730. */
  133731. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  133732. /**
  133733. * Build Mesh from CSG taking material and transforms into account
  133734. * @param name The name of the Mesh
  133735. * @param material The material of the Mesh
  133736. * @param scene The Scene
  133737. * @param keepSubMeshes Specifies if submeshes should be kept
  133738. * @returns The new Mesh
  133739. */
  133740. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  133741. }
  133742. }
  133743. declare module BABYLON {
  133744. /**
  133745. * Class used to create a trail following a mesh
  133746. */
  133747. export class TrailMesh extends Mesh {
  133748. private _generator;
  133749. private _autoStart;
  133750. private _running;
  133751. private _diameter;
  133752. private _length;
  133753. private _sectionPolygonPointsCount;
  133754. private _sectionVectors;
  133755. private _sectionNormalVectors;
  133756. private _beforeRenderObserver;
  133757. /**
  133758. * @constructor
  133759. * @param name The value used by scene.getMeshByName() to do a lookup.
  133760. * @param generator The mesh or transform node to generate a trail.
  133761. * @param scene The scene to add this mesh to.
  133762. * @param diameter Diameter of trailing mesh. Default is 1.
  133763. * @param length Length of trailing mesh. Default is 60.
  133764. * @param autoStart Automatically start trailing mesh. Default true.
  133765. */
  133766. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  133767. /**
  133768. * "TrailMesh"
  133769. * @returns "TrailMesh"
  133770. */
  133771. getClassName(): string;
  133772. private _createMesh;
  133773. /**
  133774. * Start trailing mesh.
  133775. */
  133776. start(): void;
  133777. /**
  133778. * Stop trailing mesh.
  133779. */
  133780. stop(): void;
  133781. /**
  133782. * Update trailing mesh geometry.
  133783. */
  133784. update(): void;
  133785. /**
  133786. * Returns a new TrailMesh object.
  133787. * @param name is a string, the name given to the new mesh
  133788. * @param newGenerator use new generator object for cloned trail mesh
  133789. * @returns a new mesh
  133790. */
  133791. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  133792. /**
  133793. * Serializes this trail mesh
  133794. * @param serializationObject object to write serialization to
  133795. */
  133796. serialize(serializationObject: any): void;
  133797. /**
  133798. * Parses a serialized trail mesh
  133799. * @param parsedMesh the serialized mesh
  133800. * @param scene the scene to create the trail mesh in
  133801. * @returns the created trail mesh
  133802. */
  133803. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  133804. }
  133805. }
  133806. declare module BABYLON {
  133807. /**
  133808. * Class containing static functions to help procedurally build meshes
  133809. */
  133810. export class TiledBoxBuilder {
  133811. /**
  133812. * Creates a box mesh
  133813. * 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)
  133814. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  133815. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133816. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133817. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133818. * @param name defines the name of the mesh
  133819. * @param options defines the options used to create the mesh
  133820. * @param scene defines the hosting scene
  133821. * @returns the box mesh
  133822. */
  133823. static CreateTiledBox(name: string, options: {
  133824. pattern?: number;
  133825. width?: number;
  133826. height?: number;
  133827. depth?: number;
  133828. tileSize?: number;
  133829. tileWidth?: number;
  133830. tileHeight?: number;
  133831. alignHorizontal?: number;
  133832. alignVertical?: number;
  133833. faceUV?: Vector4[];
  133834. faceColors?: Color4[];
  133835. sideOrientation?: number;
  133836. updatable?: boolean;
  133837. }, scene?: Nullable<Scene>): Mesh;
  133838. }
  133839. }
  133840. declare module BABYLON {
  133841. /**
  133842. * Class containing static functions to help procedurally build meshes
  133843. */
  133844. export class TorusKnotBuilder {
  133845. /**
  133846. * Creates a torus knot mesh
  133847. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  133848. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  133849. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  133850. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  133851. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133852. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133853. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  133854. * @param name defines the name of the mesh
  133855. * @param options defines the options used to create the mesh
  133856. * @param scene defines the hosting scene
  133857. * @returns the torus knot mesh
  133858. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  133859. */
  133860. static CreateTorusKnot(name: string, options: {
  133861. radius?: number;
  133862. tube?: number;
  133863. radialSegments?: number;
  133864. tubularSegments?: number;
  133865. p?: number;
  133866. q?: number;
  133867. updatable?: boolean;
  133868. sideOrientation?: number;
  133869. frontUVs?: Vector4;
  133870. backUVs?: Vector4;
  133871. }, scene: any): Mesh;
  133872. }
  133873. }
  133874. declare module BABYLON {
  133875. /**
  133876. * Polygon
  133877. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  133878. */
  133879. export class Polygon {
  133880. /**
  133881. * Creates a rectangle
  133882. * @param xmin bottom X coord
  133883. * @param ymin bottom Y coord
  133884. * @param xmax top X coord
  133885. * @param ymax top Y coord
  133886. * @returns points that make the resulting rectation
  133887. */
  133888. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  133889. /**
  133890. * Creates a circle
  133891. * @param radius radius of circle
  133892. * @param cx scale in x
  133893. * @param cy scale in y
  133894. * @param numberOfSides number of sides that make up the circle
  133895. * @returns points that make the resulting circle
  133896. */
  133897. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  133898. /**
  133899. * Creates a polygon from input string
  133900. * @param input Input polygon data
  133901. * @returns the parsed points
  133902. */
  133903. static Parse(input: string): Vector2[];
  133904. /**
  133905. * Starts building a polygon from x and y coordinates
  133906. * @param x x coordinate
  133907. * @param y y coordinate
  133908. * @returns the started path2
  133909. */
  133910. static StartingAt(x: number, y: number): Path2;
  133911. }
  133912. /**
  133913. * Builds a polygon
  133914. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  133915. */
  133916. export class PolygonMeshBuilder {
  133917. private _points;
  133918. private _outlinepoints;
  133919. private _holes;
  133920. private _name;
  133921. private _scene;
  133922. private _epoints;
  133923. private _eholes;
  133924. private _addToepoint;
  133925. /**
  133926. * Babylon reference to the earcut plugin.
  133927. */
  133928. bjsEarcut: any;
  133929. /**
  133930. * Creates a PolygonMeshBuilder
  133931. * @param name name of the builder
  133932. * @param contours Path of the polygon
  133933. * @param scene scene to add to when creating the mesh
  133934. * @param earcutInjection can be used to inject your own earcut reference
  133935. */
  133936. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  133937. /**
  133938. * Adds a whole within the polygon
  133939. * @param hole Array of points defining the hole
  133940. * @returns this
  133941. */
  133942. addHole(hole: Vector2[]): PolygonMeshBuilder;
  133943. /**
  133944. * Creates the polygon
  133945. * @param updatable If the mesh should be updatable
  133946. * @param depth The depth of the mesh created
  133947. * @returns the created mesh
  133948. */
  133949. build(updatable?: boolean, depth?: number): Mesh;
  133950. /**
  133951. * Creates the polygon
  133952. * @param depth The depth of the mesh created
  133953. * @returns the created VertexData
  133954. */
  133955. buildVertexData(depth?: number): VertexData;
  133956. /**
  133957. * Adds a side to the polygon
  133958. * @param positions points that make the polygon
  133959. * @param normals normals of the polygon
  133960. * @param uvs uvs of the polygon
  133961. * @param indices indices of the polygon
  133962. * @param bounds bounds of the polygon
  133963. * @param points points of the polygon
  133964. * @param depth depth of the polygon
  133965. * @param flip flip of the polygon
  133966. */
  133967. private addSide;
  133968. }
  133969. }
  133970. declare module BABYLON {
  133971. /**
  133972. * Class containing static functions to help procedurally build meshes
  133973. */
  133974. export class PolygonBuilder {
  133975. /**
  133976. * Creates a polygon mesh
  133977. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  133978. * * 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
  133979. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  133980. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133981. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  133982. * * Remember you can only change the shape positions, not their number when updating a polygon
  133983. * @param name defines the name of the mesh
  133984. * @param options defines the options used to create the mesh
  133985. * @param scene defines the hosting scene
  133986. * @param earcutInjection can be used to inject your own earcut reference
  133987. * @returns the polygon mesh
  133988. */
  133989. static CreatePolygon(name: string, options: {
  133990. shape: Vector3[];
  133991. holes?: Vector3[][];
  133992. depth?: number;
  133993. faceUV?: Vector4[];
  133994. faceColors?: Color4[];
  133995. updatable?: boolean;
  133996. sideOrientation?: number;
  133997. frontUVs?: Vector4;
  133998. backUVs?: Vector4;
  133999. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  134000. /**
  134001. * Creates an extruded polygon mesh, with depth in the Y direction.
  134002. * * 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)
  134003. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134004. * @param name defines the name of the mesh
  134005. * @param options defines the options used to create the mesh
  134006. * @param scene defines the hosting scene
  134007. * @param earcutInjection can be used to inject your own earcut reference
  134008. * @returns the polygon mesh
  134009. */
  134010. static ExtrudePolygon(name: string, options: {
  134011. shape: Vector3[];
  134012. holes?: Vector3[][];
  134013. depth?: number;
  134014. faceUV?: Vector4[];
  134015. faceColors?: Color4[];
  134016. updatable?: boolean;
  134017. sideOrientation?: number;
  134018. frontUVs?: Vector4;
  134019. backUVs?: Vector4;
  134020. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  134021. }
  134022. }
  134023. declare module BABYLON {
  134024. /**
  134025. * Class containing static functions to help procedurally build meshes
  134026. */
  134027. export class LatheBuilder {
  134028. /**
  134029. * Creates lathe mesh.
  134030. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  134031. * * 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
  134032. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  134033. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  134034. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  134035. * * 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
  134036. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  134037. * * 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
  134038. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134039. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134040. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134041. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134042. * @param name defines the name of the mesh
  134043. * @param options defines the options used to create the mesh
  134044. * @param scene defines the hosting scene
  134045. * @returns the lathe mesh
  134046. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  134047. */
  134048. static CreateLathe(name: string, options: {
  134049. shape: Vector3[];
  134050. radius?: number;
  134051. tessellation?: number;
  134052. clip?: number;
  134053. arc?: number;
  134054. closed?: boolean;
  134055. updatable?: boolean;
  134056. sideOrientation?: number;
  134057. frontUVs?: Vector4;
  134058. backUVs?: Vector4;
  134059. cap?: number;
  134060. invertUV?: boolean;
  134061. }, scene?: Nullable<Scene>): Mesh;
  134062. }
  134063. }
  134064. declare module BABYLON {
  134065. /**
  134066. * Class containing static functions to help procedurally build meshes
  134067. */
  134068. export class TiledPlaneBuilder {
  134069. /**
  134070. * Creates a tiled plane mesh
  134071. * * The parameter `pattern` will, depending on value, do nothing or
  134072. * * * flip (reflect about central vertical) alternate tiles across and up
  134073. * * * flip every tile on alternate rows
  134074. * * * rotate (180 degs) alternate tiles across and up
  134075. * * * rotate every tile on alternate rows
  134076. * * * flip and rotate alternate tiles across and up
  134077. * * * flip and rotate every tile on alternate rows
  134078. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  134079. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  134080. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134081. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  134082. * * 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)
  134083. * * 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)
  134084. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  134085. * @param name defines the name of the mesh
  134086. * @param options defines the options used to create the mesh
  134087. * @param scene defines the hosting scene
  134088. * @returns the box mesh
  134089. */
  134090. static CreateTiledPlane(name: string, options: {
  134091. pattern?: number;
  134092. tileSize?: number;
  134093. tileWidth?: number;
  134094. tileHeight?: number;
  134095. size?: number;
  134096. width?: number;
  134097. height?: number;
  134098. alignHorizontal?: number;
  134099. alignVertical?: number;
  134100. sideOrientation?: number;
  134101. frontUVs?: Vector4;
  134102. backUVs?: Vector4;
  134103. updatable?: boolean;
  134104. }, scene?: Nullable<Scene>): Mesh;
  134105. }
  134106. }
  134107. declare module BABYLON {
  134108. /**
  134109. * Class containing static functions to help procedurally build meshes
  134110. */
  134111. export class TubeBuilder {
  134112. /**
  134113. * Creates a tube mesh.
  134114. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134115. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  134116. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  134117. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  134118. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  134119. * * 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)
  134120. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  134121. * * 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
  134122. * * 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
  134123. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134124. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134125. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134126. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134127. * @param name defines the name of the mesh
  134128. * @param options defines the options used to create the mesh
  134129. * @param scene defines the hosting scene
  134130. * @returns the tube mesh
  134131. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134132. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  134133. */
  134134. static CreateTube(name: string, options: {
  134135. path: Vector3[];
  134136. radius?: number;
  134137. tessellation?: number;
  134138. radiusFunction?: {
  134139. (i: number, distance: number): number;
  134140. };
  134141. cap?: number;
  134142. arc?: number;
  134143. updatable?: boolean;
  134144. sideOrientation?: number;
  134145. frontUVs?: Vector4;
  134146. backUVs?: Vector4;
  134147. instance?: Mesh;
  134148. invertUV?: boolean;
  134149. }, scene?: Nullable<Scene>): Mesh;
  134150. }
  134151. }
  134152. declare module BABYLON {
  134153. /**
  134154. * Class containing static functions to help procedurally build meshes
  134155. */
  134156. export class IcoSphereBuilder {
  134157. /**
  134158. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  134159. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  134160. * * 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`)
  134161. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  134162. * * 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
  134163. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134164. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134165. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134166. * @param name defines the name of the mesh
  134167. * @param options defines the options used to create the mesh
  134168. * @param scene defines the hosting scene
  134169. * @returns the icosahedron mesh
  134170. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  134171. */
  134172. static CreateIcoSphere(name: string, options: {
  134173. radius?: number;
  134174. radiusX?: number;
  134175. radiusY?: number;
  134176. radiusZ?: number;
  134177. flat?: boolean;
  134178. subdivisions?: number;
  134179. sideOrientation?: number;
  134180. frontUVs?: Vector4;
  134181. backUVs?: Vector4;
  134182. updatable?: boolean;
  134183. }, scene?: Nullable<Scene>): Mesh;
  134184. }
  134185. }
  134186. declare module BABYLON {
  134187. /**
  134188. * Class containing static functions to help procedurally build meshes
  134189. */
  134190. export class DecalBuilder {
  134191. /**
  134192. * Creates a decal mesh.
  134193. * 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
  134194. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  134195. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  134196. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  134197. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  134198. * @param name defines the name of the mesh
  134199. * @param sourceMesh defines the mesh where the decal must be applied
  134200. * @param options defines the options used to create the mesh
  134201. * @param scene defines the hosting scene
  134202. * @returns the decal mesh
  134203. * @see https://doc.babylonjs.com/how_to/decals
  134204. */
  134205. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  134206. position?: Vector3;
  134207. normal?: Vector3;
  134208. size?: Vector3;
  134209. angle?: number;
  134210. }): Mesh;
  134211. }
  134212. }
  134213. declare module BABYLON {
  134214. /**
  134215. * Class containing static functions to help procedurally build meshes
  134216. */
  134217. export class MeshBuilder {
  134218. /**
  134219. * Creates a box mesh
  134220. * * The parameter `size` sets the size (float) of each box side (default 1)
  134221. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  134222. * * 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)
  134223. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134224. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134225. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134226. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134227. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  134228. * @param name defines the name of the mesh
  134229. * @param options defines the options used to create the mesh
  134230. * @param scene defines the hosting scene
  134231. * @returns the box mesh
  134232. */
  134233. static CreateBox(name: string, options: {
  134234. size?: number;
  134235. width?: number;
  134236. height?: number;
  134237. depth?: number;
  134238. faceUV?: Vector4[];
  134239. faceColors?: Color4[];
  134240. sideOrientation?: number;
  134241. frontUVs?: Vector4;
  134242. backUVs?: Vector4;
  134243. updatable?: boolean;
  134244. }, scene?: Nullable<Scene>): Mesh;
  134245. /**
  134246. * Creates a tiled box mesh
  134247. * * faceTiles sets the pattern, tile size and number of tiles for a face
  134248. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134249. * @param name defines the name of the mesh
  134250. * @param options defines the options used to create the mesh
  134251. * @param scene defines the hosting scene
  134252. * @returns the tiled box mesh
  134253. */
  134254. static CreateTiledBox(name: string, options: {
  134255. pattern?: number;
  134256. size?: number;
  134257. width?: number;
  134258. height?: number;
  134259. depth: number;
  134260. tileSize?: number;
  134261. tileWidth?: number;
  134262. tileHeight?: number;
  134263. faceUV?: Vector4[];
  134264. faceColors?: Color4[];
  134265. alignHorizontal?: number;
  134266. alignVertical?: number;
  134267. sideOrientation?: number;
  134268. updatable?: boolean;
  134269. }, scene?: Nullable<Scene>): Mesh;
  134270. /**
  134271. * Creates a sphere mesh
  134272. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  134273. * * 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`)
  134274. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  134275. * * 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
  134276. * * 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)
  134277. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134278. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134279. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134280. * @param name defines the name of the mesh
  134281. * @param options defines the options used to create the mesh
  134282. * @param scene defines the hosting scene
  134283. * @returns the sphere mesh
  134284. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  134285. */
  134286. static CreateSphere(name: string, options: {
  134287. segments?: number;
  134288. diameter?: number;
  134289. diameterX?: number;
  134290. diameterY?: number;
  134291. diameterZ?: number;
  134292. arc?: number;
  134293. slice?: number;
  134294. sideOrientation?: number;
  134295. frontUVs?: Vector4;
  134296. backUVs?: Vector4;
  134297. updatable?: boolean;
  134298. }, scene?: Nullable<Scene>): Mesh;
  134299. /**
  134300. * Creates a plane polygonal mesh. By default, this is a disc
  134301. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  134302. * * 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
  134303. * * 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
  134304. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134305. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134306. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134307. * @param name defines the name of the mesh
  134308. * @param options defines the options used to create the mesh
  134309. * @param scene defines the hosting scene
  134310. * @returns the plane polygonal mesh
  134311. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  134312. */
  134313. static CreateDisc(name: string, options: {
  134314. radius?: number;
  134315. tessellation?: number;
  134316. arc?: number;
  134317. updatable?: boolean;
  134318. sideOrientation?: number;
  134319. frontUVs?: Vector4;
  134320. backUVs?: Vector4;
  134321. }, scene?: Nullable<Scene>): Mesh;
  134322. /**
  134323. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  134324. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  134325. * * 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`)
  134326. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  134327. * * 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
  134328. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134329. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134330. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134331. * @param name defines the name of the mesh
  134332. * @param options defines the options used to create the mesh
  134333. * @param scene defines the hosting scene
  134334. * @returns the icosahedron mesh
  134335. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  134336. */
  134337. static CreateIcoSphere(name: string, options: {
  134338. radius?: number;
  134339. radiusX?: number;
  134340. radiusY?: number;
  134341. radiusZ?: number;
  134342. flat?: boolean;
  134343. subdivisions?: number;
  134344. sideOrientation?: number;
  134345. frontUVs?: Vector4;
  134346. backUVs?: Vector4;
  134347. updatable?: boolean;
  134348. }, scene?: Nullable<Scene>): Mesh;
  134349. /**
  134350. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134351. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  134352. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  134353. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  134354. * * 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
  134355. * * 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
  134356. * * 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
  134357. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134358. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134359. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134360. * * 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
  134361. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  134362. * * 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
  134363. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  134364. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134365. * @param name defines the name of the mesh
  134366. * @param options defines the options used to create the mesh
  134367. * @param scene defines the hosting scene
  134368. * @returns the ribbon mesh
  134369. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  134370. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134371. */
  134372. static CreateRibbon(name: string, options: {
  134373. pathArray: Vector3[][];
  134374. closeArray?: boolean;
  134375. closePath?: boolean;
  134376. offset?: number;
  134377. updatable?: boolean;
  134378. sideOrientation?: number;
  134379. frontUVs?: Vector4;
  134380. backUVs?: Vector4;
  134381. instance?: Mesh;
  134382. invertUV?: boolean;
  134383. uvs?: Vector2[];
  134384. colors?: Color4[];
  134385. }, scene?: Nullable<Scene>): Mesh;
  134386. /**
  134387. * Creates a cylinder or a cone mesh
  134388. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  134389. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  134390. * * 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.
  134391. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  134392. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  134393. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  134394. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  134395. * * 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).
  134396. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  134397. * * 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).
  134398. * * 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
  134399. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  134400. * * 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
  134401. * * 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.
  134402. * * If `enclose` is false, a ring surface is one element.
  134403. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  134404. * * 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
  134405. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134406. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134407. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134408. * @param name defines the name of the mesh
  134409. * @param options defines the options used to create the mesh
  134410. * @param scene defines the hosting scene
  134411. * @returns the cylinder mesh
  134412. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  134413. */
  134414. static CreateCylinder(name: string, options: {
  134415. height?: number;
  134416. diameterTop?: number;
  134417. diameterBottom?: number;
  134418. diameter?: number;
  134419. tessellation?: number;
  134420. subdivisions?: number;
  134421. arc?: number;
  134422. faceColors?: Color4[];
  134423. faceUV?: Vector4[];
  134424. updatable?: boolean;
  134425. hasRings?: boolean;
  134426. enclose?: boolean;
  134427. cap?: number;
  134428. sideOrientation?: number;
  134429. frontUVs?: Vector4;
  134430. backUVs?: Vector4;
  134431. }, scene?: Nullable<Scene>): Mesh;
  134432. /**
  134433. * Creates a torus mesh
  134434. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  134435. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  134436. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  134437. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134438. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134439. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134440. * @param name defines the name of the mesh
  134441. * @param options defines the options used to create the mesh
  134442. * @param scene defines the hosting scene
  134443. * @returns the torus mesh
  134444. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  134445. */
  134446. static CreateTorus(name: string, options: {
  134447. diameter?: number;
  134448. thickness?: number;
  134449. tessellation?: number;
  134450. updatable?: boolean;
  134451. sideOrientation?: number;
  134452. frontUVs?: Vector4;
  134453. backUVs?: Vector4;
  134454. }, scene?: Nullable<Scene>): Mesh;
  134455. /**
  134456. * Creates a torus knot mesh
  134457. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  134458. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  134459. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  134460. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  134461. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134462. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134463. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134464. * @param name defines the name of the mesh
  134465. * @param options defines the options used to create the mesh
  134466. * @param scene defines the hosting scene
  134467. * @returns the torus knot mesh
  134468. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  134469. */
  134470. static CreateTorusKnot(name: string, options: {
  134471. radius?: number;
  134472. tube?: number;
  134473. radialSegments?: number;
  134474. tubularSegments?: number;
  134475. p?: number;
  134476. q?: number;
  134477. updatable?: boolean;
  134478. sideOrientation?: number;
  134479. frontUVs?: Vector4;
  134480. backUVs?: Vector4;
  134481. }, scene?: Nullable<Scene>): Mesh;
  134482. /**
  134483. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  134484. * * 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
  134485. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  134486. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  134487. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  134488. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  134489. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  134490. * * 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
  134491. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  134492. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134493. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  134494. * @param name defines the name of the new line system
  134495. * @param options defines the options used to create the line system
  134496. * @param scene defines the hosting scene
  134497. * @returns a new line system mesh
  134498. */
  134499. static CreateLineSystem(name: string, options: {
  134500. lines: Vector3[][];
  134501. updatable?: boolean;
  134502. instance?: Nullable<LinesMesh>;
  134503. colors?: Nullable<Color4[][]>;
  134504. useVertexAlpha?: boolean;
  134505. }, scene: Nullable<Scene>): LinesMesh;
  134506. /**
  134507. * Creates a line mesh
  134508. * 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
  134509. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  134510. * * The parameter `points` is an array successive Vector3
  134511. * * 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
  134512. * * The optional parameter `colors` is an array of successive Color4, one per line point
  134513. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  134514. * * When updating an instance, remember that only point positions can change, not the number of points
  134515. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134516. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  134517. * @param name defines the name of the new line system
  134518. * @param options defines the options used to create the line system
  134519. * @param scene defines the hosting scene
  134520. * @returns a new line mesh
  134521. */
  134522. static CreateLines(name: string, options: {
  134523. points: Vector3[];
  134524. updatable?: boolean;
  134525. instance?: Nullable<LinesMesh>;
  134526. colors?: Color4[];
  134527. useVertexAlpha?: boolean;
  134528. }, scene?: Nullable<Scene>): LinesMesh;
  134529. /**
  134530. * Creates a dashed line mesh
  134531. * * 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
  134532. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  134533. * * The parameter `points` is an array successive Vector3
  134534. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  134535. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  134536. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  134537. * * 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
  134538. * * When updating an instance, remember that only point positions can change, not the number of points
  134539. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134540. * @param name defines the name of the mesh
  134541. * @param options defines the options used to create the mesh
  134542. * @param scene defines the hosting scene
  134543. * @returns the dashed line mesh
  134544. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  134545. */
  134546. static CreateDashedLines(name: string, options: {
  134547. points: Vector3[];
  134548. dashSize?: number;
  134549. gapSize?: number;
  134550. dashNb?: number;
  134551. updatable?: boolean;
  134552. instance?: LinesMesh;
  134553. }, scene?: Nullable<Scene>): LinesMesh;
  134554. /**
  134555. * 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.
  134556. * * 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.
  134557. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  134558. * * 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.
  134559. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  134560. * * 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
  134561. * * 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
  134562. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  134563. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134564. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134565. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  134566. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134567. * @param name defines the name of the mesh
  134568. * @param options defines the options used to create the mesh
  134569. * @param scene defines the hosting scene
  134570. * @returns the extruded shape mesh
  134571. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134572. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  134573. */
  134574. static ExtrudeShape(name: string, options: {
  134575. shape: Vector3[];
  134576. path: Vector3[];
  134577. scale?: number;
  134578. rotation?: number;
  134579. cap?: number;
  134580. updatable?: boolean;
  134581. sideOrientation?: number;
  134582. frontUVs?: Vector4;
  134583. backUVs?: Vector4;
  134584. instance?: Mesh;
  134585. invertUV?: boolean;
  134586. }, scene?: Nullable<Scene>): Mesh;
  134587. /**
  134588. * Creates an custom extruded shape mesh.
  134589. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  134590. * * 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.
  134591. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  134592. * * 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
  134593. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  134594. * * 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
  134595. * * It must returns a float value that will be the scale value applied to the shape on each path point
  134596. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  134597. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  134598. * * 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
  134599. * * 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
  134600. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  134601. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134602. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134603. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134604. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134605. * @param name defines the name of the mesh
  134606. * @param options defines the options used to create the mesh
  134607. * @param scene defines the hosting scene
  134608. * @returns the custom extruded shape mesh
  134609. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  134610. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134611. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  134612. */
  134613. static ExtrudeShapeCustom(name: string, options: {
  134614. shape: Vector3[];
  134615. path: Vector3[];
  134616. scaleFunction?: any;
  134617. rotationFunction?: any;
  134618. ribbonCloseArray?: boolean;
  134619. ribbonClosePath?: boolean;
  134620. cap?: number;
  134621. updatable?: boolean;
  134622. sideOrientation?: number;
  134623. frontUVs?: Vector4;
  134624. backUVs?: Vector4;
  134625. instance?: Mesh;
  134626. invertUV?: boolean;
  134627. }, scene?: Nullable<Scene>): Mesh;
  134628. /**
  134629. * Creates lathe mesh.
  134630. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  134631. * * 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
  134632. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  134633. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  134634. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  134635. * * 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
  134636. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  134637. * * 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
  134638. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134639. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134640. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134641. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134642. * @param name defines the name of the mesh
  134643. * @param options defines the options used to create the mesh
  134644. * @param scene defines the hosting scene
  134645. * @returns the lathe mesh
  134646. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  134647. */
  134648. static CreateLathe(name: string, options: {
  134649. shape: Vector3[];
  134650. radius?: number;
  134651. tessellation?: number;
  134652. clip?: number;
  134653. arc?: number;
  134654. closed?: boolean;
  134655. updatable?: boolean;
  134656. sideOrientation?: number;
  134657. frontUVs?: Vector4;
  134658. backUVs?: Vector4;
  134659. cap?: number;
  134660. invertUV?: boolean;
  134661. }, scene?: Nullable<Scene>): Mesh;
  134662. /**
  134663. * Creates a tiled plane mesh
  134664. * * You can set a limited pattern arrangement with the tiles
  134665. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134666. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134667. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134668. * @param name defines the name of the mesh
  134669. * @param options defines the options used to create the mesh
  134670. * @param scene defines the hosting scene
  134671. * @returns the plane mesh
  134672. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  134673. */
  134674. static CreateTiledPlane(name: string, options: {
  134675. pattern?: number;
  134676. tileSize?: number;
  134677. tileWidth?: number;
  134678. tileHeight?: number;
  134679. size?: number;
  134680. width?: number;
  134681. height?: number;
  134682. alignHorizontal?: number;
  134683. alignVertical?: number;
  134684. sideOrientation?: number;
  134685. frontUVs?: Vector4;
  134686. backUVs?: Vector4;
  134687. updatable?: boolean;
  134688. }, scene?: Nullable<Scene>): Mesh;
  134689. /**
  134690. * Creates a plane mesh
  134691. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  134692. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  134693. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  134694. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134695. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134696. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134697. * @param name defines the name of the mesh
  134698. * @param options defines the options used to create the mesh
  134699. * @param scene defines the hosting scene
  134700. * @returns the plane mesh
  134701. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  134702. */
  134703. static CreatePlane(name: string, options: {
  134704. size?: number;
  134705. width?: number;
  134706. height?: number;
  134707. sideOrientation?: number;
  134708. frontUVs?: Vector4;
  134709. backUVs?: Vector4;
  134710. updatable?: boolean;
  134711. sourcePlane?: Plane;
  134712. }, scene?: Nullable<Scene>): Mesh;
  134713. /**
  134714. * Creates a ground mesh
  134715. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  134716. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  134717. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134718. * @param name defines the name of the mesh
  134719. * @param options defines the options used to create the mesh
  134720. * @param scene defines the hosting scene
  134721. * @returns the ground mesh
  134722. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  134723. */
  134724. static CreateGround(name: string, options: {
  134725. width?: number;
  134726. height?: number;
  134727. subdivisions?: number;
  134728. subdivisionsX?: number;
  134729. subdivisionsY?: number;
  134730. updatable?: boolean;
  134731. }, scene?: Nullable<Scene>): Mesh;
  134732. /**
  134733. * Creates a tiled ground mesh
  134734. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  134735. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  134736. * * 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
  134737. * * 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
  134738. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134739. * @param name defines the name of the mesh
  134740. * @param options defines the options used to create the mesh
  134741. * @param scene defines the hosting scene
  134742. * @returns the tiled ground mesh
  134743. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  134744. */
  134745. static CreateTiledGround(name: string, options: {
  134746. xmin: number;
  134747. zmin: number;
  134748. xmax: number;
  134749. zmax: number;
  134750. subdivisions?: {
  134751. w: number;
  134752. h: number;
  134753. };
  134754. precision?: {
  134755. w: number;
  134756. h: number;
  134757. };
  134758. updatable?: boolean;
  134759. }, scene?: Nullable<Scene>): Mesh;
  134760. /**
  134761. * Creates a ground mesh from a height map
  134762. * * The parameter `url` sets the URL of the height map image resource.
  134763. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  134764. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  134765. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  134766. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  134767. * * 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.
  134768. * * 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).
  134769. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  134770. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134771. * @param name defines the name of the mesh
  134772. * @param url defines the url to the height map
  134773. * @param options defines the options used to create the mesh
  134774. * @param scene defines the hosting scene
  134775. * @returns the ground mesh
  134776. * @see https://doc.babylonjs.com/babylon101/height_map
  134777. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  134778. */
  134779. static CreateGroundFromHeightMap(name: string, url: string, options: {
  134780. width?: number;
  134781. height?: number;
  134782. subdivisions?: number;
  134783. minHeight?: number;
  134784. maxHeight?: number;
  134785. colorFilter?: Color3;
  134786. alphaFilter?: number;
  134787. updatable?: boolean;
  134788. onReady?: (mesh: GroundMesh) => void;
  134789. }, scene?: Nullable<Scene>): GroundMesh;
  134790. /**
  134791. * Creates a polygon mesh
  134792. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  134793. * * 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
  134794. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  134795. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134796. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  134797. * * Remember you can only change the shape positions, not their number when updating a polygon
  134798. * @param name defines the name of the mesh
  134799. * @param options defines the options used to create the mesh
  134800. * @param scene defines the hosting scene
  134801. * @param earcutInjection can be used to inject your own earcut reference
  134802. * @returns the polygon mesh
  134803. */
  134804. static CreatePolygon(name: string, options: {
  134805. shape: Vector3[];
  134806. holes?: Vector3[][];
  134807. depth?: number;
  134808. faceUV?: Vector4[];
  134809. faceColors?: Color4[];
  134810. updatable?: boolean;
  134811. sideOrientation?: number;
  134812. frontUVs?: Vector4;
  134813. backUVs?: Vector4;
  134814. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  134815. /**
  134816. * Creates an extruded polygon mesh, with depth in the Y direction.
  134817. * * 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)
  134818. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134819. * @param name defines the name of the mesh
  134820. * @param options defines the options used to create the mesh
  134821. * @param scene defines the hosting scene
  134822. * @param earcutInjection can be used to inject your own earcut reference
  134823. * @returns the polygon mesh
  134824. */
  134825. static ExtrudePolygon(name: string, options: {
  134826. shape: Vector3[];
  134827. holes?: Vector3[][];
  134828. depth?: number;
  134829. faceUV?: Vector4[];
  134830. faceColors?: Color4[];
  134831. updatable?: boolean;
  134832. sideOrientation?: number;
  134833. frontUVs?: Vector4;
  134834. backUVs?: Vector4;
  134835. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  134836. /**
  134837. * Creates a tube mesh.
  134838. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134839. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  134840. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  134841. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  134842. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  134843. * * 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)
  134844. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  134845. * * 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
  134846. * * 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
  134847. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134848. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134849. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134850. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134851. * @param name defines the name of the mesh
  134852. * @param options defines the options used to create the mesh
  134853. * @param scene defines the hosting scene
  134854. * @returns the tube mesh
  134855. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134856. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  134857. */
  134858. static CreateTube(name: string, options: {
  134859. path: Vector3[];
  134860. radius?: number;
  134861. tessellation?: number;
  134862. radiusFunction?: {
  134863. (i: number, distance: number): number;
  134864. };
  134865. cap?: number;
  134866. arc?: number;
  134867. updatable?: boolean;
  134868. sideOrientation?: number;
  134869. frontUVs?: Vector4;
  134870. backUVs?: Vector4;
  134871. instance?: Mesh;
  134872. invertUV?: boolean;
  134873. }, scene?: Nullable<Scene>): Mesh;
  134874. /**
  134875. * Creates a polyhedron mesh
  134876. * * 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
  134877. * * The parameter `size` (positive float, default 1) sets the polygon size
  134878. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  134879. * * 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`
  134880. * * 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
  134881. * * 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)`)
  134882. * * 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
  134883. * * 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
  134884. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134885. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134886. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134887. * @param name defines the name of the mesh
  134888. * @param options defines the options used to create the mesh
  134889. * @param scene defines the hosting scene
  134890. * @returns the polyhedron mesh
  134891. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  134892. */
  134893. static CreatePolyhedron(name: string, options: {
  134894. type?: number;
  134895. size?: number;
  134896. sizeX?: number;
  134897. sizeY?: number;
  134898. sizeZ?: number;
  134899. custom?: any;
  134900. faceUV?: Vector4[];
  134901. faceColors?: Color4[];
  134902. flat?: boolean;
  134903. updatable?: boolean;
  134904. sideOrientation?: number;
  134905. frontUVs?: Vector4;
  134906. backUVs?: Vector4;
  134907. }, scene?: Nullable<Scene>): Mesh;
  134908. /**
  134909. * Creates a decal mesh.
  134910. * 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
  134911. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  134912. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  134913. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  134914. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  134915. * @param name defines the name of the mesh
  134916. * @param sourceMesh defines the mesh where the decal must be applied
  134917. * @param options defines the options used to create the mesh
  134918. * @param scene defines the hosting scene
  134919. * @returns the decal mesh
  134920. * @see https://doc.babylonjs.com/how_to/decals
  134921. */
  134922. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  134923. position?: Vector3;
  134924. normal?: Vector3;
  134925. size?: Vector3;
  134926. angle?: number;
  134927. }): Mesh;
  134928. }
  134929. }
  134930. declare module BABYLON {
  134931. /**
  134932. * A simplifier interface for future simplification implementations
  134933. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134934. */
  134935. export interface ISimplifier {
  134936. /**
  134937. * Simplification of a given mesh according to the given settings.
  134938. * Since this requires computation, it is assumed that the function runs async.
  134939. * @param settings The settings of the simplification, including quality and distance
  134940. * @param successCallback A callback that will be called after the mesh was simplified.
  134941. * @param errorCallback in case of an error, this callback will be called. optional.
  134942. */
  134943. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  134944. }
  134945. /**
  134946. * Expected simplification settings.
  134947. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  134948. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134949. */
  134950. export interface ISimplificationSettings {
  134951. /**
  134952. * Gets or sets the expected quality
  134953. */
  134954. quality: number;
  134955. /**
  134956. * Gets or sets the distance when this optimized version should be used
  134957. */
  134958. distance: number;
  134959. /**
  134960. * Gets an already optimized mesh
  134961. */
  134962. optimizeMesh?: boolean;
  134963. }
  134964. /**
  134965. * Class used to specify simplification options
  134966. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134967. */
  134968. export class SimplificationSettings implements ISimplificationSettings {
  134969. /** expected quality */
  134970. quality: number;
  134971. /** distance when this optimized version should be used */
  134972. distance: number;
  134973. /** already optimized mesh */
  134974. optimizeMesh?: boolean | undefined;
  134975. /**
  134976. * Creates a SimplificationSettings
  134977. * @param quality expected quality
  134978. * @param distance distance when this optimized version should be used
  134979. * @param optimizeMesh already optimized mesh
  134980. */
  134981. constructor(
  134982. /** expected quality */
  134983. quality: number,
  134984. /** distance when this optimized version should be used */
  134985. distance: number,
  134986. /** already optimized mesh */
  134987. optimizeMesh?: boolean | undefined);
  134988. }
  134989. /**
  134990. * Interface used to define a simplification task
  134991. */
  134992. export interface ISimplificationTask {
  134993. /**
  134994. * Array of settings
  134995. */
  134996. settings: Array<ISimplificationSettings>;
  134997. /**
  134998. * Simplification type
  134999. */
  135000. simplificationType: SimplificationType;
  135001. /**
  135002. * Mesh to simplify
  135003. */
  135004. mesh: Mesh;
  135005. /**
  135006. * Callback called on success
  135007. */
  135008. successCallback?: () => void;
  135009. /**
  135010. * Defines if parallel processing can be used
  135011. */
  135012. parallelProcessing: boolean;
  135013. }
  135014. /**
  135015. * Queue used to order the simplification tasks
  135016. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135017. */
  135018. export class SimplificationQueue {
  135019. private _simplificationArray;
  135020. /**
  135021. * Gets a boolean indicating that the process is still running
  135022. */
  135023. running: boolean;
  135024. /**
  135025. * Creates a new queue
  135026. */
  135027. constructor();
  135028. /**
  135029. * Adds a new simplification task
  135030. * @param task defines a task to add
  135031. */
  135032. addTask(task: ISimplificationTask): void;
  135033. /**
  135034. * Execute next task
  135035. */
  135036. executeNext(): void;
  135037. /**
  135038. * Execute a simplification task
  135039. * @param task defines the task to run
  135040. */
  135041. runSimplification(task: ISimplificationTask): void;
  135042. private getSimplifier;
  135043. }
  135044. /**
  135045. * The implemented types of simplification
  135046. * At the moment only Quadratic Error Decimation is implemented
  135047. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135048. */
  135049. export enum SimplificationType {
  135050. /** Quadratic error decimation */
  135051. QUADRATIC = 0
  135052. }
  135053. }
  135054. declare module BABYLON {
  135055. interface Scene {
  135056. /** @hidden (Backing field) */
  135057. _simplificationQueue: SimplificationQueue;
  135058. /**
  135059. * Gets or sets the simplification queue attached to the scene
  135060. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135061. */
  135062. simplificationQueue: SimplificationQueue;
  135063. }
  135064. interface Mesh {
  135065. /**
  135066. * Simplify the mesh according to the given array of settings.
  135067. * Function will return immediately and will simplify async
  135068. * @param settings a collection of simplification settings
  135069. * @param parallelProcessing should all levels calculate parallel or one after the other
  135070. * @param simplificationType the type of simplification to run
  135071. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  135072. * @returns the current mesh
  135073. */
  135074. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  135075. }
  135076. /**
  135077. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  135078. * created in a scene
  135079. */
  135080. export class SimplicationQueueSceneComponent implements ISceneComponent {
  135081. /**
  135082. * The component name helpfull to identify the component in the list of scene components.
  135083. */
  135084. readonly name: string;
  135085. /**
  135086. * The scene the component belongs to.
  135087. */
  135088. scene: Scene;
  135089. /**
  135090. * Creates a new instance of the component for the given scene
  135091. * @param scene Defines the scene to register the component in
  135092. */
  135093. constructor(scene: Scene);
  135094. /**
  135095. * Registers the component in a given scene
  135096. */
  135097. register(): void;
  135098. /**
  135099. * Rebuilds the elements related to this component in case of
  135100. * context lost for instance.
  135101. */
  135102. rebuild(): void;
  135103. /**
  135104. * Disposes the component and the associated ressources
  135105. */
  135106. dispose(): void;
  135107. private _beforeCameraUpdate;
  135108. }
  135109. }
  135110. declare module BABYLON {
  135111. /**
  135112. * Navigation plugin interface to add navigation constrained by a navigation mesh
  135113. */
  135114. export interface INavigationEnginePlugin {
  135115. /**
  135116. * plugin name
  135117. */
  135118. name: string;
  135119. /**
  135120. * Creates a navigation mesh
  135121. * @param meshes array of all the geometry used to compute the navigatio mesh
  135122. * @param parameters bunch of parameters used to filter geometry
  135123. */
  135124. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  135125. /**
  135126. * Create a navigation mesh debug mesh
  135127. * @param scene is where the mesh will be added
  135128. * @returns debug display mesh
  135129. */
  135130. createDebugNavMesh(scene: Scene): Mesh;
  135131. /**
  135132. * Get a navigation mesh constrained position, closest to the parameter position
  135133. * @param position world position
  135134. * @returns the closest point to position constrained by the navigation mesh
  135135. */
  135136. getClosestPoint(position: Vector3): Vector3;
  135137. /**
  135138. * Get a navigation mesh constrained position, within a particular radius
  135139. * @param position world position
  135140. * @param maxRadius the maximum distance to the constrained world position
  135141. * @returns the closest point to position constrained by the navigation mesh
  135142. */
  135143. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  135144. /**
  135145. * Compute the final position from a segment made of destination-position
  135146. * @param position world position
  135147. * @param destination world position
  135148. * @returns the resulting point along the navmesh
  135149. */
  135150. moveAlong(position: Vector3, destination: Vector3): Vector3;
  135151. /**
  135152. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  135153. * @param start world position
  135154. * @param end world position
  135155. * @returns array containing world position composing the path
  135156. */
  135157. computePath(start: Vector3, end: Vector3): Vector3[];
  135158. /**
  135159. * If this plugin is supported
  135160. * @returns true if plugin is supported
  135161. */
  135162. isSupported(): boolean;
  135163. /**
  135164. * Create a new Crowd so you can add agents
  135165. * @param maxAgents the maximum agent count in the crowd
  135166. * @param maxAgentRadius the maximum radius an agent can have
  135167. * @param scene to attach the crowd to
  135168. * @returns the crowd you can add agents to
  135169. */
  135170. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  135171. /**
  135172. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135173. * The queries will try to find a solution within those bounds
  135174. * default is (1,1,1)
  135175. * @param extent x,y,z value that define the extent around the queries point of reference
  135176. */
  135177. setDefaultQueryExtent(extent: Vector3): void;
  135178. /**
  135179. * Get the Bounding box extent specified by setDefaultQueryExtent
  135180. * @returns the box extent values
  135181. */
  135182. getDefaultQueryExtent(): Vector3;
  135183. /**
  135184. * Release all resources
  135185. */
  135186. dispose(): void;
  135187. }
  135188. /**
  135189. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  135190. */
  135191. export interface ICrowd {
  135192. /**
  135193. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  135194. * You can attach anything to that node. The node position is updated in the scene update tick.
  135195. * @param pos world position that will be constrained by the navigation mesh
  135196. * @param parameters agent parameters
  135197. * @param transform hooked to the agent that will be update by the scene
  135198. * @returns agent index
  135199. */
  135200. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  135201. /**
  135202. * Returns the agent position in world space
  135203. * @param index agent index returned by addAgent
  135204. * @returns world space position
  135205. */
  135206. getAgentPosition(index: number): Vector3;
  135207. /**
  135208. * Gets the agent velocity in world space
  135209. * @param index agent index returned by addAgent
  135210. * @returns world space velocity
  135211. */
  135212. getAgentVelocity(index: number): Vector3;
  135213. /**
  135214. * remove a particular agent previously created
  135215. * @param index agent index returned by addAgent
  135216. */
  135217. removeAgent(index: number): void;
  135218. /**
  135219. * get the list of all agents attached to this crowd
  135220. * @returns list of agent indices
  135221. */
  135222. getAgents(): number[];
  135223. /**
  135224. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  135225. * @param deltaTime in seconds
  135226. */
  135227. update(deltaTime: number): void;
  135228. /**
  135229. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  135230. * @param index agent index returned by addAgent
  135231. * @param destination targeted world position
  135232. */
  135233. agentGoto(index: number, destination: Vector3): void;
  135234. /**
  135235. * Teleport the agent to a new position
  135236. * @param index agent index returned by addAgent
  135237. * @param destination targeted world position
  135238. */
  135239. agentTeleport(index: number, destination: Vector3): void;
  135240. /**
  135241. * Update agent parameters
  135242. * @param index agent index returned by addAgent
  135243. * @param parameters agent parameters
  135244. */
  135245. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  135246. /**
  135247. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135248. * The queries will try to find a solution within those bounds
  135249. * default is (1,1,1)
  135250. * @param extent x,y,z value that define the extent around the queries point of reference
  135251. */
  135252. setDefaultQueryExtent(extent: Vector3): void;
  135253. /**
  135254. * Get the Bounding box extent specified by setDefaultQueryExtent
  135255. * @returns the box extent values
  135256. */
  135257. getDefaultQueryExtent(): Vector3;
  135258. /**
  135259. * Release all resources
  135260. */
  135261. dispose(): void;
  135262. }
  135263. /**
  135264. * Configures an agent
  135265. */
  135266. export interface IAgentParameters {
  135267. /**
  135268. * Agent radius. [Limit: >= 0]
  135269. */
  135270. radius: number;
  135271. /**
  135272. * Agent height. [Limit: > 0]
  135273. */
  135274. height: number;
  135275. /**
  135276. * Maximum allowed acceleration. [Limit: >= 0]
  135277. */
  135278. maxAcceleration: number;
  135279. /**
  135280. * Maximum allowed speed. [Limit: >= 0]
  135281. */
  135282. maxSpeed: number;
  135283. /**
  135284. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  135285. */
  135286. collisionQueryRange: number;
  135287. /**
  135288. * The path visibility optimization range. [Limit: > 0]
  135289. */
  135290. pathOptimizationRange: number;
  135291. /**
  135292. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  135293. */
  135294. separationWeight: number;
  135295. }
  135296. /**
  135297. * Configures the navigation mesh creation
  135298. */
  135299. export interface INavMeshParameters {
  135300. /**
  135301. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  135302. */
  135303. cs: number;
  135304. /**
  135305. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  135306. */
  135307. ch: number;
  135308. /**
  135309. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  135310. */
  135311. walkableSlopeAngle: number;
  135312. /**
  135313. * Minimum floor to 'ceiling' height that will still allow the floor area to
  135314. * be considered walkable. [Limit: >= 3] [Units: vx]
  135315. */
  135316. walkableHeight: number;
  135317. /**
  135318. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  135319. */
  135320. walkableClimb: number;
  135321. /**
  135322. * The distance to erode/shrink the walkable area of the heightfield away from
  135323. * obstructions. [Limit: >=0] [Units: vx]
  135324. */
  135325. walkableRadius: number;
  135326. /**
  135327. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  135328. */
  135329. maxEdgeLen: number;
  135330. /**
  135331. * The maximum distance a simplfied contour's border edges should deviate
  135332. * the original raw contour. [Limit: >=0] [Units: vx]
  135333. */
  135334. maxSimplificationError: number;
  135335. /**
  135336. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  135337. */
  135338. minRegionArea: number;
  135339. /**
  135340. * Any regions with a span count smaller than this value will, if possible,
  135341. * be merged with larger regions. [Limit: >=0] [Units: vx]
  135342. */
  135343. mergeRegionArea: number;
  135344. /**
  135345. * The maximum number of vertices allowed for polygons generated during the
  135346. * contour to polygon conversion process. [Limit: >= 3]
  135347. */
  135348. maxVertsPerPoly: number;
  135349. /**
  135350. * Sets the sampling distance to use when generating the detail mesh.
  135351. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  135352. */
  135353. detailSampleDist: number;
  135354. /**
  135355. * The maximum distance the detail mesh surface should deviate from heightfield
  135356. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  135357. */
  135358. detailSampleMaxError: number;
  135359. }
  135360. }
  135361. declare module BABYLON {
  135362. /**
  135363. * RecastJS navigation plugin
  135364. */
  135365. export class RecastJSPlugin implements INavigationEnginePlugin {
  135366. /**
  135367. * Reference to the Recast library
  135368. */
  135369. bjsRECAST: any;
  135370. /**
  135371. * plugin name
  135372. */
  135373. name: string;
  135374. /**
  135375. * the first navmesh created. We might extend this to support multiple navmeshes
  135376. */
  135377. navMesh: any;
  135378. /**
  135379. * Initializes the recastJS plugin
  135380. * @param recastInjection can be used to inject your own recast reference
  135381. */
  135382. constructor(recastInjection?: any);
  135383. /**
  135384. * Creates a navigation mesh
  135385. * @param meshes array of all the geometry used to compute the navigatio mesh
  135386. * @param parameters bunch of parameters used to filter geometry
  135387. */
  135388. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  135389. /**
  135390. * Create a navigation mesh debug mesh
  135391. * @param scene is where the mesh will be added
  135392. * @returns debug display mesh
  135393. */
  135394. createDebugNavMesh(scene: Scene): Mesh;
  135395. /**
  135396. * Get a navigation mesh constrained position, closest to the parameter position
  135397. * @param position world position
  135398. * @returns the closest point to position constrained by the navigation mesh
  135399. */
  135400. getClosestPoint(position: Vector3): Vector3;
  135401. /**
  135402. * Get a navigation mesh constrained position, within a particular radius
  135403. * @param position world position
  135404. * @param maxRadius the maximum distance to the constrained world position
  135405. * @returns the closest point to position constrained by the navigation mesh
  135406. */
  135407. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  135408. /**
  135409. * Compute the final position from a segment made of destination-position
  135410. * @param position world position
  135411. * @param destination world position
  135412. * @returns the resulting point along the navmesh
  135413. */
  135414. moveAlong(position: Vector3, destination: Vector3): Vector3;
  135415. /**
  135416. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  135417. * @param start world position
  135418. * @param end world position
  135419. * @returns array containing world position composing the path
  135420. */
  135421. computePath(start: Vector3, end: Vector3): Vector3[];
  135422. /**
  135423. * Create a new Crowd so you can add agents
  135424. * @param maxAgents the maximum agent count in the crowd
  135425. * @param maxAgentRadius the maximum radius an agent can have
  135426. * @param scene to attach the crowd to
  135427. * @returns the crowd you can add agents to
  135428. */
  135429. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  135430. /**
  135431. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135432. * The queries will try to find a solution within those bounds
  135433. * default is (1,1,1)
  135434. * @param extent x,y,z value that define the extent around the queries point of reference
  135435. */
  135436. setDefaultQueryExtent(extent: Vector3): void;
  135437. /**
  135438. * Get the Bounding box extent specified by setDefaultQueryExtent
  135439. * @returns the box extent values
  135440. */
  135441. getDefaultQueryExtent(): Vector3;
  135442. /**
  135443. * Disposes
  135444. */
  135445. dispose(): void;
  135446. /**
  135447. * If this plugin is supported
  135448. * @returns true if plugin is supported
  135449. */
  135450. isSupported(): boolean;
  135451. }
  135452. /**
  135453. * Recast detour crowd implementation
  135454. */
  135455. export class RecastJSCrowd implements ICrowd {
  135456. /**
  135457. * Recast/detour plugin
  135458. */
  135459. bjsRECASTPlugin: RecastJSPlugin;
  135460. /**
  135461. * Link to the detour crowd
  135462. */
  135463. recastCrowd: any;
  135464. /**
  135465. * One transform per agent
  135466. */
  135467. transforms: TransformNode[];
  135468. /**
  135469. * All agents created
  135470. */
  135471. agents: number[];
  135472. /**
  135473. * Link to the scene is kept to unregister the crowd from the scene
  135474. */
  135475. private _scene;
  135476. /**
  135477. * Observer for crowd updates
  135478. */
  135479. private _onBeforeAnimationsObserver;
  135480. /**
  135481. * Constructor
  135482. * @param plugin recastJS plugin
  135483. * @param maxAgents the maximum agent count in the crowd
  135484. * @param maxAgentRadius the maximum radius an agent can have
  135485. * @param scene to attach the crowd to
  135486. * @returns the crowd you can add agents to
  135487. */
  135488. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  135489. /**
  135490. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  135491. * You can attach anything to that node. The node position is updated in the scene update tick.
  135492. * @param pos world position that will be constrained by the navigation mesh
  135493. * @param parameters agent parameters
  135494. * @param transform hooked to the agent that will be update by the scene
  135495. * @returns agent index
  135496. */
  135497. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  135498. /**
  135499. * Returns the agent position in world space
  135500. * @param index agent index returned by addAgent
  135501. * @returns world space position
  135502. */
  135503. getAgentPosition(index: number): Vector3;
  135504. /**
  135505. * Returns the agent velocity in world space
  135506. * @param index agent index returned by addAgent
  135507. * @returns world space velocity
  135508. */
  135509. getAgentVelocity(index: number): Vector3;
  135510. /**
  135511. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  135512. * @param index agent index returned by addAgent
  135513. * @param destination targeted world position
  135514. */
  135515. agentGoto(index: number, destination: Vector3): void;
  135516. /**
  135517. * Teleport the agent to a new position
  135518. * @param index agent index returned by addAgent
  135519. * @param destination targeted world position
  135520. */
  135521. agentTeleport(index: number, destination: Vector3): void;
  135522. /**
  135523. * Update agent parameters
  135524. * @param index agent index returned by addAgent
  135525. * @param parameters agent parameters
  135526. */
  135527. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  135528. /**
  135529. * remove a particular agent previously created
  135530. * @param index agent index returned by addAgent
  135531. */
  135532. removeAgent(index: number): void;
  135533. /**
  135534. * get the list of all agents attached to this crowd
  135535. * @returns list of agent indices
  135536. */
  135537. getAgents(): number[];
  135538. /**
  135539. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  135540. * @param deltaTime in seconds
  135541. */
  135542. update(deltaTime: number): void;
  135543. /**
  135544. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135545. * The queries will try to find a solution within those bounds
  135546. * default is (1,1,1)
  135547. * @param extent x,y,z value that define the extent around the queries point of reference
  135548. */
  135549. setDefaultQueryExtent(extent: Vector3): void;
  135550. /**
  135551. * Get the Bounding box extent specified by setDefaultQueryExtent
  135552. * @returns the box extent values
  135553. */
  135554. getDefaultQueryExtent(): Vector3;
  135555. /**
  135556. * Release all resources
  135557. */
  135558. dispose(): void;
  135559. }
  135560. }
  135561. declare module BABYLON {
  135562. /**
  135563. * Class used to enable access to IndexedDB
  135564. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  135565. */
  135566. export class Database implements IOfflineProvider {
  135567. private _callbackManifestChecked;
  135568. private _currentSceneUrl;
  135569. private _db;
  135570. private _enableSceneOffline;
  135571. private _enableTexturesOffline;
  135572. private _manifestVersionFound;
  135573. private _mustUpdateRessources;
  135574. private _hasReachedQuota;
  135575. private _isSupported;
  135576. private _idbFactory;
  135577. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  135578. private static IsUASupportingBlobStorage;
  135579. /**
  135580. * Gets a boolean indicating if Database storate is enabled (off by default)
  135581. */
  135582. static IDBStorageEnabled: boolean;
  135583. /**
  135584. * Gets a boolean indicating if scene must be saved in the database
  135585. */
  135586. get enableSceneOffline(): boolean;
  135587. /**
  135588. * Gets a boolean indicating if textures must be saved in the database
  135589. */
  135590. get enableTexturesOffline(): boolean;
  135591. /**
  135592. * Creates a new Database
  135593. * @param urlToScene defines the url to load the scene
  135594. * @param callbackManifestChecked defines the callback to use when manifest is checked
  135595. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  135596. */
  135597. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  135598. private static _ParseURL;
  135599. private static _ReturnFullUrlLocation;
  135600. private _checkManifestFile;
  135601. /**
  135602. * Open the database and make it available
  135603. * @param successCallback defines the callback to call on success
  135604. * @param errorCallback defines the callback to call on error
  135605. */
  135606. open(successCallback: () => void, errorCallback: () => void): void;
  135607. /**
  135608. * Loads an image from the database
  135609. * @param url defines the url to load from
  135610. * @param image defines the target DOM image
  135611. */
  135612. loadImage(url: string, image: HTMLImageElement): void;
  135613. private _loadImageFromDBAsync;
  135614. private _saveImageIntoDBAsync;
  135615. private _checkVersionFromDB;
  135616. private _loadVersionFromDBAsync;
  135617. private _saveVersionIntoDBAsync;
  135618. /**
  135619. * Loads a file from database
  135620. * @param url defines the URL to load from
  135621. * @param sceneLoaded defines a callback to call on success
  135622. * @param progressCallBack defines a callback to call when progress changed
  135623. * @param errorCallback defines a callback to call on error
  135624. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  135625. */
  135626. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  135627. private _loadFileAsync;
  135628. private _saveFileAsync;
  135629. /**
  135630. * Validates if xhr data is correct
  135631. * @param xhr defines the request to validate
  135632. * @param dataType defines the expected data type
  135633. * @returns true if data is correct
  135634. */
  135635. private static _ValidateXHRData;
  135636. }
  135637. }
  135638. declare module BABYLON {
  135639. /** @hidden */
  135640. export var gpuUpdateParticlesPixelShader: {
  135641. name: string;
  135642. shader: string;
  135643. };
  135644. }
  135645. declare module BABYLON {
  135646. /** @hidden */
  135647. export var gpuUpdateParticlesVertexShader: {
  135648. name: string;
  135649. shader: string;
  135650. };
  135651. }
  135652. declare module BABYLON {
  135653. /** @hidden */
  135654. export var clipPlaneFragmentDeclaration2: {
  135655. name: string;
  135656. shader: string;
  135657. };
  135658. }
  135659. declare module BABYLON {
  135660. /** @hidden */
  135661. export var gpuRenderParticlesPixelShader: {
  135662. name: string;
  135663. shader: string;
  135664. };
  135665. }
  135666. declare module BABYLON {
  135667. /** @hidden */
  135668. export var clipPlaneVertexDeclaration2: {
  135669. name: string;
  135670. shader: string;
  135671. };
  135672. }
  135673. declare module BABYLON {
  135674. /** @hidden */
  135675. export var gpuRenderParticlesVertexShader: {
  135676. name: string;
  135677. shader: string;
  135678. };
  135679. }
  135680. declare module BABYLON {
  135681. /**
  135682. * This represents a GPU particle system in Babylon
  135683. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  135684. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  135685. */
  135686. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  135687. /**
  135688. * The layer mask we are rendering the particles through.
  135689. */
  135690. layerMask: number;
  135691. private _capacity;
  135692. private _activeCount;
  135693. private _currentActiveCount;
  135694. private _accumulatedCount;
  135695. private _renderEffect;
  135696. private _updateEffect;
  135697. private _buffer0;
  135698. private _buffer1;
  135699. private _spriteBuffer;
  135700. private _updateVAO;
  135701. private _renderVAO;
  135702. private _targetIndex;
  135703. private _sourceBuffer;
  135704. private _targetBuffer;
  135705. private _engine;
  135706. private _currentRenderId;
  135707. private _started;
  135708. private _stopped;
  135709. private _timeDelta;
  135710. private _randomTexture;
  135711. private _randomTexture2;
  135712. private _attributesStrideSize;
  135713. private _updateEffectOptions;
  135714. private _randomTextureSize;
  135715. private _actualFrame;
  135716. private readonly _rawTextureWidth;
  135717. /**
  135718. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  135719. */
  135720. static get IsSupported(): boolean;
  135721. /**
  135722. * An event triggered when the system is disposed.
  135723. */
  135724. onDisposeObservable: Observable<GPUParticleSystem>;
  135725. /**
  135726. * Gets the maximum number of particles active at the same time.
  135727. * @returns The max number of active particles.
  135728. */
  135729. getCapacity(): number;
  135730. /**
  135731. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  135732. * to override the particles.
  135733. */
  135734. forceDepthWrite: boolean;
  135735. /**
  135736. * Gets or set the number of active particles
  135737. */
  135738. get activeParticleCount(): number;
  135739. set activeParticleCount(value: number);
  135740. private _preWarmDone;
  135741. /**
  135742. * Is this system ready to be used/rendered
  135743. * @return true if the system is ready
  135744. */
  135745. isReady(): boolean;
  135746. /**
  135747. * Gets if the system has been started. (Note: this will still be true after stop is called)
  135748. * @returns True if it has been started, otherwise false.
  135749. */
  135750. isStarted(): boolean;
  135751. /**
  135752. * Starts the particle system and begins to emit
  135753. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  135754. */
  135755. start(delay?: number): void;
  135756. /**
  135757. * Stops the particle system.
  135758. */
  135759. stop(): void;
  135760. /**
  135761. * Remove all active particles
  135762. */
  135763. reset(): void;
  135764. /**
  135765. * Returns the string "GPUParticleSystem"
  135766. * @returns a string containing the class name
  135767. */
  135768. getClassName(): string;
  135769. private _colorGradientsTexture;
  135770. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  135771. /**
  135772. * Adds a new color gradient
  135773. * @param gradient defines the gradient to use (between 0 and 1)
  135774. * @param color1 defines the color to affect to the specified gradient
  135775. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  135776. * @returns the current particle system
  135777. */
  135778. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  135779. /**
  135780. * Remove a specific color gradient
  135781. * @param gradient defines the gradient to remove
  135782. * @returns the current particle system
  135783. */
  135784. removeColorGradient(gradient: number): GPUParticleSystem;
  135785. private _angularSpeedGradientsTexture;
  135786. private _sizeGradientsTexture;
  135787. private _velocityGradientsTexture;
  135788. private _limitVelocityGradientsTexture;
  135789. private _dragGradientsTexture;
  135790. private _addFactorGradient;
  135791. /**
  135792. * Adds a new size gradient
  135793. * @param gradient defines the gradient to use (between 0 and 1)
  135794. * @param factor defines the size factor to affect to the specified gradient
  135795. * @returns the current particle system
  135796. */
  135797. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  135798. /**
  135799. * Remove a specific size gradient
  135800. * @param gradient defines the gradient to remove
  135801. * @returns the current particle system
  135802. */
  135803. removeSizeGradient(gradient: number): GPUParticleSystem;
  135804. /**
  135805. * Adds a new angular speed gradient
  135806. * @param gradient defines the gradient to use (between 0 and 1)
  135807. * @param factor defines the angular speed to affect to the specified gradient
  135808. * @returns the current particle system
  135809. */
  135810. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  135811. /**
  135812. * Remove a specific angular speed gradient
  135813. * @param gradient defines the gradient to remove
  135814. * @returns the current particle system
  135815. */
  135816. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  135817. /**
  135818. * Adds a new velocity gradient
  135819. * @param gradient defines the gradient to use (between 0 and 1)
  135820. * @param factor defines the velocity to affect to the specified gradient
  135821. * @returns the current particle system
  135822. */
  135823. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  135824. /**
  135825. * Remove a specific velocity gradient
  135826. * @param gradient defines the gradient to remove
  135827. * @returns the current particle system
  135828. */
  135829. removeVelocityGradient(gradient: number): GPUParticleSystem;
  135830. /**
  135831. * Adds a new limit velocity gradient
  135832. * @param gradient defines the gradient to use (between 0 and 1)
  135833. * @param factor defines the limit velocity value to affect to the specified gradient
  135834. * @returns the current particle system
  135835. */
  135836. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  135837. /**
  135838. * Remove a specific limit velocity gradient
  135839. * @param gradient defines the gradient to remove
  135840. * @returns the current particle system
  135841. */
  135842. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  135843. /**
  135844. * Adds a new drag gradient
  135845. * @param gradient defines the gradient to use (between 0 and 1)
  135846. * @param factor defines the drag value to affect to the specified gradient
  135847. * @returns the current particle system
  135848. */
  135849. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  135850. /**
  135851. * Remove a specific drag gradient
  135852. * @param gradient defines the gradient to remove
  135853. * @returns the current particle system
  135854. */
  135855. removeDragGradient(gradient: number): GPUParticleSystem;
  135856. /**
  135857. * Not supported by GPUParticleSystem
  135858. * @param gradient defines the gradient to use (between 0 and 1)
  135859. * @param factor defines the emit rate value to affect to the specified gradient
  135860. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  135861. * @returns the current particle system
  135862. */
  135863. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  135864. /**
  135865. * Not supported by GPUParticleSystem
  135866. * @param gradient defines the gradient to remove
  135867. * @returns the current particle system
  135868. */
  135869. removeEmitRateGradient(gradient: number): IParticleSystem;
  135870. /**
  135871. * Not supported by GPUParticleSystem
  135872. * @param gradient defines the gradient to use (between 0 and 1)
  135873. * @param factor defines the start size value to affect to the specified gradient
  135874. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  135875. * @returns the current particle system
  135876. */
  135877. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  135878. /**
  135879. * Not supported by GPUParticleSystem
  135880. * @param gradient defines the gradient to remove
  135881. * @returns the current particle system
  135882. */
  135883. removeStartSizeGradient(gradient: number): IParticleSystem;
  135884. /**
  135885. * Not supported by GPUParticleSystem
  135886. * @param gradient defines the gradient to use (between 0 and 1)
  135887. * @param min defines the color remap minimal range
  135888. * @param max defines the color remap maximal range
  135889. * @returns the current particle system
  135890. */
  135891. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  135892. /**
  135893. * Not supported by GPUParticleSystem
  135894. * @param gradient defines the gradient to remove
  135895. * @returns the current particle system
  135896. */
  135897. removeColorRemapGradient(): IParticleSystem;
  135898. /**
  135899. * Not supported by GPUParticleSystem
  135900. * @param gradient defines the gradient to use (between 0 and 1)
  135901. * @param min defines the alpha remap minimal range
  135902. * @param max defines the alpha remap maximal range
  135903. * @returns the current particle system
  135904. */
  135905. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  135906. /**
  135907. * Not supported by GPUParticleSystem
  135908. * @param gradient defines the gradient to remove
  135909. * @returns the current particle system
  135910. */
  135911. removeAlphaRemapGradient(): IParticleSystem;
  135912. /**
  135913. * Not supported by GPUParticleSystem
  135914. * @param gradient defines the gradient to use (between 0 and 1)
  135915. * @param color defines the color to affect to the specified gradient
  135916. * @returns the current particle system
  135917. */
  135918. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  135919. /**
  135920. * Not supported by GPUParticleSystem
  135921. * @param gradient defines the gradient to remove
  135922. * @returns the current particle system
  135923. */
  135924. removeRampGradient(): IParticleSystem;
  135925. /**
  135926. * Not supported by GPUParticleSystem
  135927. * @returns the list of ramp gradients
  135928. */
  135929. getRampGradients(): Nullable<Array<Color3Gradient>>;
  135930. /**
  135931. * Not supported by GPUParticleSystem
  135932. * Gets or sets a boolean indicating that ramp gradients must be used
  135933. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  135934. */
  135935. get useRampGradients(): boolean;
  135936. set useRampGradients(value: boolean);
  135937. /**
  135938. * Not supported by GPUParticleSystem
  135939. * @param gradient defines the gradient to use (between 0 and 1)
  135940. * @param factor defines the life time factor to affect to the specified gradient
  135941. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  135942. * @returns the current particle system
  135943. */
  135944. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  135945. /**
  135946. * Not supported by GPUParticleSystem
  135947. * @param gradient defines the gradient to remove
  135948. * @returns the current particle system
  135949. */
  135950. removeLifeTimeGradient(gradient: number): IParticleSystem;
  135951. /**
  135952. * Instantiates a GPU particle system.
  135953. * 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.
  135954. * @param name The name of the particle system
  135955. * @param options The options used to create the system
  135956. * @param scene The scene the particle system belongs to
  135957. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  135958. */
  135959. constructor(name: string, options: Partial<{
  135960. capacity: number;
  135961. randomTextureSize: number;
  135962. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  135963. protected _reset(): void;
  135964. private _createUpdateVAO;
  135965. private _createRenderVAO;
  135966. private _initialize;
  135967. /** @hidden */
  135968. _recreateUpdateEffect(): void;
  135969. /** @hidden */
  135970. _recreateRenderEffect(): void;
  135971. /**
  135972. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  135973. * @param preWarm defines if we are in the pre-warmimg phase
  135974. */
  135975. animate(preWarm?: boolean): void;
  135976. private _createFactorGradientTexture;
  135977. private _createSizeGradientTexture;
  135978. private _createAngularSpeedGradientTexture;
  135979. private _createVelocityGradientTexture;
  135980. private _createLimitVelocityGradientTexture;
  135981. private _createDragGradientTexture;
  135982. private _createColorGradientTexture;
  135983. /**
  135984. * Renders the particle system in its current state
  135985. * @param preWarm defines if the system should only update the particles but not render them
  135986. * @returns the current number of particles
  135987. */
  135988. render(preWarm?: boolean): number;
  135989. /**
  135990. * Rebuilds the particle system
  135991. */
  135992. rebuild(): void;
  135993. private _releaseBuffers;
  135994. private _releaseVAOs;
  135995. /**
  135996. * Disposes the particle system and free the associated resources
  135997. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  135998. */
  135999. dispose(disposeTexture?: boolean): void;
  136000. /**
  136001. * Clones the particle system.
  136002. * @param name The name of the cloned object
  136003. * @param newEmitter The new emitter to use
  136004. * @returns the cloned particle system
  136005. */
  136006. clone(name: string, newEmitter: any): GPUParticleSystem;
  136007. /**
  136008. * Serializes the particle system to a JSON object.
  136009. * @returns the JSON object
  136010. */
  136011. serialize(): any;
  136012. /**
  136013. * Parses a JSON object to create a GPU particle system.
  136014. * @param parsedParticleSystem The JSON object to parse
  136015. * @param scene The scene to create the particle system in
  136016. * @param rootUrl The root url to use to load external dependencies like texture
  136017. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  136018. * @returns the parsed GPU particle system
  136019. */
  136020. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  136021. }
  136022. }
  136023. declare module BABYLON {
  136024. /**
  136025. * Represents a set of particle systems working together to create a specific effect
  136026. */
  136027. export class ParticleSystemSet implements IDisposable {
  136028. /**
  136029. * Gets or sets base Assets URL
  136030. */
  136031. static BaseAssetsUrl: string;
  136032. private _emitterCreationOptions;
  136033. private _emitterNode;
  136034. /**
  136035. * Gets the particle system list
  136036. */
  136037. systems: IParticleSystem[];
  136038. /**
  136039. * Gets the emitter node used with this set
  136040. */
  136041. get emitterNode(): Nullable<TransformNode>;
  136042. /**
  136043. * Creates a new emitter mesh as a sphere
  136044. * @param options defines the options used to create the sphere
  136045. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  136046. * @param scene defines the hosting scene
  136047. */
  136048. setEmitterAsSphere(options: {
  136049. diameter: number;
  136050. segments: number;
  136051. color: Color3;
  136052. }, renderingGroupId: number, scene: Scene): void;
  136053. /**
  136054. * Starts all particle systems of the set
  136055. * @param emitter defines an optional mesh to use as emitter for the particle systems
  136056. */
  136057. start(emitter?: AbstractMesh): void;
  136058. /**
  136059. * Release all associated resources
  136060. */
  136061. dispose(): void;
  136062. /**
  136063. * Serialize the set into a JSON compatible object
  136064. * @returns a JSON compatible representation of the set
  136065. */
  136066. serialize(): any;
  136067. /**
  136068. * Parse a new ParticleSystemSet from a serialized source
  136069. * @param data defines a JSON compatible representation of the set
  136070. * @param scene defines the hosting scene
  136071. * @param gpu defines if we want GPU particles or CPU particles
  136072. * @returns a new ParticleSystemSet
  136073. */
  136074. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  136075. }
  136076. }
  136077. declare module BABYLON {
  136078. /**
  136079. * This class is made for on one-liner static method to help creating particle system set.
  136080. */
  136081. export class ParticleHelper {
  136082. /**
  136083. * Gets or sets base Assets URL
  136084. */
  136085. static BaseAssetsUrl: string;
  136086. /**
  136087. * Create a default particle system that you can tweak
  136088. * @param emitter defines the emitter to use
  136089. * @param capacity defines the system capacity (default is 500 particles)
  136090. * @param scene defines the hosting scene
  136091. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  136092. * @returns the new Particle system
  136093. */
  136094. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  136095. /**
  136096. * This is the main static method (one-liner) of this helper to create different particle systems
  136097. * @param type This string represents the type to the particle system to create
  136098. * @param scene The scene where the particle system should live
  136099. * @param gpu If the system will use gpu
  136100. * @returns the ParticleSystemSet created
  136101. */
  136102. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  136103. /**
  136104. * Static function used to export a particle system to a ParticleSystemSet variable.
  136105. * Please note that the emitter shape is not exported
  136106. * @param systems defines the particle systems to export
  136107. * @returns the created particle system set
  136108. */
  136109. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  136110. }
  136111. }
  136112. declare module BABYLON {
  136113. interface Engine {
  136114. /**
  136115. * Create an effect to use with particle systems.
  136116. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  136117. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  136118. * @param uniformsNames defines a list of attribute names
  136119. * @param samplers defines an array of string used to represent textures
  136120. * @param defines defines the string containing the defines to use to compile the shaders
  136121. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  136122. * @param onCompiled defines a function to call when the effect creation is successful
  136123. * @param onError defines a function to call when the effect creation has failed
  136124. * @returns the new Effect
  136125. */
  136126. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  136127. }
  136128. interface Mesh {
  136129. /**
  136130. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  136131. * @returns an array of IParticleSystem
  136132. */
  136133. getEmittedParticleSystems(): IParticleSystem[];
  136134. /**
  136135. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  136136. * @returns an array of IParticleSystem
  136137. */
  136138. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  136139. }
  136140. /**
  136141. * @hidden
  136142. */
  136143. export var _IDoNeedToBeInTheBuild: number;
  136144. }
  136145. declare module BABYLON {
  136146. /** Defines the 4 color options */
  136147. export enum PointColor {
  136148. /** color value */
  136149. Color = 2,
  136150. /** uv value */
  136151. UV = 1,
  136152. /** random value */
  136153. Random = 0,
  136154. /** stated value */
  136155. Stated = 3
  136156. }
  136157. /**
  136158. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  136159. * 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.
  136160. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  136161. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  136162. *
  136163. * Full documentation here : TO BE ENTERED
  136164. */
  136165. export class PointsCloudSystem implements IDisposable {
  136166. /**
  136167. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  136168. * Example : var p = SPS.particles[i];
  136169. */
  136170. particles: CloudPoint[];
  136171. /**
  136172. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  136173. */
  136174. nbParticles: number;
  136175. /**
  136176. * This a counter for your own usage. It's not set by any SPS functions.
  136177. */
  136178. counter: number;
  136179. /**
  136180. * The PCS name. This name is also given to the underlying mesh.
  136181. */
  136182. name: string;
  136183. /**
  136184. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  136185. */
  136186. mesh: Mesh;
  136187. /**
  136188. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  136189. * Please read :
  136190. */
  136191. vars: any;
  136192. /**
  136193. * @hidden
  136194. */
  136195. _size: number;
  136196. private _scene;
  136197. private _promises;
  136198. private _positions;
  136199. private _indices;
  136200. private _normals;
  136201. private _colors;
  136202. private _uvs;
  136203. private _indices32;
  136204. private _positions32;
  136205. private _colors32;
  136206. private _uvs32;
  136207. private _updatable;
  136208. private _isVisibilityBoxLocked;
  136209. private _alwaysVisible;
  136210. private _groups;
  136211. private _groupCounter;
  136212. private _computeParticleColor;
  136213. private _computeParticleTexture;
  136214. private _computeParticleRotation;
  136215. private _computeBoundingBox;
  136216. private _isReady;
  136217. /**
  136218. * Creates a PCS (Points Cloud System) object
  136219. * @param name (String) is the PCS name, this will be the underlying mesh name
  136220. * @param pointSize (number) is the size for each point
  136221. * @param scene (Scene) is the scene in which the PCS is added
  136222. * @param options defines the options of the PCS e.g.
  136223. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  136224. */
  136225. constructor(name: string, pointSize: number, scene: Scene, options?: {
  136226. updatable?: boolean;
  136227. });
  136228. /**
  136229. * Builds the PCS underlying mesh. Returns a standard Mesh.
  136230. * If no points were added to the PCS, the returned mesh is just a single point.
  136231. * @returns a promise for the created mesh
  136232. */
  136233. buildMeshAsync(): Promise<Mesh>;
  136234. /**
  136235. * @hidden
  136236. */
  136237. private _buildMesh;
  136238. private _addParticle;
  136239. private _randomUnitVector;
  136240. private _getColorIndicesForCoord;
  136241. private _setPointsColorOrUV;
  136242. private _colorFromTexture;
  136243. private _calculateDensity;
  136244. /**
  136245. * Adds points to the PCS in random positions within a unit sphere
  136246. * @param nb (positive integer) the number of particles to be created from this model
  136247. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  136248. * @returns the number of groups in the system
  136249. */
  136250. addPoints(nb: number, pointFunction?: any): number;
  136251. /**
  136252. * Adds points to the PCS from the surface of the model shape
  136253. * @param mesh is any Mesh object that will be used as a surface model for the points
  136254. * @param nb (positive integer) the number of particles to be created from this model
  136255. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  136256. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  136257. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  136258. * @returns the number of groups in the system
  136259. */
  136260. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  136261. /**
  136262. * Adds points to the PCS inside the model shape
  136263. * @param mesh is any Mesh object that will be used as a surface model for the points
  136264. * @param nb (positive integer) the number of particles to be created from this model
  136265. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  136266. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  136267. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  136268. * @returns the number of groups in the system
  136269. */
  136270. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  136271. /**
  136272. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  136273. * This method calls `updateParticle()` for each particle of the SPS.
  136274. * For an animated SPS, it is usually called within the render loop.
  136275. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  136276. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  136277. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  136278. * @returns the PCS.
  136279. */
  136280. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  136281. /**
  136282. * Disposes the PCS.
  136283. */
  136284. dispose(): void;
  136285. /**
  136286. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  136287. * doc :
  136288. * @returns the PCS.
  136289. */
  136290. refreshVisibleSize(): PointsCloudSystem;
  136291. /**
  136292. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  136293. * @param size the size (float) of the visibility box
  136294. * note : this doesn't lock the PCS mesh bounding box.
  136295. * doc :
  136296. */
  136297. setVisibilityBox(size: number): void;
  136298. /**
  136299. * Gets whether the PCS is always visible or not
  136300. * doc :
  136301. */
  136302. get isAlwaysVisible(): boolean;
  136303. /**
  136304. * Sets the PCS as always visible or not
  136305. * doc :
  136306. */
  136307. set isAlwaysVisible(val: boolean);
  136308. /**
  136309. * Tells to `setParticles()` to compute the particle rotations or not
  136310. * Default value : false. The PCS is faster when it's set to false
  136311. * Note : particle rotations are only applied to parent particles
  136312. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  136313. */
  136314. set computeParticleRotation(val: boolean);
  136315. /**
  136316. * Tells to `setParticles()` to compute the particle colors or not.
  136317. * Default value : true. The PCS is faster when it's set to false.
  136318. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  136319. */
  136320. set computeParticleColor(val: boolean);
  136321. set computeParticleTexture(val: boolean);
  136322. /**
  136323. * Gets if `setParticles()` computes the particle colors or not.
  136324. * Default value : false. The PCS is faster when it's set to false.
  136325. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  136326. */
  136327. get computeParticleColor(): boolean;
  136328. /**
  136329. * Gets if `setParticles()` computes the particle textures or not.
  136330. * Default value : false. The PCS is faster when it's set to false.
  136331. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  136332. */
  136333. get computeParticleTexture(): boolean;
  136334. /**
  136335. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  136336. */
  136337. set computeBoundingBox(val: boolean);
  136338. /**
  136339. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  136340. */
  136341. get computeBoundingBox(): boolean;
  136342. /**
  136343. * This function does nothing. It may be overwritten to set all the particle first values.
  136344. * The PCS doesn't call this function, you may have to call it by your own.
  136345. * doc :
  136346. */
  136347. initParticles(): void;
  136348. /**
  136349. * This function does nothing. It may be overwritten to recycle a particle
  136350. * The PCS doesn't call this function, you can to call it
  136351. * doc :
  136352. * @param particle The particle to recycle
  136353. * @returns the recycled particle
  136354. */
  136355. recycleParticle(particle: CloudPoint): CloudPoint;
  136356. /**
  136357. * Updates a particle : this function should be overwritten by the user.
  136358. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  136359. * doc :
  136360. * @example : just set a particle position or velocity and recycle conditions
  136361. * @param particle The particle to update
  136362. * @returns the updated particle
  136363. */
  136364. updateParticle(particle: CloudPoint): CloudPoint;
  136365. /**
  136366. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  136367. * This does nothing and may be overwritten by the user.
  136368. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  136369. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  136370. * @param update the boolean update value actually passed to setParticles()
  136371. */
  136372. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  136373. /**
  136374. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  136375. * This will be passed three parameters.
  136376. * This does nothing and may be overwritten by the user.
  136377. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  136378. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  136379. * @param update the boolean update value actually passed to setParticles()
  136380. */
  136381. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  136382. }
  136383. }
  136384. declare module BABYLON {
  136385. /**
  136386. * Represents one particle of a points cloud system.
  136387. */
  136388. export class CloudPoint {
  136389. /**
  136390. * particle global index
  136391. */
  136392. idx: number;
  136393. /**
  136394. * The color of the particle
  136395. */
  136396. color: Nullable<Color4>;
  136397. /**
  136398. * The world space position of the particle.
  136399. */
  136400. position: Vector3;
  136401. /**
  136402. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  136403. */
  136404. rotation: Vector3;
  136405. /**
  136406. * The world space rotation quaternion of the particle.
  136407. */
  136408. rotationQuaternion: Nullable<Quaternion>;
  136409. /**
  136410. * The uv of the particle.
  136411. */
  136412. uv: Nullable<Vector2>;
  136413. /**
  136414. * The current speed of the particle.
  136415. */
  136416. velocity: Vector3;
  136417. /**
  136418. * The pivot point in the particle local space.
  136419. */
  136420. pivot: Vector3;
  136421. /**
  136422. * Must the particle be translated from its pivot point in its local space ?
  136423. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  136424. * Default : false
  136425. */
  136426. translateFromPivot: boolean;
  136427. /**
  136428. * Index of this particle in the global "positions" array (Internal use)
  136429. * @hidden
  136430. */
  136431. _pos: number;
  136432. /**
  136433. * @hidden Index of this particle in the global "indices" array (Internal use)
  136434. */
  136435. _ind: number;
  136436. /**
  136437. * Group this particle belongs to
  136438. */
  136439. _group: PointsGroup;
  136440. /**
  136441. * Group id of this particle
  136442. */
  136443. groupId: number;
  136444. /**
  136445. * Index of the particle in its group id (Internal use)
  136446. */
  136447. idxInGroup: number;
  136448. /**
  136449. * @hidden Particle BoundingInfo object (Internal use)
  136450. */
  136451. _boundingInfo: BoundingInfo;
  136452. /**
  136453. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  136454. */
  136455. _pcs: PointsCloudSystem;
  136456. /**
  136457. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  136458. */
  136459. _stillInvisible: boolean;
  136460. /**
  136461. * @hidden Last computed particle rotation matrix
  136462. */
  136463. _rotationMatrix: number[];
  136464. /**
  136465. * Parent particle Id, if any.
  136466. * Default null.
  136467. */
  136468. parentId: Nullable<number>;
  136469. /**
  136470. * @hidden Internal global position in the PCS.
  136471. */
  136472. _globalPosition: Vector3;
  136473. /**
  136474. * Creates a Point Cloud object.
  136475. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  136476. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  136477. * @param group (PointsGroup) is the group the particle belongs to
  136478. * @param groupId (integer) is the group identifier in the PCS.
  136479. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  136480. * @param pcs defines the PCS it is associated to
  136481. */
  136482. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  136483. /**
  136484. * get point size
  136485. */
  136486. get size(): Vector3;
  136487. /**
  136488. * Set point size
  136489. */
  136490. set size(scale: Vector3);
  136491. /**
  136492. * Legacy support, changed quaternion to rotationQuaternion
  136493. */
  136494. get quaternion(): Nullable<Quaternion>;
  136495. /**
  136496. * Legacy support, changed quaternion to rotationQuaternion
  136497. */
  136498. set quaternion(q: Nullable<Quaternion>);
  136499. /**
  136500. * Returns a boolean. True if the particle intersects a mesh, else false
  136501. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  136502. * @param target is the object (point or mesh) what the intersection is computed against
  136503. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  136504. * @returns true if it intersects
  136505. */
  136506. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  136507. /**
  136508. * get the rotation matrix of the particle
  136509. * @hidden
  136510. */
  136511. getRotationMatrix(m: Matrix): void;
  136512. }
  136513. /**
  136514. * Represents a group of points in a points cloud system
  136515. * * PCS internal tool, don't use it manually.
  136516. */
  136517. export class PointsGroup {
  136518. /**
  136519. * The group id
  136520. * @hidden
  136521. */
  136522. groupID: number;
  136523. /**
  136524. * image data for group (internal use)
  136525. * @hidden
  136526. */
  136527. _groupImageData: Nullable<ArrayBufferView>;
  136528. /**
  136529. * Image Width (internal use)
  136530. * @hidden
  136531. */
  136532. _groupImgWidth: number;
  136533. /**
  136534. * Image Height (internal use)
  136535. * @hidden
  136536. */
  136537. _groupImgHeight: number;
  136538. /**
  136539. * Custom position function (internal use)
  136540. * @hidden
  136541. */
  136542. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  136543. /**
  136544. * density per facet for surface points
  136545. * @hidden
  136546. */
  136547. _groupDensity: number[];
  136548. /**
  136549. * Only when points are colored by texture carries pointer to texture list array
  136550. * @hidden
  136551. */
  136552. _textureNb: number;
  136553. /**
  136554. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  136555. * PCS internal tool, don't use it manually.
  136556. * @hidden
  136557. */
  136558. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  136559. }
  136560. }
  136561. declare module BABYLON {
  136562. interface Scene {
  136563. /** @hidden (Backing field) */
  136564. _physicsEngine: Nullable<IPhysicsEngine>;
  136565. /** @hidden */
  136566. _physicsTimeAccumulator: number;
  136567. /**
  136568. * Gets the current physics engine
  136569. * @returns a IPhysicsEngine or null if none attached
  136570. */
  136571. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  136572. /**
  136573. * Enables physics to the current scene
  136574. * @param gravity defines the scene's gravity for the physics engine
  136575. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  136576. * @return a boolean indicating if the physics engine was initialized
  136577. */
  136578. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  136579. /**
  136580. * Disables and disposes the physics engine associated with the scene
  136581. */
  136582. disablePhysicsEngine(): void;
  136583. /**
  136584. * Gets a boolean indicating if there is an active physics engine
  136585. * @returns a boolean indicating if there is an active physics engine
  136586. */
  136587. isPhysicsEnabled(): boolean;
  136588. /**
  136589. * Deletes a physics compound impostor
  136590. * @param compound defines the compound to delete
  136591. */
  136592. deleteCompoundImpostor(compound: any): void;
  136593. /**
  136594. * An event triggered when physic simulation is about to be run
  136595. */
  136596. onBeforePhysicsObservable: Observable<Scene>;
  136597. /**
  136598. * An event triggered when physic simulation has been done
  136599. */
  136600. onAfterPhysicsObservable: Observable<Scene>;
  136601. }
  136602. interface AbstractMesh {
  136603. /** @hidden */
  136604. _physicsImpostor: Nullable<PhysicsImpostor>;
  136605. /**
  136606. * Gets or sets impostor used for physic simulation
  136607. * @see http://doc.babylonjs.com/features/physics_engine
  136608. */
  136609. physicsImpostor: Nullable<PhysicsImpostor>;
  136610. /**
  136611. * Gets the current physics impostor
  136612. * @see http://doc.babylonjs.com/features/physics_engine
  136613. * @returns a physics impostor or null
  136614. */
  136615. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  136616. /** Apply a physic impulse to the mesh
  136617. * @param force defines the force to apply
  136618. * @param contactPoint defines where to apply the force
  136619. * @returns the current mesh
  136620. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  136621. */
  136622. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  136623. /**
  136624. * Creates a physic joint between two meshes
  136625. * @param otherMesh defines the other mesh to use
  136626. * @param pivot1 defines the pivot to use on this mesh
  136627. * @param pivot2 defines the pivot to use on the other mesh
  136628. * @param options defines additional options (can be plugin dependent)
  136629. * @returns the current mesh
  136630. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  136631. */
  136632. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  136633. /** @hidden */
  136634. _disposePhysicsObserver: Nullable<Observer<Node>>;
  136635. }
  136636. /**
  136637. * Defines the physics engine scene component responsible to manage a physics engine
  136638. */
  136639. export class PhysicsEngineSceneComponent implements ISceneComponent {
  136640. /**
  136641. * The component name helpful to identify the component in the list of scene components.
  136642. */
  136643. readonly name: string;
  136644. /**
  136645. * The scene the component belongs to.
  136646. */
  136647. scene: Scene;
  136648. /**
  136649. * Creates a new instance of the component for the given scene
  136650. * @param scene Defines the scene to register the component in
  136651. */
  136652. constructor(scene: Scene);
  136653. /**
  136654. * Registers the component in a given scene
  136655. */
  136656. register(): void;
  136657. /**
  136658. * Rebuilds the elements related to this component in case of
  136659. * context lost for instance.
  136660. */
  136661. rebuild(): void;
  136662. /**
  136663. * Disposes the component and the associated ressources
  136664. */
  136665. dispose(): void;
  136666. }
  136667. }
  136668. declare module BABYLON {
  136669. /**
  136670. * A helper for physics simulations
  136671. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136672. */
  136673. export class PhysicsHelper {
  136674. private _scene;
  136675. private _physicsEngine;
  136676. /**
  136677. * Initializes the Physics helper
  136678. * @param scene Babylon.js scene
  136679. */
  136680. constructor(scene: Scene);
  136681. /**
  136682. * Applies a radial explosion impulse
  136683. * @param origin the origin of the explosion
  136684. * @param radiusOrEventOptions the radius or the options of radial explosion
  136685. * @param strength the explosion strength
  136686. * @param falloff possible options: Constant & Linear. Defaults to Constant
  136687. * @returns A physics radial explosion event, or null
  136688. */
  136689. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  136690. /**
  136691. * Applies a radial explosion force
  136692. * @param origin the origin of the explosion
  136693. * @param radiusOrEventOptions the radius or the options of radial explosion
  136694. * @param strength the explosion strength
  136695. * @param falloff possible options: Constant & Linear. Defaults to Constant
  136696. * @returns A physics radial explosion event, or null
  136697. */
  136698. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  136699. /**
  136700. * Creates a gravitational field
  136701. * @param origin the origin of the explosion
  136702. * @param radiusOrEventOptions the radius or the options of radial explosion
  136703. * @param strength the explosion strength
  136704. * @param falloff possible options: Constant & Linear. Defaults to Constant
  136705. * @returns A physics gravitational field event, or null
  136706. */
  136707. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  136708. /**
  136709. * Creates a physics updraft event
  136710. * @param origin the origin of the updraft
  136711. * @param radiusOrEventOptions the radius or the options of the updraft
  136712. * @param strength the strength of the updraft
  136713. * @param height the height of the updraft
  136714. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  136715. * @returns A physics updraft event, or null
  136716. */
  136717. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  136718. /**
  136719. * Creates a physics vortex event
  136720. * @param origin the of the vortex
  136721. * @param radiusOrEventOptions the radius or the options of the vortex
  136722. * @param strength the strength of the vortex
  136723. * @param height the height of the vortex
  136724. * @returns a Physics vortex event, or null
  136725. * A physics vortex event or null
  136726. */
  136727. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  136728. }
  136729. /**
  136730. * Represents a physics radial explosion event
  136731. */
  136732. class PhysicsRadialExplosionEvent {
  136733. private _scene;
  136734. private _options;
  136735. private _sphere;
  136736. private _dataFetched;
  136737. /**
  136738. * Initializes a radial explosioin event
  136739. * @param _scene BabylonJS scene
  136740. * @param _options The options for the vortex event
  136741. */
  136742. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  136743. /**
  136744. * Returns the data related to the radial explosion event (sphere).
  136745. * @returns The radial explosion event data
  136746. */
  136747. getData(): PhysicsRadialExplosionEventData;
  136748. /**
  136749. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  136750. * @param impostor A physics imposter
  136751. * @param origin the origin of the explosion
  136752. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  136753. */
  136754. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  136755. /**
  136756. * Triggers affecterd impostors callbacks
  136757. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  136758. */
  136759. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  136760. /**
  136761. * Disposes the sphere.
  136762. * @param force Specifies if the sphere should be disposed by force
  136763. */
  136764. dispose(force?: boolean): void;
  136765. /*** Helpers ***/
  136766. private _prepareSphere;
  136767. private _intersectsWithSphere;
  136768. }
  136769. /**
  136770. * Represents a gravitational field event
  136771. */
  136772. class PhysicsGravitationalFieldEvent {
  136773. private _physicsHelper;
  136774. private _scene;
  136775. private _origin;
  136776. private _options;
  136777. private _tickCallback;
  136778. private _sphere;
  136779. private _dataFetched;
  136780. /**
  136781. * Initializes the physics gravitational field event
  136782. * @param _physicsHelper A physics helper
  136783. * @param _scene BabylonJS scene
  136784. * @param _origin The origin position of the gravitational field event
  136785. * @param _options The options for the vortex event
  136786. */
  136787. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  136788. /**
  136789. * Returns the data related to the gravitational field event (sphere).
  136790. * @returns A gravitational field event
  136791. */
  136792. getData(): PhysicsGravitationalFieldEventData;
  136793. /**
  136794. * Enables the gravitational field.
  136795. */
  136796. enable(): void;
  136797. /**
  136798. * Disables the gravitational field.
  136799. */
  136800. disable(): void;
  136801. /**
  136802. * Disposes the sphere.
  136803. * @param force The force to dispose from the gravitational field event
  136804. */
  136805. dispose(force?: boolean): void;
  136806. private _tick;
  136807. }
  136808. /**
  136809. * Represents a physics updraft event
  136810. */
  136811. class PhysicsUpdraftEvent {
  136812. private _scene;
  136813. private _origin;
  136814. private _options;
  136815. private _physicsEngine;
  136816. private _originTop;
  136817. private _originDirection;
  136818. private _tickCallback;
  136819. private _cylinder;
  136820. private _cylinderPosition;
  136821. private _dataFetched;
  136822. /**
  136823. * Initializes the physics updraft event
  136824. * @param _scene BabylonJS scene
  136825. * @param _origin The origin position of the updraft
  136826. * @param _options The options for the updraft event
  136827. */
  136828. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  136829. /**
  136830. * Returns the data related to the updraft event (cylinder).
  136831. * @returns A physics updraft event
  136832. */
  136833. getData(): PhysicsUpdraftEventData;
  136834. /**
  136835. * Enables the updraft.
  136836. */
  136837. enable(): void;
  136838. /**
  136839. * Disables the updraft.
  136840. */
  136841. disable(): void;
  136842. /**
  136843. * Disposes the cylinder.
  136844. * @param force Specifies if the updraft should be disposed by force
  136845. */
  136846. dispose(force?: boolean): void;
  136847. private getImpostorHitData;
  136848. private _tick;
  136849. /*** Helpers ***/
  136850. private _prepareCylinder;
  136851. private _intersectsWithCylinder;
  136852. }
  136853. /**
  136854. * Represents a physics vortex event
  136855. */
  136856. class PhysicsVortexEvent {
  136857. private _scene;
  136858. private _origin;
  136859. private _options;
  136860. private _physicsEngine;
  136861. private _originTop;
  136862. private _tickCallback;
  136863. private _cylinder;
  136864. private _cylinderPosition;
  136865. private _dataFetched;
  136866. /**
  136867. * Initializes the physics vortex event
  136868. * @param _scene The BabylonJS scene
  136869. * @param _origin The origin position of the vortex
  136870. * @param _options The options for the vortex event
  136871. */
  136872. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  136873. /**
  136874. * Returns the data related to the vortex event (cylinder).
  136875. * @returns The physics vortex event data
  136876. */
  136877. getData(): PhysicsVortexEventData;
  136878. /**
  136879. * Enables the vortex.
  136880. */
  136881. enable(): void;
  136882. /**
  136883. * Disables the cortex.
  136884. */
  136885. disable(): void;
  136886. /**
  136887. * Disposes the sphere.
  136888. * @param force
  136889. */
  136890. dispose(force?: boolean): void;
  136891. private getImpostorHitData;
  136892. private _tick;
  136893. /*** Helpers ***/
  136894. private _prepareCylinder;
  136895. private _intersectsWithCylinder;
  136896. }
  136897. /**
  136898. * Options fot the radial explosion event
  136899. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136900. */
  136901. export class PhysicsRadialExplosionEventOptions {
  136902. /**
  136903. * The radius of the sphere for the radial explosion.
  136904. */
  136905. radius: number;
  136906. /**
  136907. * The strenth of the explosion.
  136908. */
  136909. strength: number;
  136910. /**
  136911. * The strenght of the force in correspondence to the distance of the affected object
  136912. */
  136913. falloff: PhysicsRadialImpulseFalloff;
  136914. /**
  136915. * Sphere options for the radial explosion.
  136916. */
  136917. sphere: {
  136918. segments: number;
  136919. diameter: number;
  136920. };
  136921. /**
  136922. * Sphere options for the radial explosion.
  136923. */
  136924. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  136925. }
  136926. /**
  136927. * Options fot the updraft event
  136928. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136929. */
  136930. export class PhysicsUpdraftEventOptions {
  136931. /**
  136932. * The radius of the cylinder for the vortex
  136933. */
  136934. radius: number;
  136935. /**
  136936. * The strenth of the updraft.
  136937. */
  136938. strength: number;
  136939. /**
  136940. * The height of the cylinder for the updraft.
  136941. */
  136942. height: number;
  136943. /**
  136944. * The mode for the the updraft.
  136945. */
  136946. updraftMode: PhysicsUpdraftMode;
  136947. }
  136948. /**
  136949. * Options fot the vortex event
  136950. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136951. */
  136952. export class PhysicsVortexEventOptions {
  136953. /**
  136954. * The radius of the cylinder for the vortex
  136955. */
  136956. radius: number;
  136957. /**
  136958. * The strenth of the vortex.
  136959. */
  136960. strength: number;
  136961. /**
  136962. * The height of the cylinder for the vortex.
  136963. */
  136964. height: number;
  136965. /**
  136966. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  136967. */
  136968. centripetalForceThreshold: number;
  136969. /**
  136970. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  136971. */
  136972. centripetalForceMultiplier: number;
  136973. /**
  136974. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  136975. */
  136976. centrifugalForceMultiplier: number;
  136977. /**
  136978. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  136979. */
  136980. updraftForceMultiplier: number;
  136981. }
  136982. /**
  136983. * The strenght of the force in correspondence to the distance of the affected object
  136984. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136985. */
  136986. export enum PhysicsRadialImpulseFalloff {
  136987. /** Defines that impulse is constant in strength across it's whole radius */
  136988. Constant = 0,
  136989. /** Defines that impulse gets weaker if it's further from the origin */
  136990. Linear = 1
  136991. }
  136992. /**
  136993. * The strength of the force in correspondence to the distance of the affected object
  136994. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136995. */
  136996. export enum PhysicsUpdraftMode {
  136997. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  136998. Center = 0,
  136999. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  137000. Perpendicular = 1
  137001. }
  137002. /**
  137003. * Interface for a physics hit data
  137004. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137005. */
  137006. export interface PhysicsHitData {
  137007. /**
  137008. * The force applied at the contact point
  137009. */
  137010. force: Vector3;
  137011. /**
  137012. * The contact point
  137013. */
  137014. contactPoint: Vector3;
  137015. /**
  137016. * The distance from the origin to the contact point
  137017. */
  137018. distanceFromOrigin: number;
  137019. }
  137020. /**
  137021. * Interface for radial explosion event data
  137022. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137023. */
  137024. export interface PhysicsRadialExplosionEventData {
  137025. /**
  137026. * A sphere used for the radial explosion event
  137027. */
  137028. sphere: Mesh;
  137029. }
  137030. /**
  137031. * Interface for gravitational field event data
  137032. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137033. */
  137034. export interface PhysicsGravitationalFieldEventData {
  137035. /**
  137036. * A sphere mesh used for the gravitational field event
  137037. */
  137038. sphere: Mesh;
  137039. }
  137040. /**
  137041. * Interface for updraft event data
  137042. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137043. */
  137044. export interface PhysicsUpdraftEventData {
  137045. /**
  137046. * A cylinder used for the updraft event
  137047. */
  137048. cylinder: Mesh;
  137049. }
  137050. /**
  137051. * Interface for vortex event data
  137052. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137053. */
  137054. export interface PhysicsVortexEventData {
  137055. /**
  137056. * A cylinder used for the vortex event
  137057. */
  137058. cylinder: Mesh;
  137059. }
  137060. /**
  137061. * Interface for an affected physics impostor
  137062. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137063. */
  137064. export interface PhysicsAffectedImpostorWithData {
  137065. /**
  137066. * The impostor affected by the effect
  137067. */
  137068. impostor: PhysicsImpostor;
  137069. /**
  137070. * The data about the hit/horce from the explosion
  137071. */
  137072. hitData: PhysicsHitData;
  137073. }
  137074. }
  137075. declare module BABYLON {
  137076. /** @hidden */
  137077. export var blackAndWhitePixelShader: {
  137078. name: string;
  137079. shader: string;
  137080. };
  137081. }
  137082. declare module BABYLON {
  137083. /**
  137084. * Post process used to render in black and white
  137085. */
  137086. export class BlackAndWhitePostProcess extends PostProcess {
  137087. /**
  137088. * Linear about to convert he result to black and white (default: 1)
  137089. */
  137090. degree: number;
  137091. /**
  137092. * Creates a black and white post process
  137093. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  137094. * @param name The name of the effect.
  137095. * @param options The required width/height ratio to downsize to before computing the render pass.
  137096. * @param camera The camera to apply the render pass to.
  137097. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137098. * @param engine The engine which the post process will be applied. (default: current engine)
  137099. * @param reusable If the post process can be reused on the same frame. (default: false)
  137100. */
  137101. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137102. }
  137103. }
  137104. declare module BABYLON {
  137105. /**
  137106. * This represents a set of one or more post processes in Babylon.
  137107. * A post process can be used to apply a shader to a texture after it is rendered.
  137108. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  137109. */
  137110. export class PostProcessRenderEffect {
  137111. private _postProcesses;
  137112. private _getPostProcesses;
  137113. private _singleInstance;
  137114. private _cameras;
  137115. private _indicesForCamera;
  137116. /**
  137117. * Name of the effect
  137118. * @hidden
  137119. */
  137120. _name: string;
  137121. /**
  137122. * Instantiates a post process render effect.
  137123. * A post process can be used to apply a shader to a texture after it is rendered.
  137124. * @param engine The engine the effect is tied to
  137125. * @param name The name of the effect
  137126. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  137127. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  137128. */
  137129. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  137130. /**
  137131. * Checks if all the post processes in the effect are supported.
  137132. */
  137133. get isSupported(): boolean;
  137134. /**
  137135. * Updates the current state of the effect
  137136. * @hidden
  137137. */
  137138. _update(): void;
  137139. /**
  137140. * Attaches the effect on cameras
  137141. * @param cameras The camera to attach to.
  137142. * @hidden
  137143. */
  137144. _attachCameras(cameras: Camera): void;
  137145. /**
  137146. * Attaches the effect on cameras
  137147. * @param cameras The camera to attach to.
  137148. * @hidden
  137149. */
  137150. _attachCameras(cameras: Camera[]): void;
  137151. /**
  137152. * Detaches the effect on cameras
  137153. * @param cameras The camera to detatch from.
  137154. * @hidden
  137155. */
  137156. _detachCameras(cameras: Camera): void;
  137157. /**
  137158. * Detatches the effect on cameras
  137159. * @param cameras The camera to detatch from.
  137160. * @hidden
  137161. */
  137162. _detachCameras(cameras: Camera[]): void;
  137163. /**
  137164. * Enables the effect on given cameras
  137165. * @param cameras The camera to enable.
  137166. * @hidden
  137167. */
  137168. _enable(cameras: Camera): void;
  137169. /**
  137170. * Enables the effect on given cameras
  137171. * @param cameras The camera to enable.
  137172. * @hidden
  137173. */
  137174. _enable(cameras: Nullable<Camera[]>): void;
  137175. /**
  137176. * Disables the effect on the given cameras
  137177. * @param cameras The camera to disable.
  137178. * @hidden
  137179. */
  137180. _disable(cameras: Camera): void;
  137181. /**
  137182. * Disables the effect on the given cameras
  137183. * @param cameras The camera to disable.
  137184. * @hidden
  137185. */
  137186. _disable(cameras: Nullable<Camera[]>): void;
  137187. /**
  137188. * Gets a list of the post processes contained in the effect.
  137189. * @param camera The camera to get the post processes on.
  137190. * @returns The list of the post processes in the effect.
  137191. */
  137192. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  137193. }
  137194. }
  137195. declare module BABYLON {
  137196. /** @hidden */
  137197. export var extractHighlightsPixelShader: {
  137198. name: string;
  137199. shader: string;
  137200. };
  137201. }
  137202. declare module BABYLON {
  137203. /**
  137204. * 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.
  137205. */
  137206. export class ExtractHighlightsPostProcess extends PostProcess {
  137207. /**
  137208. * The luminance threshold, pixels below this value will be set to black.
  137209. */
  137210. threshold: number;
  137211. /** @hidden */
  137212. _exposure: number;
  137213. /**
  137214. * Post process which has the input texture to be used when performing highlight extraction
  137215. * @hidden
  137216. */
  137217. _inputPostProcess: Nullable<PostProcess>;
  137218. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137219. }
  137220. }
  137221. declare module BABYLON {
  137222. /** @hidden */
  137223. export var bloomMergePixelShader: {
  137224. name: string;
  137225. shader: string;
  137226. };
  137227. }
  137228. declare module BABYLON {
  137229. /**
  137230. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  137231. */
  137232. export class BloomMergePostProcess extends PostProcess {
  137233. /** Weight of the bloom to be added to the original input. */
  137234. weight: number;
  137235. /**
  137236. * Creates a new instance of @see BloomMergePostProcess
  137237. * @param name The name of the effect.
  137238. * @param originalFromInput Post process which's input will be used for the merge.
  137239. * @param blurred Blurred highlights post process which's output will be used.
  137240. * @param weight Weight of the bloom to be added to the original input.
  137241. * @param options The required width/height ratio to downsize to before computing the render pass.
  137242. * @param camera The camera to apply the render pass to.
  137243. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137244. * @param engine The engine which the post process will be applied. (default: current engine)
  137245. * @param reusable If the post process can be reused on the same frame. (default: false)
  137246. * @param textureType Type of textures used when performing the post process. (default: 0)
  137247. * @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)
  137248. */
  137249. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  137250. /** Weight of the bloom to be added to the original input. */
  137251. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137252. }
  137253. }
  137254. declare module BABYLON {
  137255. /**
  137256. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  137257. */
  137258. export class BloomEffect extends PostProcessRenderEffect {
  137259. private bloomScale;
  137260. /**
  137261. * @hidden Internal
  137262. */
  137263. _effects: Array<PostProcess>;
  137264. /**
  137265. * @hidden Internal
  137266. */
  137267. _downscale: ExtractHighlightsPostProcess;
  137268. private _blurX;
  137269. private _blurY;
  137270. private _merge;
  137271. /**
  137272. * The luminance threshold to find bright areas of the image to bloom.
  137273. */
  137274. get threshold(): number;
  137275. set threshold(value: number);
  137276. /**
  137277. * The strength of the bloom.
  137278. */
  137279. get weight(): number;
  137280. set weight(value: number);
  137281. /**
  137282. * Specifies the size of the bloom blur kernel, relative to the final output size
  137283. */
  137284. get kernel(): number;
  137285. set kernel(value: number);
  137286. /**
  137287. * Creates a new instance of @see BloomEffect
  137288. * @param scene The scene the effect belongs to.
  137289. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  137290. * @param bloomKernel The size of the kernel to be used when applying the blur.
  137291. * @param bloomWeight The the strength of bloom.
  137292. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  137293. * @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)
  137294. */
  137295. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  137296. /**
  137297. * Disposes each of the internal effects for a given camera.
  137298. * @param camera The camera to dispose the effect on.
  137299. */
  137300. disposeEffects(camera: Camera): void;
  137301. /**
  137302. * @hidden Internal
  137303. */
  137304. _updateEffects(): void;
  137305. /**
  137306. * Internal
  137307. * @returns if all the contained post processes are ready.
  137308. * @hidden
  137309. */
  137310. _isReady(): boolean;
  137311. }
  137312. }
  137313. declare module BABYLON {
  137314. /** @hidden */
  137315. export var chromaticAberrationPixelShader: {
  137316. name: string;
  137317. shader: string;
  137318. };
  137319. }
  137320. declare module BABYLON {
  137321. /**
  137322. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  137323. */
  137324. export class ChromaticAberrationPostProcess extends PostProcess {
  137325. /**
  137326. * The amount of seperation of rgb channels (default: 30)
  137327. */
  137328. aberrationAmount: number;
  137329. /**
  137330. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  137331. */
  137332. radialIntensity: number;
  137333. /**
  137334. * 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))
  137335. */
  137336. direction: Vector2;
  137337. /**
  137338. * 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))
  137339. */
  137340. centerPosition: Vector2;
  137341. /**
  137342. * Creates a new instance ChromaticAberrationPostProcess
  137343. * @param name The name of the effect.
  137344. * @param screenWidth The width of the screen to apply the effect on.
  137345. * @param screenHeight The height of the screen to apply the effect on.
  137346. * @param options The required width/height ratio to downsize to before computing the render pass.
  137347. * @param camera The camera to apply the render pass to.
  137348. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137349. * @param engine The engine which the post process will be applied. (default: current engine)
  137350. * @param reusable If the post process can be reused on the same frame. (default: false)
  137351. * @param textureType Type of textures used when performing the post process. (default: 0)
  137352. * @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)
  137353. */
  137354. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137355. }
  137356. }
  137357. declare module BABYLON {
  137358. /** @hidden */
  137359. export var circleOfConfusionPixelShader: {
  137360. name: string;
  137361. shader: string;
  137362. };
  137363. }
  137364. declare module BABYLON {
  137365. /**
  137366. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  137367. */
  137368. export class CircleOfConfusionPostProcess extends PostProcess {
  137369. /**
  137370. * 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.
  137371. */
  137372. lensSize: number;
  137373. /**
  137374. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  137375. */
  137376. fStop: number;
  137377. /**
  137378. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  137379. */
  137380. focusDistance: number;
  137381. /**
  137382. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  137383. */
  137384. focalLength: number;
  137385. private _depthTexture;
  137386. /**
  137387. * Creates a new instance CircleOfConfusionPostProcess
  137388. * @param name The name of the effect.
  137389. * @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.
  137390. * @param options The required width/height ratio to downsize to before computing the render pass.
  137391. * @param camera The camera to apply the render pass to.
  137392. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137393. * @param engine The engine which the post process will be applied. (default: current engine)
  137394. * @param reusable If the post process can be reused on the same frame. (default: false)
  137395. * @param textureType Type of textures used when performing the post process. (default: 0)
  137396. * @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)
  137397. */
  137398. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137399. /**
  137400. * 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.
  137401. */
  137402. set depthTexture(value: RenderTargetTexture);
  137403. }
  137404. }
  137405. declare module BABYLON {
  137406. /** @hidden */
  137407. export var colorCorrectionPixelShader: {
  137408. name: string;
  137409. shader: string;
  137410. };
  137411. }
  137412. declare module BABYLON {
  137413. /**
  137414. *
  137415. * This post-process allows the modification of rendered colors by using
  137416. * a 'look-up table' (LUT). This effect is also called Color Grading.
  137417. *
  137418. * The object needs to be provided an url to a texture containing the color
  137419. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  137420. * Use an image editing software to tweak the LUT to match your needs.
  137421. *
  137422. * For an example of a color LUT, see here:
  137423. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  137424. * For explanations on color grading, see here:
  137425. * @see http://udn.epicgames.com/Three/ColorGrading.html
  137426. *
  137427. */
  137428. export class ColorCorrectionPostProcess extends PostProcess {
  137429. private _colorTableTexture;
  137430. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137431. }
  137432. }
  137433. declare module BABYLON {
  137434. /** @hidden */
  137435. export var convolutionPixelShader: {
  137436. name: string;
  137437. shader: string;
  137438. };
  137439. }
  137440. declare module BABYLON {
  137441. /**
  137442. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  137443. * input texture to perform effects such as edge detection or sharpening
  137444. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  137445. */
  137446. export class ConvolutionPostProcess extends PostProcess {
  137447. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  137448. kernel: number[];
  137449. /**
  137450. * Creates a new instance ConvolutionPostProcess
  137451. * @param name The name of the effect.
  137452. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  137453. * @param options The required width/height ratio to downsize to before computing the render pass.
  137454. * @param camera The camera to apply the render pass to.
  137455. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137456. * @param engine The engine which the post process will be applied. (default: current engine)
  137457. * @param reusable If the post process can be reused on the same frame. (default: false)
  137458. * @param textureType Type of textures used when performing the post process. (default: 0)
  137459. */
  137460. constructor(name: string,
  137461. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  137462. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  137463. /**
  137464. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137465. */
  137466. static EdgeDetect0Kernel: number[];
  137467. /**
  137468. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137469. */
  137470. static EdgeDetect1Kernel: number[];
  137471. /**
  137472. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137473. */
  137474. static EdgeDetect2Kernel: number[];
  137475. /**
  137476. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137477. */
  137478. static SharpenKernel: number[];
  137479. /**
  137480. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137481. */
  137482. static EmbossKernel: number[];
  137483. /**
  137484. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137485. */
  137486. static GaussianKernel: number[];
  137487. }
  137488. }
  137489. declare module BABYLON {
  137490. /**
  137491. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  137492. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  137493. * based on samples that have a large difference in distance than the center pixel.
  137494. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  137495. */
  137496. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  137497. direction: Vector2;
  137498. /**
  137499. * Creates a new instance CircleOfConfusionPostProcess
  137500. * @param name The name of the effect.
  137501. * @param scene The scene the effect belongs to.
  137502. * @param direction The direction the blur should be applied.
  137503. * @param kernel The size of the kernel used to blur.
  137504. * @param options The required width/height ratio to downsize to before computing the render pass.
  137505. * @param camera The camera to apply the render pass to.
  137506. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  137507. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  137508. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137509. * @param engine The engine which the post process will be applied. (default: current engine)
  137510. * @param reusable If the post process can be reused on the same frame. (default: false)
  137511. * @param textureType Type of textures used when performing the post process. (default: 0)
  137512. * @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)
  137513. */
  137514. 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);
  137515. }
  137516. }
  137517. declare module BABYLON {
  137518. /** @hidden */
  137519. export var depthOfFieldMergePixelShader: {
  137520. name: string;
  137521. shader: string;
  137522. };
  137523. }
  137524. declare module BABYLON {
  137525. /**
  137526. * Options to be set when merging outputs from the default pipeline.
  137527. */
  137528. export class DepthOfFieldMergePostProcessOptions {
  137529. /**
  137530. * The original image to merge on top of
  137531. */
  137532. originalFromInput: PostProcess;
  137533. /**
  137534. * Parameters to perform the merge of the depth of field effect
  137535. */
  137536. depthOfField?: {
  137537. circleOfConfusion: PostProcess;
  137538. blurSteps: Array<PostProcess>;
  137539. };
  137540. /**
  137541. * Parameters to perform the merge of bloom effect
  137542. */
  137543. bloom?: {
  137544. blurred: PostProcess;
  137545. weight: number;
  137546. };
  137547. }
  137548. /**
  137549. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  137550. */
  137551. export class DepthOfFieldMergePostProcess extends PostProcess {
  137552. private blurSteps;
  137553. /**
  137554. * Creates a new instance of DepthOfFieldMergePostProcess
  137555. * @param name The name of the effect.
  137556. * @param originalFromInput Post process which's input will be used for the merge.
  137557. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  137558. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  137559. * @param options The required width/height ratio to downsize to before computing the render pass.
  137560. * @param camera The camera to apply the render pass to.
  137561. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137562. * @param engine The engine which the post process will be applied. (default: current engine)
  137563. * @param reusable If the post process can be reused on the same frame. (default: false)
  137564. * @param textureType Type of textures used when performing the post process. (default: 0)
  137565. * @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)
  137566. */
  137567. 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);
  137568. /**
  137569. * Updates the effect with the current post process compile time values and recompiles the shader.
  137570. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  137571. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  137572. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  137573. * @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
  137574. * @param onCompiled Called when the shader has been compiled.
  137575. * @param onError Called if there is an error when compiling a shader.
  137576. */
  137577. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  137578. }
  137579. }
  137580. declare module BABYLON {
  137581. /**
  137582. * Specifies the level of max blur that should be applied when using the depth of field effect
  137583. */
  137584. export enum DepthOfFieldEffectBlurLevel {
  137585. /**
  137586. * Subtle blur
  137587. */
  137588. Low = 0,
  137589. /**
  137590. * Medium blur
  137591. */
  137592. Medium = 1,
  137593. /**
  137594. * Large blur
  137595. */
  137596. High = 2
  137597. }
  137598. /**
  137599. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  137600. */
  137601. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  137602. private _circleOfConfusion;
  137603. /**
  137604. * @hidden Internal, blurs from high to low
  137605. */
  137606. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  137607. private _depthOfFieldBlurY;
  137608. private _dofMerge;
  137609. /**
  137610. * @hidden Internal post processes in depth of field effect
  137611. */
  137612. _effects: Array<PostProcess>;
  137613. /**
  137614. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  137615. */
  137616. set focalLength(value: number);
  137617. get focalLength(): number;
  137618. /**
  137619. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  137620. */
  137621. set fStop(value: number);
  137622. get fStop(): number;
  137623. /**
  137624. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  137625. */
  137626. set focusDistance(value: number);
  137627. get focusDistance(): number;
  137628. /**
  137629. * 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.
  137630. */
  137631. set lensSize(value: number);
  137632. get lensSize(): number;
  137633. /**
  137634. * Creates a new instance DepthOfFieldEffect
  137635. * @param scene The scene the effect belongs to.
  137636. * @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.
  137637. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  137638. * @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)
  137639. */
  137640. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  137641. /**
  137642. * Get the current class name of the current effet
  137643. * @returns "DepthOfFieldEffect"
  137644. */
  137645. getClassName(): string;
  137646. /**
  137647. * 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.
  137648. */
  137649. set depthTexture(value: RenderTargetTexture);
  137650. /**
  137651. * Disposes each of the internal effects for a given camera.
  137652. * @param camera The camera to dispose the effect on.
  137653. */
  137654. disposeEffects(camera: Camera): void;
  137655. /**
  137656. * @hidden Internal
  137657. */
  137658. _updateEffects(): void;
  137659. /**
  137660. * Internal
  137661. * @returns if all the contained post processes are ready.
  137662. * @hidden
  137663. */
  137664. _isReady(): boolean;
  137665. }
  137666. }
  137667. declare module BABYLON {
  137668. /** @hidden */
  137669. export var displayPassPixelShader: {
  137670. name: string;
  137671. shader: string;
  137672. };
  137673. }
  137674. declare module BABYLON {
  137675. /**
  137676. * DisplayPassPostProcess which produces an output the same as it's input
  137677. */
  137678. export class DisplayPassPostProcess extends PostProcess {
  137679. /**
  137680. * Creates the DisplayPassPostProcess
  137681. * @param name The name of the effect.
  137682. * @param options The required width/height ratio to downsize to before computing the render pass.
  137683. * @param camera The camera to apply the render pass to.
  137684. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137685. * @param engine The engine which the post process will be applied. (default: current engine)
  137686. * @param reusable If the post process can be reused on the same frame. (default: false)
  137687. */
  137688. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137689. }
  137690. }
  137691. declare module BABYLON {
  137692. /** @hidden */
  137693. export var filterPixelShader: {
  137694. name: string;
  137695. shader: string;
  137696. };
  137697. }
  137698. declare module BABYLON {
  137699. /**
  137700. * Applies a kernel filter to the image
  137701. */
  137702. export class FilterPostProcess extends PostProcess {
  137703. /** The matrix to be applied to the image */
  137704. kernelMatrix: Matrix;
  137705. /**
  137706. *
  137707. * @param name The name of the effect.
  137708. * @param kernelMatrix The matrix to be applied to the image
  137709. * @param options The required width/height ratio to downsize to before computing the render pass.
  137710. * @param camera The camera to apply the render pass to.
  137711. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137712. * @param engine The engine which the post process will be applied. (default: current engine)
  137713. * @param reusable If the post process can be reused on the same frame. (default: false)
  137714. */
  137715. constructor(name: string,
  137716. /** The matrix to be applied to the image */
  137717. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137718. }
  137719. }
  137720. declare module BABYLON {
  137721. /** @hidden */
  137722. export var fxaaPixelShader: {
  137723. name: string;
  137724. shader: string;
  137725. };
  137726. }
  137727. declare module BABYLON {
  137728. /** @hidden */
  137729. export var fxaaVertexShader: {
  137730. name: string;
  137731. shader: string;
  137732. };
  137733. }
  137734. declare module BABYLON {
  137735. /**
  137736. * Fxaa post process
  137737. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  137738. */
  137739. export class FxaaPostProcess extends PostProcess {
  137740. /** @hidden */
  137741. texelWidth: number;
  137742. /** @hidden */
  137743. texelHeight: number;
  137744. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  137745. private _getDefines;
  137746. }
  137747. }
  137748. declare module BABYLON {
  137749. /** @hidden */
  137750. export var grainPixelShader: {
  137751. name: string;
  137752. shader: string;
  137753. };
  137754. }
  137755. declare module BABYLON {
  137756. /**
  137757. * The GrainPostProcess adds noise to the image at mid luminance levels
  137758. */
  137759. export class GrainPostProcess extends PostProcess {
  137760. /**
  137761. * The intensity of the grain added (default: 30)
  137762. */
  137763. intensity: number;
  137764. /**
  137765. * If the grain should be randomized on every frame
  137766. */
  137767. animated: boolean;
  137768. /**
  137769. * Creates a new instance of @see GrainPostProcess
  137770. * @param name The name of the effect.
  137771. * @param options The required width/height ratio to downsize to before computing the render pass.
  137772. * @param camera The camera to apply the render pass to.
  137773. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137774. * @param engine The engine which the post process will be applied. (default: current engine)
  137775. * @param reusable If the post process can be reused on the same frame. (default: false)
  137776. * @param textureType Type of textures used when performing the post process. (default: 0)
  137777. * @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)
  137778. */
  137779. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137780. }
  137781. }
  137782. declare module BABYLON {
  137783. /** @hidden */
  137784. export var highlightsPixelShader: {
  137785. name: string;
  137786. shader: string;
  137787. };
  137788. }
  137789. declare module BABYLON {
  137790. /**
  137791. * Extracts highlights from the image
  137792. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  137793. */
  137794. export class HighlightsPostProcess extends PostProcess {
  137795. /**
  137796. * Extracts highlights from the image
  137797. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  137798. * @param name The name of the effect.
  137799. * @param options The required width/height ratio to downsize to before computing the render pass.
  137800. * @param camera The camera to apply the render pass to.
  137801. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137802. * @param engine The engine which the post process will be applied. (default: current engine)
  137803. * @param reusable If the post process can be reused on the same frame. (default: false)
  137804. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  137805. */
  137806. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  137807. }
  137808. }
  137809. declare module BABYLON {
  137810. /** @hidden */
  137811. export var mrtFragmentDeclaration: {
  137812. name: string;
  137813. shader: string;
  137814. };
  137815. }
  137816. declare module BABYLON {
  137817. /** @hidden */
  137818. export var geometryPixelShader: {
  137819. name: string;
  137820. shader: string;
  137821. };
  137822. }
  137823. declare module BABYLON {
  137824. /** @hidden */
  137825. export var geometryVertexShader: {
  137826. name: string;
  137827. shader: string;
  137828. };
  137829. }
  137830. declare module BABYLON {
  137831. /** @hidden */
  137832. interface ISavedTransformationMatrix {
  137833. world: Matrix;
  137834. viewProjection: Matrix;
  137835. }
  137836. /**
  137837. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  137838. */
  137839. export class GeometryBufferRenderer {
  137840. /**
  137841. * Constant used to retrieve the position texture index in the G-Buffer textures array
  137842. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  137843. */
  137844. static readonly POSITION_TEXTURE_TYPE: number;
  137845. /**
  137846. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  137847. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  137848. */
  137849. static readonly VELOCITY_TEXTURE_TYPE: number;
  137850. /**
  137851. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  137852. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  137853. */
  137854. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  137855. /**
  137856. * Dictionary used to store the previous transformation matrices of each rendered mesh
  137857. * in order to compute objects velocities when enableVelocity is set to "true"
  137858. * @hidden
  137859. */
  137860. _previousTransformationMatrices: {
  137861. [index: number]: ISavedTransformationMatrix;
  137862. };
  137863. /**
  137864. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  137865. * in order to compute objects velocities when enableVelocity is set to "true"
  137866. * @hidden
  137867. */
  137868. _previousBonesTransformationMatrices: {
  137869. [index: number]: Float32Array;
  137870. };
  137871. /**
  137872. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  137873. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  137874. */
  137875. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  137876. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  137877. renderTransparentMeshes: boolean;
  137878. private _scene;
  137879. private _multiRenderTarget;
  137880. private _ratio;
  137881. private _enablePosition;
  137882. private _enableVelocity;
  137883. private _enableReflectivity;
  137884. private _positionIndex;
  137885. private _velocityIndex;
  137886. private _reflectivityIndex;
  137887. protected _effect: Effect;
  137888. protected _cachedDefines: string;
  137889. /**
  137890. * Set the render list (meshes to be rendered) used in the G buffer.
  137891. */
  137892. set renderList(meshes: Mesh[]);
  137893. /**
  137894. * Gets wether or not G buffer are supported by the running hardware.
  137895. * This requires draw buffer supports
  137896. */
  137897. get isSupported(): boolean;
  137898. /**
  137899. * Returns the index of the given texture type in the G-Buffer textures array
  137900. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  137901. * @returns the index of the given texture type in the G-Buffer textures array
  137902. */
  137903. getTextureIndex(textureType: number): number;
  137904. /**
  137905. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  137906. */
  137907. get enablePosition(): boolean;
  137908. /**
  137909. * Sets whether or not objects positions are enabled for the G buffer.
  137910. */
  137911. set enablePosition(enable: boolean);
  137912. /**
  137913. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  137914. */
  137915. get enableVelocity(): boolean;
  137916. /**
  137917. * Sets wether or not objects velocities are enabled for the G buffer.
  137918. */
  137919. set enableVelocity(enable: boolean);
  137920. /**
  137921. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  137922. */
  137923. get enableReflectivity(): boolean;
  137924. /**
  137925. * Sets wether or not objects roughness are enabled for the G buffer.
  137926. */
  137927. set enableReflectivity(enable: boolean);
  137928. /**
  137929. * Gets the scene associated with the buffer.
  137930. */
  137931. get scene(): Scene;
  137932. /**
  137933. * Gets the ratio used by the buffer during its creation.
  137934. * How big is the buffer related to the main canvas.
  137935. */
  137936. get ratio(): number;
  137937. /** @hidden */
  137938. static _SceneComponentInitialization: (scene: Scene) => void;
  137939. /**
  137940. * Creates a new G Buffer for the scene
  137941. * @param scene The scene the buffer belongs to
  137942. * @param ratio How big is the buffer related to the main canvas.
  137943. */
  137944. constructor(scene: Scene, ratio?: number);
  137945. /**
  137946. * Checks wether everything is ready to render a submesh to the G buffer.
  137947. * @param subMesh the submesh to check readiness for
  137948. * @param useInstances is the mesh drawn using instance or not
  137949. * @returns true if ready otherwise false
  137950. */
  137951. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  137952. /**
  137953. * Gets the current underlying G Buffer.
  137954. * @returns the buffer
  137955. */
  137956. getGBuffer(): MultiRenderTarget;
  137957. /**
  137958. * Gets the number of samples used to render the buffer (anti aliasing).
  137959. */
  137960. get samples(): number;
  137961. /**
  137962. * Sets the number of samples used to render the buffer (anti aliasing).
  137963. */
  137964. set samples(value: number);
  137965. /**
  137966. * Disposes the renderer and frees up associated resources.
  137967. */
  137968. dispose(): void;
  137969. protected _createRenderTargets(): void;
  137970. private _copyBonesTransformationMatrices;
  137971. }
  137972. }
  137973. declare module BABYLON {
  137974. interface Scene {
  137975. /** @hidden (Backing field) */
  137976. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  137977. /**
  137978. * Gets or Sets the current geometry buffer associated to the scene.
  137979. */
  137980. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  137981. /**
  137982. * Enables a GeometryBufferRender and associates it with the scene
  137983. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  137984. * @returns the GeometryBufferRenderer
  137985. */
  137986. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  137987. /**
  137988. * Disables the GeometryBufferRender associated with the scene
  137989. */
  137990. disableGeometryBufferRenderer(): void;
  137991. }
  137992. /**
  137993. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  137994. * in several rendering techniques.
  137995. */
  137996. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  137997. /**
  137998. * The component name helpful to identify the component in the list of scene components.
  137999. */
  138000. readonly name: string;
  138001. /**
  138002. * The scene the component belongs to.
  138003. */
  138004. scene: Scene;
  138005. /**
  138006. * Creates a new instance of the component for the given scene
  138007. * @param scene Defines the scene to register the component in
  138008. */
  138009. constructor(scene: Scene);
  138010. /**
  138011. * Registers the component in a given scene
  138012. */
  138013. register(): void;
  138014. /**
  138015. * Rebuilds the elements related to this component in case of
  138016. * context lost for instance.
  138017. */
  138018. rebuild(): void;
  138019. /**
  138020. * Disposes the component and the associated ressources
  138021. */
  138022. dispose(): void;
  138023. private _gatherRenderTargets;
  138024. }
  138025. }
  138026. declare module BABYLON {
  138027. /** @hidden */
  138028. export var motionBlurPixelShader: {
  138029. name: string;
  138030. shader: string;
  138031. };
  138032. }
  138033. declare module BABYLON {
  138034. /**
  138035. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  138036. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  138037. * As an example, all you have to do is to create the post-process:
  138038. * var mb = new BABYLON.MotionBlurPostProcess(
  138039. * 'mb', // The name of the effect.
  138040. * scene, // The scene containing the objects to blur according to their velocity.
  138041. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  138042. * camera // The camera to apply the render pass to.
  138043. * );
  138044. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  138045. */
  138046. export class MotionBlurPostProcess extends PostProcess {
  138047. /**
  138048. * Defines how much the image is blurred by the movement. Default value is equal to 1
  138049. */
  138050. motionStrength: number;
  138051. /**
  138052. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  138053. */
  138054. get motionBlurSamples(): number;
  138055. /**
  138056. * Sets the number of iterations to be used for motion blur quality
  138057. */
  138058. set motionBlurSamples(samples: number);
  138059. private _motionBlurSamples;
  138060. private _geometryBufferRenderer;
  138061. /**
  138062. * Creates a new instance MotionBlurPostProcess
  138063. * @param name The name of the effect.
  138064. * @param scene The scene containing the objects to blur according to their velocity.
  138065. * @param options The required width/height ratio to downsize to before computing the render pass.
  138066. * @param camera The camera to apply the render pass to.
  138067. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138068. * @param engine The engine which the post process will be applied. (default: current engine)
  138069. * @param reusable If the post process can be reused on the same frame. (default: false)
  138070. * @param textureType Type of textures used when performing the post process. (default: 0)
  138071. * @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)
  138072. */
  138073. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  138074. /**
  138075. * Excludes the given skinned mesh from computing bones velocities.
  138076. * 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.
  138077. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  138078. */
  138079. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  138080. /**
  138081. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  138082. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  138083. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  138084. */
  138085. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  138086. /**
  138087. * Disposes the post process.
  138088. * @param camera The camera to dispose the post process on.
  138089. */
  138090. dispose(camera?: Camera): void;
  138091. }
  138092. }
  138093. declare module BABYLON {
  138094. /** @hidden */
  138095. export var refractionPixelShader: {
  138096. name: string;
  138097. shader: string;
  138098. };
  138099. }
  138100. declare module BABYLON {
  138101. /**
  138102. * Post process which applies a refractin texture
  138103. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  138104. */
  138105. export class RefractionPostProcess extends PostProcess {
  138106. /** the base color of the refraction (used to taint the rendering) */
  138107. color: Color3;
  138108. /** simulated refraction depth */
  138109. depth: number;
  138110. /** the coefficient of the base color (0 to remove base color tainting) */
  138111. colorLevel: number;
  138112. private _refTexture;
  138113. private _ownRefractionTexture;
  138114. /**
  138115. * Gets or sets the refraction texture
  138116. * Please note that you are responsible for disposing the texture if you set it manually
  138117. */
  138118. get refractionTexture(): Texture;
  138119. set refractionTexture(value: Texture);
  138120. /**
  138121. * Initializes the RefractionPostProcess
  138122. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  138123. * @param name The name of the effect.
  138124. * @param refractionTextureUrl Url of the refraction texture to use
  138125. * @param color the base color of the refraction (used to taint the rendering)
  138126. * @param depth simulated refraction depth
  138127. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  138128. * @param camera The camera to apply the render pass to.
  138129. * @param options The required width/height ratio to downsize to before computing the render pass.
  138130. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138131. * @param engine The engine which the post process will be applied. (default: current engine)
  138132. * @param reusable If the post process can be reused on the same frame. (default: false)
  138133. */
  138134. constructor(name: string, refractionTextureUrl: string,
  138135. /** the base color of the refraction (used to taint the rendering) */
  138136. color: Color3,
  138137. /** simulated refraction depth */
  138138. depth: number,
  138139. /** the coefficient of the base color (0 to remove base color tainting) */
  138140. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  138141. /**
  138142. * Disposes of the post process
  138143. * @param camera Camera to dispose post process on
  138144. */
  138145. dispose(camera: Camera): void;
  138146. }
  138147. }
  138148. declare module BABYLON {
  138149. /** @hidden */
  138150. export var sharpenPixelShader: {
  138151. name: string;
  138152. shader: string;
  138153. };
  138154. }
  138155. declare module BABYLON {
  138156. /**
  138157. * The SharpenPostProcess applies a sharpen kernel to every pixel
  138158. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  138159. */
  138160. export class SharpenPostProcess extends PostProcess {
  138161. /**
  138162. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  138163. */
  138164. colorAmount: number;
  138165. /**
  138166. * How much sharpness should be applied (default: 0.3)
  138167. */
  138168. edgeAmount: number;
  138169. /**
  138170. * Creates a new instance ConvolutionPostProcess
  138171. * @param name The name of the effect.
  138172. * @param options The required width/height ratio to downsize to before computing the render pass.
  138173. * @param camera The camera to apply the render pass to.
  138174. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138175. * @param engine The engine which the post process will be applied. (default: current engine)
  138176. * @param reusable If the post process can be reused on the same frame. (default: false)
  138177. * @param textureType Type of textures used when performing the post process. (default: 0)
  138178. * @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)
  138179. */
  138180. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  138181. }
  138182. }
  138183. declare module BABYLON {
  138184. /**
  138185. * PostProcessRenderPipeline
  138186. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138187. */
  138188. export class PostProcessRenderPipeline {
  138189. private engine;
  138190. private _renderEffects;
  138191. private _renderEffectsForIsolatedPass;
  138192. /**
  138193. * List of inspectable custom properties (used by the Inspector)
  138194. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  138195. */
  138196. inspectableCustomProperties: IInspectable[];
  138197. /**
  138198. * @hidden
  138199. */
  138200. protected _cameras: Camera[];
  138201. /** @hidden */
  138202. _name: string;
  138203. /**
  138204. * Gets pipeline name
  138205. */
  138206. get name(): string;
  138207. /** Gets the list of attached cameras */
  138208. get cameras(): Camera[];
  138209. /**
  138210. * Initializes a PostProcessRenderPipeline
  138211. * @param engine engine to add the pipeline to
  138212. * @param name name of the pipeline
  138213. */
  138214. constructor(engine: Engine, name: string);
  138215. /**
  138216. * Gets the class name
  138217. * @returns "PostProcessRenderPipeline"
  138218. */
  138219. getClassName(): string;
  138220. /**
  138221. * If all the render effects in the pipeline are supported
  138222. */
  138223. get isSupported(): boolean;
  138224. /**
  138225. * Adds an effect to the pipeline
  138226. * @param renderEffect the effect to add
  138227. */
  138228. addEffect(renderEffect: PostProcessRenderEffect): void;
  138229. /** @hidden */
  138230. _rebuild(): void;
  138231. /** @hidden */
  138232. _enableEffect(renderEffectName: string, cameras: Camera): void;
  138233. /** @hidden */
  138234. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  138235. /** @hidden */
  138236. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  138237. /** @hidden */
  138238. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  138239. /** @hidden */
  138240. _attachCameras(cameras: Camera, unique: boolean): void;
  138241. /** @hidden */
  138242. _attachCameras(cameras: Camera[], unique: boolean): void;
  138243. /** @hidden */
  138244. _detachCameras(cameras: Camera): void;
  138245. /** @hidden */
  138246. _detachCameras(cameras: Nullable<Camera[]>): void;
  138247. /** @hidden */
  138248. _update(): void;
  138249. /** @hidden */
  138250. _reset(): void;
  138251. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  138252. /**
  138253. * Disposes of the pipeline
  138254. */
  138255. dispose(): void;
  138256. }
  138257. }
  138258. declare module BABYLON {
  138259. /**
  138260. * PostProcessRenderPipelineManager class
  138261. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138262. */
  138263. export class PostProcessRenderPipelineManager {
  138264. private _renderPipelines;
  138265. /**
  138266. * Initializes a PostProcessRenderPipelineManager
  138267. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138268. */
  138269. constructor();
  138270. /**
  138271. * Gets the list of supported render pipelines
  138272. */
  138273. get supportedPipelines(): PostProcessRenderPipeline[];
  138274. /**
  138275. * Adds a pipeline to the manager
  138276. * @param renderPipeline The pipeline to add
  138277. */
  138278. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  138279. /**
  138280. * Attaches a camera to the pipeline
  138281. * @param renderPipelineName The name of the pipeline to attach to
  138282. * @param cameras the camera to attach
  138283. * @param unique if the camera can be attached multiple times to the pipeline
  138284. */
  138285. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  138286. /**
  138287. * Detaches a camera from the pipeline
  138288. * @param renderPipelineName The name of the pipeline to detach from
  138289. * @param cameras the camera to detach
  138290. */
  138291. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  138292. /**
  138293. * Enables an effect by name on a pipeline
  138294. * @param renderPipelineName the name of the pipeline to enable the effect in
  138295. * @param renderEffectName the name of the effect to enable
  138296. * @param cameras the cameras that the effect should be enabled on
  138297. */
  138298. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  138299. /**
  138300. * Disables an effect by name on a pipeline
  138301. * @param renderPipelineName the name of the pipeline to disable the effect in
  138302. * @param renderEffectName the name of the effect to disable
  138303. * @param cameras the cameras that the effect should be disabled on
  138304. */
  138305. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  138306. /**
  138307. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  138308. */
  138309. update(): void;
  138310. /** @hidden */
  138311. _rebuild(): void;
  138312. /**
  138313. * Disposes of the manager and pipelines
  138314. */
  138315. dispose(): void;
  138316. }
  138317. }
  138318. declare module BABYLON {
  138319. interface Scene {
  138320. /** @hidden (Backing field) */
  138321. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  138322. /**
  138323. * Gets the postprocess render pipeline manager
  138324. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138325. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  138326. */
  138327. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  138328. }
  138329. /**
  138330. * Defines the Render Pipeline scene component responsible to rendering pipelines
  138331. */
  138332. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  138333. /**
  138334. * The component name helpfull to identify the component in the list of scene components.
  138335. */
  138336. readonly name: string;
  138337. /**
  138338. * The scene the component belongs to.
  138339. */
  138340. scene: Scene;
  138341. /**
  138342. * Creates a new instance of the component for the given scene
  138343. * @param scene Defines the scene to register the component in
  138344. */
  138345. constructor(scene: Scene);
  138346. /**
  138347. * Registers the component in a given scene
  138348. */
  138349. register(): void;
  138350. /**
  138351. * Rebuilds the elements related to this component in case of
  138352. * context lost for instance.
  138353. */
  138354. rebuild(): void;
  138355. /**
  138356. * Disposes the component and the associated ressources
  138357. */
  138358. dispose(): void;
  138359. private _gatherRenderTargets;
  138360. }
  138361. }
  138362. declare module BABYLON {
  138363. /**
  138364. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  138365. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  138366. */
  138367. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  138368. private _scene;
  138369. private _camerasToBeAttached;
  138370. /**
  138371. * ID of the sharpen post process,
  138372. */
  138373. private readonly SharpenPostProcessId;
  138374. /**
  138375. * @ignore
  138376. * ID of the image processing post process;
  138377. */
  138378. readonly ImageProcessingPostProcessId: string;
  138379. /**
  138380. * @ignore
  138381. * ID of the Fast Approximate Anti-Aliasing post process;
  138382. */
  138383. readonly FxaaPostProcessId: string;
  138384. /**
  138385. * ID of the chromatic aberration post process,
  138386. */
  138387. private readonly ChromaticAberrationPostProcessId;
  138388. /**
  138389. * ID of the grain post process
  138390. */
  138391. private readonly GrainPostProcessId;
  138392. /**
  138393. * Sharpen post process which will apply a sharpen convolution to enhance edges
  138394. */
  138395. sharpen: SharpenPostProcess;
  138396. private _sharpenEffect;
  138397. private bloom;
  138398. /**
  138399. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  138400. */
  138401. depthOfField: DepthOfFieldEffect;
  138402. /**
  138403. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  138404. */
  138405. fxaa: FxaaPostProcess;
  138406. /**
  138407. * Image post processing pass used to perform operations such as tone mapping or color grading.
  138408. */
  138409. imageProcessing: ImageProcessingPostProcess;
  138410. /**
  138411. * Chromatic aberration post process which will shift rgb colors in the image
  138412. */
  138413. chromaticAberration: ChromaticAberrationPostProcess;
  138414. private _chromaticAberrationEffect;
  138415. /**
  138416. * Grain post process which add noise to the image
  138417. */
  138418. grain: GrainPostProcess;
  138419. private _grainEffect;
  138420. /**
  138421. * Glow post process which adds a glow to emissive areas of the image
  138422. */
  138423. private _glowLayer;
  138424. /**
  138425. * Animations which can be used to tweak settings over a period of time
  138426. */
  138427. animations: Animation[];
  138428. private _imageProcessingConfigurationObserver;
  138429. private _sharpenEnabled;
  138430. private _bloomEnabled;
  138431. private _depthOfFieldEnabled;
  138432. private _depthOfFieldBlurLevel;
  138433. private _fxaaEnabled;
  138434. private _imageProcessingEnabled;
  138435. private _defaultPipelineTextureType;
  138436. private _bloomScale;
  138437. private _chromaticAberrationEnabled;
  138438. private _grainEnabled;
  138439. private _buildAllowed;
  138440. /**
  138441. * Gets active scene
  138442. */
  138443. get scene(): Scene;
  138444. /**
  138445. * Enable or disable the sharpen process from the pipeline
  138446. */
  138447. set sharpenEnabled(enabled: boolean);
  138448. get sharpenEnabled(): boolean;
  138449. private _resizeObserver;
  138450. private _hardwareScaleLevel;
  138451. private _bloomKernel;
  138452. /**
  138453. * Specifies the size of the bloom blur kernel, relative to the final output size
  138454. */
  138455. get bloomKernel(): number;
  138456. set bloomKernel(value: number);
  138457. /**
  138458. * Specifies the weight of the bloom in the final rendering
  138459. */
  138460. private _bloomWeight;
  138461. /**
  138462. * Specifies the luma threshold for the area that will be blurred by the bloom
  138463. */
  138464. private _bloomThreshold;
  138465. private _hdr;
  138466. /**
  138467. * The strength of the bloom.
  138468. */
  138469. set bloomWeight(value: number);
  138470. get bloomWeight(): number;
  138471. /**
  138472. * The strength of the bloom.
  138473. */
  138474. set bloomThreshold(value: number);
  138475. get bloomThreshold(): number;
  138476. /**
  138477. * The scale of the bloom, lower value will provide better performance.
  138478. */
  138479. set bloomScale(value: number);
  138480. get bloomScale(): number;
  138481. /**
  138482. * Enable or disable the bloom from the pipeline
  138483. */
  138484. set bloomEnabled(enabled: boolean);
  138485. get bloomEnabled(): boolean;
  138486. private _rebuildBloom;
  138487. /**
  138488. * If the depth of field is enabled.
  138489. */
  138490. get depthOfFieldEnabled(): boolean;
  138491. set depthOfFieldEnabled(enabled: boolean);
  138492. /**
  138493. * Blur level of the depth of field effect. (Higher blur will effect performance)
  138494. */
  138495. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  138496. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  138497. /**
  138498. * If the anti aliasing is enabled.
  138499. */
  138500. set fxaaEnabled(enabled: boolean);
  138501. get fxaaEnabled(): boolean;
  138502. private _samples;
  138503. /**
  138504. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  138505. */
  138506. set samples(sampleCount: number);
  138507. get samples(): number;
  138508. /**
  138509. * If image processing is enabled.
  138510. */
  138511. set imageProcessingEnabled(enabled: boolean);
  138512. get imageProcessingEnabled(): boolean;
  138513. /**
  138514. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  138515. */
  138516. set glowLayerEnabled(enabled: boolean);
  138517. get glowLayerEnabled(): boolean;
  138518. /**
  138519. * Gets the glow layer (or null if not defined)
  138520. */
  138521. get glowLayer(): Nullable<GlowLayer>;
  138522. /**
  138523. * Enable or disable the chromaticAberration process from the pipeline
  138524. */
  138525. set chromaticAberrationEnabled(enabled: boolean);
  138526. get chromaticAberrationEnabled(): boolean;
  138527. /**
  138528. * Enable or disable the grain process from the pipeline
  138529. */
  138530. set grainEnabled(enabled: boolean);
  138531. get grainEnabled(): boolean;
  138532. /**
  138533. * @constructor
  138534. * @param name - The rendering pipeline name (default: "")
  138535. * @param hdr - If high dynamic range textures should be used (default: true)
  138536. * @param scene - The scene linked to this pipeline (default: the last created scene)
  138537. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  138538. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  138539. */
  138540. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  138541. /**
  138542. * Get the class name
  138543. * @returns "DefaultRenderingPipeline"
  138544. */
  138545. getClassName(): string;
  138546. /**
  138547. * Force the compilation of the entire pipeline.
  138548. */
  138549. prepare(): void;
  138550. private _hasCleared;
  138551. private _prevPostProcess;
  138552. private _prevPrevPostProcess;
  138553. private _setAutoClearAndTextureSharing;
  138554. private _depthOfFieldSceneObserver;
  138555. private _buildPipeline;
  138556. private _disposePostProcesses;
  138557. /**
  138558. * Adds a camera to the pipeline
  138559. * @param camera the camera to be added
  138560. */
  138561. addCamera(camera: Camera): void;
  138562. /**
  138563. * Removes a camera from the pipeline
  138564. * @param camera the camera to remove
  138565. */
  138566. removeCamera(camera: Camera): void;
  138567. /**
  138568. * Dispose of the pipeline and stop all post processes
  138569. */
  138570. dispose(): void;
  138571. /**
  138572. * Serialize the rendering pipeline (Used when exporting)
  138573. * @returns the serialized object
  138574. */
  138575. serialize(): any;
  138576. /**
  138577. * Parse the serialized pipeline
  138578. * @param source Source pipeline.
  138579. * @param scene The scene to load the pipeline to.
  138580. * @param rootUrl The URL of the serialized pipeline.
  138581. * @returns An instantiated pipeline from the serialized object.
  138582. */
  138583. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  138584. }
  138585. }
  138586. declare module BABYLON {
  138587. /** @hidden */
  138588. export var lensHighlightsPixelShader: {
  138589. name: string;
  138590. shader: string;
  138591. };
  138592. }
  138593. declare module BABYLON {
  138594. /** @hidden */
  138595. export var depthOfFieldPixelShader: {
  138596. name: string;
  138597. shader: string;
  138598. };
  138599. }
  138600. declare module BABYLON {
  138601. /**
  138602. * BABYLON.JS Chromatic Aberration GLSL Shader
  138603. * Author: Olivier Guyot
  138604. * Separates very slightly R, G and B colors on the edges of the screen
  138605. * Inspired by Francois Tarlier & Martins Upitis
  138606. */
  138607. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  138608. /**
  138609. * @ignore
  138610. * The chromatic aberration PostProcess id in the pipeline
  138611. */
  138612. LensChromaticAberrationEffect: string;
  138613. /**
  138614. * @ignore
  138615. * The highlights enhancing PostProcess id in the pipeline
  138616. */
  138617. HighlightsEnhancingEffect: string;
  138618. /**
  138619. * @ignore
  138620. * The depth-of-field PostProcess id in the pipeline
  138621. */
  138622. LensDepthOfFieldEffect: string;
  138623. private _scene;
  138624. private _depthTexture;
  138625. private _grainTexture;
  138626. private _chromaticAberrationPostProcess;
  138627. private _highlightsPostProcess;
  138628. private _depthOfFieldPostProcess;
  138629. private _edgeBlur;
  138630. private _grainAmount;
  138631. private _chromaticAberration;
  138632. private _distortion;
  138633. private _highlightsGain;
  138634. private _highlightsThreshold;
  138635. private _dofDistance;
  138636. private _dofAperture;
  138637. private _dofDarken;
  138638. private _dofPentagon;
  138639. private _blurNoise;
  138640. /**
  138641. * @constructor
  138642. *
  138643. * Effect parameters are as follow:
  138644. * {
  138645. * chromatic_aberration: number; // from 0 to x (1 for realism)
  138646. * edge_blur: number; // from 0 to x (1 for realism)
  138647. * distortion: number; // from 0 to x (1 for realism)
  138648. * grain_amount: number; // from 0 to 1
  138649. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  138650. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  138651. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  138652. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  138653. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  138654. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  138655. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  138656. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  138657. * }
  138658. * Note: if an effect parameter is unset, effect is disabled
  138659. *
  138660. * @param name The rendering pipeline name
  138661. * @param parameters - An object containing all parameters (see above)
  138662. * @param scene The scene linked to this pipeline
  138663. * @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)
  138664. * @param cameras The array of cameras that the rendering pipeline will be attached to
  138665. */
  138666. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  138667. /**
  138668. * Get the class name
  138669. * @returns "LensRenderingPipeline"
  138670. */
  138671. getClassName(): string;
  138672. /**
  138673. * Gets associated scene
  138674. */
  138675. get scene(): Scene;
  138676. /**
  138677. * Gets or sets the edge blur
  138678. */
  138679. get edgeBlur(): number;
  138680. set edgeBlur(value: number);
  138681. /**
  138682. * Gets or sets the grain amount
  138683. */
  138684. get grainAmount(): number;
  138685. set grainAmount(value: number);
  138686. /**
  138687. * Gets or sets the chromatic aberration amount
  138688. */
  138689. get chromaticAberration(): number;
  138690. set chromaticAberration(value: number);
  138691. /**
  138692. * Gets or sets the depth of field aperture
  138693. */
  138694. get dofAperture(): number;
  138695. set dofAperture(value: number);
  138696. /**
  138697. * Gets or sets the edge distortion
  138698. */
  138699. get edgeDistortion(): number;
  138700. set edgeDistortion(value: number);
  138701. /**
  138702. * Gets or sets the depth of field distortion
  138703. */
  138704. get dofDistortion(): number;
  138705. set dofDistortion(value: number);
  138706. /**
  138707. * Gets or sets the darken out of focus amount
  138708. */
  138709. get darkenOutOfFocus(): number;
  138710. set darkenOutOfFocus(value: number);
  138711. /**
  138712. * Gets or sets a boolean indicating if blur noise is enabled
  138713. */
  138714. get blurNoise(): boolean;
  138715. set blurNoise(value: boolean);
  138716. /**
  138717. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  138718. */
  138719. get pentagonBokeh(): boolean;
  138720. set pentagonBokeh(value: boolean);
  138721. /**
  138722. * Gets or sets the highlight grain amount
  138723. */
  138724. get highlightsGain(): number;
  138725. set highlightsGain(value: number);
  138726. /**
  138727. * Gets or sets the highlight threshold
  138728. */
  138729. get highlightsThreshold(): number;
  138730. set highlightsThreshold(value: number);
  138731. /**
  138732. * Sets the amount of blur at the edges
  138733. * @param amount blur amount
  138734. */
  138735. setEdgeBlur(amount: number): void;
  138736. /**
  138737. * Sets edge blur to 0
  138738. */
  138739. disableEdgeBlur(): void;
  138740. /**
  138741. * Sets the amout of grain
  138742. * @param amount Amount of grain
  138743. */
  138744. setGrainAmount(amount: number): void;
  138745. /**
  138746. * Set grain amount to 0
  138747. */
  138748. disableGrain(): void;
  138749. /**
  138750. * Sets the chromatic aberration amount
  138751. * @param amount amount of chromatic aberration
  138752. */
  138753. setChromaticAberration(amount: number): void;
  138754. /**
  138755. * Sets chromatic aberration amount to 0
  138756. */
  138757. disableChromaticAberration(): void;
  138758. /**
  138759. * Sets the EdgeDistortion amount
  138760. * @param amount amount of EdgeDistortion
  138761. */
  138762. setEdgeDistortion(amount: number): void;
  138763. /**
  138764. * Sets edge distortion to 0
  138765. */
  138766. disableEdgeDistortion(): void;
  138767. /**
  138768. * Sets the FocusDistance amount
  138769. * @param amount amount of FocusDistance
  138770. */
  138771. setFocusDistance(amount: number): void;
  138772. /**
  138773. * Disables depth of field
  138774. */
  138775. disableDepthOfField(): void;
  138776. /**
  138777. * Sets the Aperture amount
  138778. * @param amount amount of Aperture
  138779. */
  138780. setAperture(amount: number): void;
  138781. /**
  138782. * Sets the DarkenOutOfFocus amount
  138783. * @param amount amount of DarkenOutOfFocus
  138784. */
  138785. setDarkenOutOfFocus(amount: number): void;
  138786. private _pentagonBokehIsEnabled;
  138787. /**
  138788. * Creates a pentagon bokeh effect
  138789. */
  138790. enablePentagonBokeh(): void;
  138791. /**
  138792. * Disables the pentagon bokeh effect
  138793. */
  138794. disablePentagonBokeh(): void;
  138795. /**
  138796. * Enables noise blur
  138797. */
  138798. enableNoiseBlur(): void;
  138799. /**
  138800. * Disables noise blur
  138801. */
  138802. disableNoiseBlur(): void;
  138803. /**
  138804. * Sets the HighlightsGain amount
  138805. * @param amount amount of HighlightsGain
  138806. */
  138807. setHighlightsGain(amount: number): void;
  138808. /**
  138809. * Sets the HighlightsThreshold amount
  138810. * @param amount amount of HighlightsThreshold
  138811. */
  138812. setHighlightsThreshold(amount: number): void;
  138813. /**
  138814. * Disables highlights
  138815. */
  138816. disableHighlights(): void;
  138817. /**
  138818. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  138819. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  138820. */
  138821. dispose(disableDepthRender?: boolean): void;
  138822. private _createChromaticAberrationPostProcess;
  138823. private _createHighlightsPostProcess;
  138824. private _createDepthOfFieldPostProcess;
  138825. private _createGrainTexture;
  138826. }
  138827. }
  138828. declare module BABYLON {
  138829. /** @hidden */
  138830. export var ssao2PixelShader: {
  138831. name: string;
  138832. shader: string;
  138833. };
  138834. }
  138835. declare module BABYLON {
  138836. /** @hidden */
  138837. export var ssaoCombinePixelShader: {
  138838. name: string;
  138839. shader: string;
  138840. };
  138841. }
  138842. declare module BABYLON {
  138843. /**
  138844. * Render pipeline to produce ssao effect
  138845. */
  138846. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  138847. /**
  138848. * @ignore
  138849. * The PassPostProcess id in the pipeline that contains the original scene color
  138850. */
  138851. SSAOOriginalSceneColorEffect: string;
  138852. /**
  138853. * @ignore
  138854. * The SSAO PostProcess id in the pipeline
  138855. */
  138856. SSAORenderEffect: string;
  138857. /**
  138858. * @ignore
  138859. * The horizontal blur PostProcess id in the pipeline
  138860. */
  138861. SSAOBlurHRenderEffect: string;
  138862. /**
  138863. * @ignore
  138864. * The vertical blur PostProcess id in the pipeline
  138865. */
  138866. SSAOBlurVRenderEffect: string;
  138867. /**
  138868. * @ignore
  138869. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  138870. */
  138871. SSAOCombineRenderEffect: string;
  138872. /**
  138873. * The output strength of the SSAO post-process. Default value is 1.0.
  138874. */
  138875. totalStrength: number;
  138876. /**
  138877. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  138878. */
  138879. maxZ: number;
  138880. /**
  138881. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  138882. */
  138883. minZAspect: number;
  138884. private _samples;
  138885. /**
  138886. * Number of samples used for the SSAO calculations. Default value is 8
  138887. */
  138888. set samples(n: number);
  138889. get samples(): number;
  138890. private _textureSamples;
  138891. /**
  138892. * Number of samples to use for antialiasing
  138893. */
  138894. set textureSamples(n: number);
  138895. get textureSamples(): number;
  138896. /**
  138897. * Ratio object used for SSAO ratio and blur ratio
  138898. */
  138899. private _ratio;
  138900. /**
  138901. * Dynamically generated sphere sampler.
  138902. */
  138903. private _sampleSphere;
  138904. /**
  138905. * Blur filter offsets
  138906. */
  138907. private _samplerOffsets;
  138908. private _expensiveBlur;
  138909. /**
  138910. * If bilateral blur should be used
  138911. */
  138912. set expensiveBlur(b: boolean);
  138913. get expensiveBlur(): boolean;
  138914. /**
  138915. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  138916. */
  138917. radius: number;
  138918. /**
  138919. * The base color of the SSAO post-process
  138920. * The final result is "base + ssao" between [0, 1]
  138921. */
  138922. base: number;
  138923. /**
  138924. * Support test.
  138925. */
  138926. static get IsSupported(): boolean;
  138927. private _scene;
  138928. private _depthTexture;
  138929. private _normalTexture;
  138930. private _randomTexture;
  138931. private _originalColorPostProcess;
  138932. private _ssaoPostProcess;
  138933. private _blurHPostProcess;
  138934. private _blurVPostProcess;
  138935. private _ssaoCombinePostProcess;
  138936. /**
  138937. * Gets active scene
  138938. */
  138939. get scene(): Scene;
  138940. /**
  138941. * @constructor
  138942. * @param name The rendering pipeline name
  138943. * @param scene The scene linked to this pipeline
  138944. * @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 }
  138945. * @param cameras The array of cameras that the rendering pipeline will be attached to
  138946. */
  138947. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  138948. /**
  138949. * Get the class name
  138950. * @returns "SSAO2RenderingPipeline"
  138951. */
  138952. getClassName(): string;
  138953. /**
  138954. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  138955. */
  138956. dispose(disableGeometryBufferRenderer?: boolean): void;
  138957. private _createBlurPostProcess;
  138958. /** @hidden */
  138959. _rebuild(): void;
  138960. private _bits;
  138961. private _radicalInverse_VdC;
  138962. private _hammersley;
  138963. private _hemisphereSample_uniform;
  138964. private _generateHemisphere;
  138965. private _createSSAOPostProcess;
  138966. private _createSSAOCombinePostProcess;
  138967. private _createRandomTexture;
  138968. /**
  138969. * Serialize the rendering pipeline (Used when exporting)
  138970. * @returns the serialized object
  138971. */
  138972. serialize(): any;
  138973. /**
  138974. * Parse the serialized pipeline
  138975. * @param source Source pipeline.
  138976. * @param scene The scene to load the pipeline to.
  138977. * @param rootUrl The URL of the serialized pipeline.
  138978. * @returns An instantiated pipeline from the serialized object.
  138979. */
  138980. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  138981. }
  138982. }
  138983. declare module BABYLON {
  138984. /** @hidden */
  138985. export var ssaoPixelShader: {
  138986. name: string;
  138987. shader: string;
  138988. };
  138989. }
  138990. declare module BABYLON {
  138991. /**
  138992. * Render pipeline to produce ssao effect
  138993. */
  138994. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  138995. /**
  138996. * @ignore
  138997. * The PassPostProcess id in the pipeline that contains the original scene color
  138998. */
  138999. SSAOOriginalSceneColorEffect: string;
  139000. /**
  139001. * @ignore
  139002. * The SSAO PostProcess id in the pipeline
  139003. */
  139004. SSAORenderEffect: string;
  139005. /**
  139006. * @ignore
  139007. * The horizontal blur PostProcess id in the pipeline
  139008. */
  139009. SSAOBlurHRenderEffect: string;
  139010. /**
  139011. * @ignore
  139012. * The vertical blur PostProcess id in the pipeline
  139013. */
  139014. SSAOBlurVRenderEffect: string;
  139015. /**
  139016. * @ignore
  139017. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  139018. */
  139019. SSAOCombineRenderEffect: string;
  139020. /**
  139021. * The output strength of the SSAO post-process. Default value is 1.0.
  139022. */
  139023. totalStrength: number;
  139024. /**
  139025. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  139026. */
  139027. radius: number;
  139028. /**
  139029. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  139030. * Must not be equal to fallOff and superior to fallOff.
  139031. * Default value is 0.0075
  139032. */
  139033. area: number;
  139034. /**
  139035. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  139036. * Must not be equal to area and inferior to area.
  139037. * Default value is 0.000001
  139038. */
  139039. fallOff: number;
  139040. /**
  139041. * The base color of the SSAO post-process
  139042. * The final result is "base + ssao" between [0, 1]
  139043. */
  139044. base: number;
  139045. private _scene;
  139046. private _depthTexture;
  139047. private _randomTexture;
  139048. private _originalColorPostProcess;
  139049. private _ssaoPostProcess;
  139050. private _blurHPostProcess;
  139051. private _blurVPostProcess;
  139052. private _ssaoCombinePostProcess;
  139053. private _firstUpdate;
  139054. /**
  139055. * Gets active scene
  139056. */
  139057. get scene(): Scene;
  139058. /**
  139059. * @constructor
  139060. * @param name - The rendering pipeline name
  139061. * @param scene - The scene linked to this pipeline
  139062. * @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 }
  139063. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  139064. */
  139065. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  139066. /**
  139067. * Get the class name
  139068. * @returns "SSAORenderingPipeline"
  139069. */
  139070. getClassName(): string;
  139071. /**
  139072. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  139073. */
  139074. dispose(disableDepthRender?: boolean): void;
  139075. private _createBlurPostProcess;
  139076. /** @hidden */
  139077. _rebuild(): void;
  139078. private _createSSAOPostProcess;
  139079. private _createSSAOCombinePostProcess;
  139080. private _createRandomTexture;
  139081. }
  139082. }
  139083. declare module BABYLON {
  139084. /** @hidden */
  139085. export var screenSpaceReflectionPixelShader: {
  139086. name: string;
  139087. shader: string;
  139088. };
  139089. }
  139090. declare module BABYLON {
  139091. /**
  139092. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  139093. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  139094. */
  139095. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  139096. /**
  139097. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  139098. */
  139099. threshold: number;
  139100. /**
  139101. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  139102. */
  139103. strength: number;
  139104. /**
  139105. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  139106. */
  139107. reflectionSpecularFalloffExponent: number;
  139108. /**
  139109. * 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]
  139110. */
  139111. step: number;
  139112. /**
  139113. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  139114. */
  139115. roughnessFactor: number;
  139116. private _geometryBufferRenderer;
  139117. private _enableSmoothReflections;
  139118. private _reflectionSamples;
  139119. private _smoothSteps;
  139120. /**
  139121. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  139122. * @param name The name of the effect.
  139123. * @param scene The scene containing the objects to calculate reflections.
  139124. * @param options The required width/height ratio to downsize to before computing the render pass.
  139125. * @param camera The camera to apply the render pass to.
  139126. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139127. * @param engine The engine which the post process will be applied. (default: current engine)
  139128. * @param reusable If the post process can be reused on the same frame. (default: false)
  139129. * @param textureType Type of textures used when performing the post process. (default: 0)
  139130. * @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)
  139131. */
  139132. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139133. /**
  139134. * Gets wether or not smoothing reflections is enabled.
  139135. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  139136. */
  139137. get enableSmoothReflections(): boolean;
  139138. /**
  139139. * Sets wether or not smoothing reflections is enabled.
  139140. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  139141. */
  139142. set enableSmoothReflections(enabled: boolean);
  139143. /**
  139144. * Gets the number of samples taken while computing reflections. More samples count is high,
  139145. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  139146. */
  139147. get reflectionSamples(): number;
  139148. /**
  139149. * Sets the number of samples taken while computing reflections. More samples count is high,
  139150. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  139151. */
  139152. set reflectionSamples(samples: number);
  139153. /**
  139154. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  139155. * more the post-process will require GPU power and can generate a drop in FPS.
  139156. * Default value (5.0) work pretty well in all cases but can be adjusted.
  139157. */
  139158. get smoothSteps(): number;
  139159. set smoothSteps(steps: number);
  139160. private _updateEffectDefines;
  139161. }
  139162. }
  139163. declare module BABYLON {
  139164. /** @hidden */
  139165. export var standardPixelShader: {
  139166. name: string;
  139167. shader: string;
  139168. };
  139169. }
  139170. declare module BABYLON {
  139171. /**
  139172. * Standard rendering pipeline
  139173. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  139174. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  139175. */
  139176. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  139177. /**
  139178. * Public members
  139179. */
  139180. /**
  139181. * Post-process which contains the original scene color before the pipeline applies all the effects
  139182. */
  139183. originalPostProcess: Nullable<PostProcess>;
  139184. /**
  139185. * Post-process used to down scale an image x4
  139186. */
  139187. downSampleX4PostProcess: Nullable<PostProcess>;
  139188. /**
  139189. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  139190. */
  139191. brightPassPostProcess: Nullable<PostProcess>;
  139192. /**
  139193. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  139194. */
  139195. blurHPostProcesses: PostProcess[];
  139196. /**
  139197. * Post-process array storing all the vertical blur post-processes used by the pipeline
  139198. */
  139199. blurVPostProcesses: PostProcess[];
  139200. /**
  139201. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  139202. */
  139203. textureAdderPostProcess: Nullable<PostProcess>;
  139204. /**
  139205. * Post-process used to create volumetric lighting effect
  139206. */
  139207. volumetricLightPostProcess: Nullable<PostProcess>;
  139208. /**
  139209. * Post-process used to smooth the previous volumetric light post-process on the X axis
  139210. */
  139211. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  139212. /**
  139213. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  139214. */
  139215. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  139216. /**
  139217. * Post-process used to merge the volumetric light effect and the real scene color
  139218. */
  139219. volumetricLightMergePostProces: Nullable<PostProcess>;
  139220. /**
  139221. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  139222. */
  139223. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  139224. /**
  139225. * Base post-process used to calculate the average luminance of the final image for HDR
  139226. */
  139227. luminancePostProcess: Nullable<PostProcess>;
  139228. /**
  139229. * Post-processes used to create down sample post-processes in order to get
  139230. * the average luminance of the final image for HDR
  139231. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  139232. */
  139233. luminanceDownSamplePostProcesses: PostProcess[];
  139234. /**
  139235. * Post-process used to create a HDR effect (light adaptation)
  139236. */
  139237. hdrPostProcess: Nullable<PostProcess>;
  139238. /**
  139239. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  139240. */
  139241. textureAdderFinalPostProcess: Nullable<PostProcess>;
  139242. /**
  139243. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  139244. */
  139245. lensFlareFinalPostProcess: Nullable<PostProcess>;
  139246. /**
  139247. * Post-process used to merge the final HDR post-process and the real scene color
  139248. */
  139249. hdrFinalPostProcess: Nullable<PostProcess>;
  139250. /**
  139251. * Post-process used to create a lens flare effect
  139252. */
  139253. lensFlarePostProcess: Nullable<PostProcess>;
  139254. /**
  139255. * Post-process that merges the result of the lens flare post-process and the real scene color
  139256. */
  139257. lensFlareComposePostProcess: Nullable<PostProcess>;
  139258. /**
  139259. * Post-process used to create a motion blur effect
  139260. */
  139261. motionBlurPostProcess: Nullable<PostProcess>;
  139262. /**
  139263. * Post-process used to create a depth of field effect
  139264. */
  139265. depthOfFieldPostProcess: Nullable<PostProcess>;
  139266. /**
  139267. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  139268. */
  139269. fxaaPostProcess: Nullable<FxaaPostProcess>;
  139270. /**
  139271. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  139272. */
  139273. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  139274. /**
  139275. * Represents the brightness threshold in order to configure the illuminated surfaces
  139276. */
  139277. brightThreshold: number;
  139278. /**
  139279. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  139280. */
  139281. blurWidth: number;
  139282. /**
  139283. * Sets if the blur for highlighted surfaces must be only horizontal
  139284. */
  139285. horizontalBlur: boolean;
  139286. /**
  139287. * Gets the overall exposure used by the pipeline
  139288. */
  139289. get exposure(): number;
  139290. /**
  139291. * Sets the overall exposure used by the pipeline
  139292. */
  139293. set exposure(value: number);
  139294. /**
  139295. * Texture used typically to simulate "dirty" on camera lens
  139296. */
  139297. lensTexture: Nullable<Texture>;
  139298. /**
  139299. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  139300. */
  139301. volumetricLightCoefficient: number;
  139302. /**
  139303. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  139304. */
  139305. volumetricLightPower: number;
  139306. /**
  139307. * Used the set the blur intensity to smooth the volumetric lights
  139308. */
  139309. volumetricLightBlurScale: number;
  139310. /**
  139311. * Light (spot or directional) used to generate the volumetric lights rays
  139312. * The source light must have a shadow generate so the pipeline can get its
  139313. * depth map
  139314. */
  139315. sourceLight: Nullable<SpotLight | DirectionalLight>;
  139316. /**
  139317. * For eye adaptation, represents the minimum luminance the eye can see
  139318. */
  139319. hdrMinimumLuminance: number;
  139320. /**
  139321. * For eye adaptation, represents the decrease luminance speed
  139322. */
  139323. hdrDecreaseRate: number;
  139324. /**
  139325. * For eye adaptation, represents the increase luminance speed
  139326. */
  139327. hdrIncreaseRate: number;
  139328. /**
  139329. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  139330. */
  139331. get hdrAutoExposure(): boolean;
  139332. /**
  139333. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  139334. */
  139335. set hdrAutoExposure(value: boolean);
  139336. /**
  139337. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  139338. */
  139339. lensColorTexture: Nullable<Texture>;
  139340. /**
  139341. * The overall strengh for the lens flare effect
  139342. */
  139343. lensFlareStrength: number;
  139344. /**
  139345. * Dispersion coefficient for lens flare ghosts
  139346. */
  139347. lensFlareGhostDispersal: number;
  139348. /**
  139349. * Main lens flare halo width
  139350. */
  139351. lensFlareHaloWidth: number;
  139352. /**
  139353. * Based on the lens distortion effect, defines how much the lens flare result
  139354. * is distorted
  139355. */
  139356. lensFlareDistortionStrength: number;
  139357. /**
  139358. * Configures the blur intensity used for for lens flare (halo)
  139359. */
  139360. lensFlareBlurWidth: number;
  139361. /**
  139362. * Lens star texture must be used to simulate rays on the flares and is available
  139363. * in the documentation
  139364. */
  139365. lensStarTexture: Nullable<Texture>;
  139366. /**
  139367. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  139368. * flare effect by taking account of the dirt texture
  139369. */
  139370. lensFlareDirtTexture: Nullable<Texture>;
  139371. /**
  139372. * Represents the focal length for the depth of field effect
  139373. */
  139374. depthOfFieldDistance: number;
  139375. /**
  139376. * Represents the blur intensity for the blurred part of the depth of field effect
  139377. */
  139378. depthOfFieldBlurWidth: number;
  139379. /**
  139380. * Gets how much the image is blurred by the movement while using the motion blur post-process
  139381. */
  139382. get motionStrength(): number;
  139383. /**
  139384. * Sets how much the image is blurred by the movement while using the motion blur post-process
  139385. */
  139386. set motionStrength(strength: number);
  139387. /**
  139388. * Gets wether or not the motion blur post-process is object based or screen based.
  139389. */
  139390. get objectBasedMotionBlur(): boolean;
  139391. /**
  139392. * Sets wether or not the motion blur post-process should be object based or screen based
  139393. */
  139394. set objectBasedMotionBlur(value: boolean);
  139395. /**
  139396. * List of animations for the pipeline (IAnimatable implementation)
  139397. */
  139398. animations: Animation[];
  139399. /**
  139400. * Private members
  139401. */
  139402. private _scene;
  139403. private _currentDepthOfFieldSource;
  139404. private _basePostProcess;
  139405. private _fixedExposure;
  139406. private _currentExposure;
  139407. private _hdrAutoExposure;
  139408. private _hdrCurrentLuminance;
  139409. private _motionStrength;
  139410. private _isObjectBasedMotionBlur;
  139411. private _floatTextureType;
  139412. private _camerasToBeAttached;
  139413. private _ratio;
  139414. private _bloomEnabled;
  139415. private _depthOfFieldEnabled;
  139416. private _vlsEnabled;
  139417. private _lensFlareEnabled;
  139418. private _hdrEnabled;
  139419. private _motionBlurEnabled;
  139420. private _fxaaEnabled;
  139421. private _screenSpaceReflectionsEnabled;
  139422. private _motionBlurSamples;
  139423. private _volumetricLightStepsCount;
  139424. private _samples;
  139425. /**
  139426. * @ignore
  139427. * Specifies if the bloom pipeline is enabled
  139428. */
  139429. get BloomEnabled(): boolean;
  139430. set BloomEnabled(enabled: boolean);
  139431. /**
  139432. * @ignore
  139433. * Specifies if the depth of field pipeline is enabed
  139434. */
  139435. get DepthOfFieldEnabled(): boolean;
  139436. set DepthOfFieldEnabled(enabled: boolean);
  139437. /**
  139438. * @ignore
  139439. * Specifies if the lens flare pipeline is enabed
  139440. */
  139441. get LensFlareEnabled(): boolean;
  139442. set LensFlareEnabled(enabled: boolean);
  139443. /**
  139444. * @ignore
  139445. * Specifies if the HDR pipeline is enabled
  139446. */
  139447. get HDREnabled(): boolean;
  139448. set HDREnabled(enabled: boolean);
  139449. /**
  139450. * @ignore
  139451. * Specifies if the volumetric lights scattering effect is enabled
  139452. */
  139453. get VLSEnabled(): boolean;
  139454. set VLSEnabled(enabled: boolean);
  139455. /**
  139456. * @ignore
  139457. * Specifies if the motion blur effect is enabled
  139458. */
  139459. get MotionBlurEnabled(): boolean;
  139460. set MotionBlurEnabled(enabled: boolean);
  139461. /**
  139462. * Specifies if anti-aliasing is enabled
  139463. */
  139464. get fxaaEnabled(): boolean;
  139465. set fxaaEnabled(enabled: boolean);
  139466. /**
  139467. * Specifies if screen space reflections are enabled.
  139468. */
  139469. get screenSpaceReflectionsEnabled(): boolean;
  139470. set screenSpaceReflectionsEnabled(enabled: boolean);
  139471. /**
  139472. * Specifies the number of steps used to calculate the volumetric lights
  139473. * Typically in interval [50, 200]
  139474. */
  139475. get volumetricLightStepsCount(): number;
  139476. set volumetricLightStepsCount(count: number);
  139477. /**
  139478. * Specifies the number of samples used for the motion blur effect
  139479. * Typically in interval [16, 64]
  139480. */
  139481. get motionBlurSamples(): number;
  139482. set motionBlurSamples(samples: number);
  139483. /**
  139484. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  139485. */
  139486. get samples(): number;
  139487. set samples(sampleCount: number);
  139488. /**
  139489. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  139490. * @constructor
  139491. * @param name The rendering pipeline name
  139492. * @param scene The scene linked to this pipeline
  139493. * @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)
  139494. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  139495. * @param cameras The array of cameras that the rendering pipeline will be attached to
  139496. */
  139497. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  139498. private _buildPipeline;
  139499. private _createDownSampleX4PostProcess;
  139500. private _createBrightPassPostProcess;
  139501. private _createBlurPostProcesses;
  139502. private _createTextureAdderPostProcess;
  139503. private _createVolumetricLightPostProcess;
  139504. private _createLuminancePostProcesses;
  139505. private _createHdrPostProcess;
  139506. private _createLensFlarePostProcess;
  139507. private _createDepthOfFieldPostProcess;
  139508. private _createMotionBlurPostProcess;
  139509. private _getDepthTexture;
  139510. private _disposePostProcesses;
  139511. /**
  139512. * Dispose of the pipeline and stop all post processes
  139513. */
  139514. dispose(): void;
  139515. /**
  139516. * Serialize the rendering pipeline (Used when exporting)
  139517. * @returns the serialized object
  139518. */
  139519. serialize(): any;
  139520. /**
  139521. * Parse the serialized pipeline
  139522. * @param source Source pipeline.
  139523. * @param scene The scene to load the pipeline to.
  139524. * @param rootUrl The URL of the serialized pipeline.
  139525. * @returns An instantiated pipeline from the serialized object.
  139526. */
  139527. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  139528. /**
  139529. * Luminance steps
  139530. */
  139531. static LuminanceSteps: number;
  139532. }
  139533. }
  139534. declare module BABYLON {
  139535. /** @hidden */
  139536. export var tonemapPixelShader: {
  139537. name: string;
  139538. shader: string;
  139539. };
  139540. }
  139541. declare module BABYLON {
  139542. /** Defines operator used for tonemapping */
  139543. export enum TonemappingOperator {
  139544. /** Hable */
  139545. Hable = 0,
  139546. /** Reinhard */
  139547. Reinhard = 1,
  139548. /** HejiDawson */
  139549. HejiDawson = 2,
  139550. /** Photographic */
  139551. Photographic = 3
  139552. }
  139553. /**
  139554. * Defines a post process to apply tone mapping
  139555. */
  139556. export class TonemapPostProcess extends PostProcess {
  139557. private _operator;
  139558. /** Defines the required exposure adjustement */
  139559. exposureAdjustment: number;
  139560. /**
  139561. * Creates a new TonemapPostProcess
  139562. * @param name defines the name of the postprocess
  139563. * @param _operator defines the operator to use
  139564. * @param exposureAdjustment defines the required exposure adjustement
  139565. * @param camera defines the camera to use (can be null)
  139566. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  139567. * @param engine defines the hosting engine (can be ignore if camera is set)
  139568. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  139569. */
  139570. constructor(name: string, _operator: TonemappingOperator,
  139571. /** Defines the required exposure adjustement */
  139572. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  139573. }
  139574. }
  139575. declare module BABYLON {
  139576. /** @hidden */
  139577. export var volumetricLightScatteringPixelShader: {
  139578. name: string;
  139579. shader: string;
  139580. };
  139581. }
  139582. declare module BABYLON {
  139583. /** @hidden */
  139584. export var volumetricLightScatteringPassVertexShader: {
  139585. name: string;
  139586. shader: string;
  139587. };
  139588. }
  139589. declare module BABYLON {
  139590. /** @hidden */
  139591. export var volumetricLightScatteringPassPixelShader: {
  139592. name: string;
  139593. shader: string;
  139594. };
  139595. }
  139596. declare module BABYLON {
  139597. /**
  139598. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  139599. */
  139600. export class VolumetricLightScatteringPostProcess extends PostProcess {
  139601. private _volumetricLightScatteringPass;
  139602. private _volumetricLightScatteringRTT;
  139603. private _viewPort;
  139604. private _screenCoordinates;
  139605. private _cachedDefines;
  139606. /**
  139607. * If not undefined, the mesh position is computed from the attached node position
  139608. */
  139609. attachedNode: {
  139610. position: Vector3;
  139611. };
  139612. /**
  139613. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  139614. */
  139615. customMeshPosition: Vector3;
  139616. /**
  139617. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  139618. */
  139619. useCustomMeshPosition: boolean;
  139620. /**
  139621. * If the post-process should inverse the light scattering direction
  139622. */
  139623. invert: boolean;
  139624. /**
  139625. * The internal mesh used by the post-process
  139626. */
  139627. mesh: Mesh;
  139628. /**
  139629. * @hidden
  139630. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  139631. */
  139632. get useDiffuseColor(): boolean;
  139633. set useDiffuseColor(useDiffuseColor: boolean);
  139634. /**
  139635. * Array containing the excluded meshes not rendered in the internal pass
  139636. */
  139637. excludedMeshes: AbstractMesh[];
  139638. /**
  139639. * Controls the overall intensity of the post-process
  139640. */
  139641. exposure: number;
  139642. /**
  139643. * Dissipates each sample's contribution in range [0, 1]
  139644. */
  139645. decay: number;
  139646. /**
  139647. * Controls the overall intensity of each sample
  139648. */
  139649. weight: number;
  139650. /**
  139651. * Controls the density of each sample
  139652. */
  139653. density: number;
  139654. /**
  139655. * @constructor
  139656. * @param name The post-process name
  139657. * @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)
  139658. * @param camera The camera that the post-process will be attached to
  139659. * @param mesh The mesh used to create the light scattering
  139660. * @param samples The post-process quality, default 100
  139661. * @param samplingModeThe post-process filtering mode
  139662. * @param engine The babylon engine
  139663. * @param reusable If the post-process is reusable
  139664. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  139665. */
  139666. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  139667. /**
  139668. * Returns the string "VolumetricLightScatteringPostProcess"
  139669. * @returns "VolumetricLightScatteringPostProcess"
  139670. */
  139671. getClassName(): string;
  139672. private _isReady;
  139673. /**
  139674. * Sets the new light position for light scattering effect
  139675. * @param position The new custom light position
  139676. */
  139677. setCustomMeshPosition(position: Vector3): void;
  139678. /**
  139679. * Returns the light position for light scattering effect
  139680. * @return Vector3 The custom light position
  139681. */
  139682. getCustomMeshPosition(): Vector3;
  139683. /**
  139684. * Disposes the internal assets and detaches the post-process from the camera
  139685. */
  139686. dispose(camera: Camera): void;
  139687. /**
  139688. * Returns the render target texture used by the post-process
  139689. * @return the render target texture used by the post-process
  139690. */
  139691. getPass(): RenderTargetTexture;
  139692. private _meshExcluded;
  139693. private _createPass;
  139694. private _updateMeshScreenCoordinates;
  139695. /**
  139696. * Creates a default mesh for the Volumeric Light Scattering post-process
  139697. * @param name The mesh name
  139698. * @param scene The scene where to create the mesh
  139699. * @return the default mesh
  139700. */
  139701. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  139702. }
  139703. }
  139704. declare module BABYLON {
  139705. interface Scene {
  139706. /** @hidden (Backing field) */
  139707. _boundingBoxRenderer: BoundingBoxRenderer;
  139708. /** @hidden (Backing field) */
  139709. _forceShowBoundingBoxes: boolean;
  139710. /**
  139711. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  139712. */
  139713. forceShowBoundingBoxes: boolean;
  139714. /**
  139715. * Gets the bounding box renderer associated with the scene
  139716. * @returns a BoundingBoxRenderer
  139717. */
  139718. getBoundingBoxRenderer(): BoundingBoxRenderer;
  139719. }
  139720. interface AbstractMesh {
  139721. /** @hidden (Backing field) */
  139722. _showBoundingBox: boolean;
  139723. /**
  139724. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  139725. */
  139726. showBoundingBox: boolean;
  139727. }
  139728. /**
  139729. * Component responsible of rendering the bounding box of the meshes in a scene.
  139730. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  139731. */
  139732. export class BoundingBoxRenderer implements ISceneComponent {
  139733. /**
  139734. * The component name helpfull to identify the component in the list of scene components.
  139735. */
  139736. readonly name: string;
  139737. /**
  139738. * The scene the component belongs to.
  139739. */
  139740. scene: Scene;
  139741. /**
  139742. * Color of the bounding box lines placed in front of an object
  139743. */
  139744. frontColor: Color3;
  139745. /**
  139746. * Color of the bounding box lines placed behind an object
  139747. */
  139748. backColor: Color3;
  139749. /**
  139750. * Defines if the renderer should show the back lines or not
  139751. */
  139752. showBackLines: boolean;
  139753. /**
  139754. * @hidden
  139755. */
  139756. renderList: SmartArray<BoundingBox>;
  139757. private _colorShader;
  139758. private _vertexBuffers;
  139759. private _indexBuffer;
  139760. private _fillIndexBuffer;
  139761. private _fillIndexData;
  139762. /**
  139763. * Instantiates a new bounding box renderer in a scene.
  139764. * @param scene the scene the renderer renders in
  139765. */
  139766. constructor(scene: Scene);
  139767. /**
  139768. * Registers the component in a given scene
  139769. */
  139770. register(): void;
  139771. private _evaluateSubMesh;
  139772. private _activeMesh;
  139773. private _prepareRessources;
  139774. private _createIndexBuffer;
  139775. /**
  139776. * Rebuilds the elements related to this component in case of
  139777. * context lost for instance.
  139778. */
  139779. rebuild(): void;
  139780. /**
  139781. * @hidden
  139782. */
  139783. reset(): void;
  139784. /**
  139785. * Render the bounding boxes of a specific rendering group
  139786. * @param renderingGroupId defines the rendering group to render
  139787. */
  139788. render(renderingGroupId: number): void;
  139789. /**
  139790. * In case of occlusion queries, we can render the occlusion bounding box through this method
  139791. * @param mesh Define the mesh to render the occlusion bounding box for
  139792. */
  139793. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  139794. /**
  139795. * Dispose and release the resources attached to this renderer.
  139796. */
  139797. dispose(): void;
  139798. }
  139799. }
  139800. declare module BABYLON {
  139801. interface Scene {
  139802. /** @hidden (Backing field) */
  139803. _depthRenderer: {
  139804. [id: string]: DepthRenderer;
  139805. };
  139806. /**
  139807. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  139808. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  139809. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  139810. * @returns the created depth renderer
  139811. */
  139812. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  139813. /**
  139814. * Disables a depth renderer for a given camera
  139815. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  139816. */
  139817. disableDepthRenderer(camera?: Nullable<Camera>): void;
  139818. }
  139819. /**
  139820. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  139821. * in several rendering techniques.
  139822. */
  139823. export class DepthRendererSceneComponent implements ISceneComponent {
  139824. /**
  139825. * The component name helpfull to identify the component in the list of scene components.
  139826. */
  139827. readonly name: string;
  139828. /**
  139829. * The scene the component belongs to.
  139830. */
  139831. scene: Scene;
  139832. /**
  139833. * Creates a new instance of the component for the given scene
  139834. * @param scene Defines the scene to register the component in
  139835. */
  139836. constructor(scene: Scene);
  139837. /**
  139838. * Registers the component in a given scene
  139839. */
  139840. register(): void;
  139841. /**
  139842. * Rebuilds the elements related to this component in case of
  139843. * context lost for instance.
  139844. */
  139845. rebuild(): void;
  139846. /**
  139847. * Disposes the component and the associated ressources
  139848. */
  139849. dispose(): void;
  139850. private _gatherRenderTargets;
  139851. private _gatherActiveCameraRenderTargets;
  139852. }
  139853. }
  139854. declare module BABYLON {
  139855. /** @hidden */
  139856. export var outlinePixelShader: {
  139857. name: string;
  139858. shader: string;
  139859. };
  139860. }
  139861. declare module BABYLON {
  139862. /** @hidden */
  139863. export var outlineVertexShader: {
  139864. name: string;
  139865. shader: string;
  139866. };
  139867. }
  139868. declare module BABYLON {
  139869. interface Scene {
  139870. /** @hidden */
  139871. _outlineRenderer: OutlineRenderer;
  139872. /**
  139873. * Gets the outline renderer associated with the scene
  139874. * @returns a OutlineRenderer
  139875. */
  139876. getOutlineRenderer(): OutlineRenderer;
  139877. }
  139878. interface AbstractMesh {
  139879. /** @hidden (Backing field) */
  139880. _renderOutline: boolean;
  139881. /**
  139882. * Gets or sets a boolean indicating if the outline must be rendered as well
  139883. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  139884. */
  139885. renderOutline: boolean;
  139886. /** @hidden (Backing field) */
  139887. _renderOverlay: boolean;
  139888. /**
  139889. * Gets or sets a boolean indicating if the overlay must be rendered as well
  139890. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  139891. */
  139892. renderOverlay: boolean;
  139893. }
  139894. /**
  139895. * This class is responsible to draw bothe outline/overlay of meshes.
  139896. * It should not be used directly but through the available method on mesh.
  139897. */
  139898. export class OutlineRenderer implements ISceneComponent {
  139899. /**
  139900. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  139901. */
  139902. private static _StencilReference;
  139903. /**
  139904. * The name of the component. Each component must have a unique name.
  139905. */
  139906. name: string;
  139907. /**
  139908. * The scene the component belongs to.
  139909. */
  139910. scene: Scene;
  139911. /**
  139912. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  139913. */
  139914. zOffset: number;
  139915. private _engine;
  139916. private _effect;
  139917. private _cachedDefines;
  139918. private _savedDepthWrite;
  139919. /**
  139920. * Instantiates a new outline renderer. (There could be only one per scene).
  139921. * @param scene Defines the scene it belongs to
  139922. */
  139923. constructor(scene: Scene);
  139924. /**
  139925. * Register the component to one instance of a scene.
  139926. */
  139927. register(): void;
  139928. /**
  139929. * Rebuilds the elements related to this component in case of
  139930. * context lost for instance.
  139931. */
  139932. rebuild(): void;
  139933. /**
  139934. * Disposes the component and the associated ressources.
  139935. */
  139936. dispose(): void;
  139937. /**
  139938. * Renders the outline in the canvas.
  139939. * @param subMesh Defines the sumesh to render
  139940. * @param batch Defines the batch of meshes in case of instances
  139941. * @param useOverlay Defines if the rendering is for the overlay or the outline
  139942. */
  139943. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  139944. /**
  139945. * Returns whether or not the outline renderer is ready for a given submesh.
  139946. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  139947. * @param subMesh Defines the submesh to check readyness for
  139948. * @param useInstances Defines wheter wee are trying to render instances or not
  139949. * @returns true if ready otherwise false
  139950. */
  139951. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139952. private _beforeRenderingMesh;
  139953. private _afterRenderingMesh;
  139954. }
  139955. }
  139956. declare module BABYLON {
  139957. /**
  139958. * Defines the basic options interface of a Sprite Frame Source Size.
  139959. */
  139960. export interface ISpriteJSONSpriteSourceSize {
  139961. /**
  139962. * number of the original width of the Frame
  139963. */
  139964. w: number;
  139965. /**
  139966. * number of the original height of the Frame
  139967. */
  139968. h: number;
  139969. }
  139970. /**
  139971. * Defines the basic options interface of a Sprite Frame Data.
  139972. */
  139973. export interface ISpriteJSONSpriteFrameData {
  139974. /**
  139975. * number of the x offset of the Frame
  139976. */
  139977. x: number;
  139978. /**
  139979. * number of the y offset of the Frame
  139980. */
  139981. y: number;
  139982. /**
  139983. * number of the width of the Frame
  139984. */
  139985. w: number;
  139986. /**
  139987. * number of the height of the Frame
  139988. */
  139989. h: number;
  139990. }
  139991. /**
  139992. * Defines the basic options interface of a JSON Sprite.
  139993. */
  139994. export interface ISpriteJSONSprite {
  139995. /**
  139996. * string name of the Frame
  139997. */
  139998. filename: string;
  139999. /**
  140000. * ISpriteJSONSpriteFrame basic object of the frame data
  140001. */
  140002. frame: ISpriteJSONSpriteFrameData;
  140003. /**
  140004. * boolean to flag is the frame was rotated.
  140005. */
  140006. rotated: boolean;
  140007. /**
  140008. * boolean to flag is the frame was trimmed.
  140009. */
  140010. trimmed: boolean;
  140011. /**
  140012. * ISpriteJSONSpriteFrame basic object of the source data
  140013. */
  140014. spriteSourceSize: ISpriteJSONSpriteFrameData;
  140015. /**
  140016. * ISpriteJSONSpriteFrame basic object of the source data
  140017. */
  140018. sourceSize: ISpriteJSONSpriteSourceSize;
  140019. }
  140020. /**
  140021. * Defines the basic options interface of a JSON atlas.
  140022. */
  140023. export interface ISpriteJSONAtlas {
  140024. /**
  140025. * Array of objects that contain the frame data.
  140026. */
  140027. frames: Array<ISpriteJSONSprite>;
  140028. /**
  140029. * object basic object containing the sprite meta data.
  140030. */
  140031. meta?: object;
  140032. }
  140033. }
  140034. declare module BABYLON {
  140035. /** @hidden */
  140036. export var spriteMapPixelShader: {
  140037. name: string;
  140038. shader: string;
  140039. };
  140040. }
  140041. declare module BABYLON {
  140042. /** @hidden */
  140043. export var spriteMapVertexShader: {
  140044. name: string;
  140045. shader: string;
  140046. };
  140047. }
  140048. declare module BABYLON {
  140049. /**
  140050. * Defines the basic options interface of a SpriteMap
  140051. */
  140052. export interface ISpriteMapOptions {
  140053. /**
  140054. * Vector2 of the number of cells in the grid.
  140055. */
  140056. stageSize?: Vector2;
  140057. /**
  140058. * Vector2 of the size of the output plane in World Units.
  140059. */
  140060. outputSize?: Vector2;
  140061. /**
  140062. * Vector3 of the position of the output plane in World Units.
  140063. */
  140064. outputPosition?: Vector3;
  140065. /**
  140066. * Vector3 of the rotation of the output plane.
  140067. */
  140068. outputRotation?: Vector3;
  140069. /**
  140070. * number of layers that the system will reserve in resources.
  140071. */
  140072. layerCount?: number;
  140073. /**
  140074. * number of max animation frames a single cell will reserve in resources.
  140075. */
  140076. maxAnimationFrames?: number;
  140077. /**
  140078. * number cell index of the base tile when the system compiles.
  140079. */
  140080. baseTile?: number;
  140081. /**
  140082. * boolean flip the sprite after its been repositioned by the framing data.
  140083. */
  140084. flipU?: boolean;
  140085. /**
  140086. * Vector3 scalar of the global RGB values of the SpriteMap.
  140087. */
  140088. colorMultiply?: Vector3;
  140089. }
  140090. /**
  140091. * Defines the IDisposable interface in order to be cleanable from resources.
  140092. */
  140093. export interface ISpriteMap extends IDisposable {
  140094. /**
  140095. * String name of the SpriteMap.
  140096. */
  140097. name: string;
  140098. /**
  140099. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  140100. */
  140101. atlasJSON: ISpriteJSONAtlas;
  140102. /**
  140103. * Texture of the SpriteMap.
  140104. */
  140105. spriteSheet: Texture;
  140106. /**
  140107. * The parameters to initialize the SpriteMap with.
  140108. */
  140109. options: ISpriteMapOptions;
  140110. }
  140111. /**
  140112. * Class used to manage a grid restricted sprite deployment on an Output plane.
  140113. */
  140114. export class SpriteMap implements ISpriteMap {
  140115. /** The Name of the spriteMap */
  140116. name: string;
  140117. /** The JSON file with the frame and meta data */
  140118. atlasJSON: ISpriteJSONAtlas;
  140119. /** The systems Sprite Sheet Texture */
  140120. spriteSheet: Texture;
  140121. /** Arguments passed with the Constructor */
  140122. options: ISpriteMapOptions;
  140123. /** Public Sprite Storage array, parsed from atlasJSON */
  140124. sprites: Array<ISpriteJSONSprite>;
  140125. /** Returns the Number of Sprites in the System */
  140126. get spriteCount(): number;
  140127. /** Returns the Position of Output Plane*/
  140128. get position(): Vector3;
  140129. /** Returns the Position of Output Plane*/
  140130. set position(v: Vector3);
  140131. /** Returns the Rotation of Output Plane*/
  140132. get rotation(): Vector3;
  140133. /** Returns the Rotation of Output Plane*/
  140134. set rotation(v: Vector3);
  140135. /** Sets the AnimationMap*/
  140136. get animationMap(): RawTexture;
  140137. /** Sets the AnimationMap*/
  140138. set animationMap(v: RawTexture);
  140139. /** Scene that the SpriteMap was created in */
  140140. private _scene;
  140141. /** Texture Buffer of Float32 that holds tile frame data*/
  140142. private _frameMap;
  140143. /** Texture Buffers of Float32 that holds tileMap data*/
  140144. private _tileMaps;
  140145. /** Texture Buffer of Float32 that holds Animation Data*/
  140146. private _animationMap;
  140147. /** Custom ShaderMaterial Central to the System*/
  140148. private _material;
  140149. /** Custom ShaderMaterial Central to the System*/
  140150. private _output;
  140151. /** Systems Time Ticker*/
  140152. private _time;
  140153. /**
  140154. * Creates a new SpriteMap
  140155. * @param name defines the SpriteMaps Name
  140156. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  140157. * @param spriteSheet is the Texture that the Sprites are on.
  140158. * @param options a basic deployment configuration
  140159. * @param scene The Scene that the map is deployed on
  140160. */
  140161. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  140162. /**
  140163. * Returns tileID location
  140164. * @returns Vector2 the cell position ID
  140165. */
  140166. getTileID(): Vector2;
  140167. /**
  140168. * Gets the UV location of the mouse over the SpriteMap.
  140169. * @returns Vector2 the UV position of the mouse interaction
  140170. */
  140171. getMousePosition(): Vector2;
  140172. /**
  140173. * Creates the "frame" texture Buffer
  140174. * -------------------------------------
  140175. * Structure of frames
  140176. * "filename": "Falling-Water-2.png",
  140177. * "frame": {"x":69,"y":103,"w":24,"h":32},
  140178. * "rotated": true,
  140179. * "trimmed": true,
  140180. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  140181. * "sourceSize": {"w":32,"h":32}
  140182. * @returns RawTexture of the frameMap
  140183. */
  140184. private _createFrameBuffer;
  140185. /**
  140186. * Creates the tileMap texture Buffer
  140187. * @param buffer normally and array of numbers, or a false to generate from scratch
  140188. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  140189. * @returns RawTexture of the tileMap
  140190. */
  140191. private _createTileBuffer;
  140192. /**
  140193. * Modifies the data of the tileMaps
  140194. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  140195. * @param pos is the iVector2 Coordinates of the Tile
  140196. * @param tile The SpriteIndex of the new Tile
  140197. */
  140198. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  140199. /**
  140200. * Creates the animationMap texture Buffer
  140201. * @param buffer normally and array of numbers, or a false to generate from scratch
  140202. * @returns RawTexture of the animationMap
  140203. */
  140204. private _createTileAnimationBuffer;
  140205. /**
  140206. * Modifies the data of the animationMap
  140207. * @param cellID is the Index of the Sprite
  140208. * @param _frame is the target Animation frame
  140209. * @param toCell is the Target Index of the next frame of the animation
  140210. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  140211. * @param speed is a global scalar of the time variable on the map.
  140212. */
  140213. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  140214. /**
  140215. * Exports the .tilemaps file
  140216. */
  140217. saveTileMaps(): void;
  140218. /**
  140219. * Imports the .tilemaps file
  140220. * @param url of the .tilemaps file
  140221. */
  140222. loadTileMaps(url: string): void;
  140223. /**
  140224. * Release associated resources
  140225. */
  140226. dispose(): void;
  140227. }
  140228. }
  140229. declare module BABYLON {
  140230. /**
  140231. * Class used to manage multiple sprites of different sizes on the same spritesheet
  140232. * @see http://doc.babylonjs.com/babylon101/sprites
  140233. */
  140234. export class SpritePackedManager extends SpriteManager {
  140235. /** defines the packed manager's name */
  140236. name: string;
  140237. /**
  140238. * Creates a new sprite manager from a packed sprite sheet
  140239. * @param name defines the manager's name
  140240. * @param imgUrl defines the sprite sheet url
  140241. * @param capacity defines the maximum allowed number of sprites
  140242. * @param scene defines the hosting scene
  140243. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  140244. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  140245. * @param samplingMode defines the smapling mode to use with spritesheet
  140246. * @param fromPacked set to true; do not alter
  140247. */
  140248. constructor(
  140249. /** defines the packed manager's name */
  140250. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  140251. }
  140252. }
  140253. declare module BABYLON {
  140254. /**
  140255. * Defines the list of states available for a task inside a AssetsManager
  140256. */
  140257. export enum AssetTaskState {
  140258. /**
  140259. * Initialization
  140260. */
  140261. INIT = 0,
  140262. /**
  140263. * Running
  140264. */
  140265. RUNNING = 1,
  140266. /**
  140267. * Done
  140268. */
  140269. DONE = 2,
  140270. /**
  140271. * Error
  140272. */
  140273. ERROR = 3
  140274. }
  140275. /**
  140276. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  140277. */
  140278. export abstract class AbstractAssetTask {
  140279. /**
  140280. * Task name
  140281. */ name: string;
  140282. /**
  140283. * Callback called when the task is successful
  140284. */
  140285. onSuccess: (task: any) => void;
  140286. /**
  140287. * Callback called when the task is not successful
  140288. */
  140289. onError: (task: any, message?: string, exception?: any) => void;
  140290. /**
  140291. * Creates a new AssetsManager
  140292. * @param name defines the name of the task
  140293. */
  140294. constructor(
  140295. /**
  140296. * Task name
  140297. */ name: string);
  140298. private _isCompleted;
  140299. private _taskState;
  140300. private _errorObject;
  140301. /**
  140302. * Get if the task is completed
  140303. */
  140304. get isCompleted(): boolean;
  140305. /**
  140306. * Gets the current state of the task
  140307. */
  140308. get taskState(): AssetTaskState;
  140309. /**
  140310. * Gets the current error object (if task is in error)
  140311. */
  140312. get errorObject(): {
  140313. message?: string;
  140314. exception?: any;
  140315. };
  140316. /**
  140317. * Internal only
  140318. * @hidden
  140319. */
  140320. _setErrorObject(message?: string, exception?: any): void;
  140321. /**
  140322. * Execute the current task
  140323. * @param scene defines the scene where you want your assets to be loaded
  140324. * @param onSuccess is a callback called when the task is successfully executed
  140325. * @param onError is a callback called if an error occurs
  140326. */
  140327. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140328. /**
  140329. * Execute the current task
  140330. * @param scene defines the scene where you want your assets to be loaded
  140331. * @param onSuccess is a callback called when the task is successfully executed
  140332. * @param onError is a callback called if an error occurs
  140333. */
  140334. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140335. /**
  140336. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  140337. * This can be used with failed tasks that have the reason for failure fixed.
  140338. */
  140339. reset(): void;
  140340. private onErrorCallback;
  140341. private onDoneCallback;
  140342. }
  140343. /**
  140344. * Define the interface used by progress events raised during assets loading
  140345. */
  140346. export interface IAssetsProgressEvent {
  140347. /**
  140348. * Defines the number of remaining tasks to process
  140349. */
  140350. remainingCount: number;
  140351. /**
  140352. * Defines the total number of tasks
  140353. */
  140354. totalCount: number;
  140355. /**
  140356. * Defines the task that was just processed
  140357. */
  140358. task: AbstractAssetTask;
  140359. }
  140360. /**
  140361. * Class used to share progress information about assets loading
  140362. */
  140363. export class AssetsProgressEvent implements IAssetsProgressEvent {
  140364. /**
  140365. * Defines the number of remaining tasks to process
  140366. */
  140367. remainingCount: number;
  140368. /**
  140369. * Defines the total number of tasks
  140370. */
  140371. totalCount: number;
  140372. /**
  140373. * Defines the task that was just processed
  140374. */
  140375. task: AbstractAssetTask;
  140376. /**
  140377. * Creates a AssetsProgressEvent
  140378. * @param remainingCount defines the number of remaining tasks to process
  140379. * @param totalCount defines the total number of tasks
  140380. * @param task defines the task that was just processed
  140381. */
  140382. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  140383. }
  140384. /**
  140385. * Define a task used by AssetsManager to load meshes
  140386. */
  140387. export class MeshAssetTask extends AbstractAssetTask {
  140388. /**
  140389. * Defines the name of the task
  140390. */
  140391. name: string;
  140392. /**
  140393. * Defines the list of mesh's names you want to load
  140394. */
  140395. meshesNames: any;
  140396. /**
  140397. * Defines the root url to use as a base to load your meshes and associated resources
  140398. */
  140399. rootUrl: string;
  140400. /**
  140401. * Defines the filename of the scene to load from
  140402. */
  140403. sceneFilename: string;
  140404. /**
  140405. * Gets the list of loaded meshes
  140406. */
  140407. loadedMeshes: Array<AbstractMesh>;
  140408. /**
  140409. * Gets the list of loaded particle systems
  140410. */
  140411. loadedParticleSystems: Array<IParticleSystem>;
  140412. /**
  140413. * Gets the list of loaded skeletons
  140414. */
  140415. loadedSkeletons: Array<Skeleton>;
  140416. /**
  140417. * Gets the list of loaded animation groups
  140418. */
  140419. loadedAnimationGroups: Array<AnimationGroup>;
  140420. /**
  140421. * Callback called when the task is successful
  140422. */
  140423. onSuccess: (task: MeshAssetTask) => void;
  140424. /**
  140425. * Callback called when the task is successful
  140426. */
  140427. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  140428. /**
  140429. * Creates a new MeshAssetTask
  140430. * @param name defines the name of the task
  140431. * @param meshesNames defines the list of mesh's names you want to load
  140432. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  140433. * @param sceneFilename defines the filename of the scene to load from
  140434. */
  140435. constructor(
  140436. /**
  140437. * Defines the name of the task
  140438. */
  140439. name: string,
  140440. /**
  140441. * Defines the list of mesh's names you want to load
  140442. */
  140443. meshesNames: any,
  140444. /**
  140445. * Defines the root url to use as a base to load your meshes and associated resources
  140446. */
  140447. rootUrl: string,
  140448. /**
  140449. * Defines the filename of the scene to load from
  140450. */
  140451. sceneFilename: string);
  140452. /**
  140453. * Execute the current task
  140454. * @param scene defines the scene where you want your assets to be loaded
  140455. * @param onSuccess is a callback called when the task is successfully executed
  140456. * @param onError is a callback called if an error occurs
  140457. */
  140458. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140459. }
  140460. /**
  140461. * Define a task used by AssetsManager to load text content
  140462. */
  140463. export class TextFileAssetTask extends AbstractAssetTask {
  140464. /**
  140465. * Defines the name of the task
  140466. */
  140467. name: string;
  140468. /**
  140469. * Defines the location of the file to load
  140470. */
  140471. url: string;
  140472. /**
  140473. * Gets the loaded text string
  140474. */
  140475. text: string;
  140476. /**
  140477. * Callback called when the task is successful
  140478. */
  140479. onSuccess: (task: TextFileAssetTask) => void;
  140480. /**
  140481. * Callback called when the task is successful
  140482. */
  140483. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  140484. /**
  140485. * Creates a new TextFileAssetTask object
  140486. * @param name defines the name of the task
  140487. * @param url defines the location of the file to load
  140488. */
  140489. constructor(
  140490. /**
  140491. * Defines the name of the task
  140492. */
  140493. name: string,
  140494. /**
  140495. * Defines the location of the file to load
  140496. */
  140497. url: string);
  140498. /**
  140499. * Execute the current task
  140500. * @param scene defines the scene where you want your assets to be loaded
  140501. * @param onSuccess is a callback called when the task is successfully executed
  140502. * @param onError is a callback called if an error occurs
  140503. */
  140504. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140505. }
  140506. /**
  140507. * Define a task used by AssetsManager to load binary data
  140508. */
  140509. export class BinaryFileAssetTask extends AbstractAssetTask {
  140510. /**
  140511. * Defines the name of the task
  140512. */
  140513. name: string;
  140514. /**
  140515. * Defines the location of the file to load
  140516. */
  140517. url: string;
  140518. /**
  140519. * Gets the lodaded data (as an array buffer)
  140520. */
  140521. data: ArrayBuffer;
  140522. /**
  140523. * Callback called when the task is successful
  140524. */
  140525. onSuccess: (task: BinaryFileAssetTask) => void;
  140526. /**
  140527. * Callback called when the task is successful
  140528. */
  140529. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  140530. /**
  140531. * Creates a new BinaryFileAssetTask object
  140532. * @param name defines the name of the new task
  140533. * @param url defines the location of the file to load
  140534. */
  140535. constructor(
  140536. /**
  140537. * Defines the name of the task
  140538. */
  140539. name: string,
  140540. /**
  140541. * Defines the location of the file to load
  140542. */
  140543. url: string);
  140544. /**
  140545. * Execute the current task
  140546. * @param scene defines the scene where you want your assets to be loaded
  140547. * @param onSuccess is a callback called when the task is successfully executed
  140548. * @param onError is a callback called if an error occurs
  140549. */
  140550. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140551. }
  140552. /**
  140553. * Define a task used by AssetsManager to load images
  140554. */
  140555. export class ImageAssetTask extends AbstractAssetTask {
  140556. /**
  140557. * Defines the name of the task
  140558. */
  140559. name: string;
  140560. /**
  140561. * Defines the location of the image to load
  140562. */
  140563. url: string;
  140564. /**
  140565. * Gets the loaded images
  140566. */
  140567. image: HTMLImageElement;
  140568. /**
  140569. * Callback called when the task is successful
  140570. */
  140571. onSuccess: (task: ImageAssetTask) => void;
  140572. /**
  140573. * Callback called when the task is successful
  140574. */
  140575. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  140576. /**
  140577. * Creates a new ImageAssetTask
  140578. * @param name defines the name of the task
  140579. * @param url defines the location of the image to load
  140580. */
  140581. constructor(
  140582. /**
  140583. * Defines the name of the task
  140584. */
  140585. name: string,
  140586. /**
  140587. * Defines the location of the image to load
  140588. */
  140589. url: string);
  140590. /**
  140591. * Execute the current task
  140592. * @param scene defines the scene where you want your assets to be loaded
  140593. * @param onSuccess is a callback called when the task is successfully executed
  140594. * @param onError is a callback called if an error occurs
  140595. */
  140596. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140597. }
  140598. /**
  140599. * Defines the interface used by texture loading tasks
  140600. */
  140601. export interface ITextureAssetTask<TEX extends BaseTexture> {
  140602. /**
  140603. * Gets the loaded texture
  140604. */
  140605. texture: TEX;
  140606. }
  140607. /**
  140608. * Define a task used by AssetsManager to load 2D textures
  140609. */
  140610. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  140611. /**
  140612. * Defines the name of the task
  140613. */
  140614. name: string;
  140615. /**
  140616. * Defines the location of the file to load
  140617. */
  140618. url: string;
  140619. /**
  140620. * Defines if mipmap should not be generated (default is false)
  140621. */
  140622. noMipmap?: boolean | undefined;
  140623. /**
  140624. * Defines if texture must be inverted on Y axis (default is false)
  140625. */
  140626. invertY?: boolean | undefined;
  140627. /**
  140628. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  140629. */
  140630. samplingMode: number;
  140631. /**
  140632. * Gets the loaded texture
  140633. */
  140634. texture: Texture;
  140635. /**
  140636. * Callback called when the task is successful
  140637. */
  140638. onSuccess: (task: TextureAssetTask) => void;
  140639. /**
  140640. * Callback called when the task is successful
  140641. */
  140642. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  140643. /**
  140644. * Creates a new TextureAssetTask object
  140645. * @param name defines the name of the task
  140646. * @param url defines the location of the file to load
  140647. * @param noMipmap defines if mipmap should not be generated (default is false)
  140648. * @param invertY defines if texture must be inverted on Y axis (default is false)
  140649. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  140650. */
  140651. constructor(
  140652. /**
  140653. * Defines the name of the task
  140654. */
  140655. name: string,
  140656. /**
  140657. * Defines the location of the file to load
  140658. */
  140659. url: string,
  140660. /**
  140661. * Defines if mipmap should not be generated (default is false)
  140662. */
  140663. noMipmap?: boolean | undefined,
  140664. /**
  140665. * Defines if texture must be inverted on Y axis (default is false)
  140666. */
  140667. invertY?: boolean | undefined,
  140668. /**
  140669. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  140670. */
  140671. samplingMode?: number);
  140672. /**
  140673. * Execute the current task
  140674. * @param scene defines the scene where you want your assets to be loaded
  140675. * @param onSuccess is a callback called when the task is successfully executed
  140676. * @param onError is a callback called if an error occurs
  140677. */
  140678. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140679. }
  140680. /**
  140681. * Define a task used by AssetsManager to load cube textures
  140682. */
  140683. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  140684. /**
  140685. * Defines the name of the task
  140686. */
  140687. name: string;
  140688. /**
  140689. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  140690. */
  140691. url: string;
  140692. /**
  140693. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  140694. */
  140695. extensions?: string[] | undefined;
  140696. /**
  140697. * Defines if mipmaps should not be generated (default is false)
  140698. */
  140699. noMipmap?: boolean | undefined;
  140700. /**
  140701. * Defines the explicit list of files (undefined by default)
  140702. */
  140703. files?: string[] | undefined;
  140704. /**
  140705. * Gets the loaded texture
  140706. */
  140707. texture: CubeTexture;
  140708. /**
  140709. * Callback called when the task is successful
  140710. */
  140711. onSuccess: (task: CubeTextureAssetTask) => void;
  140712. /**
  140713. * Callback called when the task is successful
  140714. */
  140715. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  140716. /**
  140717. * Creates a new CubeTextureAssetTask
  140718. * @param name defines the name of the task
  140719. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  140720. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  140721. * @param noMipmap defines if mipmaps should not be generated (default is false)
  140722. * @param files defines the explicit list of files (undefined by default)
  140723. */
  140724. constructor(
  140725. /**
  140726. * Defines the name of the task
  140727. */
  140728. name: string,
  140729. /**
  140730. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  140731. */
  140732. url: string,
  140733. /**
  140734. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  140735. */
  140736. extensions?: string[] | undefined,
  140737. /**
  140738. * Defines if mipmaps should not be generated (default is false)
  140739. */
  140740. noMipmap?: boolean | undefined,
  140741. /**
  140742. * Defines the explicit list of files (undefined by default)
  140743. */
  140744. files?: string[] | undefined);
  140745. /**
  140746. * Execute the current task
  140747. * @param scene defines the scene where you want your assets to be loaded
  140748. * @param onSuccess is a callback called when the task is successfully executed
  140749. * @param onError is a callback called if an error occurs
  140750. */
  140751. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140752. }
  140753. /**
  140754. * Define a task used by AssetsManager to load HDR cube textures
  140755. */
  140756. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  140757. /**
  140758. * Defines the name of the task
  140759. */
  140760. name: string;
  140761. /**
  140762. * Defines the location of the file to load
  140763. */
  140764. url: string;
  140765. /**
  140766. * Defines the desired size (the more it increases the longer the generation will be)
  140767. */
  140768. size: number;
  140769. /**
  140770. * Defines if mipmaps should not be generated (default is false)
  140771. */
  140772. noMipmap: boolean;
  140773. /**
  140774. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  140775. */
  140776. generateHarmonics: boolean;
  140777. /**
  140778. * 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)
  140779. */
  140780. gammaSpace: boolean;
  140781. /**
  140782. * Internal Use Only
  140783. */
  140784. reserved: boolean;
  140785. /**
  140786. * Gets the loaded texture
  140787. */
  140788. texture: HDRCubeTexture;
  140789. /**
  140790. * Callback called when the task is successful
  140791. */
  140792. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  140793. /**
  140794. * Callback called when the task is successful
  140795. */
  140796. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  140797. /**
  140798. * Creates a new HDRCubeTextureAssetTask object
  140799. * @param name defines the name of the task
  140800. * @param url defines the location of the file to load
  140801. * @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.
  140802. * @param noMipmap defines if mipmaps should not be generated (default is false)
  140803. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  140804. * @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)
  140805. * @param reserved Internal use only
  140806. */
  140807. constructor(
  140808. /**
  140809. * Defines the name of the task
  140810. */
  140811. name: string,
  140812. /**
  140813. * Defines the location of the file to load
  140814. */
  140815. url: string,
  140816. /**
  140817. * Defines the desired size (the more it increases the longer the generation will be)
  140818. */
  140819. size: number,
  140820. /**
  140821. * Defines if mipmaps should not be generated (default is false)
  140822. */
  140823. noMipmap?: boolean,
  140824. /**
  140825. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  140826. */
  140827. generateHarmonics?: boolean,
  140828. /**
  140829. * 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)
  140830. */
  140831. gammaSpace?: boolean,
  140832. /**
  140833. * Internal Use Only
  140834. */
  140835. reserved?: boolean);
  140836. /**
  140837. * Execute the current task
  140838. * @param scene defines the scene where you want your assets to be loaded
  140839. * @param onSuccess is a callback called when the task is successfully executed
  140840. * @param onError is a callback called if an error occurs
  140841. */
  140842. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140843. }
  140844. /**
  140845. * Define a task used by AssetsManager to load Equirectangular cube textures
  140846. */
  140847. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  140848. /**
  140849. * Defines the name of the task
  140850. */
  140851. name: string;
  140852. /**
  140853. * Defines the location of the file to load
  140854. */
  140855. url: string;
  140856. /**
  140857. * Defines the desired size (the more it increases the longer the generation will be)
  140858. */
  140859. size: number;
  140860. /**
  140861. * Defines if mipmaps should not be generated (default is false)
  140862. */
  140863. noMipmap: boolean;
  140864. /**
  140865. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  140866. * but the standard material would require them in Gamma space) (default is true)
  140867. */
  140868. gammaSpace: boolean;
  140869. /**
  140870. * Gets the loaded texture
  140871. */
  140872. texture: EquiRectangularCubeTexture;
  140873. /**
  140874. * Callback called when the task is successful
  140875. */
  140876. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  140877. /**
  140878. * Callback called when the task is successful
  140879. */
  140880. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  140881. /**
  140882. * Creates a new EquiRectangularCubeTextureAssetTask object
  140883. * @param name defines the name of the task
  140884. * @param url defines the location of the file to load
  140885. * @param size defines the desired size (the more it increases the longer the generation will be)
  140886. * If the size is omitted this implies you are using a preprocessed cubemap.
  140887. * @param noMipmap defines if mipmaps should not be generated (default is false)
  140888. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  140889. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  140890. * (default is true)
  140891. */
  140892. constructor(
  140893. /**
  140894. * Defines the name of the task
  140895. */
  140896. name: string,
  140897. /**
  140898. * Defines the location of the file to load
  140899. */
  140900. url: string,
  140901. /**
  140902. * Defines the desired size (the more it increases the longer the generation will be)
  140903. */
  140904. size: number,
  140905. /**
  140906. * Defines if mipmaps should not be generated (default is false)
  140907. */
  140908. noMipmap?: boolean,
  140909. /**
  140910. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  140911. * but the standard material would require them in Gamma space) (default is true)
  140912. */
  140913. gammaSpace?: boolean);
  140914. /**
  140915. * Execute the current task
  140916. * @param scene defines the scene where you want your assets to be loaded
  140917. * @param onSuccess is a callback called when the task is successfully executed
  140918. * @param onError is a callback called if an error occurs
  140919. */
  140920. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140921. }
  140922. /**
  140923. * This class can be used to easily import assets into a scene
  140924. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  140925. */
  140926. export class AssetsManager {
  140927. private _scene;
  140928. private _isLoading;
  140929. protected _tasks: AbstractAssetTask[];
  140930. protected _waitingTasksCount: number;
  140931. protected _totalTasksCount: number;
  140932. /**
  140933. * Callback called when all tasks are processed
  140934. */
  140935. onFinish: (tasks: AbstractAssetTask[]) => void;
  140936. /**
  140937. * Callback called when a task is successful
  140938. */
  140939. onTaskSuccess: (task: AbstractAssetTask) => void;
  140940. /**
  140941. * Callback called when a task had an error
  140942. */
  140943. onTaskError: (task: AbstractAssetTask) => void;
  140944. /**
  140945. * Callback called when a task is done (whatever the result is)
  140946. */
  140947. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  140948. /**
  140949. * Observable called when all tasks are processed
  140950. */
  140951. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  140952. /**
  140953. * Observable called when a task had an error
  140954. */
  140955. onTaskErrorObservable: Observable<AbstractAssetTask>;
  140956. /**
  140957. * Observable called when all tasks were executed
  140958. */
  140959. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  140960. /**
  140961. * Observable called when a task is done (whatever the result is)
  140962. */
  140963. onProgressObservable: Observable<IAssetsProgressEvent>;
  140964. /**
  140965. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  140966. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  140967. */
  140968. useDefaultLoadingScreen: boolean;
  140969. /**
  140970. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  140971. * when all assets have been downloaded.
  140972. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  140973. */
  140974. autoHideLoadingUI: boolean;
  140975. /**
  140976. * Creates a new AssetsManager
  140977. * @param scene defines the scene to work on
  140978. */
  140979. constructor(scene: Scene);
  140980. /**
  140981. * Add a MeshAssetTask to the list of active tasks
  140982. * @param taskName defines the name of the new task
  140983. * @param meshesNames defines the name of meshes to load
  140984. * @param rootUrl defines the root url to use to locate files
  140985. * @param sceneFilename defines the filename of the scene file
  140986. * @returns a new MeshAssetTask object
  140987. */
  140988. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  140989. /**
  140990. * Add a TextFileAssetTask to the list of active tasks
  140991. * @param taskName defines the name of the new task
  140992. * @param url defines the url of the file to load
  140993. * @returns a new TextFileAssetTask object
  140994. */
  140995. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  140996. /**
  140997. * Add a BinaryFileAssetTask to the list of active tasks
  140998. * @param taskName defines the name of the new task
  140999. * @param url defines the url of the file to load
  141000. * @returns a new BinaryFileAssetTask object
  141001. */
  141002. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  141003. /**
  141004. * Add a ImageAssetTask to the list of active tasks
  141005. * @param taskName defines the name of the new task
  141006. * @param url defines the url of the file to load
  141007. * @returns a new ImageAssetTask object
  141008. */
  141009. addImageTask(taskName: string, url: string): ImageAssetTask;
  141010. /**
  141011. * Add a TextureAssetTask to the list of active tasks
  141012. * @param taskName defines the name of the new task
  141013. * @param url defines the url of the file to load
  141014. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  141015. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  141016. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  141017. * @returns a new TextureAssetTask object
  141018. */
  141019. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  141020. /**
  141021. * Add a CubeTextureAssetTask to the list of active tasks
  141022. * @param taskName defines the name of the new task
  141023. * @param url defines the url of the file to load
  141024. * @param extensions defines the extension to use to load the cube map (can be null)
  141025. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  141026. * @param files defines the list of files to load (can be null)
  141027. * @returns a new CubeTextureAssetTask object
  141028. */
  141029. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  141030. /**
  141031. *
  141032. * Add a HDRCubeTextureAssetTask to the list of active tasks
  141033. * @param taskName defines the name of the new task
  141034. * @param url defines the url of the file to load
  141035. * @param size defines the size you want for the cubemap (can be null)
  141036. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  141037. * @param generateHarmonics defines if you want to automatically generate (true by default)
  141038. * @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)
  141039. * @param reserved Internal use only
  141040. * @returns a new HDRCubeTextureAssetTask object
  141041. */
  141042. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  141043. /**
  141044. *
  141045. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  141046. * @param taskName defines the name of the new task
  141047. * @param url defines the url of the file to load
  141048. * @param size defines the size you want for the cubemap (can be null)
  141049. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  141050. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  141051. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  141052. * @returns a new EquiRectangularCubeTextureAssetTask object
  141053. */
  141054. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  141055. /**
  141056. * Remove a task from the assets manager.
  141057. * @param task the task to remove
  141058. */
  141059. removeTask(task: AbstractAssetTask): void;
  141060. private _decreaseWaitingTasksCount;
  141061. private _runTask;
  141062. /**
  141063. * Reset the AssetsManager and remove all tasks
  141064. * @return the current instance of the AssetsManager
  141065. */
  141066. reset(): AssetsManager;
  141067. /**
  141068. * Start the loading process
  141069. * @return the current instance of the AssetsManager
  141070. */
  141071. load(): AssetsManager;
  141072. /**
  141073. * Start the loading process as an async operation
  141074. * @return a promise returning the list of failed tasks
  141075. */
  141076. loadAsync(): Promise<void>;
  141077. }
  141078. }
  141079. declare module BABYLON {
  141080. /**
  141081. * Wrapper class for promise with external resolve and reject.
  141082. */
  141083. export class Deferred<T> {
  141084. /**
  141085. * The promise associated with this deferred object.
  141086. */
  141087. readonly promise: Promise<T>;
  141088. private _resolve;
  141089. private _reject;
  141090. /**
  141091. * The resolve method of the promise associated with this deferred object.
  141092. */
  141093. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  141094. /**
  141095. * The reject method of the promise associated with this deferred object.
  141096. */
  141097. get reject(): (reason?: any) => void;
  141098. /**
  141099. * Constructor for this deferred object.
  141100. */
  141101. constructor();
  141102. }
  141103. }
  141104. declare module BABYLON {
  141105. /**
  141106. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  141107. */
  141108. export class MeshExploder {
  141109. private _centerMesh;
  141110. private _meshes;
  141111. private _meshesOrigins;
  141112. private _toCenterVectors;
  141113. private _scaledDirection;
  141114. private _newPosition;
  141115. private _centerPosition;
  141116. /**
  141117. * Explodes meshes from a center mesh.
  141118. * @param meshes The meshes to explode.
  141119. * @param centerMesh The mesh to be center of explosion.
  141120. */
  141121. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  141122. private _setCenterMesh;
  141123. /**
  141124. * Get class name
  141125. * @returns "MeshExploder"
  141126. */
  141127. getClassName(): string;
  141128. /**
  141129. * "Exploded meshes"
  141130. * @returns Array of meshes with the centerMesh at index 0.
  141131. */
  141132. getMeshes(): Array<Mesh>;
  141133. /**
  141134. * Explodes meshes giving a specific direction
  141135. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  141136. */
  141137. explode(direction?: number): void;
  141138. }
  141139. }
  141140. declare module BABYLON {
  141141. /**
  141142. * Class used to help managing file picking and drag'n'drop
  141143. */
  141144. export class FilesInput {
  141145. /**
  141146. * List of files ready to be loaded
  141147. */
  141148. static get FilesToLoad(): {
  141149. [key: string]: File;
  141150. };
  141151. /**
  141152. * Callback called when a file is processed
  141153. */
  141154. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  141155. private _engine;
  141156. private _currentScene;
  141157. private _sceneLoadedCallback;
  141158. private _progressCallback;
  141159. private _additionalRenderLoopLogicCallback;
  141160. private _textureLoadingCallback;
  141161. private _startingProcessingFilesCallback;
  141162. private _onReloadCallback;
  141163. private _errorCallback;
  141164. private _elementToMonitor;
  141165. private _sceneFileToLoad;
  141166. private _filesToLoad;
  141167. /**
  141168. * Creates a new FilesInput
  141169. * @param engine defines the rendering engine
  141170. * @param scene defines the hosting scene
  141171. * @param sceneLoadedCallback callback called when scene is loaded
  141172. * @param progressCallback callback called to track progress
  141173. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  141174. * @param textureLoadingCallback callback called when a texture is loading
  141175. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  141176. * @param onReloadCallback callback called when a reload is requested
  141177. * @param errorCallback callback call if an error occurs
  141178. */
  141179. 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);
  141180. private _dragEnterHandler;
  141181. private _dragOverHandler;
  141182. private _dropHandler;
  141183. /**
  141184. * Calls this function to listen to drag'n'drop events on a specific DOM element
  141185. * @param elementToMonitor defines the DOM element to track
  141186. */
  141187. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  141188. /**
  141189. * Release all associated resources
  141190. */
  141191. dispose(): void;
  141192. private renderFunction;
  141193. private drag;
  141194. private drop;
  141195. private _traverseFolder;
  141196. private _processFiles;
  141197. /**
  141198. * Load files from a drop event
  141199. * @param event defines the drop event to use as source
  141200. */
  141201. loadFiles(event: any): void;
  141202. private _processReload;
  141203. /**
  141204. * Reload the current scene from the loaded files
  141205. */
  141206. reload(): void;
  141207. }
  141208. }
  141209. declare module BABYLON {
  141210. /**
  141211. * Defines the root class used to create scene optimization to use with SceneOptimizer
  141212. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141213. */
  141214. export class SceneOptimization {
  141215. /**
  141216. * Defines the priority of this optimization (0 by default which means first in the list)
  141217. */
  141218. priority: number;
  141219. /**
  141220. * Gets a string describing the action executed by the current optimization
  141221. * @returns description string
  141222. */
  141223. getDescription(): string;
  141224. /**
  141225. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141226. * @param scene defines the current scene where to apply this optimization
  141227. * @param optimizer defines the current optimizer
  141228. * @returns true if everything that can be done was applied
  141229. */
  141230. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141231. /**
  141232. * Creates the SceneOptimization object
  141233. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141234. * @param desc defines the description associated with the optimization
  141235. */
  141236. constructor(
  141237. /**
  141238. * Defines the priority of this optimization (0 by default which means first in the list)
  141239. */
  141240. priority?: number);
  141241. }
  141242. /**
  141243. * Defines an optimization used to reduce the size of render target textures
  141244. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141245. */
  141246. export class TextureOptimization extends SceneOptimization {
  141247. /**
  141248. * Defines the priority of this optimization (0 by default which means first in the list)
  141249. */
  141250. priority: number;
  141251. /**
  141252. * 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
  141253. */
  141254. maximumSize: number;
  141255. /**
  141256. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  141257. */
  141258. step: number;
  141259. /**
  141260. * Gets a string describing the action executed by the current optimization
  141261. * @returns description string
  141262. */
  141263. getDescription(): string;
  141264. /**
  141265. * Creates the TextureOptimization object
  141266. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141267. * @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
  141268. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  141269. */
  141270. constructor(
  141271. /**
  141272. * Defines the priority of this optimization (0 by default which means first in the list)
  141273. */
  141274. priority?: number,
  141275. /**
  141276. * 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
  141277. */
  141278. maximumSize?: number,
  141279. /**
  141280. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  141281. */
  141282. step?: number);
  141283. /**
  141284. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141285. * @param scene defines the current scene where to apply this optimization
  141286. * @param optimizer defines the current optimizer
  141287. * @returns true if everything that can be done was applied
  141288. */
  141289. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141290. }
  141291. /**
  141292. * Defines an optimization used to increase or decrease the rendering resolution
  141293. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141294. */
  141295. export class HardwareScalingOptimization extends SceneOptimization {
  141296. /**
  141297. * Defines the priority of this optimization (0 by default which means first in the list)
  141298. */
  141299. priority: number;
  141300. /**
  141301. * Defines the maximum scale to use (2 by default)
  141302. */
  141303. maximumScale: number;
  141304. /**
  141305. * Defines the step to use between two passes (0.5 by default)
  141306. */
  141307. step: number;
  141308. private _currentScale;
  141309. private _directionOffset;
  141310. /**
  141311. * Gets a string describing the action executed by the current optimization
  141312. * @return description string
  141313. */
  141314. getDescription(): string;
  141315. /**
  141316. * Creates the HardwareScalingOptimization object
  141317. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141318. * @param maximumScale defines the maximum scale to use (2 by default)
  141319. * @param step defines the step to use between two passes (0.5 by default)
  141320. */
  141321. constructor(
  141322. /**
  141323. * Defines the priority of this optimization (0 by default which means first in the list)
  141324. */
  141325. priority?: number,
  141326. /**
  141327. * Defines the maximum scale to use (2 by default)
  141328. */
  141329. maximumScale?: number,
  141330. /**
  141331. * Defines the step to use between two passes (0.5 by default)
  141332. */
  141333. step?: number);
  141334. /**
  141335. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141336. * @param scene defines the current scene where to apply this optimization
  141337. * @param optimizer defines the current optimizer
  141338. * @returns true if everything that can be done was applied
  141339. */
  141340. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141341. }
  141342. /**
  141343. * Defines an optimization used to remove shadows
  141344. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141345. */
  141346. export class ShadowsOptimization extends SceneOptimization {
  141347. /**
  141348. * Gets a string describing the action executed by the current optimization
  141349. * @return description string
  141350. */
  141351. getDescription(): string;
  141352. /**
  141353. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141354. * @param scene defines the current scene where to apply this optimization
  141355. * @param optimizer defines the current optimizer
  141356. * @returns true if everything that can be done was applied
  141357. */
  141358. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141359. }
  141360. /**
  141361. * Defines an optimization used to turn post-processes off
  141362. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141363. */
  141364. export class PostProcessesOptimization extends SceneOptimization {
  141365. /**
  141366. * Gets a string describing the action executed by the current optimization
  141367. * @return description string
  141368. */
  141369. getDescription(): string;
  141370. /**
  141371. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141372. * @param scene defines the current scene where to apply this optimization
  141373. * @param optimizer defines the current optimizer
  141374. * @returns true if everything that can be done was applied
  141375. */
  141376. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141377. }
  141378. /**
  141379. * Defines an optimization used to turn lens flares off
  141380. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141381. */
  141382. export class LensFlaresOptimization extends SceneOptimization {
  141383. /**
  141384. * Gets a string describing the action executed by the current optimization
  141385. * @return description string
  141386. */
  141387. getDescription(): string;
  141388. /**
  141389. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141390. * @param scene defines the current scene where to apply this optimization
  141391. * @param optimizer defines the current optimizer
  141392. * @returns true if everything that can be done was applied
  141393. */
  141394. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141395. }
  141396. /**
  141397. * Defines an optimization based on user defined callback.
  141398. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141399. */
  141400. export class CustomOptimization extends SceneOptimization {
  141401. /**
  141402. * Callback called to apply the custom optimization.
  141403. */
  141404. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  141405. /**
  141406. * Callback called to get custom description
  141407. */
  141408. onGetDescription: () => string;
  141409. /**
  141410. * Gets a string describing the action executed by the current optimization
  141411. * @returns description string
  141412. */
  141413. getDescription(): string;
  141414. /**
  141415. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141416. * @param scene defines the current scene where to apply this optimization
  141417. * @param optimizer defines the current optimizer
  141418. * @returns true if everything that can be done was applied
  141419. */
  141420. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141421. }
  141422. /**
  141423. * Defines an optimization used to turn particles off
  141424. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141425. */
  141426. export class ParticlesOptimization extends SceneOptimization {
  141427. /**
  141428. * Gets a string describing the action executed by the current optimization
  141429. * @return description string
  141430. */
  141431. getDescription(): string;
  141432. /**
  141433. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141434. * @param scene defines the current scene where to apply this optimization
  141435. * @param optimizer defines the current optimizer
  141436. * @returns true if everything that can be done was applied
  141437. */
  141438. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141439. }
  141440. /**
  141441. * Defines an optimization used to turn render targets off
  141442. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141443. */
  141444. export class RenderTargetsOptimization extends SceneOptimization {
  141445. /**
  141446. * Gets a string describing the action executed by the current optimization
  141447. * @return description string
  141448. */
  141449. getDescription(): string;
  141450. /**
  141451. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141452. * @param scene defines the current scene where to apply this optimization
  141453. * @param optimizer defines the current optimizer
  141454. * @returns true if everything that can be done was applied
  141455. */
  141456. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141457. }
  141458. /**
  141459. * Defines an optimization used to merge meshes with compatible materials
  141460. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141461. */
  141462. export class MergeMeshesOptimization extends SceneOptimization {
  141463. private static _UpdateSelectionTree;
  141464. /**
  141465. * Gets or sets a boolean which defines if optimization octree has to be updated
  141466. */
  141467. static get UpdateSelectionTree(): boolean;
  141468. /**
  141469. * Gets or sets a boolean which defines if optimization octree has to be updated
  141470. */
  141471. static set UpdateSelectionTree(value: boolean);
  141472. /**
  141473. * Gets a string describing the action executed by the current optimization
  141474. * @return description string
  141475. */
  141476. getDescription(): string;
  141477. private _canBeMerged;
  141478. /**
  141479. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141480. * @param scene defines the current scene where to apply this optimization
  141481. * @param optimizer defines the current optimizer
  141482. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  141483. * @returns true if everything that can be done was applied
  141484. */
  141485. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  141486. }
  141487. /**
  141488. * Defines a list of options used by SceneOptimizer
  141489. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141490. */
  141491. export class SceneOptimizerOptions {
  141492. /**
  141493. * Defines the target frame rate to reach (60 by default)
  141494. */
  141495. targetFrameRate: number;
  141496. /**
  141497. * Defines the interval between two checkes (2000ms by default)
  141498. */
  141499. trackerDuration: number;
  141500. /**
  141501. * Gets the list of optimizations to apply
  141502. */
  141503. optimizations: SceneOptimization[];
  141504. /**
  141505. * Creates a new list of options used by SceneOptimizer
  141506. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  141507. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  141508. */
  141509. constructor(
  141510. /**
  141511. * Defines the target frame rate to reach (60 by default)
  141512. */
  141513. targetFrameRate?: number,
  141514. /**
  141515. * Defines the interval between two checkes (2000ms by default)
  141516. */
  141517. trackerDuration?: number);
  141518. /**
  141519. * Add a new optimization
  141520. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  141521. * @returns the current SceneOptimizerOptions
  141522. */
  141523. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  141524. /**
  141525. * Add a new custom optimization
  141526. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  141527. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  141528. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141529. * @returns the current SceneOptimizerOptions
  141530. */
  141531. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  141532. /**
  141533. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  141534. * @param targetFrameRate defines the target frame rate (60 by default)
  141535. * @returns a SceneOptimizerOptions object
  141536. */
  141537. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  141538. /**
  141539. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  141540. * @param targetFrameRate defines the target frame rate (60 by default)
  141541. * @returns a SceneOptimizerOptions object
  141542. */
  141543. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  141544. /**
  141545. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  141546. * @param targetFrameRate defines the target frame rate (60 by default)
  141547. * @returns a SceneOptimizerOptions object
  141548. */
  141549. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  141550. }
  141551. /**
  141552. * Class used to run optimizations in order to reach a target frame rate
  141553. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141554. */
  141555. export class SceneOptimizer implements IDisposable {
  141556. private _isRunning;
  141557. private _options;
  141558. private _scene;
  141559. private _currentPriorityLevel;
  141560. private _targetFrameRate;
  141561. private _trackerDuration;
  141562. private _currentFrameRate;
  141563. private _sceneDisposeObserver;
  141564. private _improvementMode;
  141565. /**
  141566. * Defines an observable called when the optimizer reaches the target frame rate
  141567. */
  141568. onSuccessObservable: Observable<SceneOptimizer>;
  141569. /**
  141570. * Defines an observable called when the optimizer enables an optimization
  141571. */
  141572. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  141573. /**
  141574. * Defines an observable called when the optimizer is not able to reach the target frame rate
  141575. */
  141576. onFailureObservable: Observable<SceneOptimizer>;
  141577. /**
  141578. * Gets a boolean indicating if the optimizer is in improvement mode
  141579. */
  141580. get isInImprovementMode(): boolean;
  141581. /**
  141582. * Gets the current priority level (0 at start)
  141583. */
  141584. get currentPriorityLevel(): number;
  141585. /**
  141586. * Gets the current frame rate checked by the SceneOptimizer
  141587. */
  141588. get currentFrameRate(): number;
  141589. /**
  141590. * Gets or sets the current target frame rate (60 by default)
  141591. */
  141592. get targetFrameRate(): number;
  141593. /**
  141594. * Gets or sets the current target frame rate (60 by default)
  141595. */
  141596. set targetFrameRate(value: number);
  141597. /**
  141598. * Gets or sets the current interval between two checks (every 2000ms by default)
  141599. */
  141600. get trackerDuration(): number;
  141601. /**
  141602. * Gets or sets the current interval between two checks (every 2000ms by default)
  141603. */
  141604. set trackerDuration(value: number);
  141605. /**
  141606. * Gets the list of active optimizations
  141607. */
  141608. get optimizations(): SceneOptimization[];
  141609. /**
  141610. * Creates a new SceneOptimizer
  141611. * @param scene defines the scene to work on
  141612. * @param options defines the options to use with the SceneOptimizer
  141613. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  141614. * @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)
  141615. */
  141616. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  141617. /**
  141618. * Stops the current optimizer
  141619. */
  141620. stop(): void;
  141621. /**
  141622. * Reset the optimizer to initial step (current priority level = 0)
  141623. */
  141624. reset(): void;
  141625. /**
  141626. * Start the optimizer. By default it will try to reach a specific framerate
  141627. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  141628. */
  141629. start(): void;
  141630. private _checkCurrentState;
  141631. /**
  141632. * Release all resources
  141633. */
  141634. dispose(): void;
  141635. /**
  141636. * Helper function to create a SceneOptimizer with one single line of code
  141637. * @param scene defines the scene to work on
  141638. * @param options defines the options to use with the SceneOptimizer
  141639. * @param onSuccess defines a callback to call on success
  141640. * @param onFailure defines a callback to call on failure
  141641. * @returns the new SceneOptimizer object
  141642. */
  141643. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  141644. }
  141645. }
  141646. declare module BABYLON {
  141647. /**
  141648. * Class used to serialize a scene into a string
  141649. */
  141650. export class SceneSerializer {
  141651. /**
  141652. * Clear cache used by a previous serialization
  141653. */
  141654. static ClearCache(): void;
  141655. /**
  141656. * Serialize a scene into a JSON compatible object
  141657. * @param scene defines the scene to serialize
  141658. * @returns a JSON compatible object
  141659. */
  141660. static Serialize(scene: Scene): any;
  141661. /**
  141662. * Serialize a mesh into a JSON compatible object
  141663. * @param toSerialize defines the mesh to serialize
  141664. * @param withParents defines if parents must be serialized as well
  141665. * @param withChildren defines if children must be serialized as well
  141666. * @returns a JSON compatible object
  141667. */
  141668. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  141669. }
  141670. }
  141671. declare module BABYLON {
  141672. /**
  141673. * Class used to host texture specific utilities
  141674. */
  141675. export class TextureTools {
  141676. /**
  141677. * Uses the GPU to create a copy texture rescaled at a given size
  141678. * @param texture Texture to copy from
  141679. * @param width defines the desired width
  141680. * @param height defines the desired height
  141681. * @param useBilinearMode defines if bilinear mode has to be used
  141682. * @return the generated texture
  141683. */
  141684. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  141685. }
  141686. }
  141687. declare module BABYLON {
  141688. /**
  141689. * This represents the different options available for the video capture.
  141690. */
  141691. export interface VideoRecorderOptions {
  141692. /** Defines the mime type of the video. */
  141693. mimeType: string;
  141694. /** Defines the FPS the video should be recorded at. */
  141695. fps: number;
  141696. /** Defines the chunk size for the recording data. */
  141697. recordChunckSize: number;
  141698. /** The audio tracks to attach to the recording. */
  141699. audioTracks?: MediaStreamTrack[];
  141700. }
  141701. /**
  141702. * This can help with recording videos from BabylonJS.
  141703. * This is based on the available WebRTC functionalities of the browser.
  141704. *
  141705. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  141706. */
  141707. export class VideoRecorder {
  141708. private static readonly _defaultOptions;
  141709. /**
  141710. * Returns whether or not the VideoRecorder is available in your browser.
  141711. * @param engine Defines the Babylon Engine.
  141712. * @returns true if supported otherwise false.
  141713. */
  141714. static IsSupported(engine: Engine): boolean;
  141715. private readonly _options;
  141716. private _canvas;
  141717. private _mediaRecorder;
  141718. private _recordedChunks;
  141719. private _fileName;
  141720. private _resolve;
  141721. private _reject;
  141722. /**
  141723. * True when a recording is already in progress.
  141724. */
  141725. get isRecording(): boolean;
  141726. /**
  141727. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  141728. * @param engine Defines the BabylonJS Engine you wish to record.
  141729. * @param options Defines options that can be used to customize the capture.
  141730. */
  141731. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  141732. /**
  141733. * Stops the current recording before the default capture timeout passed in the startRecording function.
  141734. */
  141735. stopRecording(): void;
  141736. /**
  141737. * Starts recording the canvas for a max duration specified in parameters.
  141738. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  141739. * If null no automatic download will start and you can rely on the promise to get the data back.
  141740. * @param maxDuration Defines the maximum recording time in seconds.
  141741. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  141742. * @return A promise callback at the end of the recording with the video data in Blob.
  141743. */
  141744. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  141745. /**
  141746. * Releases internal resources used during the recording.
  141747. */
  141748. dispose(): void;
  141749. private _handleDataAvailable;
  141750. private _handleError;
  141751. private _handleStop;
  141752. }
  141753. }
  141754. declare module BABYLON {
  141755. /**
  141756. * Class containing a set of static utilities functions for screenshots
  141757. */
  141758. export class ScreenshotTools {
  141759. /**
  141760. * Captures a screenshot of the current rendering
  141761. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141762. * @param engine defines the rendering engine
  141763. * @param camera defines the source camera
  141764. * @param size This parameter can be set to a single number or to an object with the
  141765. * following (optional) properties: precision, width, height. If a single number is passed,
  141766. * it will be used for both width and height. If an object is passed, the screenshot size
  141767. * will be derived from the parameters. The precision property is a multiplier allowing
  141768. * rendering at a higher or lower resolution
  141769. * @param successCallback defines the callback receives a single parameter which contains the
  141770. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  141771. * src parameter of an <img> to display it
  141772. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  141773. * Check your browser for supported MIME types
  141774. */
  141775. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  141776. /**
  141777. * Captures a screenshot of the current rendering
  141778. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141779. * @param engine defines the rendering engine
  141780. * @param camera defines the source camera
  141781. * @param size This parameter can be set to a single number or to an object with the
  141782. * following (optional) properties: precision, width, height. If a single number is passed,
  141783. * it will be used for both width and height. If an object is passed, the screenshot size
  141784. * will be derived from the parameters. The precision property is a multiplier allowing
  141785. * rendering at a higher or lower resolution
  141786. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  141787. * Check your browser for supported MIME types
  141788. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  141789. * to the src parameter of an <img> to display it
  141790. */
  141791. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  141792. /**
  141793. * Generates an image screenshot from the specified camera.
  141794. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141795. * @param engine The engine to use for rendering
  141796. * @param camera The camera to use for rendering
  141797. * @param size This parameter can be set to a single number or to an object with the
  141798. * following (optional) properties: precision, width, height. If a single number is passed,
  141799. * it will be used for both width and height. If an object is passed, the screenshot size
  141800. * will be derived from the parameters. The precision property is a multiplier allowing
  141801. * rendering at a higher or lower resolution
  141802. * @param successCallback The callback receives a single parameter which contains the
  141803. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  141804. * src parameter of an <img> to display it
  141805. * @param mimeType The MIME type of the screenshot image (default: image/png).
  141806. * Check your browser for supported MIME types
  141807. * @param samples Texture samples (default: 1)
  141808. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  141809. * @param fileName A name for for the downloaded file.
  141810. */
  141811. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  141812. /**
  141813. * Generates an image screenshot from the specified camera.
  141814. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141815. * @param engine The engine to use for rendering
  141816. * @param camera The camera to use for rendering
  141817. * @param size This parameter can be set to a single number or to an object with the
  141818. * following (optional) properties: precision, width, height. If a single number is passed,
  141819. * it will be used for both width and height. If an object is passed, the screenshot size
  141820. * will be derived from the parameters. The precision property is a multiplier allowing
  141821. * rendering at a higher or lower resolution
  141822. * @param mimeType The MIME type of the screenshot image (default: image/png).
  141823. * Check your browser for supported MIME types
  141824. * @param samples Texture samples (default: 1)
  141825. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  141826. * @param fileName A name for for the downloaded file.
  141827. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  141828. * to the src parameter of an <img> to display it
  141829. */
  141830. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  141831. /**
  141832. * Gets height and width for screenshot size
  141833. * @private
  141834. */
  141835. private static _getScreenshotSize;
  141836. }
  141837. }
  141838. declare module BABYLON {
  141839. /**
  141840. * Interface for a data buffer
  141841. */
  141842. export interface IDataBuffer {
  141843. /**
  141844. * Reads bytes from the data buffer.
  141845. * @param byteOffset The byte offset to read
  141846. * @param byteLength The byte length to read
  141847. * @returns A promise that resolves when the bytes are read
  141848. */
  141849. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  141850. /**
  141851. * The byte length of the buffer.
  141852. */
  141853. readonly byteLength: number;
  141854. }
  141855. /**
  141856. * Utility class for reading from a data buffer
  141857. */
  141858. export class DataReader {
  141859. /**
  141860. * The data buffer associated with this data reader.
  141861. */
  141862. readonly buffer: IDataBuffer;
  141863. /**
  141864. * The current byte offset from the beginning of the data buffer.
  141865. */
  141866. byteOffset: number;
  141867. private _dataView;
  141868. private _dataByteOffset;
  141869. /**
  141870. * Constructor
  141871. * @param buffer The buffer to read
  141872. */
  141873. constructor(buffer: IDataBuffer);
  141874. /**
  141875. * Loads the given byte length.
  141876. * @param byteLength The byte length to load
  141877. * @returns A promise that resolves when the load is complete
  141878. */
  141879. loadAsync(byteLength: number): Promise<void>;
  141880. /**
  141881. * Read a unsigned 32-bit integer from the currently loaded data range.
  141882. * @returns The 32-bit integer read
  141883. */
  141884. readUint32(): number;
  141885. /**
  141886. * Read a byte array from the currently loaded data range.
  141887. * @param byteLength The byte length to read
  141888. * @returns The byte array read
  141889. */
  141890. readUint8Array(byteLength: number): Uint8Array;
  141891. /**
  141892. * Read a string from the currently loaded data range.
  141893. * @param byteLength The byte length to read
  141894. * @returns The string read
  141895. */
  141896. readString(byteLength: number): string;
  141897. /**
  141898. * Skips the given byte length the currently loaded data range.
  141899. * @param byteLength The byte length to skip
  141900. */
  141901. skipBytes(byteLength: number): void;
  141902. }
  141903. }
  141904. declare module BABYLON {
  141905. /**
  141906. * Options used for hit testing
  141907. */
  141908. export interface IWebXRHitTestOptions {
  141909. /**
  141910. * Only test when user interacted with the scene. Default - hit test every frame
  141911. */
  141912. testOnPointerDownOnly?: boolean;
  141913. /**
  141914. * The node to use to transform the local results to world coordinates
  141915. */
  141916. worldParentNode?: TransformNode;
  141917. }
  141918. /**
  141919. * Interface defining the babylon result of raycasting/hit-test
  141920. */
  141921. export interface IWebXRHitResult {
  141922. /**
  141923. * The native hit test result
  141924. */
  141925. xrHitResult: XRHitResult;
  141926. /**
  141927. * Transformation matrix that can be applied to a node that will put it in the hit point location
  141928. */
  141929. transformationMatrix: Matrix;
  141930. }
  141931. /**
  141932. * The currently-working hit-test module.
  141933. * Hit test (or raycasting) is used to interact with the real world.
  141934. * For further information read here - https://github.com/immersive-web/hit-test
  141935. */
  141936. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  141937. /**
  141938. * options to use when constructing this feature
  141939. */
  141940. readonly options: IWebXRHitTestOptions;
  141941. /**
  141942. * The module's name
  141943. */
  141944. static readonly Name: string;
  141945. /**
  141946. * The (Babylon) version of this module.
  141947. * This is an integer representing the implementation version.
  141948. * This number does not correspond to the webxr specs version
  141949. */
  141950. static readonly Version: number;
  141951. /**
  141952. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  141953. * @param event the (select) event to use to select with
  141954. * @param referenceSpace the reference space to use for this hit test
  141955. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  141956. */
  141957. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  141958. /**
  141959. * execute a hit test with an XR Ray
  141960. *
  141961. * @param xrSession a native xrSession that will execute this hit test
  141962. * @param xrRay the ray (position and direction) to use for raycasting
  141963. * @param referenceSpace native XR reference space to use for the hit-test
  141964. * @param filter filter function that will filter the results
  141965. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  141966. */
  141967. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  141968. /**
  141969. * Triggered when new babylon (transformed) hit test results are available
  141970. */
  141971. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  141972. private _onSelectEnabled;
  141973. /**
  141974. * Creates a new instance of the (legacy version) hit test feature
  141975. * @param _xrSessionManager an instance of WebXRSessionManager
  141976. * @param options options to use when constructing this feature
  141977. */
  141978. constructor(_xrSessionManager: WebXRSessionManager,
  141979. /**
  141980. * options to use when constructing this feature
  141981. */
  141982. options?: IWebXRHitTestOptions);
  141983. /**
  141984. * Populated with the last native XR Hit Results
  141985. */
  141986. lastNativeXRHitResults: XRHitResult[];
  141987. /**
  141988. * attach this feature
  141989. * Will usually be called by the features manager
  141990. *
  141991. * @returns true if successful.
  141992. */
  141993. attach(): boolean;
  141994. /**
  141995. * detach this feature.
  141996. * Will usually be called by the features manager
  141997. *
  141998. * @returns true if successful.
  141999. */
  142000. detach(): boolean;
  142001. private _onHitTestResults;
  142002. private _origin;
  142003. private _direction;
  142004. private _mat;
  142005. protected _onXRFrame(frame: XRFrame): void;
  142006. private _onSelect;
  142007. /**
  142008. * Dispose this feature and all of the resources attached
  142009. */
  142010. dispose(): void;
  142011. }
  142012. }
  142013. declare module BABYLON {
  142014. /**
  142015. * Options used in the plane detector module
  142016. */
  142017. export interface IWebXRPlaneDetectorOptions {
  142018. /**
  142019. * The node to use to transform the local results to world coordinates
  142020. */
  142021. worldParentNode?: TransformNode;
  142022. }
  142023. /**
  142024. * A babylon interface for a webxr plane.
  142025. * A Plane is actually a polygon, built from N points in space
  142026. *
  142027. * Supported in chrome 79, not supported in canary 81 ATM
  142028. */
  142029. export interface IWebXRPlane {
  142030. /**
  142031. * a babylon-assigned ID for this polygon
  142032. */
  142033. id: number;
  142034. /**
  142035. * the native xr-plane object
  142036. */
  142037. xrPlane: XRPlane;
  142038. /**
  142039. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  142040. */
  142041. polygonDefinition: Array<Vector3>;
  142042. /**
  142043. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  142044. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  142045. */
  142046. transformationMatrix: Matrix;
  142047. }
  142048. /**
  142049. * The plane detector is used to detect planes in the real world when in AR
  142050. * For more information see https://github.com/immersive-web/real-world-geometry/
  142051. */
  142052. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  142053. private _options;
  142054. /**
  142055. * The module's name
  142056. */
  142057. static readonly Name: string;
  142058. /**
  142059. * The (Babylon) version of this module.
  142060. * This is an integer representing the implementation version.
  142061. * This number does not correspond to the webxr specs version
  142062. */
  142063. static readonly Version: number;
  142064. /**
  142065. * Observers registered here will be executed when a new plane was added to the session
  142066. */
  142067. onPlaneAddedObservable: Observable<IWebXRPlane>;
  142068. /**
  142069. * Observers registered here will be executed when a plane is no longer detected in the session
  142070. */
  142071. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  142072. /**
  142073. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  142074. * This can execute N times every frame
  142075. */
  142076. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  142077. private _enabled;
  142078. private _detectedPlanes;
  142079. private _lastFrameDetected;
  142080. /**
  142081. * construct a new Plane Detector
  142082. * @param _xrSessionManager an instance of xr Session manager
  142083. * @param _options configuration to use when constructing this feature
  142084. */
  142085. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  142086. private _init;
  142087. protected _onXRFrame(frame: XRFrame): void;
  142088. /**
  142089. * Dispose this feature and all of the resources attached
  142090. */
  142091. dispose(): void;
  142092. private _updatePlaneWithXRPlane;
  142093. /**
  142094. * avoiding using Array.find for global support.
  142095. * @param xrPlane the plane to find in the array
  142096. */
  142097. private findIndexInPlaneArray;
  142098. }
  142099. }
  142100. declare module BABYLON {
  142101. /**
  142102. * Configuration options of the anchor system
  142103. */
  142104. export interface IWebXRAnchorSystemOptions {
  142105. /**
  142106. * a node that will be used to convert local to world coordinates
  142107. */
  142108. worldParentNode?: TransformNode;
  142109. /**
  142110. * should the anchor system use plane detection.
  142111. * If set to true, the plane-detection feature should be set using setPlaneDetector
  142112. */
  142113. usePlaneDetection?: boolean;
  142114. /**
  142115. * Should a new anchor be added every time a select event is triggered
  142116. */
  142117. addAnchorOnSelect?: boolean;
  142118. }
  142119. /**
  142120. * A babylon container for an XR Anchor
  142121. */
  142122. export interface IWebXRAnchor {
  142123. /**
  142124. * A babylon-assigned ID for this anchor
  142125. */
  142126. id: number;
  142127. /**
  142128. * The native anchor object
  142129. */
  142130. xrAnchor: XRAnchor;
  142131. /**
  142132. * Transformation matrix to apply to an object attached to this anchor
  142133. */
  142134. transformationMatrix: Matrix;
  142135. }
  142136. /**
  142137. * An implementation of the anchor system of WebXR.
  142138. * Note that the current documented implementation is not available in any browser. Future implementations
  142139. * will use the frame to create an anchor and not the session or a detected plane
  142140. * For further information see https://github.com/immersive-web/anchors/
  142141. */
  142142. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  142143. private _options;
  142144. /**
  142145. * The module's name
  142146. */
  142147. static readonly Name: string;
  142148. /**
  142149. * The (Babylon) version of this module.
  142150. * This is an integer representing the implementation version.
  142151. * This number does not correspond to the webxr specs version
  142152. */
  142153. static readonly Version: number;
  142154. /**
  142155. * Observers registered here will be executed when a new anchor was added to the session
  142156. */
  142157. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  142158. /**
  142159. * Observers registered here will be executed when an existing anchor updates
  142160. * This can execute N times every frame
  142161. */
  142162. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  142163. /**
  142164. * Observers registered here will be executed when an anchor was removed from the session
  142165. */
  142166. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  142167. private _planeDetector;
  142168. private _hitTestModule;
  142169. private _enabled;
  142170. private _trackedAnchors;
  142171. private _lastFrameDetected;
  142172. /**
  142173. * constructs a new anchor system
  142174. * @param _xrSessionManager an instance of WebXRSessionManager
  142175. * @param _options configuration object for this feature
  142176. */
  142177. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  142178. /**
  142179. * set the plane detector to use in order to create anchors from frames
  142180. * @param planeDetector the plane-detector module to use
  142181. * @param enable enable plane-anchors. default is true
  142182. */
  142183. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  142184. /**
  142185. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  142186. * @param hitTestModule the hit-test module to use.
  142187. */
  142188. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  142189. /**
  142190. * attach this feature
  142191. * Will usually be called by the features manager
  142192. *
  142193. * @returns true if successful.
  142194. */
  142195. attach(): boolean;
  142196. /**
  142197. * detach this feature.
  142198. * Will usually be called by the features manager
  142199. *
  142200. * @returns true if successful.
  142201. */
  142202. detach(): boolean;
  142203. /**
  142204. * Dispose this feature and all of the resources attached
  142205. */
  142206. dispose(): void;
  142207. protected _onXRFrame(frame: XRFrame): void;
  142208. private _onSelect;
  142209. /**
  142210. * Add anchor at a specific XR point.
  142211. *
  142212. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  142213. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  142214. * @returns a promise the fulfills when the anchor was created
  142215. */
  142216. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  142217. private _updateAnchorWithXRFrame;
  142218. /**
  142219. * avoiding using Array.find for global support.
  142220. * @param xrAnchor the plane to find in the array
  142221. */
  142222. private _findIndexInAnchorArray;
  142223. }
  142224. }
  142225. declare module BABYLON {
  142226. /**
  142227. * Options interface for the background remover plugin
  142228. */
  142229. export interface IWebXRBackgroundRemoverOptions {
  142230. /**
  142231. * don't disable the environment helper
  142232. */
  142233. ignoreEnvironmentHelper?: boolean;
  142234. /**
  142235. * flags to configure the removal of the environment helper.
  142236. * If not set, the entire background will be removed. If set, flags should be set as well.
  142237. */
  142238. environmentHelperRemovalFlags?: {
  142239. /**
  142240. * Should the skybox be removed (default false)
  142241. */
  142242. skyBox?: boolean;
  142243. /**
  142244. * Should the ground be removed (default false)
  142245. */
  142246. ground?: boolean;
  142247. };
  142248. /**
  142249. * Further background meshes to disable when entering AR
  142250. */
  142251. backgroundMeshes?: AbstractMesh[];
  142252. }
  142253. /**
  142254. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  142255. */
  142256. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  142257. /**
  142258. * read-only options to be used in this module
  142259. */
  142260. readonly options: IWebXRBackgroundRemoverOptions;
  142261. /**
  142262. * The module's name
  142263. */
  142264. static readonly Name: string;
  142265. /**
  142266. * The (Babylon) version of this module.
  142267. * This is an integer representing the implementation version.
  142268. * This number does not correspond to the webxr specs version
  142269. */
  142270. static readonly Version: number;
  142271. /**
  142272. * registered observers will be triggered when the background state changes
  142273. */
  142274. onBackgroundStateChangedObservable: Observable<boolean>;
  142275. /**
  142276. * constructs a new background remover module
  142277. * @param _xrSessionManager the session manager for this module
  142278. * @param options read-only options to be used in this module
  142279. */
  142280. constructor(_xrSessionManager: WebXRSessionManager,
  142281. /**
  142282. * read-only options to be used in this module
  142283. */
  142284. options?: IWebXRBackgroundRemoverOptions);
  142285. /**
  142286. * attach this feature
  142287. * Will usually be called by the features manager
  142288. *
  142289. * @returns true if successful.
  142290. */
  142291. attach(): boolean;
  142292. /**
  142293. * detach this feature.
  142294. * Will usually be called by the features manager
  142295. *
  142296. * @returns true if successful.
  142297. */
  142298. detach(): boolean;
  142299. private _setBackgroundState;
  142300. /**
  142301. * Dispose this feature and all of the resources attached
  142302. */
  142303. dispose(): void;
  142304. protected _onXRFrame(_xrFrame: XRFrame): void;
  142305. }
  142306. }
  142307. declare module BABYLON {
  142308. /**
  142309. * Options for the controller physics feature
  142310. */
  142311. export class IWebXRControllerPhysicsOptions {
  142312. /**
  142313. * the xr input to use with this pointer selection
  142314. */
  142315. xrInput: WebXRInput;
  142316. /**
  142317. * The physics properties of the future impostors
  142318. */
  142319. physicsProperties?: {
  142320. /**
  142321. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  142322. * Note that this requires a physics engine that supports mesh impostors!
  142323. */
  142324. useControllerMesh?: boolean;
  142325. /**
  142326. * The type of impostor to create. Default is sphere
  142327. */
  142328. impostorType?: number;
  142329. /**
  142330. * the size of the impostor. Defaults to 10cm
  142331. */
  142332. impostorSize?: number | {
  142333. width: number;
  142334. height: number;
  142335. depth: number;
  142336. };
  142337. /**
  142338. * Friction definitions
  142339. */
  142340. friction?: number;
  142341. /**
  142342. * Restitution
  142343. */
  142344. restitution?: number;
  142345. };
  142346. /**
  142347. * Should the headset get its own impostor
  142348. */
  142349. enableHeadsetImpostor?: boolean;
  142350. /**
  142351. * Optional parameters for the headset impostor
  142352. */
  142353. headsetImpostorParams?: {
  142354. /**
  142355. * The type of impostor to create. Default is sphere
  142356. */
  142357. impostorType: number;
  142358. /**
  142359. * the size of the impostor. Defaults to 10cm
  142360. */
  142361. impostorSize?: number | {
  142362. width: number;
  142363. height: number;
  142364. depth: number;
  142365. };
  142366. /**
  142367. * Friction definitions
  142368. */
  142369. friction?: number;
  142370. /**
  142371. * Restitution
  142372. */
  142373. restitution?: number;
  142374. };
  142375. }
  142376. /**
  142377. * Add physics impostor to your webxr controllers,
  142378. * including naive calculation of their linear and angular velocity
  142379. */
  142380. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  142381. private readonly _options;
  142382. /**
  142383. * The module's name
  142384. */
  142385. static readonly Name: string;
  142386. /**
  142387. * The (Babylon) version of this module.
  142388. * This is an integer representing the implementation version.
  142389. * This number does not correspond to the webxr specs version
  142390. */
  142391. static readonly Version: number;
  142392. private _lastTimestamp;
  142393. private _delta;
  142394. private _controllers;
  142395. private _headsetImpostor?;
  142396. private _headsetMesh?;
  142397. private _tmpVector;
  142398. private _tmpQuaternion;
  142399. /**
  142400. * Construct a new Controller Physics Feature
  142401. * @param _xrSessionManager the corresponding xr session manager
  142402. * @param _options options to create this feature with
  142403. */
  142404. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  142405. /**
  142406. * Update the physics properties provided in the constructor
  142407. * @param newProperties the new properties object
  142408. */
  142409. setPhysicsProperties(newProperties: {
  142410. impostorType?: number;
  142411. impostorSize?: number | {
  142412. width: number;
  142413. height: number;
  142414. depth: number;
  142415. };
  142416. friction?: number;
  142417. restitution?: number;
  142418. }): void;
  142419. /**
  142420. * Get the physics impostor of a specific controller.
  142421. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  142422. * @param controller the controller or the controller id of which to get the impostor
  142423. * @returns the impostor or null
  142424. */
  142425. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  142426. /**
  142427. * Get the headset impostor, if enabled
  142428. * @returns the impostor
  142429. */
  142430. getHeadsetImpostor(): PhysicsImpostor | undefined;
  142431. /**
  142432. * attach this feature
  142433. * Will usually be called by the features manager
  142434. *
  142435. * @returns true if successful.
  142436. */
  142437. attach(): boolean;
  142438. /**
  142439. * detach this feature.
  142440. * Will usually be called by the features manager
  142441. *
  142442. * @returns true if successful.
  142443. */
  142444. detach(): boolean;
  142445. /**
  142446. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  142447. * @param xrController the controller to add
  142448. */
  142449. addController(xrController: WebXRInputSource): void;
  142450. private _debugMode;
  142451. /**
  142452. * @hidden
  142453. * enable debugging - will show console outputs and the impostor mesh
  142454. */
  142455. _enablePhysicsDebug(): void;
  142456. private _attachController;
  142457. private _detachController;
  142458. protected _onXRFrame(_xrFrame: any): void;
  142459. }
  142460. }
  142461. declare module BABYLON {
  142462. /**
  142463. * The motion controller class for all microsoft mixed reality controllers
  142464. */
  142465. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  142466. /**
  142467. * The base url used to load the left and right controller models
  142468. */
  142469. static MODEL_BASE_URL: string;
  142470. /**
  142471. * The name of the left controller model file
  142472. */
  142473. static MODEL_LEFT_FILENAME: string;
  142474. /**
  142475. * The name of the right controller model file
  142476. */
  142477. static MODEL_RIGHT_FILENAME: string;
  142478. profileId: string;
  142479. protected readonly _mapping: {
  142480. defaultButton: {
  142481. "valueNodeName": string;
  142482. "unpressedNodeName": string;
  142483. "pressedNodeName": string;
  142484. };
  142485. defaultAxis: {
  142486. "valueNodeName": string;
  142487. "minNodeName": string;
  142488. "maxNodeName": string;
  142489. };
  142490. buttons: {
  142491. "xr-standard-trigger": {
  142492. "rootNodeName": string;
  142493. "componentProperty": string;
  142494. "states": string[];
  142495. };
  142496. "xr-standard-squeeze": {
  142497. "rootNodeName": string;
  142498. "componentProperty": string;
  142499. "states": string[];
  142500. };
  142501. "xr-standard-touchpad": {
  142502. "rootNodeName": string;
  142503. "labelAnchorNodeName": string;
  142504. "touchPointNodeName": string;
  142505. };
  142506. "xr-standard-thumbstick": {
  142507. "rootNodeName": string;
  142508. "componentProperty": string;
  142509. "states": string[];
  142510. };
  142511. };
  142512. axes: {
  142513. "xr-standard-touchpad": {
  142514. "x-axis": {
  142515. "rootNodeName": string;
  142516. };
  142517. "y-axis": {
  142518. "rootNodeName": string;
  142519. };
  142520. };
  142521. "xr-standard-thumbstick": {
  142522. "x-axis": {
  142523. "rootNodeName": string;
  142524. };
  142525. "y-axis": {
  142526. "rootNodeName": string;
  142527. };
  142528. };
  142529. };
  142530. };
  142531. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  142532. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  142533. protected _getFilenameAndPath(): {
  142534. filename: string;
  142535. path: string;
  142536. };
  142537. protected _updateModel(): void;
  142538. protected _getModelLoadingConstraints(): boolean;
  142539. protected _setRootMesh(meshes: AbstractMesh[]): void;
  142540. }
  142541. }
  142542. declare module BABYLON {
  142543. /**
  142544. * The motion controller class for oculus touch (quest, rift).
  142545. * This class supports legacy mapping as well the standard xr mapping
  142546. */
  142547. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  142548. private _forceLegacyControllers;
  142549. /**
  142550. * The base url used to load the left and right controller models
  142551. */
  142552. static MODEL_BASE_URL: string;
  142553. /**
  142554. * The name of the left controller model file
  142555. */
  142556. static MODEL_LEFT_FILENAME: string;
  142557. /**
  142558. * The name of the right controller model file
  142559. */
  142560. static MODEL_RIGHT_FILENAME: string;
  142561. /**
  142562. * Base Url for the Quest controller model.
  142563. */
  142564. static QUEST_MODEL_BASE_URL: string;
  142565. profileId: string;
  142566. private _modelRootNode;
  142567. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  142568. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  142569. protected _getFilenameAndPath(): {
  142570. filename: string;
  142571. path: string;
  142572. };
  142573. /**
  142574. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  142575. * between the touch and touch 2.
  142576. */
  142577. private _isQuest;
  142578. protected _updateModel(): void;
  142579. protected _getModelLoadingConstraints(): boolean;
  142580. protected _setRootMesh(meshes: AbstractMesh[]): void;
  142581. }
  142582. }
  142583. declare module BABYLON {
  142584. /**
  142585. * The motion controller class for the standard HTC-Vive controllers
  142586. */
  142587. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  142588. /**
  142589. * The base url used to load the left and right controller models
  142590. */
  142591. static MODEL_BASE_URL: string;
  142592. /**
  142593. * File name for the controller model.
  142594. */
  142595. static MODEL_FILENAME: string;
  142596. profileId: string;
  142597. private _modelRootNode;
  142598. /**
  142599. * Create a new Vive motion controller object
  142600. * @param scene the scene to use to create this controller
  142601. * @param gamepadObject the corresponding gamepad object
  142602. * @param handness the handness of the controller
  142603. */
  142604. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  142605. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  142606. protected _getFilenameAndPath(): {
  142607. filename: string;
  142608. path: string;
  142609. };
  142610. protected _updateModel(): void;
  142611. protected _getModelLoadingConstraints(): boolean;
  142612. protected _setRootMesh(meshes: AbstractMesh[]): void;
  142613. }
  142614. }
  142615. declare module BABYLON {
  142616. /**
  142617. * A cursor which tracks a point on a path
  142618. */
  142619. export class PathCursor {
  142620. private path;
  142621. /**
  142622. * Stores path cursor callbacks for when an onchange event is triggered
  142623. */
  142624. private _onchange;
  142625. /**
  142626. * The value of the path cursor
  142627. */
  142628. value: number;
  142629. /**
  142630. * The animation array of the path cursor
  142631. */
  142632. animations: Animation[];
  142633. /**
  142634. * Initializes the path cursor
  142635. * @param path The path to track
  142636. */
  142637. constructor(path: Path2);
  142638. /**
  142639. * Gets the cursor point on the path
  142640. * @returns A point on the path cursor at the cursor location
  142641. */
  142642. getPoint(): Vector3;
  142643. /**
  142644. * Moves the cursor ahead by the step amount
  142645. * @param step The amount to move the cursor forward
  142646. * @returns This path cursor
  142647. */
  142648. moveAhead(step?: number): PathCursor;
  142649. /**
  142650. * Moves the cursor behind by the step amount
  142651. * @param step The amount to move the cursor back
  142652. * @returns This path cursor
  142653. */
  142654. moveBack(step?: number): PathCursor;
  142655. /**
  142656. * Moves the cursor by the step amount
  142657. * If the step amount is greater than one, an exception is thrown
  142658. * @param step The amount to move the cursor
  142659. * @returns This path cursor
  142660. */
  142661. move(step: number): PathCursor;
  142662. /**
  142663. * Ensures that the value is limited between zero and one
  142664. * @returns This path cursor
  142665. */
  142666. private ensureLimits;
  142667. /**
  142668. * Runs onchange callbacks on change (used by the animation engine)
  142669. * @returns This path cursor
  142670. */
  142671. private raiseOnChange;
  142672. /**
  142673. * Executes a function on change
  142674. * @param f A path cursor onchange callback
  142675. * @returns This path cursor
  142676. */
  142677. onchange(f: (cursor: PathCursor) => void): PathCursor;
  142678. }
  142679. }
  142680. declare module BABYLON {
  142681. /** @hidden */
  142682. export var blurPixelShader: {
  142683. name: string;
  142684. shader: string;
  142685. };
  142686. }
  142687. declare module BABYLON {
  142688. /** @hidden */
  142689. export var pointCloudVertexDeclaration: {
  142690. name: string;
  142691. shader: string;
  142692. };
  142693. }
  142694. // Mixins
  142695. interface Window {
  142696. mozIndexedDB: IDBFactory;
  142697. webkitIndexedDB: IDBFactory;
  142698. msIndexedDB: IDBFactory;
  142699. webkitURL: typeof URL;
  142700. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  142701. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  142702. WebGLRenderingContext: WebGLRenderingContext;
  142703. MSGesture: MSGesture;
  142704. CANNON: any;
  142705. AudioContext: AudioContext;
  142706. webkitAudioContext: AudioContext;
  142707. PointerEvent: any;
  142708. Math: Math;
  142709. Uint8Array: Uint8ArrayConstructor;
  142710. Float32Array: Float32ArrayConstructor;
  142711. mozURL: typeof URL;
  142712. msURL: typeof URL;
  142713. VRFrameData: any; // WebVR, from specs 1.1
  142714. DracoDecoderModule: any;
  142715. setImmediate(handler: (...args: any[]) => void): number;
  142716. }
  142717. interface HTMLCanvasElement {
  142718. requestPointerLock(): void;
  142719. msRequestPointerLock?(): void;
  142720. mozRequestPointerLock?(): void;
  142721. webkitRequestPointerLock?(): void;
  142722. /** Track wether a record is in progress */
  142723. isRecording: boolean;
  142724. /** Capture Stream method defined by some browsers */
  142725. captureStream(fps?: number): MediaStream;
  142726. }
  142727. interface CanvasRenderingContext2D {
  142728. msImageSmoothingEnabled: boolean;
  142729. }
  142730. interface MouseEvent {
  142731. mozMovementX: number;
  142732. mozMovementY: number;
  142733. webkitMovementX: number;
  142734. webkitMovementY: number;
  142735. msMovementX: number;
  142736. msMovementY: number;
  142737. }
  142738. interface Navigator {
  142739. mozGetVRDevices: (any: any) => any;
  142740. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  142741. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  142742. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  142743. webkitGetGamepads(): Gamepad[];
  142744. msGetGamepads(): Gamepad[];
  142745. webkitGamepads(): Gamepad[];
  142746. }
  142747. interface HTMLVideoElement {
  142748. mozSrcObject: any;
  142749. }
  142750. interface Math {
  142751. fround(x: number): number;
  142752. imul(a: number, b: number): number;
  142753. }
  142754. interface WebGLRenderingContext {
  142755. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  142756. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  142757. vertexAttribDivisor(index: number, divisor: number): void;
  142758. createVertexArray(): any;
  142759. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  142760. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  142761. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  142762. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  142763. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  142764. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  142765. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  142766. // Queries
  142767. createQuery(): WebGLQuery;
  142768. deleteQuery(query: WebGLQuery): void;
  142769. beginQuery(target: number, query: WebGLQuery): void;
  142770. endQuery(target: number): void;
  142771. getQueryParameter(query: WebGLQuery, pname: number): any;
  142772. getQuery(target: number, pname: number): any;
  142773. MAX_SAMPLES: number;
  142774. RGBA8: number;
  142775. READ_FRAMEBUFFER: number;
  142776. DRAW_FRAMEBUFFER: number;
  142777. UNIFORM_BUFFER: number;
  142778. HALF_FLOAT_OES: number;
  142779. RGBA16F: number;
  142780. RGBA32F: number;
  142781. R32F: number;
  142782. RG32F: number;
  142783. RGB32F: number;
  142784. R16F: number;
  142785. RG16F: number;
  142786. RGB16F: number;
  142787. RED: number;
  142788. RG: number;
  142789. R8: number;
  142790. RG8: number;
  142791. UNSIGNED_INT_24_8: number;
  142792. DEPTH24_STENCIL8: number;
  142793. MIN: number;
  142794. MAX: number;
  142795. /* Multiple Render Targets */
  142796. drawBuffers(buffers: number[]): void;
  142797. readBuffer(src: number): void;
  142798. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  142799. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  142800. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  142801. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  142802. // Occlusion Query
  142803. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  142804. ANY_SAMPLES_PASSED: number;
  142805. QUERY_RESULT_AVAILABLE: number;
  142806. QUERY_RESULT: number;
  142807. }
  142808. interface WebGLProgram {
  142809. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  142810. }
  142811. interface EXT_disjoint_timer_query {
  142812. QUERY_COUNTER_BITS_EXT: number;
  142813. TIME_ELAPSED_EXT: number;
  142814. TIMESTAMP_EXT: number;
  142815. GPU_DISJOINT_EXT: number;
  142816. QUERY_RESULT_EXT: number;
  142817. QUERY_RESULT_AVAILABLE_EXT: number;
  142818. queryCounterEXT(query: WebGLQuery, target: number): void;
  142819. createQueryEXT(): WebGLQuery;
  142820. beginQueryEXT(target: number, query: WebGLQuery): void;
  142821. endQueryEXT(target: number): void;
  142822. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  142823. deleteQueryEXT(query: WebGLQuery): void;
  142824. }
  142825. interface WebGLUniformLocation {
  142826. _currentState: any;
  142827. }
  142828. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  142829. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  142830. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  142831. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  142832. interface WebGLRenderingContext {
  142833. readonly RASTERIZER_DISCARD: number;
  142834. readonly DEPTH_COMPONENT24: number;
  142835. readonly TEXTURE_3D: number;
  142836. readonly TEXTURE_2D_ARRAY: number;
  142837. readonly TEXTURE_COMPARE_FUNC: number;
  142838. readonly TEXTURE_COMPARE_MODE: number;
  142839. readonly COMPARE_REF_TO_TEXTURE: number;
  142840. readonly TEXTURE_WRAP_R: number;
  142841. readonly HALF_FLOAT: number;
  142842. readonly RGB8: number;
  142843. readonly RED_INTEGER: number;
  142844. readonly RG_INTEGER: number;
  142845. readonly RGB_INTEGER: number;
  142846. readonly RGBA_INTEGER: number;
  142847. readonly R8_SNORM: number;
  142848. readonly RG8_SNORM: number;
  142849. readonly RGB8_SNORM: number;
  142850. readonly RGBA8_SNORM: number;
  142851. readonly R8I: number;
  142852. readonly RG8I: number;
  142853. readonly RGB8I: number;
  142854. readonly RGBA8I: number;
  142855. readonly R8UI: number;
  142856. readonly RG8UI: number;
  142857. readonly RGB8UI: number;
  142858. readonly RGBA8UI: number;
  142859. readonly R16I: number;
  142860. readonly RG16I: number;
  142861. readonly RGB16I: number;
  142862. readonly RGBA16I: number;
  142863. readonly R16UI: number;
  142864. readonly RG16UI: number;
  142865. readonly RGB16UI: number;
  142866. readonly RGBA16UI: number;
  142867. readonly R32I: number;
  142868. readonly RG32I: number;
  142869. readonly RGB32I: number;
  142870. readonly RGBA32I: number;
  142871. readonly R32UI: number;
  142872. readonly RG32UI: number;
  142873. readonly RGB32UI: number;
  142874. readonly RGBA32UI: number;
  142875. readonly RGB10_A2UI: number;
  142876. readonly R11F_G11F_B10F: number;
  142877. readonly RGB9_E5: number;
  142878. readonly RGB10_A2: number;
  142879. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  142880. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  142881. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  142882. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  142883. readonly DEPTH_COMPONENT32F: number;
  142884. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  142885. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  142886. 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;
  142887. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  142888. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  142889. readonly TRANSFORM_FEEDBACK: number;
  142890. readonly INTERLEAVED_ATTRIBS: number;
  142891. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  142892. createTransformFeedback(): WebGLTransformFeedback;
  142893. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  142894. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  142895. beginTransformFeedback(primitiveMode: number): void;
  142896. endTransformFeedback(): void;
  142897. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  142898. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  142899. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  142900. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  142901. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  142902. }
  142903. interface ImageBitmap {
  142904. readonly width: number;
  142905. readonly height: number;
  142906. close(): void;
  142907. }
  142908. interface WebGLQuery extends WebGLObject {
  142909. }
  142910. declare var WebGLQuery: {
  142911. prototype: WebGLQuery;
  142912. new(): WebGLQuery;
  142913. };
  142914. interface WebGLSampler extends WebGLObject {
  142915. }
  142916. declare var WebGLSampler: {
  142917. prototype: WebGLSampler;
  142918. new(): WebGLSampler;
  142919. };
  142920. interface WebGLSync extends WebGLObject {
  142921. }
  142922. declare var WebGLSync: {
  142923. prototype: WebGLSync;
  142924. new(): WebGLSync;
  142925. };
  142926. interface WebGLTransformFeedback extends WebGLObject {
  142927. }
  142928. declare var WebGLTransformFeedback: {
  142929. prototype: WebGLTransformFeedback;
  142930. new(): WebGLTransformFeedback;
  142931. };
  142932. interface WebGLVertexArrayObject extends WebGLObject {
  142933. }
  142934. declare var WebGLVertexArrayObject: {
  142935. prototype: WebGLVertexArrayObject;
  142936. new(): WebGLVertexArrayObject;
  142937. };
  142938. // Type definitions for WebVR API
  142939. // Project: https://w3c.github.io/webvr/
  142940. // Definitions by: six a <https://github.com/lostfictions>
  142941. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  142942. interface VRDisplay extends EventTarget {
  142943. /**
  142944. * Dictionary of capabilities describing the VRDisplay.
  142945. */
  142946. readonly capabilities: VRDisplayCapabilities;
  142947. /**
  142948. * z-depth defining the far plane of the eye view frustum
  142949. * enables mapping of values in the render target depth
  142950. * attachment to scene coordinates. Initially set to 10000.0.
  142951. */
  142952. depthFar: number;
  142953. /**
  142954. * z-depth defining the near plane of the eye view frustum
  142955. * enables mapping of values in the render target depth
  142956. * attachment to scene coordinates. Initially set to 0.01.
  142957. */
  142958. depthNear: number;
  142959. /**
  142960. * An identifier for this distinct VRDisplay. Used as an
  142961. * association point in the Gamepad API.
  142962. */
  142963. readonly displayId: number;
  142964. /**
  142965. * A display name, a user-readable name identifying it.
  142966. */
  142967. readonly displayName: string;
  142968. readonly isConnected: boolean;
  142969. readonly isPresenting: boolean;
  142970. /**
  142971. * If this VRDisplay supports room-scale experiences, the optional
  142972. * stage attribute contains details on the room-scale parameters.
  142973. */
  142974. readonly stageParameters: VRStageParameters | null;
  142975. /**
  142976. * Passing the value returned by `requestAnimationFrame` to
  142977. * `cancelAnimationFrame` will unregister the callback.
  142978. * @param handle Define the hanle of the request to cancel
  142979. */
  142980. cancelAnimationFrame(handle: number): void;
  142981. /**
  142982. * Stops presenting to the VRDisplay.
  142983. * @returns a promise to know when it stopped
  142984. */
  142985. exitPresent(): Promise<void>;
  142986. /**
  142987. * Return the current VREyeParameters for the given eye.
  142988. * @param whichEye Define the eye we want the parameter for
  142989. * @returns the eye parameters
  142990. */
  142991. getEyeParameters(whichEye: string): VREyeParameters;
  142992. /**
  142993. * Populates the passed VRFrameData with the information required to render
  142994. * the current frame.
  142995. * @param frameData Define the data structure to populate
  142996. * @returns true if ok otherwise false
  142997. */
  142998. getFrameData(frameData: VRFrameData): boolean;
  142999. /**
  143000. * Get the layers currently being presented.
  143001. * @returns the list of VR layers
  143002. */
  143003. getLayers(): VRLayer[];
  143004. /**
  143005. * Return a VRPose containing the future predicted pose of the VRDisplay
  143006. * when the current frame will be presented. The value returned will not
  143007. * change until JavaScript has returned control to the browser.
  143008. *
  143009. * The VRPose will contain the position, orientation, velocity,
  143010. * and acceleration of each of these properties.
  143011. * @returns the pose object
  143012. */
  143013. getPose(): VRPose;
  143014. /**
  143015. * Return the current instantaneous pose of the VRDisplay, with no
  143016. * prediction applied.
  143017. * @returns the current instantaneous pose
  143018. */
  143019. getImmediatePose(): VRPose;
  143020. /**
  143021. * The callback passed to `requestAnimationFrame` will be called
  143022. * any time a new frame should be rendered. When the VRDisplay is
  143023. * presenting the callback will be called at the native refresh
  143024. * rate of the HMD. When not presenting this function acts
  143025. * identically to how window.requestAnimationFrame acts. Content should
  143026. * make no assumptions of frame rate or vsync behavior as the HMD runs
  143027. * asynchronously from other displays and at differing refresh rates.
  143028. * @param callback Define the eaction to run next frame
  143029. * @returns the request handle it
  143030. */
  143031. requestAnimationFrame(callback: FrameRequestCallback): number;
  143032. /**
  143033. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  143034. * Repeat calls while already presenting will update the VRLayers being displayed.
  143035. * @param layers Define the list of layer to present
  143036. * @returns a promise to know when the request has been fulfilled
  143037. */
  143038. requestPresent(layers: VRLayer[]): Promise<void>;
  143039. /**
  143040. * Reset the pose for this display, treating its current position and
  143041. * orientation as the "origin/zero" values. VRPose.position,
  143042. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  143043. * updated when calling resetPose(). This should be called in only
  143044. * sitting-space experiences.
  143045. */
  143046. resetPose(): void;
  143047. /**
  143048. * The VRLayer provided to the VRDisplay will be captured and presented
  143049. * in the HMD. Calling this function has the same effect on the source
  143050. * canvas as any other operation that uses its source image, and canvases
  143051. * created without preserveDrawingBuffer set to true will be cleared.
  143052. * @param pose Define the pose to submit
  143053. */
  143054. submitFrame(pose?: VRPose): void;
  143055. }
  143056. declare var VRDisplay: {
  143057. prototype: VRDisplay;
  143058. new(): VRDisplay;
  143059. };
  143060. interface VRLayer {
  143061. leftBounds?: number[] | Float32Array | null;
  143062. rightBounds?: number[] | Float32Array | null;
  143063. source?: HTMLCanvasElement | null;
  143064. }
  143065. interface VRDisplayCapabilities {
  143066. readonly canPresent: boolean;
  143067. readonly hasExternalDisplay: boolean;
  143068. readonly hasOrientation: boolean;
  143069. readonly hasPosition: boolean;
  143070. readonly maxLayers: number;
  143071. }
  143072. interface VREyeParameters {
  143073. /** @deprecated */
  143074. readonly fieldOfView: VRFieldOfView;
  143075. readonly offset: Float32Array;
  143076. readonly renderHeight: number;
  143077. readonly renderWidth: number;
  143078. }
  143079. interface VRFieldOfView {
  143080. readonly downDegrees: number;
  143081. readonly leftDegrees: number;
  143082. readonly rightDegrees: number;
  143083. readonly upDegrees: number;
  143084. }
  143085. interface VRFrameData {
  143086. readonly leftProjectionMatrix: Float32Array;
  143087. readonly leftViewMatrix: Float32Array;
  143088. readonly pose: VRPose;
  143089. readonly rightProjectionMatrix: Float32Array;
  143090. readonly rightViewMatrix: Float32Array;
  143091. readonly timestamp: number;
  143092. }
  143093. interface VRPose {
  143094. readonly angularAcceleration: Float32Array | null;
  143095. readonly angularVelocity: Float32Array | null;
  143096. readonly linearAcceleration: Float32Array | null;
  143097. readonly linearVelocity: Float32Array | null;
  143098. readonly orientation: Float32Array | null;
  143099. readonly position: Float32Array | null;
  143100. readonly timestamp: number;
  143101. }
  143102. interface VRStageParameters {
  143103. sittingToStandingTransform?: Float32Array;
  143104. sizeX?: number;
  143105. sizeY?: number;
  143106. }
  143107. interface Navigator {
  143108. getVRDisplays(): Promise<VRDisplay[]>;
  143109. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  143110. }
  143111. interface Window {
  143112. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  143113. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  143114. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  143115. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  143116. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  143117. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  143118. }
  143119. interface Gamepad {
  143120. readonly displayId: number;
  143121. }
  143122. type XRSessionMode =
  143123. | "inline"
  143124. | "immersive-vr"
  143125. | "immersive-ar";
  143126. type XRReferenceSpaceType =
  143127. | "viewer"
  143128. | "local"
  143129. | "local-floor"
  143130. | "bounded-floor"
  143131. | "unbounded";
  143132. type XREnvironmentBlendMode =
  143133. | "opaque"
  143134. | "additive"
  143135. | "alpha-blend";
  143136. type XRVisibilityState =
  143137. | "visible"
  143138. | "visible-blurred"
  143139. | "hidden";
  143140. type XRHandedness =
  143141. | "none"
  143142. | "left"
  143143. | "right";
  143144. type XRTargetRayMode =
  143145. | "gaze"
  143146. | "tracked-pointer"
  143147. | "screen";
  143148. type XREye =
  143149. | "none"
  143150. | "left"
  143151. | "right";
  143152. interface XRSpace extends EventTarget {
  143153. }
  143154. interface XRRenderState {
  143155. depthNear?: number;
  143156. depthFar?: number;
  143157. inlineVerticalFieldOfView?: number;
  143158. baseLayer?: XRWebGLLayer;
  143159. }
  143160. interface XRInputSource {
  143161. handedness: XRHandedness;
  143162. targetRayMode: XRTargetRayMode;
  143163. targetRaySpace: XRSpace;
  143164. gripSpace: XRSpace | undefined;
  143165. gamepad: Gamepad | undefined;
  143166. profiles: Array<string>;
  143167. }
  143168. interface XRSessionInit {
  143169. optionalFeatures?: XRReferenceSpaceType[];
  143170. requiredFeatures?: XRReferenceSpaceType[];
  143171. }
  143172. interface XRSession extends XRAnchorCreator {
  143173. addEventListener: Function;
  143174. removeEventListener: Function;
  143175. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  143176. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  143177. requestAnimationFrame: Function;
  143178. end(): Promise<void>;
  143179. renderState: XRRenderState;
  143180. inputSources: Array<XRInputSource>;
  143181. // AR hit test
  143182. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  143183. updateWorldTrackingState(options: {
  143184. planeDetectionState?: { enabled: boolean; }
  143185. }): void;
  143186. }
  143187. interface XRReferenceSpace extends XRSpace {
  143188. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  143189. onreset: any;
  143190. }
  143191. type XRPlaneSet = Set<XRPlane>;
  143192. type XRAnchorSet = Set<XRAnchor>;
  143193. interface XRFrame {
  143194. session: XRSession;
  143195. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  143196. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  143197. // Anchors
  143198. trackedAnchors?: XRAnchorSet;
  143199. // Planes
  143200. worldInformation: {
  143201. detectedPlanes?: XRPlaneSet;
  143202. };
  143203. }
  143204. interface XRViewerPose extends XRPose {
  143205. views: Array<XRView>;
  143206. }
  143207. interface XRPose {
  143208. transform: XRRigidTransform;
  143209. emulatedPosition: boolean;
  143210. }
  143211. interface XRWebGLLayerOptions {
  143212. antialias?: boolean;
  143213. depth?: boolean;
  143214. stencil?: boolean;
  143215. alpha?: boolean;
  143216. multiview?: boolean;
  143217. framebufferScaleFactor?: number;
  143218. }
  143219. declare var XRWebGLLayer: {
  143220. prototype: XRWebGLLayer;
  143221. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  143222. };
  143223. interface XRWebGLLayer {
  143224. framebuffer: WebGLFramebuffer;
  143225. framebufferWidth: number;
  143226. framebufferHeight: number;
  143227. getViewport: Function;
  143228. }
  143229. declare class XRRigidTransform {
  143230. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  143231. position: DOMPointReadOnly;
  143232. orientation: DOMPointReadOnly;
  143233. matrix: Float32Array;
  143234. inverse: XRRigidTransform;
  143235. }
  143236. interface XRView {
  143237. eye: XREye;
  143238. projectionMatrix: Float32Array;
  143239. transform: XRRigidTransform;
  143240. }
  143241. interface XRInputSourceChangeEvent {
  143242. session: XRSession;
  143243. removed: Array<XRInputSource>;
  143244. added: Array<XRInputSource>;
  143245. }
  143246. interface XRInputSourceEvent extends Event {
  143247. readonly frame: XRFrame;
  143248. readonly inputSource: XRInputSource;
  143249. }
  143250. // Experimental(er) features
  143251. declare class XRRay {
  143252. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  143253. origin: DOMPointReadOnly;
  143254. direction: DOMPointReadOnly;
  143255. matrix: Float32Array;
  143256. }
  143257. interface XRHitResult {
  143258. hitMatrix: Float32Array;
  143259. }
  143260. interface XRAnchor {
  143261. // remove?
  143262. id?: string;
  143263. anchorSpace: XRSpace;
  143264. lastChangedTime: number;
  143265. detach(): void;
  143266. }
  143267. interface XRPlane extends XRAnchorCreator {
  143268. orientation: "Horizontal" | "Vertical";
  143269. planeSpace: XRSpace;
  143270. polygon: Array<DOMPointReadOnly>;
  143271. lastChangedTime: number;
  143272. }
  143273. interface XRAnchorCreator {
  143274. // AR Anchors
  143275. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  143276. }